Imports
/-
Copyright (c) 2026 Google LLC. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
-/
module
public import Cryptids.Semantics.PA.Syntax
public import Mathlib.Data.Nat.Pairing
Gödel–Henkin Completeness of PAProvable
This module proves Gödel's first-order completeness theorem specialized to Peano Arithmetic
(PAProvable): a PAFormula is provable in PAProvable if and only if it holds in every
first-order PAModel M (Type) under every variable assignment:
paProvable_iff_holdsIn_all_models:
PAProvable φ ↔ ∀ (M : Type) [PAStructure M] [PAModel M] (v : ℕ → M), PAFormula.HoldsIn v φ
This bridge allows semantic proofs in an arbitrary first-order model [PAModel M] to be compiled
directly into formal Hilbert derivations PAProvable φ.
@[expose] public sectionnamespace ConjectureMachines
Smallest variable index strictly greater than every variable (free or bound) occurring in a
PAFormula.
def PAFormula.maxVar : PAFormula → ℕ
| .bot => 0
| .eq t₁ t₂ => max t₁.freshVar t₂.freshVar
| .and φ ψ | .or φ ψ | .imp φ ψ => max φ.maxVar ψ.maxVar
| .all x φ | .ex x φ => max (x + 1) φ.maxVar
Simultaneous variable-to-variable renaming on PATerm.
def PATerm.vsubst (ρ : ℕ → ℕ) : PATerm → PATerm
| .var x => .var (ρ x)
| .zero => .zero
| .succ t => .succ (t.vsubst ρ)
| .add t₁ t₂ => .add (t₁.vsubst ρ) (t₂.vsubst ρ)
| .mul t₁ t₂ => .mul (t₁.vsubst ρ) (t₂.vsubst ρ)
Simultaneous variable-to-variable renaming on PAFormula, preserving bound variable names.
def PAFormula.vsubst (ρ : ℕ → ℕ) : PAFormula → PAFormula
| .bot => .bot
| .eq t₁ t₂ => .eq (t₁.vsubst ρ) (t₂.vsubst ρ)
| .and φ ψ => .and (φ.vsubst ρ) (ψ.vsubst ρ)
| .or φ ψ => .or (φ.vsubst ρ) (ψ.vsubst ρ)
| .imp φ ψ => .imp (φ.vsubst ρ) (ψ.vsubst ρ)
| .all y φ => .all y (φ.vsubst (Function.update ρ y y))
| .ex y φ => .ex y (φ.vsubst (Function.update ρ y y))end ConjectureMachinesnamespace ConjectureMachines.Semantics.PASection 1: Variable Bounds and Simultaneous Variable Renaming
private theorem term_subst_eq_self_of_hasVar_false {t : PATerm} {x : ℕ} (s : PATerm)
(hx : t.hasVar x = false) : t.subst x s = t := t:PATermx:ℕs:PATermhx:PATerm.hasVar x t = false⊢ t.subst x s = t
induction t with
x:ℕs:PATermy:ℕhx:PATerm.hasVar x (PATerm.var y) = false⊢ (PATerm.var y).subst x s = PATerm.var y
x:ℕs:PATermy:ℕhx:y ≠ x⊢ (PATerm.var y).subst x s = PATerm.var y
All goals completed! 🐙
x:ℕs:PATermhx:PATerm.hasVar x PATerm.zero = false⊢ PATerm.zero.subst x s = PATerm.zero All goals completed! 🐙
x:ℕs:PATermt✝:PATermih:PATerm.hasVar x t✝ = false → t✝.subst x s = t✝hx:PATerm.hasVar x t✝.succ = false⊢ t✝.succ.subst x s = t✝.succ All goals completed! 🐙
x:ℕs:PATermt₁✝:PATermt₂✝:PATermih₁:PATerm.hasVar x t₁✝ = false → t₁✝.subst x s = t₁✝ih₂:PATerm.hasVar x t₂✝ = false → t₂✝.subst x s = t₂✝hx:PATerm.hasVar x (t₁✝.add t₂✝) = false⊢ (t₁✝.add t₂✝).subst x s = t₁✝.add t₂✝
x:ℕs:PATermt₁✝:PATermt₂✝:PATermih₁:PATerm.hasVar x t₁✝ = false → t₁✝.subst x s = t₁✝ih₂:PATerm.hasVar x t₂✝ = false → t₂✝.subst x s = t₂✝hx:PATerm.hasVar x t₁✝ = false ∧ PATerm.hasVar x t₂✝ = false⊢ (t₁✝.add t₂✝).subst x s = t₁✝.add t₂✝
All goals completed! 🐙
x:ℕs:PATermt₁✝:PATermt₂✝:PATermih₁:PATerm.hasVar x t₁✝ = false → t₁✝.subst x s = t₁✝ih₂:PATerm.hasVar x t₂✝ = false → t₂✝.subst x s = t₂✝hx:PATerm.hasVar x (t₁✝.mul t₂✝) = false⊢ (t₁✝.mul t₂✝).subst x s = t₁✝.mul t₂✝
x:ℕs:PATermt₁✝:PATermt₂✝:PATermih₁:PATerm.hasVar x t₁✝ = false → t₁✝.subst x s = t₁✝ih₂:PATerm.hasVar x t₂✝ = false → t₂✝.subst x s = t₂✝hx:PATerm.hasVar x t₁✝ = false ∧ PATerm.hasVar x t₂✝ = false⊢ (t₁✝.mul t₂✝).subst x s = t₁✝.mul t₂✝
All goals completed! 🐙private theorem lt_freshVar_of_hasVar {t : PATerm} {x : ℕ} (h : t.hasVar x = true) :
x < t.freshVar := t:PATermx:ℕh:PATerm.hasVar x t = true⊢ x < t.freshVar
t:PATermx:ℕh:PATerm.hasVar x t = truehge:¬x < t.freshVar⊢ False
t:PATermx:ℕh:PATerm.hasVar x t = truehge:¬x < t.freshVarhf:PATerm.hasVar x t = false⊢ False
t:PATermx:ℕh:false = truehge:¬x < t.freshVarhf:PATerm.hasVar x t = false⊢ False
cases h All goals completed! 🐙private theorem hasFree_false_of_maxVar_le {φ : PAFormula} {w : ℕ} (h : φ.maxVar ≤ w) :
φ.hasFree w = false := by φ:PAFormulaw:ℕh:φ.maxVar ≤ w⊢ PAFormula.hasFree w φ = false
induction φ with
| bot => bot w:ℕh:PAFormula.bot.maxVar ≤ w⊢ PAFormula.hasFree w PAFormula.bot = false rfl All goals completed! 🐙
| eq t₁ t₂ => eq w:ℕt₁:PATermt₂:PATermh:(PAFormula.eq t₁ t₂).maxVar ≤ w⊢ PAFormula.hasFree w (PAFormula.eq t₁ t₂) = false
simp only [PAFormula.maxVar, Nat.max_le] at h eq w:ℕt₁:PATermt₂:PATermh:t₁.freshVar ≤ w ∧ t₂.freshVar ≤ w⊢ PAFormula.hasFree w (PAFormula.eq t₁ t₂) = false
simp only [PAFormula.hasFree, Bool.or_eq_false_iff] eq w:ℕt₁:PATermt₂:PATermh:t₁.freshVar ≤ w ∧ t₂.freshVar ≤ w⊢ PATerm.hasVar w t₁ = false ∧ PATerm.hasVar w t₂ = false
exact ⟨hasVar_false_of_freshVar_le h.1, hasVar_false_of_freshVar_le h.2⟩ All goals completed! 🐙
| and _ _ ih₁ ih₂ and w:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseih₂:ψ✝.maxVar ≤ w → PAFormula.hasFree w ψ✝ = falseh:(φ✝.and ψ✝).maxVar ≤ w⊢ PAFormula.hasFree w (φ✝.and ψ✝) = false | or _ _ ih₁ ih₂ or w:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseih₂:ψ✝.maxVar ≤ w → PAFormula.hasFree w ψ✝ = falseh:(φ✝.or ψ✝).maxVar ≤ w⊢ PAFormula.hasFree w (φ✝.or ψ✝) = false | imp _ _ ih₁ ih₂ imp w:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseih₂:ψ✝.maxVar ≤ w → PAFormula.hasFree w ψ✝ = falseh:(φ✝.imp ψ✝).maxVar ≤ w⊢ PAFormula.hasFree w (φ✝.imp ψ✝) = false => imp w:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseih₂:ψ✝.maxVar ≤ w → PAFormula.hasFree w ψ✝ = falseh:(φ✝.imp ψ✝).maxVar ≤ w⊢ PAFormula.hasFree w (φ✝.imp ψ✝) = falseor w:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseih₂:ψ✝.maxVar ≤ w → PAFormula.hasFree w ψ✝ = falseh:(φ✝.or ψ✝).maxVar ≤ w⊢ PAFormula.hasFree w (φ✝.or ψ✝) = falseand w:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseih₂:ψ✝.maxVar ≤ w → PAFormula.hasFree w ψ✝ = falseh:(φ✝.and ψ✝).maxVar ≤ w⊢ PAFormula.hasFree w (φ✝.and ψ✝) = false
simp only [PAFormula.maxVar, Nat.max_le] at h imp w:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseih₂:ψ✝.maxVar ≤ w → PAFormula.hasFree w ψ✝ = falseh:φ✝.maxVar ≤ w ∧ ψ✝.maxVar ≤ w⊢ PAFormula.hasFree w (φ✝.imp ψ✝) = false
simp only [PAFormula.hasFree, Bool.or_eq_false_iff] imp w:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseih₂:ψ✝.maxVar ≤ w → PAFormula.hasFree w ψ✝ = falseh:φ✝.maxVar ≤ w ∧ ψ✝.maxVar ≤ w⊢ PAFormula.hasFree w φ✝ = false ∧ PAFormula.hasFree w ψ✝ = false
exact ⟨ih₁ h.1, ih₂ h.2⟩ All goals completed! 🐙
| all x _ ih all w:ℕx:ℕφ✝:PAFormulaih:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseh:(PAFormula.all x φ✝).maxVar ≤ w⊢ PAFormula.hasFree w (PAFormula.all x φ✝) = false | ex x _ ih ex w:ℕx:ℕφ✝:PAFormulaih:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseh:(PAFormula.ex x φ✝).maxVar ≤ w⊢ PAFormula.hasFree w (PAFormula.ex x φ✝) = false => ex w:ℕx:ℕφ✝:PAFormulaih:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseh:(PAFormula.ex x φ✝).maxVar ≤ w⊢ PAFormula.hasFree w (PAFormula.ex x φ✝) = falseall w:ℕx:ℕφ✝:PAFormulaih:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseh:(PAFormula.all x φ✝).maxVar ≤ w⊢ PAFormula.hasFree w (PAFormula.all x φ✝) = false
simp only [PAFormula.maxVar, Nat.max_le] at h ex w:ℕx:ℕφ✝:PAFormulaih:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseh:x + 1 ≤ w ∧ φ✝.maxVar ≤ w⊢ PAFormula.hasFree w (PAFormula.ex x φ✝) = false
simp only [PAFormula.hasFree, Bool.and_eq_false_iff] ex w:ℕx:ℕφ✝:PAFormulaih:φ✝.maxVar ≤ w → PAFormula.hasFree w φ✝ = falseh:x + 1 ≤ w ∧ φ✝.maxVar ≤ w⊢ (!x == w) = false ∨ PAFormula.hasFree w φ✝ = false
exact Or.inr (ih h.2) All goals completed! 🐙private theorem lt_maxVar_of_hasFree {φ : PAFormula} {x : ℕ} (h : φ.hasFree x = true) :
x < φ.maxVar := by φ:PAFormulax:ℕh:PAFormula.hasFree x φ = true⊢ x < φ.maxVar
by_contra hge φ:PAFormulax:ℕh:PAFormula.hasFree x φ = truehge:¬x < φ.maxVar⊢ False
have hf := hasFree_false_of_maxVar_le (Nat.le_of_not_lt hge) φ:PAFormulax:ℕh:PAFormula.hasFree x φ = truehge:¬x < φ.maxVarhf:PAFormula.hasFree x φ = false⊢ False
rw [hf φ:PAFormulax:ℕh:false = truehge:¬x < φ.maxVarhf:PAFormula.hasFree x φ = false⊢ False] at h φ:PAFormulax:ℕh:false = truehge:¬x < φ.maxVarhf:PAFormula.hasFree x φ = false⊢ False
cases h All goals completed! 🐙private theorem freeFor_var_self (x : ℕ) (φ : PAFormula) :
φ.freeFor x (.var x) = true := by x:ℕφ:PAFormula⊢ PAFormula.freeFor x (PATerm.var x) φ = true
induction φ with
| bot bot x:ℕ⊢ PAFormula.freeFor x (PATerm.var x) PAFormula.bot = true | eq _ _ eq x:ℕt₁✝:PATermt₂✝:PATerm⊢ PAFormula.freeFor x (PATerm.var x) (PAFormula.eq t₁✝ t₂✝) = true => eq x:ℕt₁✝:PATermt₂✝:PATerm⊢ PAFormula.freeFor x (PATerm.var x) (PAFormula.eq t₁✝ t₂✝) = truebot x:ℕ⊢ PAFormula.freeFor x (PATerm.var x) PAFormula.bot = true rfl All goals completed! 🐙
| and _ _ ih₁ ih₂ and x:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.freeFor x (PATerm.var x) φ✝ = trueih₂:PAFormula.freeFor x (PATerm.var x) ψ✝ = true⊢ PAFormula.freeFor x (PATerm.var x) (φ✝.and ψ✝) = true | or _ _ ih₁ ih₂ or x:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.freeFor x (PATerm.var x) φ✝ = trueih₂:PAFormula.freeFor x (PATerm.var x) ψ✝ = true⊢ PAFormula.freeFor x (PATerm.var x) (φ✝.or ψ✝) = true | imp _ _ ih₁ ih₂ imp x:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.freeFor x (PATerm.var x) φ✝ = trueih₂:PAFormula.freeFor x (PATerm.var x) ψ✝ = true⊢ PAFormula.freeFor x (PATerm.var x) (φ✝.imp ψ✝) = true => imp x:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.freeFor x (PATerm.var x) φ✝ = trueih₂:PAFormula.freeFor x (PATerm.var x) ψ✝ = true⊢ PAFormula.freeFor x (PATerm.var x) (φ✝.imp ψ✝) = trueor x:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.freeFor x (PATerm.var x) φ✝ = trueih₂:PAFormula.freeFor x (PATerm.var x) ψ✝ = true⊢ PAFormula.freeFor x (PATerm.var x) (φ✝.or ψ✝) = trueand x:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.freeFor x (PATerm.var x) φ✝ = trueih₂:PAFormula.freeFor x (PATerm.var x) ψ✝ = true⊢ PAFormula.freeFor x (PATerm.var x) (φ✝.and ψ✝) = true
simp [PAFormula.freeFor, ih₁, ih₂] All goals completed! 🐙
| all y _ ih all x:ℕy:ℕφ✝:PAFormulaih:PAFormula.freeFor x (PATerm.var x) φ✝ = true⊢ PAFormula.freeFor x (PATerm.var x) (PAFormula.all y φ✝) = true | ex y _ ih ex x:ℕy:ℕφ✝:PAFormulaih:PAFormula.freeFor x (PATerm.var x) φ✝ = true⊢ PAFormula.freeFor x (PATerm.var x) (PAFormula.ex y φ✝) = true => ex x:ℕy:ℕφ✝:PAFormulaih:PAFormula.freeFor x (PATerm.var x) φ✝ = true⊢ PAFormula.freeFor x (PATerm.var x) (PAFormula.ex y φ✝) = trueall x:ℕy:ℕφ✝:PAFormulaih:PAFormula.freeFor x (PATerm.var x) φ✝ = true⊢ PAFormula.freeFor x (PATerm.var x) (PAFormula.all y φ✝) = true
simp only [PAFormula.freeFor, PATerm.hasVar] ex x:ℕy:ℕφ✝:PAFormulaih:PAFormula.freeFor x (PATerm.var x) φ✝ = true⊢ (y == x || (!PAFormula.hasFree x φ✝ || !x == y) && PAFormula.freeFor x (PATerm.var x) φ✝) = true
by_cases hxy : y = x pos x:ℕy:ℕφ✝:PAFormulaih:PAFormula.freeFor x (PATerm.var x) φ✝ = truehxy:y = x⊢ (y == x || (!PAFormula.hasFree x φ✝ || !x == y) && PAFormula.freeFor x (PATerm.var x) φ✝) = trueneg x:ℕy:ℕφ✝:PAFormulaih:PAFormula.freeFor x (PATerm.var x) φ✝ = truehxy:¬y = x⊢ (y == x || (!PAFormula.hasFree x φ✝ || !x == y) && PAFormula.freeFor x (PATerm.var x) φ✝) = true
· pos x:ℕy:ℕφ✝:PAFormulaih:PAFormula.freeFor x (PATerm.var x) φ✝ = truehxy:y = x⊢ (y == x || (!PAFormula.hasFree x φ✝ || !x == y) && PAFormula.freeFor x (PATerm.var x) φ✝) = true simp [hxy] All goals completed! 🐙
· neg x:ℕy:ℕφ✝:PAFormulaih:PAFormula.freeFor x (PATerm.var x) φ✝ = truehxy:¬y = x⊢ (y == x || (!PAFormula.hasFree x φ✝ || !x == y) && PAFormula.freeFor x (PATerm.var x) φ✝) = true simp [hxy, Ne.symm hxy, ih] All goals completed! 🐙private theorem term_subst_var_self (x : ℕ) (t : PATerm) :
t.subst x (.var x) = t := by x:ℕt:PATerm⊢ t.subst x (PATerm.var x) = t
induction t with
| var y => var x:ℕy:ℕ⊢ (PATerm.var y).subst x (PATerm.var x) = PATerm.var y
simp only [PATerm.subst] var x:ℕy:ℕ⊢ (if (y == x) = true then PATerm.var x else PATerm.var y) = PATerm.var y
by_cases hxy : y = x pos x:ℕy:ℕhxy:y = x⊢ (if (y == x) = true then PATerm.var x else PATerm.var y) = PATerm.var yneg x:ℕy:ℕhxy:¬y = x⊢ (if (y == x) = true then PATerm.var x else PATerm.var y) = PATerm.var y
· pos x:ℕy:ℕhxy:y = x⊢ (if (y == x) = true then PATerm.var x else PATerm.var y) = PATerm.var y subst hxy pos y:ℕ⊢ (if (y == y) = true then PATerm.var y else PATerm.var y) = PATerm.var y; simp All goals completed! 🐙
· neg x:ℕy:ℕhxy:¬y = x⊢ (if (y == x) = true then PATerm.var x else PATerm.var y) = PATerm.var y simp [hxy] All goals completed! 🐙
| zero => zero x:ℕ⊢ PATerm.zero.subst x (PATerm.var x) = PATerm.zero rfl All goals completed! 🐙
| succ _ ih => succ x:ℕt✝:PATermih:t✝.subst x (PATerm.var x) = t✝⊢ t✝.succ.subst x (PATerm.var x) = t✝.succ exact congrArg PATerm.succ ih All goals completed! 🐙
| add _ _ ih₁ ih₂ => add x:ℕt₁✝:PATermt₂✝:PATermih₁:t₁✝.subst x (PATerm.var x) = t₁✝ih₂:t₂✝.subst x (PATerm.var x) = t₂✝⊢ (t₁✝.add t₂✝).subst x (PATerm.var x) = t₁✝.add t₂✝ exact congrArg₂ PATerm.add ih₁ ih₂ All goals completed! 🐙
| mul _ _ ih₁ ih₂ => mul x:ℕt₁✝:PATermt₂✝:PATermih₁:t₁✝.subst x (PATerm.var x) = t₁✝ih₂:t₂✝.subst x (PATerm.var x) = t₂✝⊢ (t₁✝.mul t₂✝).subst x (PATerm.var x) = t₁✝.mul t₂✝ exact congrArg₂ PATerm.mul ih₁ ih₂ All goals completed! 🐙private theorem subst_var_self (x : ℕ) (φ : PAFormula) :
φ.subst x (.var x) = φ := by x:ℕφ:PAFormula⊢ PAFormula.subst x (PATerm.var x) φ = φ
induction φ with
| bot => bot x:ℕ⊢ PAFormula.subst x (PATerm.var x) PAFormula.bot = PAFormula.bot rfl All goals completed! 🐙
| eq t₁ t₂ => eq x:ℕt₁:PATermt₂:PATerm⊢ PAFormula.subst x (PATerm.var x) (PAFormula.eq t₁ t₂) = PAFormula.eq t₁ t₂ exact congrArg₂ PAFormula.eq (term_subst_var_self x t₁) (term_subst_var_self x t₂) All goals completed! 🐙
| and _ _ ih₁ ih₂ => and x:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.subst x (PATerm.var x) φ✝ = φ✝ih₂:PAFormula.subst x (PATerm.var x) ψ✝ = ψ✝⊢ PAFormula.subst x (PATerm.var x) (φ✝.and ψ✝) = φ✝.and ψ✝ exact congrArg₂ PAFormula.and ih₁ ih₂ All goals completed! 🐙
| or _ _ ih₁ ih₂ => or x:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.subst x (PATerm.var x) φ✝ = φ✝ih₂:PAFormula.subst x (PATerm.var x) ψ✝ = ψ✝⊢ PAFormula.subst x (PATerm.var x) (φ✝.or ψ✝) = φ✝.or ψ✝ exact congrArg₂ PAFormula.or ih₁ ih₂ All goals completed! 🐙
| imp _ _ ih₁ ih₂ => imp x:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.subst x (PATerm.var x) φ✝ = φ✝ih₂:PAFormula.subst x (PATerm.var x) ψ✝ = ψ✝⊢ PAFormula.subst x (PATerm.var x) (φ✝.imp ψ✝) = φ✝.imp ψ✝ exact congrArg₂ PAFormula.imp ih₁ ih₂ All goals completed! 🐙
| all y φ ih => all x:ℕy:ℕφ:PAFormulaih:PAFormula.subst x (PATerm.var x) φ = φ⊢ PAFormula.subst x (PATerm.var x) (PAFormula.all y φ) = PAFormula.all y φ
simp only [PAFormula.subst] all x:ℕy:ℕφ:PAFormulaih:PAFormula.subst x (PATerm.var x) φ = φ⊢ (if (y == x) = true then PAFormula.all y φ else PAFormula.all y (PAFormula.subst x (PATerm.var x) φ)) =
PAFormula.all y φ
by_cases hxy : y = x pos x:ℕy:ℕφ:PAFormulaih:PAFormula.subst x (PATerm.var x) φ = φhxy:y = x⊢ (if (y == x) = true then PAFormula.all y φ else PAFormula.all y (PAFormula.subst x (PATerm.var x) φ)) =
PAFormula.all y φneg x:ℕy:ℕφ:PAFormulaih:PAFormula.subst x (PATerm.var x) φ = φhxy:¬y = x⊢ (if (y == x) = true then PAFormula.all y φ else PAFormula.all y (PAFormula.subst x (PATerm.var x) φ)) =
PAFormula.all y φ
· pos x:ℕy:ℕφ:PAFormulaih:PAFormula.subst x (PATerm.var x) φ = φhxy:y = x⊢ (if (y == x) = true then PAFormula.all y φ else PAFormula.all y (PAFormula.subst x (PATerm.var x) φ)) =
PAFormula.all y φ simp [hxy] All goals completed! 🐙
· neg x:ℕy:ℕφ:PAFormulaih:PAFormula.subst x (PATerm.var x) φ = φhxy:¬y = x⊢ (if (y == x) = true then PAFormula.all y φ else PAFormula.all y (PAFormula.subst x (PATerm.var x) φ)) =
PAFormula.all y φ simp [hxy, ih] All goals completed! 🐙
| ex y φ ih => ex x:ℕy:ℕφ:PAFormulaih:PAFormula.subst x (PATerm.var x) φ = φ⊢ PAFormula.subst x (PATerm.var x) (PAFormula.ex y φ) = PAFormula.ex y φ
simp only [PAFormula.subst] ex x:ℕy:ℕφ:PAFormulaih:PAFormula.subst x (PATerm.var x) φ = φ⊢ (if (y == x) = true then PAFormula.ex y φ else PAFormula.ex y (PAFormula.subst x (PATerm.var x) φ)) = PAFormula.ex y φ
by_cases hxy : y = x pos x:ℕy:ℕφ:PAFormulaih:PAFormula.subst x (PATerm.var x) φ = φhxy:y = x⊢ (if (y == x) = true then PAFormula.ex y φ else PAFormula.ex y (PAFormula.subst x (PATerm.var x) φ)) = PAFormula.ex y φneg x:ℕy:ℕφ:PAFormulaih:PAFormula.subst x (PATerm.var x) φ = φhxy:¬y = x⊢ (if (y == x) = true then PAFormula.ex y φ else PAFormula.ex y (PAFormula.subst x (PATerm.var x) φ)) = PAFormula.ex y φ
· pos x:ℕy:ℕφ:PAFormulaih:PAFormula.subst x (PATerm.var x) φ = φhxy:y = x⊢ (if (y == x) = true then PAFormula.ex y φ else PAFormula.ex y (PAFormula.subst x (PATerm.var x) φ)) = PAFormula.ex y φ simp [hxy] All goals completed! 🐙
· neg x:ℕy:ℕφ:PAFormulaih:PAFormula.subst x (PATerm.var x) φ = φhxy:¬y = x⊢ (if (y == x) = true then PAFormula.ex y φ else PAFormula.ex y (PAFormula.subst x (PATerm.var x) φ)) = PAFormula.ex y φ simp [hxy, ih] All goals completed! 🐙private theorem freeFor_var_of_maxVar_le (x : ℕ) {w : ℕ} {φ : PAFormula} (hw : φ.maxVar ≤ w) :
φ.freeFor x (.var w) = true := by x:ℕw:ℕφ:PAFormulahw:φ.maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) φ = true
induction φ with
| bot bot x:ℕw:ℕhw:PAFormula.bot.maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) PAFormula.bot = true | eq _ _ eq x:ℕw:ℕt₁✝:PATermt₂✝:PATermhw:(PAFormula.eq t₁✝ t₂✝).maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (PAFormula.eq t₁✝ t₂✝) = true => eq x:ℕw:ℕt₁✝:PATermt₂✝:PATermhw:(PAFormula.eq t₁✝ t₂✝).maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (PAFormula.eq t₁✝ t₂✝) = truebot x:ℕw:ℕhw:PAFormula.bot.maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) PAFormula.bot = true rfl All goals completed! 🐙
| and _ _ ih₁ ih₂ and x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) ψ✝ = truehw:(φ✝.and ψ✝).maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (φ✝.and ψ✝) = true | or _ _ ih₁ ih₂ or x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) ψ✝ = truehw:(φ✝.or ψ✝).maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (φ✝.or ψ✝) = true | imp _ _ ih₁ ih₂ imp x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) ψ✝ = truehw:(φ✝.imp ψ✝).maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (φ✝.imp ψ✝) = true => imp x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) ψ✝ = truehw:(φ✝.imp ψ✝).maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (φ✝.imp ψ✝) = trueor x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) ψ✝ = truehw:(φ✝.or ψ✝).maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (φ✝.or ψ✝) = trueand x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) ψ✝ = truehw:(φ✝.and ψ✝).maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (φ✝.and ψ✝) = true
simp only [PAFormula.maxVar, Nat.max_le] at hw imp x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) ψ✝ = truehw:φ✝.maxVar ≤ w ∧ ψ✝.maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (φ✝.imp ψ✝) = true
simp [PAFormula.freeFor, ih₁ hw.1, ih₂ hw.2] All goals completed! 🐙
| all y _ ih all x:ℕw:ℕy:ℕφ✝:PAFormulaih:φ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) φ✝ = truehw:(PAFormula.all y φ✝).maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (PAFormula.all y φ✝) = true | ex y _ ih ex x:ℕw:ℕy:ℕφ✝:PAFormulaih:φ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) φ✝ = truehw:(PAFormula.ex y φ✝).maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (PAFormula.ex y φ✝) = true => ex x:ℕw:ℕy:ℕφ✝:PAFormulaih:φ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) φ✝ = truehw:(PAFormula.ex y φ✝).maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (PAFormula.ex y φ✝) = trueall x:ℕw:ℕy:ℕφ✝:PAFormulaih:φ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) φ✝ = truehw:(PAFormula.all y φ✝).maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (PAFormula.all y φ✝) = true
simp only [PAFormula.maxVar, Nat.max_le] at hw ex x:ℕw:ℕy:ℕφ✝:PAFormulaih:φ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) φ✝ = truehw:y + 1 ≤ w ∧ φ✝.maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) (PAFormula.ex y φ✝) = true
have hwy : w ≠ y := by x:ℕw:ℕφ:PAFormulahw:φ.maxVar ≤ w⊢ PAFormula.freeFor x (PATerm.var w) φ = true omega ex x:ℕw:ℕy:ℕφ✝:PAFormulaih:φ✝.maxVar ≤ w → PAFormula.freeFor x (PATerm.var w) φ✝ = truehw:y + 1 ≤ w ∧ φ✝.maxVar ≤ whwy:w ≠ y⊢ PAFormula.freeFor x (PATerm.var w) (PAFormula.ex y φ✝) = true
simp [PAFormula.freeFor, PATerm.hasVar, hwy, ih hw.2] All goals completed! 🐙private theorem freeFor_of_hasFree_false {w : ℕ} (s : PATerm) {φ : PAFormula}
(hw : φ.maxVar ≤ w) : φ.freeFor w s = true := by w:ℕs:PATermφ:PAFormulahw:φ.maxVar ≤ w⊢ PAFormula.freeFor w s φ = true
induction φ with
| bot bot w:ℕs:PATermhw:PAFormula.bot.maxVar ≤ w⊢ PAFormula.freeFor w s PAFormula.bot = true | eq _ _ eq w:ℕs:PATermt₁✝:PATermt₂✝:PATermhw:(PAFormula.eq t₁✝ t₂✝).maxVar ≤ w⊢ PAFormula.freeFor w s (PAFormula.eq t₁✝ t₂✝) = true => eq w:ℕs:PATermt₁✝:PATermt₂✝:PATermhw:(PAFormula.eq t₁✝ t₂✝).maxVar ≤ w⊢ PAFormula.freeFor w s (PAFormula.eq t₁✝ t₂✝) = truebot w:ℕs:PATermhw:PAFormula.bot.maxVar ≤ w⊢ PAFormula.freeFor w s PAFormula.bot = true rfl All goals completed! 🐙
| and _ _ ih₁ ih₂ and w:ℕs:PATermφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w s φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w s ψ✝ = truehw:(φ✝.and ψ✝).maxVar ≤ w⊢ PAFormula.freeFor w s (φ✝.and ψ✝) = true | or _ _ ih₁ ih₂ or w:ℕs:PATermφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w s φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w s ψ✝ = truehw:(φ✝.or ψ✝).maxVar ≤ w⊢ PAFormula.freeFor w s (φ✝.or ψ✝) = true | imp _ _ ih₁ ih₂ imp w:ℕs:PATermφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w s φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w s ψ✝ = truehw:(φ✝.imp ψ✝).maxVar ≤ w⊢ PAFormula.freeFor w s (φ✝.imp ψ✝) = true => imp w:ℕs:PATermφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w s φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w s ψ✝ = truehw:(φ✝.imp ψ✝).maxVar ≤ w⊢ PAFormula.freeFor w s (φ✝.imp ψ✝) = trueor w:ℕs:PATermφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w s φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w s ψ✝ = truehw:(φ✝.or ψ✝).maxVar ≤ w⊢ PAFormula.freeFor w s (φ✝.or ψ✝) = trueand w:ℕs:PATermφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w s φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w s ψ✝ = truehw:(φ✝.and ψ✝).maxVar ≤ w⊢ PAFormula.freeFor w s (φ✝.and ψ✝) = true
simp only [PAFormula.maxVar, Nat.max_le] at hw imp w:ℕs:PATermφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w s φ✝ = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w s ψ✝ = truehw:φ✝.maxVar ≤ w ∧ ψ✝.maxVar ≤ w⊢ PAFormula.freeFor w s (φ✝.imp ψ✝) = true
simp [PAFormula.freeFor, ih₁ hw.1, ih₂ hw.2] All goals completed! 🐙
| all y φ ih all w:ℕs:PATermy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w s φ = truehw:(PAFormula.all y φ).maxVar ≤ w⊢ PAFormula.freeFor w s (PAFormula.all y φ) = true | ex y φ ih ex w:ℕs:PATermy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w s φ = truehw:(PAFormula.ex y φ).maxVar ≤ w⊢ PAFormula.freeFor w s (PAFormula.ex y φ) = true => ex w:ℕs:PATermy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w s φ = truehw:(PAFormula.ex y φ).maxVar ≤ w⊢ PAFormula.freeFor w s (PAFormula.ex y φ) = trueall w:ℕs:PATermy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w s φ = truehw:(PAFormula.all y φ).maxVar ≤ w⊢ PAFormula.freeFor w s (PAFormula.all y φ) = true
simp only [PAFormula.maxVar, Nat.max_le] at hw ex w:ℕs:PATermy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w s φ = truehw:y + 1 ≤ w ∧ φ.maxVar ≤ w⊢ PAFormula.freeFor w s (PAFormula.ex y φ) = true
simp [PAFormula.freeFor, hasFree_false_of_maxVar_le hw.2, ih hw.2] All goals completed! 🐙private theorem freeFor_inverse_var {x w : ℕ} {φ : PAFormula} (hw : φ.maxVar ≤ w) :
(φ.subst x (.var w)).freeFor w (.var x) = true := by x:ℕw:ℕφ:PAFormulahw:φ.maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = true
induction φ with
| bot bot x:ℕw:ℕhw:PAFormula.bot.maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) PAFormula.bot) = true | eq _ _ eq x:ℕw:ℕt₁✝:PATermt₂✝:PATermhw:(PAFormula.eq t₁✝ t₂✝).maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.eq t₁✝ t₂✝)) = true => eq x:ℕw:ℕt₁✝:PATermt₂✝:PATermhw:(PAFormula.eq t₁✝ t₂✝).maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.eq t₁✝ t₂✝)) = truebot x:ℕw:ℕhw:PAFormula.bot.maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) PAFormula.bot) = true rfl All goals completed! 🐙
| and _ _ ih₁ ih₂ and x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ✝) = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ✝) = truehw:(φ✝.and ψ✝).maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (φ✝.and ψ✝)) = true | or _ _ ih₁ ih₂ or x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ✝) = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ✝) = truehw:(φ✝.or ψ✝).maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (φ✝.or ψ✝)) = true | imp _ _ ih₁ ih₂ imp x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ✝) = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ✝) = truehw:(φ✝.imp ψ✝).maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (φ✝.imp ψ✝)) = true => imp x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ✝) = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ✝) = truehw:(φ✝.imp ψ✝).maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (φ✝.imp ψ✝)) = trueor x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ✝) = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ✝) = truehw:(φ✝.or ψ✝).maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (φ✝.or ψ✝)) = trueand x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ✝) = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ✝) = truehw:(φ✝.and ψ✝).maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (φ✝.and ψ✝)) = true
simp only [PAFormula.maxVar, Nat.max_le] at hw imp x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ✝) = trueih₂:ψ✝.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ✝) = truehw:φ✝.maxVar ≤ w ∧ ψ✝.maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (φ✝.imp ψ✝)) = true
simp [PAFormula.subst, PAFormula.freeFor, ih₁ hw.1, ih₂ hw.2] All goals completed! 🐙
| all y φ ih all x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = truehw:(PAFormula.all y φ).maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.all y φ)) = true | ex y φ ih ex x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = truehw:(PAFormula.ex y φ).maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ)) = true => ex x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = truehw:(PAFormula.ex y φ).maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ)) = trueall x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = truehw:(PAFormula.all y φ).maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.all y φ)) = true
simp only [PAFormula.maxVar, Nat.max_le] at hw ex x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = truehw:y + 1 ≤ w ∧ φ.maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ)) = true
simp only [PAFormula.subst] ex x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = truehw:y + 1 ≤ w ∧ φ.maxVar ≤ w⊢ PAFormula.freeFor w (PATerm.var x)
(if (y == x) = true then PAFormula.ex y φ else PAFormula.ex y (PAFormula.subst x (PATerm.var w) φ)) =
true
by_cases hxy : y = x pos x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = truehw:y + 1 ≤ w ∧ φ.maxVar ≤ whxy:y = x⊢ PAFormula.freeFor w (PATerm.var x)
(if (y == x) = true then PAFormula.ex y φ else PAFormula.ex y (PAFormula.subst x (PATerm.var w) φ)) =
trueneg x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = truehw:y + 1 ≤ w ∧ φ.maxVar ≤ whxy:¬y = x⊢ PAFormula.freeFor w (PATerm.var x)
(if (y == x) = true then PAFormula.ex y φ else PAFormula.ex y (PAFormula.subst x (PATerm.var w) φ)) =
true
· pos x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = truehw:y + 1 ≤ w ∧ φ.maxVar ≤ whxy:y = x⊢ PAFormula.freeFor w (PATerm.var x)
(if (y == x) = true then PAFormula.ex y φ else PAFormula.ex y (PAFormula.subst x (PATerm.var w) φ)) =
true subst hxy pos w:ℕy:ℕφ:PAFormulahw:y + 1 ≤ w ∧ φ.maxVar ≤ wih:φ.maxVar ≤ w → PAFormula.freeFor w (PATerm.var y) (PAFormula.subst y (PATerm.var w) φ) = true⊢ PAFormula.freeFor w (PATerm.var y)
(if (y == y) = true then PAFormula.ex y φ else PAFormula.ex y (PAFormula.subst y (PATerm.var w) φ)) =
true
simp only [beq_self_eq_true, ↓reduceIte] pos w:ℕy:ℕφ:PAFormulahw:y + 1 ≤ w ∧ φ.maxVar ≤ wih:φ.maxVar ≤ w → PAFormula.freeFor w (PATerm.var y) (PAFormula.subst y (PATerm.var w) φ) = true⊢ PAFormula.freeFor w (PATerm.var y) (PAFormula.ex y φ) = true
exact freeFor_of_hasFree_false (.var y) (Nat.max_le.mpr hw) All goals completed! 🐙
· neg x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = truehw:y + 1 ≤ w ∧ φ.maxVar ≤ whxy:¬y = x⊢ PAFormula.freeFor w (PATerm.var x)
(if (y == x) = true then PAFormula.ex y φ else PAFormula.ex y (PAFormula.subst x (PATerm.var w) φ)) =
true have hb : (y == x) = false := beq_eq_false_iff_ne.mpr hxy neg x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = truehw:y + 1 ≤ w ∧ φ.maxVar ≤ whxy:¬y = xhb:(y == x) = false⊢ PAFormula.freeFor w (PATerm.var x)
(if (y == x) = true then PAFormula.ex y φ else PAFormula.ex y (PAFormula.subst x (PATerm.var w) φ)) =
true
simp [hb, PAFormula.freeFor, PATerm.hasVar, Ne.symm hxy, ih hw.2] All goals completed! 🐙private theorem term_subst_inverse_var {x w : ℕ} {t : PATerm} (hw : t.freshVar ≤ w) :
(t.subst x (.var w)).subst w (.var x) = t := by x:ℕw:ℕt:PATermhw:t.freshVar ≤ w⊢ (t.subst x (PATerm.var w)).subst w (PATerm.var x) = t
induction t with
| var z => var x:ℕw:ℕz:ℕhw:(PATerm.var z).freshVar ≤ w⊢ ((PATerm.var z).subst x (PATerm.var w)).subst w (PATerm.var x) = PATerm.var z
simp only [PATerm.freshVar] at hw var x:ℕw:ℕz:ℕhw:z + 1 ≤ w⊢ ((PATerm.var z).subst x (PATerm.var w)).subst w (PATerm.var x) = PATerm.var z
simp only [PATerm.subst] var x:ℕw:ℕz:ℕhw:z + 1 ≤ w⊢ (if (z == x) = true then PATerm.var w else PATerm.var z).subst w (PATerm.var x) = PATerm.var z
by_cases hzx : z = x pos x:ℕw:ℕz:ℕhw:z + 1 ≤ whzx:z = x⊢ (if (z == x) = true then PATerm.var w else PATerm.var z).subst w (PATerm.var x) = PATerm.var zneg x:ℕw:ℕz:ℕhw:z + 1 ≤ whzx:¬z = x⊢ (if (z == x) = true then PATerm.var w else PATerm.var z).subst w (PATerm.var x) = PATerm.var z
· pos x:ℕw:ℕz:ℕhw:z + 1 ≤ whzx:z = x⊢ (if (z == x) = true then PATerm.var w else PATerm.var z).subst w (PATerm.var x) = PATerm.var z subst hzx pos w:ℕz:ℕhw:z + 1 ≤ w⊢ (if (z == z) = true then PATerm.var w else PATerm.var z).subst w (PATerm.var z) = PATerm.var z; simp [PATerm.subst] All goals completed! 🐙
· neg x:ℕw:ℕz:ℕhw:z + 1 ≤ whzx:¬z = x⊢ (if (z == x) = true then PATerm.var w else PATerm.var z).subst w (PATerm.var x) = PATerm.var z have hzw : z ≠ w := by x:ℕw:ℕt:PATermhw:t.freshVar ≤ w⊢ (t.subst x (PATerm.var w)).subst w (PATerm.var x) = t omega neg x:ℕw:ℕz:ℕhw:z + 1 ≤ whzx:¬z = xhzw:z ≠ w⊢ (if (z == x) = true then PATerm.var w else PATerm.var z).subst w (PATerm.var x) = PATerm.var z
simp [hzx, PATerm.subst, hzw] All goals completed! 🐙
| zero => zero x:ℕw:ℕhw:PATerm.zero.freshVar ≤ w⊢ (PATerm.zero.subst x (PATerm.var w)).subst w (PATerm.var x) = PATerm.zero rfl All goals completed! 🐙
| succ _ ih => succ x:ℕw:ℕt✝:PATermih:t✝.freshVar ≤ w → (t✝.subst x (PATerm.var w)).subst w (PATerm.var x) = t✝hw:t✝.succ.freshVar ≤ w⊢ (t✝.succ.subst x (PATerm.var w)).subst w (PATerm.var x) = t✝.succ exact congrArg PATerm.succ (ih hw) All goals completed! 🐙
| add _ _ ih₁ ih₂ => add x:ℕw:ℕt₁✝:PATermt₂✝:PATermih₁:t₁✝.freshVar ≤ w → (t₁✝.subst x (PATerm.var w)).subst w (PATerm.var x) = t₁✝ih₂:t₂✝.freshVar ≤ w → (t₂✝.subst x (PATerm.var w)).subst w (PATerm.var x) = t₂✝hw:(t₁✝.add t₂✝).freshVar ≤ w⊢ ((t₁✝.add t₂✝).subst x (PATerm.var w)).subst w (PATerm.var x) = t₁✝.add t₂✝
simp only [PATerm.freshVar, Nat.max_le] at hw add x:ℕw:ℕt₁✝:PATermt₂✝:PATermih₁:t₁✝.freshVar ≤ w → (t₁✝.subst x (PATerm.var w)).subst w (PATerm.var x) = t₁✝ih₂:t₂✝.freshVar ≤ w → (t₂✝.subst x (PATerm.var w)).subst w (PATerm.var x) = t₂✝hw:t₁✝.freshVar ≤ w ∧ t₂✝.freshVar ≤ w⊢ ((t₁✝.add t₂✝).subst x (PATerm.var w)).subst w (PATerm.var x) = t₁✝.add t₂✝
exact congrArg₂ PATerm.add (ih₁ hw.1) (ih₂ hw.2) All goals completed! 🐙
| mul _ _ ih₁ ih₂ => mul x:ℕw:ℕt₁✝:PATermt₂✝:PATermih₁:t₁✝.freshVar ≤ w → (t₁✝.subst x (PATerm.var w)).subst w (PATerm.var x) = t₁✝ih₂:t₂✝.freshVar ≤ w → (t₂✝.subst x (PATerm.var w)).subst w (PATerm.var x) = t₂✝hw:(t₁✝.mul t₂✝).freshVar ≤ w⊢ ((t₁✝.mul t₂✝).subst x (PATerm.var w)).subst w (PATerm.var x) = t₁✝.mul t₂✝
simp only [PATerm.freshVar, Nat.max_le] at hw mul x:ℕw:ℕt₁✝:PATermt₂✝:PATermih₁:t₁✝.freshVar ≤ w → (t₁✝.subst x (PATerm.var w)).subst w (PATerm.var x) = t₁✝ih₂:t₂✝.freshVar ≤ w → (t₂✝.subst x (PATerm.var w)).subst w (PATerm.var x) = t₂✝hw:t₁✝.freshVar ≤ w ∧ t₂✝.freshVar ≤ w⊢ ((t₁✝.mul t₂✝).subst x (PATerm.var w)).subst w (PATerm.var x) = t₁✝.mul t₂✝
exact congrArg₂ PATerm.mul (ih₁ hw.1) (ih₂ hw.2) All goals completed! 🐙private theorem subst_inverse_var {x w : ℕ} {φ : PAFormula} (hw : φ.maxVar ≤ w) :
(φ.subst x (.var w)).subst w (.var x) = φ := by x:ℕw:ℕφ:PAFormulahw:φ.maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φ
induction φ with
| bot => bot x:ℕw:ℕhw:PAFormula.bot.maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) PAFormula.bot) = PAFormula.bot rfl All goals completed! 🐙
| eq t₁ t₂ => eq x:ℕw:ℕt₁:PATermt₂:PATermhw:(PAFormula.eq t₁ t₂).maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.eq t₁ t₂)) = PAFormula.eq t₁ t₂
simp only [PAFormula.maxVar, Nat.max_le] at hw eq x:ℕw:ℕt₁:PATermt₂:PATermhw:t₁.freshVar ≤ w ∧ t₂.freshVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.eq t₁ t₂)) = PAFormula.eq t₁ t₂
exact congrArg₂ PAFormula.eq (term_subst_inverse_var hw.1) (term_subst_inverse_var hw.2) All goals completed! 🐙
| and _ _ ih₁ ih₂ => and x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ✝) = φ✝ih₂:ψ✝.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ✝) = ψ✝hw:(φ✝.and ψ✝).maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (φ✝.and ψ✝)) = φ✝.and ψ✝
simp only [PAFormula.maxVar, Nat.max_le] at hw and x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ✝) = φ✝ih₂:ψ✝.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ✝) = ψ✝hw:φ✝.maxVar ≤ w ∧ ψ✝.maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (φ✝.and ψ✝)) = φ✝.and ψ✝
exact congrArg₂ PAFormula.and (ih₁ hw.1) (ih₂ hw.2) All goals completed! 🐙
| or _ _ ih₁ ih₂ => or x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ✝) = φ✝ih₂:ψ✝.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ✝) = ψ✝hw:(φ✝.or ψ✝).maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (φ✝.or ψ✝)) = φ✝.or ψ✝
simp only [PAFormula.maxVar, Nat.max_le] at hw or x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ✝) = φ✝ih₂:ψ✝.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ✝) = ψ✝hw:φ✝.maxVar ≤ w ∧ ψ✝.maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (φ✝.or ψ✝)) = φ✝.or ψ✝
exact congrArg₂ PAFormula.or (ih₁ hw.1) (ih₂ hw.2) All goals completed! 🐙
| imp _ _ ih₁ ih₂ => imp x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ✝) = φ✝ih₂:ψ✝.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ✝) = ψ✝hw:(φ✝.imp ψ✝).maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (φ✝.imp ψ✝)) = φ✝.imp ψ✝
simp only [PAFormula.maxVar, Nat.max_le] at hw imp x:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:φ✝.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ✝) = φ✝ih₂:ψ✝.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ✝) = ψ✝hw:φ✝.maxVar ≤ w ∧ ψ✝.maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (φ✝.imp ψ✝)) = φ✝.imp ψ✝
exact congrArg₂ PAFormula.imp (ih₁ hw.1) (ih₂ hw.2) All goals completed! 🐙
| all y φ ih => all x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:(PAFormula.all y φ).maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.all y φ)) = PAFormula.all y φ
simp only [PAFormula.maxVar, Nat.max_le] at hw all x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.all y φ)) = PAFormula.all y φ
have hyw : y ≠ w := by x:ℕw:ℕφ:PAFormulahw:φ.maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φ omega all x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.all y φ)) = PAFormula.all y φ
have hbw : (y == w) = false := beq_eq_false_iff_ne.mpr hyw all x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = false⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.all y φ)) = PAFormula.all y φ
by_cases hxy : y = x pos x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = falsehxy:y = x⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.all y φ)) = PAFormula.all y φneg x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = falsehxy:¬y = x⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.all y φ)) = PAFormula.all y φ
· pos x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = falsehxy:y = x⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.all y φ)) = PAFormula.all y φ subst hxy pos w:ℕy:ℕφ:PAFormulahw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = falseih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var y) (PAFormula.subst y (PATerm.var w) φ) = φ⊢ PAFormula.subst w (PATerm.var y) (PAFormula.subst y (PATerm.var w) (PAFormula.all y φ)) = PAFormula.all y φ
simp [PAFormula.subst, hbw,
subst_eq_self_of_hasFree_false (.var y) (hasFree_false_of_maxVar_le hw.2)] All goals completed! 🐙
· neg x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = falsehxy:¬y = x⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.all y φ)) = PAFormula.all y φ have hbx : (y == x) = false := beq_eq_false_iff_ne.mpr hxy neg x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = falsehxy:¬y = xhbx:(y == x) = false⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.all y φ)) = PAFormula.all y φ
simp [PAFormula.subst, hbx, hbw, ih hw.2] All goals completed! 🐙
| ex y φ ih => ex x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:(PAFormula.ex y φ).maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ)) = PAFormula.ex y φ
simp only [PAFormula.maxVar, Nat.max_le] at hw ex x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ)) = PAFormula.ex y φ
have hyw : y ≠ w := by x:ℕw:ℕφ:PAFormulahw:φ.maxVar ≤ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φ omega ex x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ w⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ)) = PAFormula.ex y φ
have hbw : (y == w) = false := beq_eq_false_iff_ne.mpr hyw ex x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = false⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ)) = PAFormula.ex y φ
by_cases hxy : y = x pos x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = falsehxy:y = x⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ)) = PAFormula.ex y φneg x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = falsehxy:¬y = x⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ)) = PAFormula.ex y φ
· pos x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = falsehxy:y = x⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ)) = PAFormula.ex y φ subst hxy pos w:ℕy:ℕφ:PAFormulahw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = falseih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var y) (PAFormula.subst y (PATerm.var w) φ) = φ⊢ PAFormula.subst w (PATerm.var y) (PAFormula.subst y (PATerm.var w) (PAFormula.ex y φ)) = PAFormula.ex y φ
simp [PAFormula.subst, hbw,
subst_eq_self_of_hasFree_false (.var y) (hasFree_false_of_maxVar_le hw.2)] All goals completed! 🐙
· neg x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = falsehxy:¬y = x⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ)) = PAFormula.ex y φ have hbx : (y == x) = false := beq_eq_false_iff_ne.mpr hxy neg x:ℕw:ℕy:ℕφ:PAFormulaih:φ.maxVar ≤ w → PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) φ) = φhw:y + 1 ≤ w ∧ φ.maxVar ≤ whyw:y ≠ whbw:(y == w) = falsehxy:¬y = xhbx:(y == x) = false⊢ PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ)) = PAFormula.ex y φ
simp [PAFormula.subst, hbx, hbw, ih hw.2] All goals completed! 🐙private theorem hasVar_subst_var_self_false {t : PATerm} {x w : ℕ} (hwx : w ≠ x) :
(t.subst x (.var w)).hasVar x = false := by t:PATermx:ℕw:ℕhwx:w ≠ x⊢ PATerm.hasVar x (t.subst x (PATerm.var w)) = false
induction t with
| var z => var x:ℕw:ℕhwx:w ≠ xz:ℕ⊢ PATerm.hasVar x ((PATerm.var z).subst x (PATerm.var w)) = false
simp only [PATerm.subst] var x:ℕw:ℕhwx:w ≠ xz:ℕ⊢ PATerm.hasVar x (if (z == x) = true then PATerm.var w else PATerm.var z) = false
by_cases hzx : z = x pos x:ℕw:ℕhwx:w ≠ xz:ℕhzx:z = x⊢ PATerm.hasVar x (if (z == x) = true then PATerm.var w else PATerm.var z) = falseneg x:ℕw:ℕhwx:w ≠ xz:ℕhzx:¬z = x⊢ PATerm.hasVar x (if (z == x) = true then PATerm.var w else PATerm.var z) = false
· pos x:ℕw:ℕhwx:w ≠ xz:ℕhzx:z = x⊢ PATerm.hasVar x (if (z == x) = true then PATerm.var w else PATerm.var z) = false subst hzx pos w:ℕz:ℕhwx:w ≠ z⊢ PATerm.hasVar z (if (z == z) = true then PATerm.var w else PATerm.var z) = false; simp [PATerm.hasVar, hwx] All goals completed! 🐙
· neg x:ℕw:ℕhwx:w ≠ xz:ℕhzx:¬z = x⊢ PATerm.hasVar x (if (z == x) = true then PATerm.var w else PATerm.var z) = false simp [hzx, PATerm.hasVar] All goals completed! 🐙
| zero => zero x:ℕw:ℕhwx:w ≠ x⊢ PATerm.hasVar x (PATerm.zero.subst x (PATerm.var w)) = false rfl All goals completed! 🐙
| succ _ ih => succ x:ℕw:ℕhwx:w ≠ xt✝:PATermih:PATerm.hasVar x (t✝.subst x (PATerm.var w)) = false⊢ PATerm.hasVar x (t✝.succ.subst x (PATerm.var w)) = false exact ih All goals completed! 🐙
| add _ _ ih₁ ih₂ add x:ℕw:ℕhwx:w ≠ xt₁✝:PATermt₂✝:PATermih₁:PATerm.hasVar x (t₁✝.subst x (PATerm.var w)) = falseih₂:PATerm.hasVar x (t₂✝.subst x (PATerm.var w)) = false⊢ PATerm.hasVar x ((t₁✝.add t₂✝).subst x (PATerm.var w)) = false | mul _ _ ih₁ ih₂ mul x:ℕw:ℕhwx:w ≠ xt₁✝:PATermt₂✝:PATermih₁:PATerm.hasVar x (t₁✝.subst x (PATerm.var w)) = falseih₂:PATerm.hasVar x (t₂✝.subst x (PATerm.var w)) = false⊢ PATerm.hasVar x ((t₁✝.mul t₂✝).subst x (PATerm.var w)) = false => mul x:ℕw:ℕhwx:w ≠ xt₁✝:PATermt₂✝:PATermih₁:PATerm.hasVar x (t₁✝.subst x (PATerm.var w)) = falseih₂:PATerm.hasVar x (t₂✝.subst x (PATerm.var w)) = false⊢ PATerm.hasVar x ((t₁✝.mul t₂✝).subst x (PATerm.var w)) = falseadd x:ℕw:ℕhwx:w ≠ xt₁✝:PATermt₂✝:PATermih₁:PATerm.hasVar x (t₁✝.subst x (PATerm.var w)) = falseih₂:PATerm.hasVar x (t₂✝.subst x (PATerm.var w)) = false⊢ PATerm.hasVar x ((t₁✝.add t₂✝).subst x (PATerm.var w)) = false
simp [PATerm.subst, PATerm.hasVar, ih₁, ih₂] All goals completed! 🐙private theorem hasFree_subst_var_self_false {φ : PAFormula} {x w : ℕ} (hwx : w ≠ x) :
(φ.subst x (.var w)).hasFree x = false := by φ:PAFormulax:ℕw:ℕhwx:w ≠ x⊢ PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ) = false
induction φ with
| bot => bot x:ℕw:ℕhwx:w ≠ x⊢ PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) PAFormula.bot) = false rfl All goals completed! 🐙
| eq t₁ t₂ => eq x:ℕw:ℕhwx:w ≠ xt₁:PATermt₂:PATerm⊢ PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) (PAFormula.eq t₁ t₂)) = false
simp [PAFormula.subst, PAFormula.hasFree, hasVar_subst_var_self_false hwx] All goals completed! 🐙
| and _ _ ih₁ ih₂ and x:ℕw:ℕhwx:w ≠ xφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = falseih₂:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) ψ✝) = false⊢ PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) (φ✝.and ψ✝)) = false | or _ _ ih₁ ih₂ or x:ℕw:ℕhwx:w ≠ xφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = falseih₂:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) ψ✝) = false⊢ PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) (φ✝.or ψ✝)) = false | imp _ _ ih₁ ih₂ imp x:ℕw:ℕhwx:w ≠ xφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = falseih₂:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) ψ✝) = false⊢ PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) (φ✝.imp ψ✝)) = false => imp x:ℕw:ℕhwx:w ≠ xφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = falseih₂:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) ψ✝) = false⊢ PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) (φ✝.imp ψ✝)) = falseor x:ℕw:ℕhwx:w ≠ xφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = falseih₂:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) ψ✝) = false⊢ PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) (φ✝.or ψ✝)) = falseand x:ℕw:ℕhwx:w ≠ xφ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = falseih₂:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) ψ✝) = false⊢ PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) (φ✝.and ψ✝)) = false
simp [PAFormula.subst, PAFormula.hasFree, ih₁, ih₂] All goals completed! 🐙
| all y _ ih all x:ℕw:ℕhwx:w ≠ xy:ℕφ✝:PAFormulaih:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = false⊢ PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) (PAFormula.all y φ✝)) = false | ex y _ ih ex x:ℕw:ℕhwx:w ≠ xy:ℕφ✝:PAFormulaih:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = false⊢ PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ✝)) = false => ex x:ℕw:ℕhwx:w ≠ xy:ℕφ✝:PAFormulaih:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = false⊢ PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) (PAFormula.ex y φ✝)) = falseall x:ℕw:ℕhwx:w ≠ xy:ℕφ✝:PAFormulaih:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = false⊢ PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) (PAFormula.all y φ✝)) = false
simp only [PAFormula.subst] ex x:ℕw:ℕhwx:w ≠ xy:ℕφ✝:PAFormulaih:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = false⊢ PAFormula.hasFree x
(if (y == x) = true then PAFormula.ex y φ✝ else PAFormula.ex y (PAFormula.subst x (PATerm.var w) φ✝)) =
false
by_cases hxy : y = x pos x:ℕw:ℕhwx:w ≠ xy:ℕφ✝:PAFormulaih:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = falsehxy:y = x⊢ PAFormula.hasFree x
(if (y == x) = true then PAFormula.ex y φ✝ else PAFormula.ex y (PAFormula.subst x (PATerm.var w) φ✝)) =
falseneg x:ℕw:ℕhwx:w ≠ xy:ℕφ✝:PAFormulaih:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = falsehxy:¬y = x⊢ PAFormula.hasFree x
(if (y == x) = true then PAFormula.ex y φ✝ else PAFormula.ex y (PAFormula.subst x (PATerm.var w) φ✝)) =
false
· pos x:ℕw:ℕhwx:w ≠ xy:ℕφ✝:PAFormulaih:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = falsehxy:y = x⊢ PAFormula.hasFree x
(if (y == x) = true then PAFormula.ex y φ✝ else PAFormula.ex y (PAFormula.subst x (PATerm.var w) φ✝)) =
false subst hxy pos w:ℕy:ℕφ✝:PAFormulahwx:w ≠ yih:PAFormula.hasFree y (PAFormula.subst y (PATerm.var w) φ✝) = false⊢ PAFormula.hasFree y
(if (y == y) = true then PAFormula.ex y φ✝ else PAFormula.ex y (PAFormula.subst y (PATerm.var w) φ✝)) =
false; simp [PAFormula.hasFree] All goals completed! 🐙
· neg x:ℕw:ℕhwx:w ≠ xy:ℕφ✝:PAFormulaih:PAFormula.hasFree x (PAFormula.subst x (PATerm.var w) φ✝) = falsehxy:¬y = x⊢ PAFormula.hasFree x
(if (y == x) = true then PAFormula.ex y φ✝ else PAFormula.ex y (PAFormula.subst x (PATerm.var w) φ✝)) =
false simp [hxy, PAFormula.hasFree, ih] All goals completed! 🐙private theorem update_id_self (y : ℕ) : Function.update (id : ℕ → ℕ) y y = id := by y:ℕ⊢ Function.update id y y = id
funext x y:ℕx:ℕ⊢ Function.update id y y x = id x
by_cases h : x = y pos y:ℕx:ℕh:x = y⊢ Function.update id y y x = id xneg y:ℕx:ℕh:¬x = y⊢ Function.update id y y x = id x
· pos y:ℕx:ℕh:x = y⊢ Function.update id y y x = id x subst h pos x:ℕ⊢ Function.update id x x x = id x; simp All goals completed! 🐙
· neg y:ℕx:ℕh:¬x = y⊢ Function.update id y y x = id x simp [h] All goals completed! 🐙private theorem term_vsubst_id (t : PATerm) : t.vsubst id = t := by t:PATerm⊢ PATerm.vsubst id t = t
induction t with
| var _ var x✝:ℕ⊢ PATerm.vsubst id (PATerm.var x✝) = PATerm.var x✝ | zero zero ⊢ PATerm.vsubst id PATerm.zero = PATerm.zero => zero ⊢ PATerm.vsubst id PATerm.zero = PATerm.zerovar x✝:ℕ⊢ PATerm.vsubst id (PATerm.var x✝) = PATerm.var x✝ rfl All goals completed! 🐙
| succ _ ih => succ t✝:PATermih:PATerm.vsubst id t✝ = t✝⊢ PATerm.vsubst id t✝.succ = t✝.succ exact congrArg PATerm.succ ih All goals completed! 🐙
| add _ _ ih₁ ih₂ => add t₁✝:PATermt₂✝:PATermih₁:PATerm.vsubst id t₁✝ = t₁✝ih₂:PATerm.vsubst id t₂✝ = t₂✝⊢ PATerm.vsubst id (t₁✝.add t₂✝) = t₁✝.add t₂✝ exact congrArg₂ PATerm.add ih₁ ih₂ All goals completed! 🐙
| mul _ _ ih₁ ih₂ => mul t₁✝:PATermt₂✝:PATermih₁:PATerm.vsubst id t₁✝ = t₁✝ih₂:PATerm.vsubst id t₂✝ = t₂✝⊢ PATerm.vsubst id (t₁✝.mul t₂✝) = t₁✝.mul t₂✝ exact congrArg₂ PATerm.mul ih₁ ih₂ All goals completed! 🐙private theorem vsubst_id (φ : PAFormula) : φ.vsubst id = φ := by φ:PAFormula⊢ PAFormula.vsubst id φ = φ
induction φ with
| bot => bot ⊢ PAFormula.vsubst id PAFormula.bot = PAFormula.bot rfl All goals completed! 🐙
| eq t₁ t₂ => eq t₁:PATermt₂:PATerm⊢ PAFormula.vsubst id (PAFormula.eq t₁ t₂) = PAFormula.eq t₁ t₂ exact congrArg₂ PAFormula.eq (term_vsubst_id t₁) (term_vsubst_id t₂) All goals completed! 🐙
| and _ _ ih₁ ih₂ => and φ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.vsubst id φ✝ = φ✝ih₂:PAFormula.vsubst id ψ✝ = ψ✝⊢ PAFormula.vsubst id (φ✝.and ψ✝) = φ✝.and ψ✝ exact congrArg₂ PAFormula.and ih₁ ih₂ All goals completed! 🐙
| or _ _ ih₁ ih₂ => or φ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.vsubst id φ✝ = φ✝ih₂:PAFormula.vsubst id ψ✝ = ψ✝⊢ PAFormula.vsubst id (φ✝.or ψ✝) = φ✝.or ψ✝ exact congrArg₂ PAFormula.or ih₁ ih₂ All goals completed! 🐙
| imp _ _ ih₁ ih₂ => imp φ✝:PAFormulaψ✝:PAFormulaih₁:PAFormula.vsubst id φ✝ = φ✝ih₂:PAFormula.vsubst id ψ✝ = ψ✝⊢ PAFormula.vsubst id (φ✝.imp ψ✝) = φ✝.imp ψ✝ exact congrArg₂ PAFormula.imp ih₁ ih₂ All goals completed! 🐙
| all y _ ih => all y:ℕφ✝:PAFormulaih:PAFormula.vsubst id φ✝ = φ✝⊢ PAFormula.vsubst id (PAFormula.all y φ✝) = PAFormula.all y φ✝
simp only [PAFormula.vsubst, update_id_self] all y:ℕφ✝:PAFormulaih:PAFormula.vsubst id φ✝ = φ✝⊢ PAFormula.all y (PAFormula.vsubst id φ✝) = PAFormula.all y φ✝
exact congrArg (PAFormula.all y) ih All goals completed! 🐙
| ex y _ ih => ex y:ℕφ✝:PAFormulaih:PAFormula.vsubst id φ✝ = φ✝⊢ PAFormula.vsubst id (PAFormula.ex y φ✝) = PAFormula.ex y φ✝
simp only [PAFormula.vsubst, update_id_self] ex y:ℕφ✝:PAFormulaih:PAFormula.vsubst id φ✝ = φ✝⊢ PAFormula.ex y (PAFormula.vsubst id φ✝) = PAFormula.ex y φ✝
exact congrArg (PAFormula.ex y) ih All goals completed! 🐙private theorem term_vsubst_subst_var {t : PATerm} {ρ : ℕ → ℕ} {y w : ℕ}
(h : ∀ x, t.hasVar x = true → x ≠ y → ρ x ≠ y) :
(t.vsubst (Function.update ρ y y)).subst y (.var w) = t.vsubst (Function.update ρ y w) := by t:PATermρ:ℕ → ℕy:ℕw:ℕh:∀ (x : ℕ), PATerm.hasVar x t = true → x ≠ y → ρ x ≠ y⊢ (PATerm.vsubst (Function.update ρ y y) t).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t
induction t with
| var x => var ρ:ℕ → ℕy:ℕw:ℕx:ℕh:∀ (x_1 : ℕ), PATerm.hasVar x_1 (PATerm.var x) = true → x_1 ≠ y → ρ x_1 ≠ y⊢ (PATerm.vsubst (Function.update ρ y y) (PATerm.var x)).subst y (PATerm.var w) =
PATerm.vsubst (Function.update ρ y w) (PATerm.var x)
simp only [PATerm.vsubst] var ρ:ℕ → ℕy:ℕw:ℕx:ℕh:∀ (x_1 : ℕ), PATerm.hasVar x_1 (PATerm.var x) = true → x_1 ≠ y → ρ x_1 ≠ y⊢ (PATerm.var (Function.update ρ y y x)).subst y (PATerm.var w) = PATerm.var (Function.update ρ y w x)
by_cases hxy : x = y pos ρ:ℕ → ℕy:ℕw:ℕx:ℕh:∀ (x_1 : ℕ), PATerm.hasVar x_1 (PATerm.var x) = true → x_1 ≠ y → ρ x_1 ≠ yhxy:x = y⊢ (PATerm.var (Function.update ρ y y x)).subst y (PATerm.var w) = PATerm.var (Function.update ρ y w x)neg ρ:ℕ → ℕy:ℕw:ℕx:ℕh:∀ (x_1 : ℕ), PATerm.hasVar x_1 (PATerm.var x) = true → x_1 ≠ y → ρ x_1 ≠ yhxy:¬x = y⊢ (PATerm.var (Function.update ρ y y x)).subst y (PATerm.var w) = PATerm.var (Function.update ρ y w x)
· pos ρ:ℕ → ℕy:ℕw:ℕx:ℕh:∀ (x_1 : ℕ), PATerm.hasVar x_1 (PATerm.var x) = true → x_1 ≠ y → ρ x_1 ≠ yhxy:x = y⊢ (PATerm.var (Function.update ρ y y x)).subst y (PATerm.var w) = PATerm.var (Function.update ρ y w x) subst hxy pos ρ:ℕ → ℕw:ℕx:ℕh:∀ (x_1 : ℕ), PATerm.hasVar x_1 (PATerm.var x) = true → x_1 ≠ x → ρ x_1 ≠ x⊢ (PATerm.var (Function.update ρ x x x)).subst x (PATerm.var w) = PATerm.var (Function.update ρ x w x); simp [PATerm.subst] All goals completed! 🐙
· neg ρ:ℕ → ℕy:ℕw:ℕx:ℕh:∀ (x_1 : ℕ), PATerm.hasVar x_1 (PATerm.var x) = true → x_1 ≠ y → ρ x_1 ≠ yhxy:¬x = y⊢ (PATerm.var (Function.update ρ y y x)).subst y (PATerm.var w) = PATerm.var (Function.update ρ y w x) have hρ : ρ x ≠ y := h x (by ρ:ℕ → ℕy:ℕw:ℕx:ℕh:∀ (x_1 : ℕ), PATerm.hasVar x_1 (PATerm.var x) = true → x_1 ≠ y → ρ x_1 ≠ yhxy:¬x = y⊢ PATerm.hasVar x (PATerm.var x) = true simp [PATerm.hasVar] All goals completed! 🐙) hxy neg ρ:ℕ → ℕy:ℕw:ℕx:ℕh:∀ (x_1 : ℕ), PATerm.hasVar x_1 (PATerm.var x) = true → x_1 ≠ y → ρ x_1 ≠ yhxy:¬x = yhρ:ρ x ≠ y⊢ (PATerm.var (Function.update ρ y y x)).subst y (PATerm.var w) = PATerm.var (Function.update ρ y w x)
simp [hxy, PATerm.subst, hρ] All goals completed! 🐙
| zero => zero ρ:ℕ → ℕy:ℕw:ℕh:∀ (x : ℕ), PATerm.hasVar x PATerm.zero = true → x ≠ y → ρ x ≠ y⊢ (PATerm.vsubst (Function.update ρ y y) PATerm.zero).subst y (PATerm.var w) =
PATerm.vsubst (Function.update ρ y w) PATerm.zero rfl All goals completed! 🐙
| succ _ ih => succ ρ:ℕ → ℕy:ℕw:ℕt✝:PATermih:(∀ (x : ℕ), PATerm.hasVar x t✝ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t✝).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t✝h:∀ (x : ℕ), PATerm.hasVar x t✝.succ = true → x ≠ y → ρ x ≠ y⊢ (PATerm.vsubst (Function.update ρ y y) t✝.succ).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t✝.succ
exact congrArg PATerm.succ (ih h) All goals completed! 🐙
| add t₁ t₂ ih₁ ih₂ => add ρ:ℕ → ℕy:ℕw:ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₁).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₁ih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₂).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₂h:∀ (x : ℕ), PATerm.hasVar x (t₁.add t₂) = true → x ≠ y → ρ x ≠ y⊢ (PATerm.vsubst (Function.update ρ y y) (t₁.add t₂)).subst y (PATerm.var w) =
PATerm.vsubst (Function.update ρ y w) (t₁.add t₂)
refine congrArg₂ PATerm.add (ih₁ fun x hx ↦ h x ?_) (ih₂ fun x hx ↦ h x ?_) add.refine_1 ρ:ℕ → ℕy:ℕw:ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₁).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₁ih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₂).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₂h:∀ (x : ℕ), PATerm.hasVar x (t₁.add t₂) = true → x ≠ y → ρ x ≠ yx:ℕhx:PATerm.hasVar x t₁ = true⊢ PATerm.hasVar x (t₁.add t₂) = trueadd.refine_2 ρ:ℕ → ℕy:ℕw:ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₁).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₁ih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₂).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₂h:∀ (x : ℕ), PATerm.hasVar x (t₁.add t₂) = true → x ≠ y → ρ x ≠ yx:ℕhx:PATerm.hasVar x t₂ = true⊢ PATerm.hasVar x (t₁.add t₂) = true <;> add.refine_1 ρ:ℕ → ℕy:ℕw:ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₁).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₁ih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₂).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₂h:∀ (x : ℕ), PATerm.hasVar x (t₁.add t₂) = true → x ≠ y → ρ x ≠ yx:ℕhx:PATerm.hasVar x t₁ = true⊢ PATerm.hasVar x (t₁.add t₂) = trueadd.refine_2 ρ:ℕ → ℕy:ℕw:ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₁).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₁ih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₂).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₂h:∀ (x : ℕ), PATerm.hasVar x (t₁.add t₂) = true → x ≠ y → ρ x ≠ yx:ℕhx:PATerm.hasVar x t₂ = true⊢ PATerm.hasVar x (t₁.add t₂) = true
simp [PATerm.hasVar, hx] All goals completed! 🐙
| mul t₁ t₂ ih₁ ih₂ => mul ρ:ℕ → ℕy:ℕw:ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₁).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₁ih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₂).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₂h:∀ (x : ℕ), PATerm.hasVar x (t₁.mul t₂) = true → x ≠ y → ρ x ≠ y⊢ (PATerm.vsubst (Function.update ρ y y) (t₁.mul t₂)).subst y (PATerm.var w) =
PATerm.vsubst (Function.update ρ y w) (t₁.mul t₂)
refine congrArg₂ PATerm.mul (ih₁ fun x hx ↦ h x ?_) (ih₂ fun x hx ↦ h x ?_) mul.refine_1 ρ:ℕ → ℕy:ℕw:ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₁).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₁ih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₂).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₂h:∀ (x : ℕ), PATerm.hasVar x (t₁.mul t₂) = true → x ≠ y → ρ x ≠ yx:ℕhx:PATerm.hasVar x t₁ = true⊢ PATerm.hasVar x (t₁.mul t₂) = truemul.refine_2 ρ:ℕ → ℕy:ℕw:ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₁).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₁ih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₂).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₂h:∀ (x : ℕ), PATerm.hasVar x (t₁.mul t₂) = true → x ≠ y → ρ x ≠ yx:ℕhx:PATerm.hasVar x t₂ = true⊢ PATerm.hasVar x (t₁.mul t₂) = true <;> mul.refine_1 ρ:ℕ → ℕy:ℕw:ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₁).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₁ih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₂).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₂h:∀ (x : ℕ), PATerm.hasVar x (t₁.mul t₂) = true → x ≠ y → ρ x ≠ yx:ℕhx:PATerm.hasVar x t₁ = true⊢ PATerm.hasVar x (t₁.mul t₂) = truemul.refine_2 ρ:ℕ → ℕy:ℕw:ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₁).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₁ih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≠ y → ρ x ≠ y) →
(PATerm.vsubst (Function.update ρ y y) t₂).subst y (PATerm.var w) = PATerm.vsubst (Function.update ρ y w) t₂h:∀ (x : ℕ), PATerm.hasVar x (t₁.mul t₂) = true → x ≠ y → ρ x ≠ yx:ℕhx:PATerm.hasVar x t₂ = true⊢ PATerm.hasVar x (t₁.mul t₂) = true
simp [PATerm.hasVar, hx] All goals completed! 🐙private theorem vsubst_subst_var {φ : PAFormula} {ρ : ℕ → ℕ} {y w : ℕ}
(h : ∀ x, φ.hasFree x = true → x ≠ y → ρ x ≠ y) :
(φ.vsubst (Function.update ρ y y)).subst y (.var w) = φ.vsubst (Function.update ρ y w) := by φ:PAFormulaρ:ℕ → ℕy:ℕw:ℕh:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ) =
PAFormula.vsubst (Function.update ρ y w) φ
induction φ generalizing ρ with
| bot => bot y:ℕw:ℕρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x PAFormula.bot = true → x ≠ y → ρ x ≠ y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) PAFormula.bot) =
PAFormula.vsubst (Function.update ρ y w) PAFormula.bot rfl All goals completed! 🐙
| eq t₁ t₂ => eq y:ℕw:ℕt₁:PATermt₂:PATermρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true → x ≠ y → ρ x ≠ y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) (PAFormula.eq t₁ t₂)) =
PAFormula.vsubst (Function.update ρ y w) (PAFormula.eq t₁ t₂)
refine congrArg₂ PAFormula.eq
(term_vsubst_subst_var fun x hx ↦ h x ?_)
(term_vsubst_subst_var fun x hx ↦ h x ?_) eq.refine_1 y:ℕw:ℕt₁:PATermt₂:PATermρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true → x ≠ y → ρ x ≠ yx:ℕhx:PATerm.hasVar x t₁ = true⊢ PAFormula.hasFree x (PAFormula.eq t₁ t₂) = trueeq.refine_2 y:ℕw:ℕt₁:PATermt₂:PATermρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true → x ≠ y → ρ x ≠ yx:ℕhx:PATerm.hasVar x t₂ = true⊢ PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true <;> eq.refine_1 y:ℕw:ℕt₁:PATermt₂:PATermρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true → x ≠ y → ρ x ≠ yx:ℕhx:PATerm.hasVar x t₁ = true⊢ PAFormula.hasFree x (PAFormula.eq t₁ t₂) = trueeq.refine_2 y:ℕw:ℕt₁:PATermt₂:PATermρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true → x ≠ y → ρ x ≠ yx:ℕhx:PATerm.hasVar x t₂ = true⊢ PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true
simp [PAFormula.hasFree, hx] All goals completed! 🐙
| and _ _ ih₁ ih₂ => and y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.and ψ✝) = true → x ≠ y → ρ x ≠ y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) (φ✝.and ψ✝)) =
PAFormula.vsubst (Function.update ρ y w) (φ✝.and ψ✝)
refine congrArg₂ PAFormula.and (ih₁ fun x hx ↦ h x ?_) (ih₂ fun x hx ↦ h x ?_) and.refine_1 y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.and ψ✝) = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ✝ = true⊢ PAFormula.hasFree x (φ✝.and ψ✝) = trueand.refine_2 y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.and ψ✝) = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x ψ✝ = true⊢ PAFormula.hasFree x (φ✝.and ψ✝) = true <;> and.refine_1 y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.and ψ✝) = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ✝ = true⊢ PAFormula.hasFree x (φ✝.and ψ✝) = trueand.refine_2 y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.and ψ✝) = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x ψ✝ = true⊢ PAFormula.hasFree x (φ✝.and ψ✝) = true
simp [PAFormula.hasFree, hx] All goals completed! 🐙
| or _ _ ih₁ ih₂ => or y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.or ψ✝) = true → x ≠ y → ρ x ≠ y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) (φ✝.or ψ✝)) =
PAFormula.vsubst (Function.update ρ y w) (φ✝.or ψ✝)
refine congrArg₂ PAFormula.or (ih₁ fun x hx ↦ h x ?_) (ih₂ fun x hx ↦ h x ?_) or.refine_1 y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.or ψ✝) = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ✝ = true⊢ PAFormula.hasFree x (φ✝.or ψ✝) = trueor.refine_2 y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.or ψ✝) = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x ψ✝ = true⊢ PAFormula.hasFree x (φ✝.or ψ✝) = true <;> or.refine_1 y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.or ψ✝) = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ✝ = true⊢ PAFormula.hasFree x (φ✝.or ψ✝) = trueor.refine_2 y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.or ψ✝) = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x ψ✝ = true⊢ PAFormula.hasFree x (φ✝.or ψ✝) = true
simp [PAFormula.hasFree, hx] All goals completed! 🐙
| imp _ _ ih₁ ih₂ => imp y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.imp ψ✝) = true → x ≠ y → ρ x ≠ y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) (φ✝.imp ψ✝)) =
PAFormula.vsubst (Function.update ρ y w) (φ✝.imp ψ✝)
refine congrArg₂ PAFormula.imp (ih₁ fun x hx ↦ h x ?_) (ih₂ fun x hx ↦ h x ?_) imp.refine_1 y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.imp ψ✝) = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ✝ = true⊢ PAFormula.hasFree x (φ✝.imp ψ✝) = trueimp.refine_2 y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.imp ψ✝) = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x ψ✝ = true⊢ PAFormula.hasFree x (φ✝.imp ψ✝) = true <;> imp.refine_1 y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.imp ψ✝) = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ✝ = true⊢ PAFormula.hasFree x (φ✝.imp ψ✝) = trueimp.refine_2 y:ℕw:ℕφ✝:PAFormulaψ✝:PAFormulaih₁:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ✝) =
PAFormula.vsubst (Function.update ρ y w) φ✝ih₂:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) ψ✝) =
PAFormula.vsubst (Function.update ρ y w) ψ✝ρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.imp ψ✝) = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x ψ✝ = true⊢ PAFormula.hasFree x (φ✝.imp ψ✝) = true
simp [PAFormula.hasFree, hx] All goals completed! 🐙
| all z χ ih => all y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) (PAFormula.all z χ)) =
PAFormula.vsubst (Function.update ρ y w) (PAFormula.all z χ)
simp only [PAFormula.vsubst] all y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ y y) z z) χ)) =
PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ y w) z z) χ)
by_cases hzy : z = y pos y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ yhzy:z = y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ y y) z z) χ)) =
PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ y w) z z) χ)neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ y y) z z) χ)) =
PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ y w) z z) χ)
· pos y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ yhzy:z = y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ y y) z z) χ)) =
PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ y w) z z) χ) subst hzy pos w:ℕz:ℕχ:PAFormulaρ:ℕ → ℕih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ z → ρ x ≠ z) →
PAFormula.subst z (PATerm.var w) (PAFormula.vsubst (Function.update ρ z z) χ) =
PAFormula.vsubst (Function.update ρ z w) χh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ z → ρ x ≠ z⊢ PAFormula.subst z (PATerm.var w) (PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ z z) z z) χ)) =
PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ z w) z z) χ)
simp [PAFormula.subst, Function.update_idem] All goals completed! 🐙
· neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ y y) z z) χ)) =
PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ y w) z z) χ) have hb : (z == y) = false := beq_eq_false_iff_ne.mpr hzy neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = false⊢ PAFormula.subst y (PATerm.var w) (PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ y y) z z) χ)) =
PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ y w) z z) χ)
simp only [PAFormula.subst, hb, Bool.false_eq_true, ↓reduceIte,
Function.update_comm (Ne.symm hzy)] neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = false⊢ PAFormula.all z (PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update (Function.update ρ z z) y y) χ)) =
PAFormula.all z (PAFormula.vsubst (Function.update (Function.update ρ z z) y w) χ)
refine congrArg (PAFormula.all z) (ih fun x hx hxy ↦ ?_) neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ y⊢ Function.update ρ z z x ≠ y
by_cases hxz : x = z pos y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yhxz:x = z⊢ Function.update ρ z z x ≠ yneg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yhxz:¬x = z⊢ Function.update ρ z z x ≠ y
· pos y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yhxz:x = z⊢ Function.update ρ z z x ≠ y subst hxz pos y:ℕw:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕx:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yh:∀ (x_1 : ℕ), PAFormula.hasFree x_1 (PAFormula.all x χ) = true → x_1 ≠ y → ρ x_1 ≠ yhzy:¬x = yhb:(x == y) = false⊢ Function.update ρ x x x ≠ y; simp [hzy] All goals completed! 🐙
· neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yhxz:¬x = z⊢ Function.update ρ z z x ≠ y simp only [Function.update_of_ne hxz] neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yhxz:¬x = z⊢ ρ x ≠ y
exact h x (by y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yhxz:¬x = z⊢ PAFormula.hasFree x (PAFormula.all z χ) = true simp [PAFormula.hasFree, Ne.symm hxz, hx] All goals completed! 🐙) hxy
| ex z χ ih => ex y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) (PAFormula.ex z χ)) =
PAFormula.vsubst (Function.update ρ y w) (PAFormula.ex z χ)
simp only [PAFormula.vsubst] ex y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ y y) z z) χ)) =
PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ y w) z z) χ)
by_cases hzy : z = y pos y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ yhzy:z = y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ y y) z z) χ)) =
PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ y w) z z) χ)neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ y y) z z) χ)) =
PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ y w) z z) χ)
· pos y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ yhzy:z = y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ y y) z z) χ)) =
PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ y w) z z) χ) subst hzy pos w:ℕz:ℕχ:PAFormulaρ:ℕ → ℕih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ z → ρ x ≠ z) →
PAFormula.subst z (PATerm.var w) (PAFormula.vsubst (Function.update ρ z z) χ) =
PAFormula.vsubst (Function.update ρ z w) χh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ z → ρ x ≠ z⊢ PAFormula.subst z (PATerm.var w) (PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ z z) z z) χ)) =
PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ z w) z z) χ)
simp [PAFormula.subst, Function.update_idem] All goals completed! 🐙
· neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = y⊢ PAFormula.subst y (PATerm.var w) (PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ y y) z z) χ)) =
PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ y w) z z) χ) have hb : (z == y) = false := beq_eq_false_iff_ne.mpr hzy neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = false⊢ PAFormula.subst y (PATerm.var w) (PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ y y) z z) χ)) =
PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ y w) z z) χ)
simp only [PAFormula.subst, hb, Bool.false_eq_true, ↓reduceIte,
Function.update_comm (Ne.symm hzy)] neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = false⊢ PAFormula.ex z (PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update (Function.update ρ z z) y y) χ)) =
PAFormula.ex z (PAFormula.vsubst (Function.update (Function.update ρ z z) y w) χ)
refine congrArg (PAFormula.ex z) (ih fun x hx hxy ↦ ?_) neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ y⊢ Function.update ρ z z x ≠ y
by_cases hxz : x = z pos y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yhxz:x = z⊢ Function.update ρ z z x ≠ yneg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yhxz:¬x = z⊢ Function.update ρ z z x ≠ y
· pos y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yhxz:x = z⊢ Function.update ρ z z x ≠ y subst hxz pos y:ℕw:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕx:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yh:∀ (x_1 : ℕ), PAFormula.hasFree x_1 (PAFormula.ex x χ) = true → x_1 ≠ y → ρ x_1 ≠ yhzy:¬x = yhb:(x == y) = false⊢ Function.update ρ x x x ≠ y; simp [hzy] All goals completed! 🐙
· neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yhxz:¬x = z⊢ Function.update ρ z z x ≠ y simp only [Function.update_of_ne hxz] neg y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yhxz:¬x = z⊢ ρ x ≠ y
exact h x (by y:ℕw:ℕz:ℕχ:PAFormulaih:∀ {ρ : ℕ → ℕ},
(∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≠ y → ρ x ≠ y) →
PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) χ) =
PAFormula.vsubst (Function.update ρ y w) χρ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≠ y → ρ x ≠ yhzy:¬z = yhb:(z == y) = falsex:ℕhx:PAFormula.hasFree x χ = truehxy:x ≠ yhxz:¬x = z⊢ PAFormula.hasFree x (PAFormula.ex z χ) = true simp [PAFormula.hasFree, Ne.symm hxz, hx] All goals completed! 🐙) hxyprivate theorem vsubst_update_id_eq_subst (ψ : PAFormula) (x w : ℕ) :
ψ.vsubst (Function.update id x w) = ψ.subst x (.var w) := by ψ:PAFormulax:ℕw:ℕ⊢ PAFormula.vsubst (Function.update id x w) ψ = PAFormula.subst x (PATerm.var w) ψ
have heq := vsubst_subst_var (φ := ψ) (ρ := id) (y := x) (w := w)
(fun z _ hzx ↦ hzx) ψ:PAFormulax:ℕw:ℕheq:PAFormula.subst x (PATerm.var w) (PAFormula.vsubst (Function.update id x x) ψ) =
PAFormula.vsubst (Function.update id x w) ψ⊢ PAFormula.vsubst (Function.update id x w) ψ = PAFormula.subst x (PATerm.var w) ψ
rw [update_id_self, ψ:PAFormulax:ℕw:ℕheq:PAFormula.subst x (PATerm.var w) (PAFormula.vsubst id ψ) = PAFormula.vsubst (Function.update id x w) ψ⊢ PAFormula.vsubst (Function.update id x w) ψ = PAFormula.subst x (PATerm.var w) ψ vsubst_id ψ:PAFormulax:ℕw:ℕheq:PAFormula.subst x (PATerm.var w) ψ = PAFormula.vsubst (Function.update id x w) ψ⊢ PAFormula.vsubst (Function.update id x w) ψ = PAFormula.subst x (PATerm.var w) ψ] at heq ψ:PAFormulax:ℕw:ℕheq:PAFormula.subst x (PATerm.var w) ψ = PAFormula.vsubst (Function.update id x w) ψ⊢ PAFormula.vsubst (Function.update id x w) ψ = PAFormula.subst x (PATerm.var w) ψ
exact heq.symm All goals completed! 🐙
Variable renaming ρ is capture-safe for φ: every free variable x of φ is either left
fixed (ρ x = x) or mapped to a variable ≥ φ.maxVar (disjoint from all variables of φ).
private def SafeFor (ρ : ℕ → ℕ) (φ : PAFormula) : Prop :=
∀ x, φ.hasFree x = true → ρ x = x ∨ φ.maxVar ≤ ρ xprivate theorem safeFor_id (φ : PAFormula) : SafeFor id φ :=
fun _ _ ↦ Or.inl rflprivate theorem safeFor_mono {ρ : ℕ → ℕ} {φ ψ : PAFormula} (h : SafeFor ρ ψ)
(hmax : φ.maxVar ≤ ψ.maxVar) (hfree : ∀ x, φ.hasFree x = true → ψ.hasFree x = true) :
SafeFor ρ φ := by ρ:ℕ → ℕφ:PAFormulaψ:PAFormulah:SafeFor ρ ψhmax:φ.maxVar ≤ ψ.maxVarhfree:∀ (x : ℕ), PAFormula.hasFree x φ = true → PAFormula.hasFree x ψ = true⊢ SafeFor ρ φ
intro x hx ρ:ℕ → ℕφ:PAFormulaψ:PAFormulah:SafeFor ρ ψhmax:φ.maxVar ≤ ψ.maxVarhfree:∀ (x : ℕ), PAFormula.hasFree x φ = true → PAFormula.hasFree x ψ = truex:ℕhx:PAFormula.hasFree x φ = true⊢ ρ x = x ∨ φ.maxVar ≤ ρ x
rcases h x (hfree x hx) with heq | hge inl ρ:ℕ → ℕφ:PAFormulaψ:PAFormulah:SafeFor ρ ψhmax:φ.maxVar ≤ ψ.maxVarhfree:∀ (x : ℕ), PAFormula.hasFree x φ = true → PAFormula.hasFree x ψ = truex:ℕhx:PAFormula.hasFree x φ = trueheq:ρ x = x⊢ ρ x = x ∨ φ.maxVar ≤ ρ xinr ρ:ℕ → ℕφ:PAFormulaψ:PAFormulah:SafeFor ρ ψhmax:φ.maxVar ≤ ψ.maxVarhfree:∀ (x : ℕ), PAFormula.hasFree x φ = true → PAFormula.hasFree x ψ = truex:ℕhx:PAFormula.hasFree x φ = truehge:ψ.maxVar ≤ ρ x⊢ ρ x = x ∨ φ.maxVar ≤ ρ x
· inl ρ:ℕ → ℕφ:PAFormulaψ:PAFormulah:SafeFor ρ ψhmax:φ.maxVar ≤ ψ.maxVarhfree:∀ (x : ℕ), PAFormula.hasFree x φ = true → PAFormula.hasFree x ψ = truex:ℕhx:PAFormula.hasFree x φ = trueheq:ρ x = x⊢ ρ x = x ∨ φ.maxVar ≤ ρ x exact Or.inl heq All goals completed! 🐙
· inr ρ:ℕ → ℕφ:PAFormulaψ:PAFormulah:SafeFor ρ ψhmax:φ.maxVar ≤ ψ.maxVarhfree:∀ (x : ℕ), PAFormula.hasFree x φ = true → PAFormula.hasFree x ψ = truex:ℕhx:PAFormula.hasFree x φ = truehge:ψ.maxVar ≤ ρ x⊢ ρ x = x ∨ φ.maxVar ≤ ρ x exact Or.inr (le_trans hmax hge) All goals completed! 🐙private theorem safeFor_update_fresh {ρ : ℕ → ℕ} {y w : ℕ} {φ : PAFormula}
(h : ∀ x, φ.hasFree x = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ x)
(hw : φ.maxVar ≤ w) :
SafeFor (Function.update ρ y w) φ := by ρ:ℕ → ℕy:ℕw:ℕφ:PAFormulah:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhw:φ.maxVar ≤ w⊢ SafeFor (Function.update ρ y w) φ
intro x hx ρ:ℕ → ℕy:ℕw:ℕφ:PAFormulah:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhw:φ.maxVar ≤ wx:ℕhx:PAFormula.hasFree x φ = true⊢ Function.update ρ y w x = x ∨ φ.maxVar ≤ Function.update ρ y w x
by_cases hxy : x = y pos ρ:ℕ → ℕy:ℕw:ℕφ:PAFormulah:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhw:φ.maxVar ≤ wx:ℕhx:PAFormula.hasFree x φ = truehxy:x = y⊢ Function.update ρ y w x = x ∨ φ.maxVar ≤ Function.update ρ y w xneg ρ:ℕ → ℕy:ℕw:ℕφ:PAFormulah:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhw:φ.maxVar ≤ wx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = y⊢ Function.update ρ y w x = x ∨ φ.maxVar ≤ Function.update ρ y w x
· pos ρ:ℕ → ℕy:ℕw:ℕφ:PAFormulah:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhw:φ.maxVar ≤ wx:ℕhx:PAFormula.hasFree x φ = truehxy:x = y⊢ Function.update ρ y w x = x ∨ φ.maxVar ≤ Function.update ρ y w x subst hxy pos ρ:ℕ → ℕw:ℕφ:PAFormulahw:φ.maxVar ≤ wx:ℕhx:PAFormula.hasFree x φ = trueh:∀ (x_1 : ℕ), PAFormula.hasFree x_1 φ = true → x_1 ≠ x → ρ x_1 = x_1 ∨ φ.maxVar ≤ ρ x_1⊢ Function.update ρ x w x = x ∨ φ.maxVar ≤ Function.update ρ x w x; simp [hw] All goals completed! 🐙
· neg ρ:ℕ → ℕy:ℕw:ℕφ:PAFormulah:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhw:φ.maxVar ≤ wx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = y⊢ Function.update ρ y w x = x ∨ φ.maxVar ≤ Function.update ρ y w x simp only [Function.update_of_ne hxy] neg ρ:ℕ → ℕy:ℕw:ℕφ:PAFormulah:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhw:φ.maxVar ≤ wx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = y⊢ ρ x = x ∨ φ.maxVar ≤ ρ x
exact h x hx hxy All goals completed! 🐙private theorem freshVar_le_vsubst {t : PATerm} {σ : ℕ → ℕ}
(h : ∀ x, t.hasVar x = true → x ≤ σ x) :
t.freshVar ≤ (t.vsubst σ).freshVar := by t:PATermσ:ℕ → ℕh:∀ (x : ℕ), PATerm.hasVar x t = true → x ≤ σ x⊢ t.freshVar ≤ (PATerm.vsubst σ t).freshVar
induction t with
| var x => var σ:ℕ → ℕx:ℕh:∀ (x_1 : ℕ), PATerm.hasVar x_1 (PATerm.var x) = true → x_1 ≤ σ x_1⊢ (PATerm.var x).freshVar ≤ (PATerm.vsubst σ (PATerm.var x)).freshVar
simp only [PATerm.freshVar, PATerm.vsubst] var σ:ℕ → ℕx:ℕh:∀ (x_1 : ℕ), PATerm.hasVar x_1 (PATerm.var x) = true → x_1 ≤ σ x_1⊢ x + 1 ≤ σ x + 1
have hx := h x (by σ:ℕ → ℕx:ℕh:∀ (x_1 : ℕ), PATerm.hasVar x_1 (PATerm.var x) = true → x_1 ≤ σ x_1⊢ PATerm.hasVar x (PATerm.var x) = true simp [PATerm.hasVar] All goals completed! 🐙) var σ:ℕ → ℕx:ℕh:∀ (x_1 : ℕ), PATerm.hasVar x_1 (PATerm.var x) = true → x_1 ≤ σ x_1hx:x ≤ σ x⊢ x + 1 ≤ σ x + 1
omega All goals completed! 🐙
| zero => zero σ:ℕ → ℕh:∀ (x : ℕ), PATerm.hasVar x PATerm.zero = true → x ≤ σ x⊢ PATerm.zero.freshVar ≤ (PATerm.vsubst σ PATerm.zero).freshVar exact Nat.le_refl 0 All goals completed! 🐙
| succ _ ih => succ σ:ℕ → ℕt✝:PATermih:(∀ (x : ℕ), PATerm.hasVar x t✝ = true → x ≤ σ x) → t✝.freshVar ≤ (PATerm.vsubst σ t✝).freshVarh:∀ (x : ℕ), PATerm.hasVar x t✝.succ = true → x ≤ σ x⊢ t✝.succ.freshVar ≤ (PATerm.vsubst σ t✝.succ).freshVar exact ih h All goals completed! 🐙
| add t₁ t₂ ih₁ ih₂ add σ:ℕ → ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≤ σ x) → t₁.freshVar ≤ (PATerm.vsubst σ t₁).freshVarih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≤ σ x) → t₂.freshVar ≤ (PATerm.vsubst σ t₂).freshVarh:∀ (x : ℕ), PATerm.hasVar x (t₁.add t₂) = true → x ≤ σ x⊢ (t₁.add t₂).freshVar ≤ (PATerm.vsubst σ (t₁.add t₂)).freshVar | mul t₁ t₂ ih₁ ih₂ mul σ:ℕ → ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≤ σ x) → t₁.freshVar ≤ (PATerm.vsubst σ t₁).freshVarih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≤ σ x) → t₂.freshVar ≤ (PATerm.vsubst σ t₂).freshVarh:∀ (x : ℕ), PATerm.hasVar x (t₁.mul t₂) = true → x ≤ σ x⊢ (t₁.mul t₂).freshVar ≤ (PATerm.vsubst σ (t₁.mul t₂)).freshVar => mul σ:ℕ → ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≤ σ x) → t₁.freshVar ≤ (PATerm.vsubst σ t₁).freshVarih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≤ σ x) → t₂.freshVar ≤ (PATerm.vsubst σ t₂).freshVarh:∀ (x : ℕ), PATerm.hasVar x (t₁.mul t₂) = true → x ≤ σ x⊢ (t₁.mul t₂).freshVar ≤ (PATerm.vsubst σ (t₁.mul t₂)).freshVaradd σ:ℕ → ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≤ σ x) → t₁.freshVar ≤ (PATerm.vsubst σ t₁).freshVarih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≤ σ x) → t₂.freshVar ≤ (PATerm.vsubst σ t₂).freshVarh:∀ (x : ℕ), PATerm.hasVar x (t₁.add t₂) = true → x ≤ σ x⊢ (t₁.add t₂).freshVar ≤ (PATerm.vsubst σ (t₁.add t₂)).freshVar
refine max_le_max (ih₁ fun x hx ↦ h x ?_) (ih₂ fun x hx ↦ h x ?_) mul.refine_1 σ:ℕ → ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≤ σ x) → t₁.freshVar ≤ (PATerm.vsubst σ t₁).freshVarih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≤ σ x) → t₂.freshVar ≤ (PATerm.vsubst σ t₂).freshVarh:∀ (x : ℕ), PATerm.hasVar x (t₁.mul t₂) = true → x ≤ σ xx:ℕhx:PATerm.hasVar x t₁ = true⊢ PATerm.hasVar x (t₁.mul t₂) = truemul.refine_2 σ:ℕ → ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≤ σ x) → t₁.freshVar ≤ (PATerm.vsubst σ t₁).freshVarih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≤ σ x) → t₂.freshVar ≤ (PATerm.vsubst σ t₂).freshVarh:∀ (x : ℕ), PATerm.hasVar x (t₁.mul t₂) = true → x ≤ σ xx:ℕhx:PATerm.hasVar x t₂ = true⊢ PATerm.hasVar x (t₁.mul t₂) = true <;> mul.refine_1 σ:ℕ → ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≤ σ x) → t₁.freshVar ≤ (PATerm.vsubst σ t₁).freshVarih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≤ σ x) → t₂.freshVar ≤ (PATerm.vsubst σ t₂).freshVarh:∀ (x : ℕ), PATerm.hasVar x (t₁.mul t₂) = true → x ≤ σ xx:ℕhx:PATerm.hasVar x t₁ = true⊢ PATerm.hasVar x (t₁.mul t₂) = truemul.refine_2 σ:ℕ → ℕt₁:PATermt₂:PATermih₁:(∀ (x : ℕ), PATerm.hasVar x t₁ = true → x ≤ σ x) → t₁.freshVar ≤ (PATerm.vsubst σ t₁).freshVarih₂:(∀ (x : ℕ), PATerm.hasVar x t₂ = true → x ≤ σ x) → t₂.freshVar ≤ (PATerm.vsubst σ t₂).freshVarh:∀ (x : ℕ), PATerm.hasVar x (t₁.mul t₂) = true → x ≤ σ xx:ℕhx:PATerm.hasVar x t₂ = true⊢ PATerm.hasVar x (t₁.mul t₂) = true
simp [PATerm.hasVar, hx] All goals completed! 🐙private theorem maxVar_le_vsubst_maxVar {φ : PAFormula} {σ : ℕ → ℕ}
(h : ∀ x, φ.hasFree x = true → x ≤ σ x) :
φ.maxVar ≤ (φ.vsubst σ).maxVar := by φ:PAFormulaσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≤ σ x⊢ φ.maxVar ≤ (PAFormula.vsubst σ φ).maxVar
induction φ generalizing σ with
| bot => bot σ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x PAFormula.bot = true → x ≤ σ x⊢ PAFormula.bot.maxVar ≤ (PAFormula.vsubst σ PAFormula.bot).maxVar exact Nat.le_refl 0 All goals completed! 🐙
| eq t₁ t₂ => eq t₁:PATermt₂:PATermσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true → x ≤ σ x⊢ (PAFormula.eq t₁ t₂).maxVar ≤ (PAFormula.vsubst σ (PAFormula.eq t₁ t₂)).maxVar
refine max_le_max
(freshVar_le_vsubst fun x hx ↦ h x ?_)
(freshVar_le_vsubst fun x hx ↦ h x ?_) eq.refine_1 t₁:PATermt₂:PATermσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true → x ≤ σ xx:ℕhx:PATerm.hasVar x t₁ = true⊢ PAFormula.hasFree x (PAFormula.eq t₁ t₂) = trueeq.refine_2 t₁:PATermt₂:PATermσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true → x ≤ σ xx:ℕhx:PATerm.hasVar x t₂ = true⊢ PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true <;> eq.refine_1 t₁:PATermt₂:PATermσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true → x ≤ σ xx:ℕhx:PATerm.hasVar x t₁ = true⊢ PAFormula.hasFree x (PAFormula.eq t₁ t₂) = trueeq.refine_2 t₁:PATermt₂:PATermσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true → x ≤ σ xx:ℕhx:PATerm.hasVar x t₂ = true⊢ PAFormula.hasFree x (PAFormula.eq t₁ t₂) = true
simp [PAFormula.hasFree, hx] All goals completed! 🐙
| and _ _ ih₁ ih₂ and φ✝:PAFormulaψ✝:PAFormulaih₁:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≤ σ x) → φ✝.maxVar ≤ (PAFormula.vsubst σ φ✝).maxVarih₂:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≤ σ x) → ψ✝.maxVar ≤ (PAFormula.vsubst σ ψ✝).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.and ψ✝) = true → x ≤ σ x⊢ (φ✝.and ψ✝).maxVar ≤ (PAFormula.vsubst σ (φ✝.and ψ✝)).maxVar | or _ _ ih₁ ih₂ or φ✝:PAFormulaψ✝:PAFormulaih₁:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≤ σ x) → φ✝.maxVar ≤ (PAFormula.vsubst σ φ✝).maxVarih₂:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≤ σ x) → ψ✝.maxVar ≤ (PAFormula.vsubst σ ψ✝).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.or ψ✝) = true → x ≤ σ x⊢ (φ✝.or ψ✝).maxVar ≤ (PAFormula.vsubst σ (φ✝.or ψ✝)).maxVar | imp _ _ ih₁ ih₂ imp φ✝:PAFormulaψ✝:PAFormulaih₁:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≤ σ x) → φ✝.maxVar ≤ (PAFormula.vsubst σ φ✝).maxVarih₂:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≤ σ x) → ψ✝.maxVar ≤ (PAFormula.vsubst σ ψ✝).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.imp ψ✝) = true → x ≤ σ x⊢ (φ✝.imp ψ✝).maxVar ≤ (PAFormula.vsubst σ (φ✝.imp ψ✝)).maxVar => imp φ✝:PAFormulaψ✝:PAFormulaih₁:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≤ σ x) → φ✝.maxVar ≤ (PAFormula.vsubst σ φ✝).maxVarih₂:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≤ σ x) → ψ✝.maxVar ≤ (PAFormula.vsubst σ ψ✝).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.imp ψ✝) = true → x ≤ σ x⊢ (φ✝.imp ψ✝).maxVar ≤ (PAFormula.vsubst σ (φ✝.imp ψ✝)).maxVaror φ✝:PAFormulaψ✝:PAFormulaih₁:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≤ σ x) → φ✝.maxVar ≤ (PAFormula.vsubst σ φ✝).maxVarih₂:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≤ σ x) → ψ✝.maxVar ≤ (PAFormula.vsubst σ ψ✝).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.or ψ✝) = true → x ≤ σ x⊢ (φ✝.or ψ✝).maxVar ≤ (PAFormula.vsubst σ (φ✝.or ψ✝)).maxVarand φ✝:PAFormulaψ✝:PAFormulaih₁:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≤ σ x) → φ✝.maxVar ≤ (PAFormula.vsubst σ φ✝).maxVarih₂:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≤ σ x) → ψ✝.maxVar ≤ (PAFormula.vsubst σ ψ✝).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.and ψ✝) = true → x ≤ σ x⊢ (φ✝.and ψ✝).maxVar ≤ (PAFormula.vsubst σ (φ✝.and ψ✝)).maxVar
refine max_le_max (ih₁ fun x hx ↦ h x ?_) (ih₂ fun x hx ↦ h x ?_) imp.refine_1 φ✝:PAFormulaψ✝:PAFormulaih₁:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≤ σ x) → φ✝.maxVar ≤ (PAFormula.vsubst σ φ✝).maxVarih₂:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≤ σ x) → ψ✝.maxVar ≤ (PAFormula.vsubst σ ψ✝).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.imp ψ✝) = true → x ≤ σ xx:ℕhx:PAFormula.hasFree x φ✝ = true⊢ PAFormula.hasFree x (φ✝.imp ψ✝) = trueimp.refine_2 φ✝:PAFormulaψ✝:PAFormulaih₁:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≤ σ x) → φ✝.maxVar ≤ (PAFormula.vsubst σ φ✝).maxVarih₂:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≤ σ x) → ψ✝.maxVar ≤ (PAFormula.vsubst σ ψ✝).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.imp ψ✝) = true → x ≤ σ xx:ℕhx:PAFormula.hasFree x ψ✝ = true⊢ PAFormula.hasFree x (φ✝.imp ψ✝) = true <;> imp.refine_1 φ✝:PAFormulaψ✝:PAFormulaih₁:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≤ σ x) → φ✝.maxVar ≤ (PAFormula.vsubst σ φ✝).maxVarih₂:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≤ σ x) → ψ✝.maxVar ≤ (PAFormula.vsubst σ ψ✝).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.imp ψ✝) = true → x ≤ σ xx:ℕhx:PAFormula.hasFree x φ✝ = true⊢ PAFormula.hasFree x (φ✝.imp ψ✝) = trueimp.refine_2 φ✝:PAFormulaψ✝:PAFormulaih₁:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x φ✝ = true → x ≤ σ x) → φ✝.maxVar ≤ (PAFormula.vsubst σ φ✝).maxVarih₂:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x ψ✝ = true → x ≤ σ x) → ψ✝.maxVar ≤ (PAFormula.vsubst σ ψ✝).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (φ✝.imp ψ✝) = true → x ≤ σ xx:ℕhx:PAFormula.hasFree x ψ✝ = true⊢ PAFormula.hasFree x (φ✝.imp ψ✝) = true
simp [PAFormula.hasFree, hx] All goals completed! 🐙
| all z χ ih all z:ℕχ:PAFormulaih:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≤ σ x) → χ.maxVar ≤ (PAFormula.vsubst σ χ).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≤ σ x⊢ (PAFormula.all z χ).maxVar ≤ (PAFormula.vsubst σ (PAFormula.all z χ)).maxVar | ex z χ ih ex z:ℕχ:PAFormulaih:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≤ σ x) → χ.maxVar ≤ (PAFormula.vsubst σ χ).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≤ σ x⊢ (PAFormula.ex z χ).maxVar ≤ (PAFormula.vsubst σ (PAFormula.ex z χ)).maxVar => ex z:ℕχ:PAFormulaih:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≤ σ x) → χ.maxVar ≤ (PAFormula.vsubst σ χ).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≤ σ x⊢ (PAFormula.ex z χ).maxVar ≤ (PAFormula.vsubst σ (PAFormula.ex z χ)).maxVarall z:ℕχ:PAFormulaih:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≤ σ x) → χ.maxVar ≤ (PAFormula.vsubst σ χ).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.all z χ) = true → x ≤ σ x⊢ (PAFormula.all z χ).maxVar ≤ (PAFormula.vsubst σ (PAFormula.all z χ)).maxVar
refine max_le_max (Nat.le_refl (z + 1)) (ih fun x hx ↦ ?_) ex z:ℕχ:PAFormulaih:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≤ σ x) → χ.maxVar ≤ (PAFormula.vsubst σ χ).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≤ σ xx:ℕhx:PAFormula.hasFree x χ = true⊢ x ≤ Function.update σ z z x
by_cases hxz : x = z pos z:ℕχ:PAFormulaih:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≤ σ x) → χ.maxVar ≤ (PAFormula.vsubst σ χ).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≤ σ xx:ℕhx:PAFormula.hasFree x χ = truehxz:x = z⊢ x ≤ Function.update σ z z xneg z:ℕχ:PAFormulaih:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≤ σ x) → χ.maxVar ≤ (PAFormula.vsubst σ χ).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≤ σ xx:ℕhx:PAFormula.hasFree x χ = truehxz:¬x = z⊢ x ≤ Function.update σ z z x
· pos z:ℕχ:PAFormulaih:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≤ σ x) → χ.maxVar ≤ (PAFormula.vsubst σ χ).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≤ σ xx:ℕhx:PAFormula.hasFree x χ = truehxz:x = z⊢ x ≤ Function.update σ z z x subst hxz pos χ:PAFormulaih:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≤ σ x) → χ.maxVar ≤ (PAFormula.vsubst σ χ).maxVarσ:ℕ → ℕx:ℕhx:PAFormula.hasFree x χ = trueh:∀ (x_1 : ℕ), PAFormula.hasFree x_1 (PAFormula.ex x χ) = true → x_1 ≤ σ x_1⊢ x ≤ Function.update σ x x x; simp All goals completed! 🐙
· neg z:ℕχ:PAFormulaih:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≤ σ x) → χ.maxVar ≤ (PAFormula.vsubst σ χ).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≤ σ xx:ℕhx:PAFormula.hasFree x χ = truehxz:¬x = z⊢ x ≤ Function.update σ z z x simp only [Function.update_of_ne hxz] neg z:ℕχ:PAFormulaih:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≤ σ x) → χ.maxVar ≤ (PAFormula.vsubst σ χ).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≤ σ xx:ℕhx:PAFormula.hasFree x χ = truehxz:¬x = z⊢ x ≤ σ x
exact h x (by z:ℕχ:PAFormulaih:∀ {σ : ℕ → ℕ}, (∀ (x : ℕ), PAFormula.hasFree x χ = true → x ≤ σ x) → χ.maxVar ≤ (PAFormula.vsubst σ χ).maxVarσ:ℕ → ℕh:∀ (x : ℕ), PAFormula.hasFree x (PAFormula.ex z χ) = true → x ≤ σ xx:ℕhx:PAFormula.hasFree x χ = truehxz:¬x = z⊢ PAFormula.hasFree x (PAFormula.ex z χ) = true simp [PAFormula.hasFree, Ne.symm hxz, hx] All goals completed! 🐙)Section 2: Finite-Context Derivability, Deduction Theorem, and FOL Lemmas
Derivability from a finite hypothesis list Δ over PAProvable using only modus ponens
(with universal generalization restricted to theorems of PAProvable, ensuring the unconditional
deduction theorem).
private inductive CtxProvable (Δ : List PAFormula) : PAFormula → Prop where
| ax {φ : PAFormula} : PAProvable φ → CtxProvable Δ φ
| hyp {φ : PAFormula} : φ ∈ Δ → CtxProvable Δ φ
| mp {φ ψ : PAFormula} : CtxProvable Δ φ → CtxProvable Δ (.imp φ ψ) → CtxProvable Δ ψprivate theorem ctx_nil_iff {φ : PAFormula} : CtxProvable [] φ ↔ PAProvable φ := by φ:PAFormula⊢ CtxProvable [] φ ↔ PAProvable φ
refine ⟨fun h ↦ ?_, CtxProvable.ax⟩ φ:PAFormulah:CtxProvable [] φ⊢ PAProvable φ
induction h with
| ax hp => ax φ:PAFormulaφ✝:PAFormulahp:PAProvable φ✝⊢ PAProvable φ✝ exact hp All goals completed! 🐙
| hyp hm => hyp φ:PAFormulaφ✝:PAFormulahm:φ✝ ∈ []⊢ PAProvable φ✝ cases hm All goals completed! 🐙
| mp _ _ ih₁ ih₂ => mp φ:PAFormulaφ✝:PAFormulaψ✝:PAFormulaa✝¹:CtxProvable [] φ✝a✝:CtxProvable [] (φ✝.imp ψ✝)ih₁:PAProvable φ✝ih₂:PAProvable (φ✝.imp ψ✝)⊢ PAProvable ψ✝ exact .mp ih₁ ih₂ All goals completed! 🐙private theorem ctx_mono {Δ₁ Δ₂ : List PAFormula} (hsub : ∀ γ ∈ Δ₁, γ ∈ Δ₂)
{φ : PAFormula} (h : CtxProvable Δ₁ φ) : CtxProvable Δ₂ φ := by Δ₁:List PAFormulaΔ₂:List PAFormulahsub:∀ γ ∈ Δ₁, γ ∈ Δ₂φ:PAFormulah:CtxProvable Δ₁ φ⊢ CtxProvable Δ₂ φ
induction h with
| ax hp => ax Δ₁:List PAFormulaΔ₂:List PAFormulahsub:∀ γ ∈ Δ₁, γ ∈ Δ₂φ:PAFormulaφ✝:PAFormulahp:PAProvable φ✝⊢ CtxProvable Δ₂ φ✝ exact .ax hp All goals completed! 🐙
| hyp hm => hyp Δ₁:List PAFormulaΔ₂:List PAFormulahsub:∀ γ ∈ Δ₁, γ ∈ Δ₂φ:PAFormulaφ✝:PAFormulahm:φ✝ ∈ Δ₁⊢ CtxProvable Δ₂ φ✝ exact .hyp (hsub _ hm) All goals completed! 🐙
| mp _ _ ih₁ ih₂ => mp Δ₁:List PAFormulaΔ₂:List PAFormulahsub:∀ γ ∈ Δ₁, γ ∈ Δ₂φ:PAFormulaφ✝:PAFormulaψ✝:PAFormulaa✝¹:CtxProvable Δ₁ φ✝a✝:CtxProvable Δ₁ (φ✝.imp ψ✝)ih₁:CtxProvable Δ₂ φ✝ih₂:CtxProvable Δ₂ (φ✝.imp ψ✝)⊢ CtxProvable Δ₂ ψ✝ exact .mp ih₁ ih₂ All goals completed! 🐙private theorem ctx_imp_refl (Δ : List PAFormula) (φ : PAFormula) :
CtxProvable Δ (.imp φ φ) :=
.mp (.ax (.imp_k φ φ))
(.mp (.ax (.imp_k φ (.imp φ φ))) (.ax (.imp_s φ (.imp φ φ) φ)))private theorem ctx_deduction {Δ : List PAFormula} {α β : PAFormula}
(h : CtxProvable (α :: Δ) β) : CtxProvable Δ (.imp α β) := by Δ:List PAFormulaα:PAFormulaβ:PAFormulah:CtxProvable (α :: Δ) β⊢ CtxProvable Δ (α.imp β)
induction h with
| ax hp => ax Δ:List PAFormulaα:PAFormulaβ:PAFormulaφ✝:PAFormulahp:PAProvable φ✝⊢ CtxProvable Δ (α.imp φ✝) exact .mp (.ax hp) (.ax (.imp_k _ α)) All goals completed! 🐙
| hyp hm => hyp Δ:List PAFormulaα:PAFormulaβ:PAFormulaφ✝:PAFormulahm:φ✝ ∈ α :: Δ⊢ CtxProvable Δ (α.imp φ✝)
rcases List.mem_cons.mp hm with heq | hm' hyp.inl Δ:List PAFormulaα:PAFormulaβ:PAFormulaφ✝:PAFormulahm:φ✝ ∈ α :: Δheq:φ✝ = α⊢ CtxProvable Δ (α.imp φ✝)hyp.inr Δ:List PAFormulaα:PAFormulaβ:PAFormulaφ✝:PAFormulahm:φ✝ ∈ α :: Δhm':φ✝ ∈ Δ⊢ CtxProvable Δ (α.imp φ✝)
· hyp.inl Δ:List PAFormulaα:PAFormulaβ:PAFormulaφ✝:PAFormulahm:φ✝ ∈ α :: Δheq:φ✝ = α⊢ CtxProvable Δ (α.imp φ✝) subst heq hyp.inl Δ:List PAFormulaβ:PAFormulaφ✝:PAFormulahm:φ✝ ∈ φ✝ :: Δ⊢ CtxProvable Δ (φ✝.imp φ✝); exact ctx_imp_refl Δ _ All goals completed! 🐙
· hyp.inr Δ:List PAFormulaα:PAFormulaβ:PAFormulaφ✝:PAFormulahm:φ✝ ∈ α :: Δhm':φ✝ ∈ Δ⊢ CtxProvable Δ (α.imp φ✝) exact .mp (.hyp hm') (.ax (.imp_k _ α)) All goals completed! 🐙
| mp _ _ ih₁ ih₂ => mp Δ:List PAFormulaα:PAFormulaβ:PAFormulaφ✝:PAFormulaψ✝:PAFormulaa✝¹:CtxProvable (α :: Δ) φ✝a✝:CtxProvable (α :: Δ) (φ✝.imp ψ✝)ih₁:CtxProvable Δ (α.imp φ✝)ih₂:CtxProvable Δ (α.imp (φ✝.imp ψ✝))⊢ CtxProvable Δ (α.imp ψ✝)
exact .mp ih₁ (.mp ih₂ (.ax (.imp_s α _ _))) All goals completed! 🐙private theorem ctx_by_contra {Δ : List PAFormula} {φ : PAFormula}
(h : CtxProvable (φ.not :: Δ) .bot) : CtxProvable Δ φ :=
.mp (ctx_deduction h) (.ax (.dne φ))private theorem ctx_exfalso {Δ : List PAFormula} (φ : PAFormula)
(h : CtxProvable Δ .bot) : CtxProvable Δ φ :=
ctx_by_contra (ctx_mono (fun _ hm ↦ List.mem_cons_of_mem _ hm) h)private theorem ctx_gen (w : ℕ) {Δ : List PAFormula} {α : PAFormula}
(hf : ∀ γ ∈ Δ, γ.hasFree w = false) (h : CtxProvable Δ α) :
CtxProvable Δ (.all w α) := by w:ℕΔ:List PAFormulaα:PAFormulahf:∀ γ ∈ Δ, PAFormula.hasFree w γ = falseh:CtxProvable Δ α⊢ CtxProvable Δ (PAFormula.all w α)
induction Δ generalizing α with
| nil => nil w:ℕα:PAFormulahf:∀ γ ∈ [], PAFormula.hasFree w γ = falseh:CtxProvable [] α⊢ CtxProvable [] (PAFormula.all w α)
exact .ax (.gen w (ctx_nil_iff.mp h)) All goals completed! 🐙
| cons δ Δ' ih => cons w:ℕδ:PAFormulaΔ':List PAFormulaih:∀ {α : PAFormula}, (∀ γ ∈ Δ', PAFormula.hasFree w γ = false) → CtxProvable Δ' α → CtxProvable Δ' (PAFormula.all w α)α:PAFormulahf:∀ γ ∈ δ :: Δ', PAFormula.hasFree w γ = falseh:CtxProvable (δ :: Δ') α⊢ CtxProvable (δ :: Δ') (PAFormula.all w α)
have hded : CtxProvable Δ' (.imp δ α) := ctx_deduction h cons w:ℕδ:PAFormulaΔ':List PAFormulaih:∀ {α : PAFormula}, (∀ γ ∈ Δ', PAFormula.hasFree w γ = false) → CtxProvable Δ' α → CtxProvable Δ' (PAFormula.all w α)α:PAFormulahf:∀ γ ∈ δ :: Δ', PAFormula.hasFree w γ = falseh:CtxProvable (δ :: Δ') αhded:CtxProvable Δ' (δ.imp α)⊢ CtxProvable (δ :: Δ') (PAFormula.all w α)
have hall : CtxProvable Δ' (.all w (.imp δ α)) :=
ih (fun γ hγ ↦ hf γ (List.mem_cons_of_mem _ hγ)) hded cons w:ℕδ:PAFormulaΔ':List PAFormulaih:∀ {α : PAFormula}, (∀ γ ∈ Δ', PAFormula.hasFree w γ = false) → CtxProvable Δ' α → CtxProvable Δ' (PAFormula.all w α)α:PAFormulahf:∀ γ ∈ δ :: Δ', PAFormula.hasFree w γ = falseh:CtxProvable (δ :: Δ') αhded:CtxProvable Δ' (δ.imp α)hall:CtxProvable Δ' (PAFormula.all w (δ.imp α))⊢ CtxProvable (δ :: Δ') (PAFormula.all w α)
have himp : CtxProvable Δ' (.imp (.all w δ) (.all w α)) :=
.mp hall (.ax (.all_imp w δ α)) cons w:ℕδ:PAFormulaΔ':List PAFormulaih:∀ {α : PAFormula}, (∀ γ ∈ Δ', PAFormula.hasFree w γ = false) → CtxProvable Δ' α → CtxProvable Δ' (PAFormula.all w α)α:PAFormulahf:∀ γ ∈ δ :: Δ', PAFormula.hasFree w γ = falseh:CtxProvable (δ :: Δ') αhded:CtxProvable Δ' (δ.imp α)hall:CtxProvable Δ' (PAFormula.all w (δ.imp α))himp:CtxProvable Δ' ((PAFormula.all w δ).imp (PAFormula.all w α))⊢ CtxProvable (δ :: Δ') (PAFormula.all w α)
have himp' : CtxProvable (δ :: Δ') (.imp (.all w δ) (.all w α)) :=
ctx_mono (fun _ hm ↦ List.mem_cons_of_mem _ hm) himp cons w:ℕδ:PAFormulaΔ':List PAFormulaih:∀ {α : PAFormula}, (∀ γ ∈ Δ', PAFormula.hasFree w γ = false) → CtxProvable Δ' α → CtxProvable Δ' (PAFormula.all w α)α:PAFormulahf:∀ γ ∈ δ :: Δ', PAFormula.hasFree w γ = falseh:CtxProvable (δ :: Δ') αhded:CtxProvable Δ' (δ.imp α)hall:CtxProvable Δ' (PAFormula.all w (δ.imp α))himp:CtxProvable Δ' ((PAFormula.all w δ).imp (PAFormula.all w α))himp':CtxProvable (δ :: Δ') ((PAFormula.all w δ).imp (PAFormula.all w α))⊢ CtxProvable (δ :: Δ') (PAFormula.all w α)
have hvac : PAProvable (.imp δ (.all w δ)) :=
.all_vacuous w δ (hf δ (List.mem_cons_self ..)) cons w:ℕδ:PAFormulaΔ':List PAFormulaih:∀ {α : PAFormula}, (∀ γ ∈ Δ', PAFormula.hasFree w γ = false) → CtxProvable Δ' α → CtxProvable Δ' (PAFormula.all w α)α:PAFormulahf:∀ γ ∈ δ :: Δ', PAFormula.hasFree w γ = falseh:CtxProvable (δ :: Δ') αhded:CtxProvable Δ' (δ.imp α)hall:CtxProvable Δ' (PAFormula.all w (δ.imp α))himp:CtxProvable Δ' ((PAFormula.all w δ).imp (PAFormula.all w α))himp':CtxProvable (δ :: Δ') ((PAFormula.all w δ).imp (PAFormula.all w α))hvac:PAProvable (δ.imp (PAFormula.all w δ))⊢ CtxProvable (δ :: Δ') (PAFormula.all w α)
exact .mp (.mp (.hyp (List.mem_cons_self ..)) (.ax hvac)) himp' All goals completed! 🐙private theorem pa_all_not_subst_imp_not_ex {x w : ℕ} {ψ : PAFormula}
(hw : (PAFormula.ex x ψ).maxVar ≤ w) :
PAProvable (.imp (.all w (.not (ψ.subst x (.var w)))) (.not (.ex x ψ))) := by x:ℕw:ℕψ:PAFormulahw:(PAFormula.ex x ψ).maxVar ≤ w⊢ PAProvable ((PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not).imp (PAFormula.ex x ψ).not)
simp only [PAFormula.maxVar, Nat.max_le] at hw x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ w⊢ PAProvable ((PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not).imp (PAFormula.ex x ψ).not)
have hwx : w ≠ x := by omega x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ whwx:w ≠ x⊢ PAProvable ((PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not).imp (PAFormula.ex x ψ).not)
let γ : PAFormula := .all w (.not (ψ.subst x (.var w))) x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ whwx:w ≠ xγ:PAFormula := PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not⊢ PAProvable ((PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not).imp (PAFormula.ex x ψ).not)
have hγx : γ.hasFree x = false := by
simp [γ, PAFormula.hasFree, hasFree_subst_var_self_false hwx] x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ whwx:w ≠ xγ:PAFormula := PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).nothγx:PAFormula.hasFree x γ = false⊢ PAProvable ((PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not).imp (PAFormula.ex x ψ).not)
have hfree : (PAFormula.not (ψ.subst x (.var w))).freeFor w (.var x) = true := by
simp [PAFormula.freeFor, freeFor_inverse_var hw.2] x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ whwx:w ≠ xγ:PAFormula := PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).nothγx:PAFormula.hasFree x γ = falsehfree:PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = true⊢ PAProvable ((PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not).imp (PAFormula.ex x ψ).not)
have hsub : (PAFormula.not (ψ.subst x (.var w))).subst w (.var x) = ψ.not := by
simp [PAFormula.subst, subst_inverse_var hw.2] x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ whwx:w ≠ xγ:PAFormula := PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).nothγx:PAFormula.hasFree x γ = falsehfree:PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = truehsub:PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = ψ.not⊢ PAProvable ((PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not).imp (PAFormula.ex x ψ).not)
have helim : PAProvable (.imp γ ψ.not) := by
have h := PAProvable.all_elim w (.var x) (.not (ψ.subst x (.var w))) hfree x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ whwx:w ≠ xγ:PAFormula := PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).nothγx:PAFormula.hasFree x γ = falsehfree:PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = truehsub:PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = ψ.noth:PAProvable
((PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not).imp
(PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not))⊢ PAProvable (γ.imp ψ.not)
rwa [hsub] at h x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ whwx:w ≠ xγ:PAFormula := PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).nothγx:PAFormula.hasFree x γ = falsehfree:PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = truehsub:PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = ψ.nothelim:PAProvable (γ.imp ψ.not)⊢ PAProvable ((PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not).imp (PAFormula.ex x ψ).not)
have h1 : CtxProvable [γ] ψ.not :=
.mp (.hyp (List.mem_singleton.mpr rfl)) (.ax helim) x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ whwx:w ≠ xγ:PAFormula := PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).nothγx:PAFormula.hasFree x γ = falsehfree:PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = truehsub:PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = ψ.nothelim:PAProvable (γ.imp ψ.not)h1:CtxProvable [γ] ψ.not⊢ PAProvable ((PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not).imp (PAFormula.ex x ψ).not)
have h2 : CtxProvable [γ] (.all x (.imp ψ .bot)) :=
ctx_gen x (fun δ hδ ↦ by x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ whwx:w ≠ xγ:PAFormula := PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).nothγx:PAFormula.hasFree x γ = falsehfree:PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = truehsub:PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = ψ.nothelim:PAProvable (γ.imp ψ.not)h1:CtxProvable [γ] ψ.notδ:PAFormulahδ:δ ∈ [γ]⊢ PAFormula.hasFree x δ = false rw [List.mem_singleton.mp hδ x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ whwx:w ≠ xγ:PAFormula := PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).nothγx:PAFormula.hasFree x γ = falsehfree:PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = truehsub:PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = ψ.nothelim:PAProvable (γ.imp ψ.not)h1:CtxProvable [γ] ψ.notδ:PAFormulahδ:δ ∈ [γ]⊢ PAFormula.hasFree x γ = false] x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ whwx:w ≠ xγ:PAFormula := PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).nothγx:PAFormula.hasFree x γ = falsehfree:PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = truehsub:PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = ψ.nothelim:PAProvable (γ.imp ψ.not)h1:CtxProvable [γ] ψ.notδ:PAFormulahδ:δ ∈ [γ]⊢ PAFormula.hasFree x γ = false; exact hγx All goals completed! 🐙) h1 x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ whwx:w ≠ xγ:PAFormula := PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).nothγx:PAFormula.hasFree x γ = falsehfree:PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = truehsub:PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = ψ.nothelim:PAProvable (γ.imp ψ.not)h1:CtxProvable [γ] ψ.noth2:CtxProvable [γ] (PAFormula.all x (ψ.imp PAFormula.bot))⊢ PAProvable ((PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not).imp (PAFormula.ex x ψ).not)
have h3 : CtxProvable [γ] (.not (.ex x ψ)) :=
.mp h2 (.ax (.ex_elim x ψ .bot rfl)) x:ℕw:ℕψ:PAFormulahw:x + 1 ≤ w ∧ ψ.maxVar ≤ whwx:w ≠ xγ:PAFormula := PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).nothγx:PAFormula.hasFree x γ = falsehfree:PAFormula.freeFor w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = truehsub:PAFormula.subst w (PATerm.var x) (PAFormula.subst x (PATerm.var w) ψ).not = ψ.nothelim:PAProvable (γ.imp ψ.not)h1:CtxProvable [γ] ψ.noth2:CtxProvable [γ] (PAFormula.all x (ψ.imp PAFormula.bot))h3:CtxProvable [γ] (PAFormula.ex x ψ).not⊢ PAProvable ((PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not).imp (PAFormula.ex x ψ).not)
exact ctx_nil_iff.mp (ctx_deduction h3) All goals completed! 🐙private theorem pa_de_morgan_all (y : ℕ) (ψ : PAFormula) :
PAProvable (.imp (.not (.all y ψ)) (.ex y (.not ψ))) := by y:ℕψ:PAFormula⊢ PAProvable ((PAFormula.all y ψ).not.imp (PAFormula.ex y ψ.not))
let γ₁ : PAFormula := (PAFormula.ex y ψ.not).not y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).not⊢ PAProvable ((PAFormula.all y ψ).not.imp (PAFormula.ex y ψ.not))
let γ₂ : PAFormula := (PAFormula.all y ψ).not y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).not⊢ PAProvable ((PAFormula.all y ψ).not.imp (PAFormula.ex y ψ.not))
have hfree : ψ.not.freeFor y (.var y) = true := freeFor_var_self y ψ.not y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = true⊢ PAProvable ((PAFormula.all y ψ).not.imp (PAFormula.ex y ψ.not))
have hex : PAProvable (.imp ψ.not (.ex y ψ.not)) := by
have h := PAProvable.ex_intro y (.var y) ψ.not hfree y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = trueh:PAProvable ((PAFormula.subst y (PATerm.var y) ψ.not).imp (PAFormula.ex y ψ.not))⊢ PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))
rwa [subst_var_self] at h y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))⊢ PAProvable ((PAFormula.all y ψ).not.imp (PAFormula.ex y ψ.not))
have hbot₁ : CtxProvable [ψ.not, γ₁, γ₂] .bot := by
have hn : CtxProvable [ψ.not, γ₁, γ₂] ψ.not := .hyp (by y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))⊢ ψ.not ∈ [ψ.not, γ₁, γ₂] simp All goals completed! 🐙) y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hn:CtxProvable [ψ.not, γ₁, γ₂] ψ.not⊢ CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bot
have hg₁ : CtxProvable [ψ.not, γ₁, γ₂] γ₁ := .hyp (by y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hn:CtxProvable [ψ.not, γ₁, γ₂] ψ.not⊢ γ₁ ∈ [ψ.not, γ₁, γ₂] simp All goals completed! 🐙) y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hn:CtxProvable [ψ.not, γ₁, γ₂] ψ.nothg₁:CtxProvable [ψ.not, γ₁, γ₂] γ₁⊢ CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bot
exact .mp (.mp hn (.ax hex)) hg₁ y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hbot₁:CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bot⊢ PAProvable ((PAFormula.all y ψ).not.imp (PAFormula.ex y ψ.not))
have hψ : CtxProvable [γ₁, γ₂] ψ := ctx_by_contra hbot₁ y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hbot₁:CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bothψ:CtxProvable [γ₁, γ₂] ψ⊢ PAProvable ((PAFormula.all y ψ).not.imp (PAFormula.ex y ψ.not))
have hall : CtxProvable [γ₁, γ₂] (.all y ψ) := by
refine ctx_gen y (fun δ hδ ↦ ?_) hψ y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hbot₁:CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bothψ:CtxProvable [γ₁, γ₂] ψδ:PAFormulahδ:δ ∈ [γ₁, γ₂]⊢ PAFormula.hasFree y δ = false
rcases List.mem_cons.mp hδ with rfl | hδ' inl y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hbot₁:CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bothψ:CtxProvable [γ₁, γ₂] ψhδ:γ₁ ∈ [γ₁, γ₂]⊢ PAFormula.hasFree y γ₁ = falseinr y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hbot₁:CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bothψ:CtxProvable [γ₁, γ₂] ψδ:PAFormulahδ:δ ∈ [γ₁, γ₂]hδ':δ ∈ [γ₂]⊢ PAFormula.hasFree y δ = false
· inl y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hbot₁:CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bothψ:CtxProvable [γ₁, γ₂] ψhδ:γ₁ ∈ [γ₁, γ₂]⊢ PAFormula.hasFree y γ₁ = false simp [γ₁, PAFormula.hasFree] All goals completed! 🐙
· inr y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hbot₁:CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bothψ:CtxProvable [γ₁, γ₂] ψδ:PAFormulahδ:δ ∈ [γ₁, γ₂]hδ':δ ∈ [γ₂]⊢ PAFormula.hasFree y δ = false rw [List.mem_singleton.mp hδ' inr y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hbot₁:CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bothψ:CtxProvable [γ₁, γ₂] ψδ:PAFormulahδ:δ ∈ [γ₁, γ₂]hδ':δ ∈ [γ₂]⊢ PAFormula.hasFree y γ₂ = false] inr y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hbot₁:CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bothψ:CtxProvable [γ₁, γ₂] ψδ:PAFormulahδ:δ ∈ [γ₁, γ₂]hδ':δ ∈ [γ₂]⊢ PAFormula.hasFree y γ₂ = false
simp [γ₂, PAFormula.hasFree] y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hbot₁:CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bothψ:CtxProvable [γ₁, γ₂] ψhall:CtxProvable [γ₁, γ₂] (PAFormula.all y ψ)⊢ PAProvable ((PAFormula.all y ψ).not.imp (PAFormula.ex y ψ.not))
have hbot₂ : CtxProvable [γ₁, γ₂] .bot :=
.mp hall (.hyp (by y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hbot₁:CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bothψ:CtxProvable [γ₁, γ₂] ψhall:CtxProvable [γ₁, γ₂] (PAFormula.all y ψ)⊢ (PAFormula.all y ψ).imp PAFormula.bot ∈ [γ₁, γ₂] simp [γ₂] All goals completed! 🐙)) y:ℕψ:PAFormulaγ₁:PAFormula := (PAFormula.ex y ψ.not).notγ₂:PAFormula := (PAFormula.all y ψ).nothfree:PAFormula.freeFor y (PATerm.var y) ψ.not = truehex:PAProvable (ψ.not.imp (PAFormula.ex y ψ.not))hbot₁:CtxProvable [ψ.not, γ₁, γ₂] PAFormula.bothψ:CtxProvable [γ₁, γ₂] ψhall:CtxProvable [γ₁, γ₂] (PAFormula.all y ψ)hbot₂:CtxProvable [γ₁, γ₂] PAFormula.bot⊢ PAProvable ((PAFormula.all y ψ).not.imp (PAFormula.ex y ψ.not))
exact ctx_nil_iff.mp (ctx_deduction (ctx_by_contra hbot₂)) All goals completed! 🐙private theorem pa_eq_symm (s t : PATerm) :
PAProvable (.imp (.eq s t) (.eq t s)) := by s:PATermt:PATerm⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq t s))
let x := max s.freshVar t.freshVar s:PATermt:PATermx:ℕ := max s.freshVar t.freshVar⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq t s))
have hsx : s.hasVar x = false := hasVar_false_of_freshVar_le (Nat.le_max_left ..) s:PATermt:PATermx:ℕ := max s.freshVar t.freshVarhsx:PATerm.hasVar x s = false⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq t s))
let φ : PAFormula := .eq (.var x) s s:PATermt:PATermx:ℕ := max s.freshVar t.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq (PATerm.var x) s⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq t s))
have hsub_s : φ.subst x s = .eq s s := by
simp [φ, PAFormula.subst, PATerm.subst, term_subst_eq_self_of_hasVar_false s hsx] s:PATermt:PATermx:ℕ := max s.freshVar t.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq (PATerm.var x) shsub_s:PAFormula.subst x s φ = PAFormula.eq s s⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq t s))
have hsub_t : φ.subst x t = .eq t s := by
simp [φ, PAFormula.subst, PATerm.subst, term_subst_eq_self_of_hasVar_false t hsx] s:PATermt:PATermx:ℕ := max s.freshVar t.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq (PATerm.var x) shsub_s:PAFormula.subst x s φ = PAFormula.eq s shsub_t:PAFormula.subst x t φ = PAFormula.eq t s⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq t s))
have heq := PAProvable.eq_subst x s t φ rfl rfl s:PATermt:PATermx:ℕ := max s.freshVar t.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq (PATerm.var x) shsub_s:PAFormula.subst x s φ = PAFormula.eq s shsub_t:PAFormula.subst x t φ = PAFormula.eq t sheq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.subst x s φ).imp (PAFormula.subst x t φ)))⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq t s))
rw [hsub_s, s:PATermt:PATermx:ℕ := max s.freshVar t.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq (PATerm.var x) shsub_s:PAFormula.subst x s φ = PAFormula.eq s shsub_t:PAFormula.subst x t φ = PAFormula.eq t sheq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq s s).imp (PAFormula.subst x t φ)))⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq t s)) hsub_t s:PATermt:PATermx:ℕ := max s.freshVar t.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq (PATerm.var x) shsub_s:PAFormula.subst x s φ = PAFormula.eq s shsub_t:PAFormula.subst x t φ = PAFormula.eq t sheq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq s s).imp (PAFormula.eq t s)))⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq t s))] at heq s:PATermt:PATermx:ℕ := max s.freshVar t.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq (PATerm.var x) shsub_s:PAFormula.subst x s φ = PAFormula.eq s shsub_t:PAFormula.subst x t φ = PAFormula.eq t sheq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq s s).imp (PAFormula.eq t s)))⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq t s))
have hctx : CtxProvable [.eq s t] (.eq t s) :=
.mp (.ax (.eq_refl s)) (.mp (.hyp (List.mem_singleton.mpr rfl)) (.ax heq)) s:PATermt:PATermx:ℕ := max s.freshVar t.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq (PATerm.var x) shsub_s:PAFormula.subst x s φ = PAFormula.eq s shsub_t:PAFormula.subst x t φ = PAFormula.eq t sheq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq s s).imp (PAFormula.eq t s)))hctx:CtxProvable [PAFormula.eq s t] (PAFormula.eq t s)⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq t s))
exact ctx_nil_iff.mp (ctx_deduction hctx) All goals completed! 🐙private theorem pa_eq_trans (r s t : PATerm) :
PAProvable (.imp (.eq r s) (.imp (.eq s t) (.eq r t))) := by r:PATerms:PATermt:PATerm⊢ PAProvable ((PAFormula.eq r s).imp ((PAFormula.eq s t).imp (PAFormula.eq r t)))
let x := r.freshVar r:PATerms:PATermt:PATermx:ℕ := r.freshVar⊢ PAProvable ((PAFormula.eq r s).imp ((PAFormula.eq s t).imp (PAFormula.eq r t)))
have hrx : r.hasVar x = false := hasVar_false_of_freshVar_le (Nat.le_refl _) r:PATerms:PATermt:PATermx:ℕ := r.freshVarhrx:PATerm.hasVar x r = false⊢ PAProvable ((PAFormula.eq r s).imp ((PAFormula.eq s t).imp (PAFormula.eq r t)))
let φ : PAFormula := .eq r (.var x) r:PATerms:PATermt:PATermx:ℕ := r.freshVarhrx:PATerm.hasVar x r = falseφ:PAFormula := PAFormula.eq r (PATerm.var x)⊢ PAProvable ((PAFormula.eq r s).imp ((PAFormula.eq s t).imp (PAFormula.eq r t)))
have hsub_s : φ.subst x s = .eq r s := by
simp [φ, PAFormula.subst, PATerm.subst, term_subst_eq_self_of_hasVar_false s hrx] r:PATerms:PATermt:PATermx:ℕ := r.freshVarhrx:PATerm.hasVar x r = falseφ:PAFormula := PAFormula.eq r (PATerm.var x)hsub_s:PAFormula.subst x s φ = PAFormula.eq r s⊢ PAProvable ((PAFormula.eq r s).imp ((PAFormula.eq s t).imp (PAFormula.eq r t)))
have hsub_t : φ.subst x t = .eq r t := by
simp [φ, PAFormula.subst, PATerm.subst, term_subst_eq_self_of_hasVar_false t hrx] r:PATerms:PATermt:PATermx:ℕ := r.freshVarhrx:PATerm.hasVar x r = falseφ:PAFormula := PAFormula.eq r (PATerm.var x)hsub_s:PAFormula.subst x s φ = PAFormula.eq r shsub_t:PAFormula.subst x t φ = PAFormula.eq r t⊢ PAProvable ((PAFormula.eq r s).imp ((PAFormula.eq s t).imp (PAFormula.eq r t)))
have heq := PAProvable.eq_subst x s t φ rfl rfl r:PATerms:PATermt:PATermx:ℕ := r.freshVarhrx:PATerm.hasVar x r = falseφ:PAFormula := PAFormula.eq r (PATerm.var x)hsub_s:PAFormula.subst x s φ = PAFormula.eq r shsub_t:PAFormula.subst x t φ = PAFormula.eq r theq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.subst x s φ).imp (PAFormula.subst x t φ)))⊢ PAProvable ((PAFormula.eq r s).imp ((PAFormula.eq s t).imp (PAFormula.eq r t)))
rw [hsub_s, r:PATerms:PATermt:PATermx:ℕ := r.freshVarhrx:PATerm.hasVar x r = falseφ:PAFormula := PAFormula.eq r (PATerm.var x)hsub_s:PAFormula.subst x s φ = PAFormula.eq r shsub_t:PAFormula.subst x t φ = PAFormula.eq r theq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq r s).imp (PAFormula.subst x t φ)))⊢ PAProvable ((PAFormula.eq r s).imp ((PAFormula.eq s t).imp (PAFormula.eq r t))) hsub_t r:PATerms:PATermt:PATermx:ℕ := r.freshVarhrx:PATerm.hasVar x r = falseφ:PAFormula := PAFormula.eq r (PATerm.var x)hsub_s:PAFormula.subst x s φ = PAFormula.eq r shsub_t:PAFormula.subst x t φ = PAFormula.eq r theq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq r s).imp (PAFormula.eq r t)))⊢ PAProvable ((PAFormula.eq r s).imp ((PAFormula.eq s t).imp (PAFormula.eq r t)))] at heq r:PATerms:PATermt:PATermx:ℕ := r.freshVarhrx:PATerm.hasVar x r = falseφ:PAFormula := PAFormula.eq r (PATerm.var x)hsub_s:PAFormula.subst x s φ = PAFormula.eq r shsub_t:PAFormula.subst x t φ = PAFormula.eq r theq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq r s).imp (PAFormula.eq r t)))⊢ PAProvable ((PAFormula.eq r s).imp ((PAFormula.eq s t).imp (PAFormula.eq r t)))
have hctx : CtxProvable [.eq s t, .eq r s] (.eq r t) :=
.mp (.hyp (by r:PATerms:PATermt:PATermx:ℕ := r.freshVarhrx:PATerm.hasVar x r = falseφ:PAFormula := PAFormula.eq r (PATerm.var x)hsub_s:PAFormula.subst x s φ = PAFormula.eq r shsub_t:PAFormula.subst x t φ = PAFormula.eq r theq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq r s).imp (PAFormula.eq r t)))⊢ PAFormula.eq r s ∈ [PAFormula.eq s t, PAFormula.eq r s] simp All goals completed! 🐙)) (.mp (.hyp (by r:PATerms:PATermt:PATermx:ℕ := r.freshVarhrx:PATerm.hasVar x r = falseφ:PAFormula := PAFormula.eq r (PATerm.var x)hsub_s:PAFormula.subst x s φ = PAFormula.eq r shsub_t:PAFormula.subst x t φ = PAFormula.eq r theq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq r s).imp (PAFormula.eq r t)))⊢ PAFormula.eq s t ∈ [PAFormula.eq s t, PAFormula.eq r s] simp All goals completed! 🐙)) (.ax heq)) r:PATerms:PATermt:PATermx:ℕ := r.freshVarhrx:PATerm.hasVar x r = falseφ:PAFormula := PAFormula.eq r (PATerm.var x)hsub_s:PAFormula.subst x s φ = PAFormula.eq r shsub_t:PAFormula.subst x t φ = PAFormula.eq r theq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq r s).imp (PAFormula.eq r t)))hctx:CtxProvable [PAFormula.eq s t, PAFormula.eq r s] (PAFormula.eq r t)⊢ PAProvable ((PAFormula.eq r s).imp ((PAFormula.eq s t).imp (PAFormula.eq r t)))
exact ctx_nil_iff.mp (ctx_deduction (ctx_deduction hctx)) All goals completed! 🐙private theorem pa_eq_succ (s t : PATerm) :
PAProvable (.imp (.eq s t) (.eq (.succ s) (.succ t))) := by s:PATermt:PATerm⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq s.succ t.succ))
let x := s.freshVar s:PATermt:PATermx:ℕ := s.freshVar⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq s.succ t.succ))
have hsx : s.hasVar x = false := hasVar_false_of_freshVar_le (Nat.le_refl _) s:PATermt:PATermx:ℕ := s.freshVarhsx:PATerm.hasVar x s = false⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq s.succ t.succ))
let φ : PAFormula := .eq (.succ s) (.succ (.var x)) s:PATermt:PATermx:ℕ := s.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq s.succ (PATerm.var x).succ⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq s.succ t.succ))
have hsub_s : φ.subst x s = .eq (.succ s) (.succ s) := by
simp [φ, PAFormula.subst, PATerm.subst, term_subst_eq_self_of_hasVar_false s hsx] s:PATermt:PATermx:ℕ := s.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq s.succ (PATerm.var x).succhsub_s:PAFormula.subst x s φ = PAFormula.eq s.succ s.succ⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq s.succ t.succ))
have hsub_t : φ.subst x t = .eq (.succ s) (.succ t) := by
simp [φ, PAFormula.subst, PATerm.subst, term_subst_eq_self_of_hasVar_false t hsx] s:PATermt:PATermx:ℕ := s.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq s.succ (PATerm.var x).succhsub_s:PAFormula.subst x s φ = PAFormula.eq s.succ s.succhsub_t:PAFormula.subst x t φ = PAFormula.eq s.succ t.succ⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq s.succ t.succ))
have heq := PAProvable.eq_subst x s t φ rfl rfl s:PATermt:PATermx:ℕ := s.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq s.succ (PATerm.var x).succhsub_s:PAFormula.subst x s φ = PAFormula.eq s.succ s.succhsub_t:PAFormula.subst x t φ = PAFormula.eq s.succ t.succheq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.subst x s φ).imp (PAFormula.subst x t φ)))⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq s.succ t.succ))
rw [hsub_s, s:PATermt:PATermx:ℕ := s.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq s.succ (PATerm.var x).succhsub_s:PAFormula.subst x s φ = PAFormula.eq s.succ s.succhsub_t:PAFormula.subst x t φ = PAFormula.eq s.succ t.succheq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq s.succ s.succ).imp (PAFormula.subst x t φ)))⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq s.succ t.succ)) hsub_t s:PATermt:PATermx:ℕ := s.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq s.succ (PATerm.var x).succhsub_s:PAFormula.subst x s φ = PAFormula.eq s.succ s.succhsub_t:PAFormula.subst x t φ = PAFormula.eq s.succ t.succheq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq s.succ s.succ).imp (PAFormula.eq s.succ t.succ)))⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq s.succ t.succ))] at heq s:PATermt:PATermx:ℕ := s.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq s.succ (PATerm.var x).succhsub_s:PAFormula.subst x s φ = PAFormula.eq s.succ s.succhsub_t:PAFormula.subst x t φ = PAFormula.eq s.succ t.succheq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq s.succ s.succ).imp (PAFormula.eq s.succ t.succ)))⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq s.succ t.succ))
have hctx : CtxProvable [.eq s t] (.eq (.succ s) (.succ t)) :=
.mp (.ax (.eq_refl (.succ s))) (.mp (.hyp (List.mem_singleton.mpr rfl)) (.ax heq)) s:PATermt:PATermx:ℕ := s.freshVarhsx:PATerm.hasVar x s = falseφ:PAFormula := PAFormula.eq s.succ (PATerm.var x).succhsub_s:PAFormula.subst x s φ = PAFormula.eq s.succ s.succhsub_t:PAFormula.subst x t φ = PAFormula.eq s.succ t.succheq:PAProvable ((PAFormula.eq s t).imp ((PAFormula.eq s.succ s.succ).imp (PAFormula.eq s.succ t.succ)))hctx:CtxProvable [PAFormula.eq s t] (PAFormula.eq s.succ t.succ)⊢ PAProvable ((PAFormula.eq s t).imp (PAFormula.eq s.succ t.succ))
exact ctx_nil_iff.mp (ctx_deduction hctx) All goals completed! 🐙private theorem pa_eq_add (s₁ t₁ s₂ t₂ : PATerm) :
PAProvable (.imp (.eq s₁ t₁) (.imp (.eq s₂ t₂) (.eq (.add s₁ s₂) (.add t₁ t₂)))) := by s₁:PATermt₁:PATerms₂:PATermt₂:PATerm⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
let x := max s₁.freshVar s₂.freshVar s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVar⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
have hs₁x : s₁.hasVar x = false := hasVar_false_of_freshVar_le (Nat.le_max_left ..) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = false⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
have hs₂x : s₂.hasVar x = false := hasVar_false_of_freshVar_le (Nat.le_max_right ..) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = false⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
let φ₁ : PAFormula := .eq (.add s₁ s₂) (.add (.var x) s₂) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
have heq₁ := PAProvable.eq_subst x s₁ t₁ φ₁ rfl rfl s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)heq₁:PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.subst x s₁ φ₁).imp (PAFormula.subst x t₁ φ₁)))⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
simp only [φ₁, PAFormula.subst, PATerm.subst, beq_self_eq_true, ↓reduceIte,
term_subst_eq_self_of_hasVar_false s₁ hs₁x, term_subst_eq_self_of_hasVar_false t₁ hs₁x,
term_subst_eq_self_of_hasVar_false s₁ hs₂x, term_subst_eq_self_of_hasVar_false t₁ hs₂x] at heq₁ s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.add s₂) (s₁.add s₂)).imp (PAFormula.eq (s₁.add s₂) (t₁.add s₂))))⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
let y := max t₁.freshVar s₂.freshVar s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.add s₂) (s₁.add s₂)).imp (PAFormula.eq (s₁.add s₂) (t₁.add s₂))))y:ℕ := max t₁.freshVar s₂.freshVar⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
have ht₁y : t₁.hasVar y = false := hasVar_false_of_freshVar_le (Nat.le_max_left ..) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.add s₂) (s₁.add s₂)).imp (PAFormula.eq (s₁.add s₂) (t₁.add s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = false⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
have hs₂y : s₂.hasVar y = false := hasVar_false_of_freshVar_le (Nat.le_max_right ..) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.add s₂) (s₁.add s₂)).imp (PAFormula.eq (s₁.add s₂) (t₁.add s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = false⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
let φ₂ : PAFormula := .eq (.add t₁ s₂) (.add t₁ (.var y)) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.add s₂) (s₁.add s₂)).imp (PAFormula.eq (s₁.add s₂) (t₁.add s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.add s₂) (t₁.add (PATerm.var y))⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
have heq₂ := PAProvable.eq_subst y s₂ t₂ φ₂ rfl rfl s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.add s₂) (s₁.add s₂)).imp (PAFormula.eq (s₁.add s₂) (t₁.add s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.add s₂) (t₁.add (PATerm.var y))heq₂:PAProvable ((PAFormula.eq s₂ t₂).imp ((PAFormula.subst y s₂ φ₂).imp (PAFormula.subst y t₂ φ₂)))⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
simp only [φ₂, PAFormula.subst, PATerm.subst, beq_self_eq_true, ↓reduceIte,
term_subst_eq_self_of_hasVar_false s₂ ht₁y, term_subst_eq_self_of_hasVar_false t₂ ht₁y,
term_subst_eq_self_of_hasVar_false s₂ hs₂y, term_subst_eq_self_of_hasVar_false t₂ hs₂y] at heq₂ s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.add s₂) (s₁.add s₂)).imp (PAFormula.eq (s₁.add s₂) (t₁.add s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.add s₂) (t₁.add (PATerm.var y))heq₂:PAProvable
((PAFormula.eq s₂ t₂).imp ((PAFormula.eq (t₁.add s₂) (t₁.add s₂)).imp (PAFormula.eq (t₁.add s₂) (t₁.add t₂))))⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
have hctx : CtxProvable [.eq s₂ t₂, .eq s₁ t₁] (.eq (.add s₁ s₂) (.add t₁ t₂)) := by
have hA : CtxProvable [.eq s₂ t₂, .eq s₁ t₁] (.eq (.add s₁ s₂) (.add t₁ s₂)) :=
.mp (.ax (.eq_refl (.add s₁ s₂))) (.mp (.hyp (by s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.add s₂) (s₁.add s₂)).imp (PAFormula.eq (s₁.add s₂) (t₁.add s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.add s₂) (t₁.add (PATerm.var y))heq₂:PAProvable
((PAFormula.eq s₂ t₂).imp ((PAFormula.eq (t₁.add s₂) (t₁.add s₂)).imp (PAFormula.eq (t₁.add s₂) (t₁.add t₂))))⊢ PAFormula.eq s₁ t₁ ∈ [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] simp All goals completed! 🐙)) (.ax heq₁)) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.add s₂) (s₁.add s₂)).imp (PAFormula.eq (s₁.add s₂) (t₁.add s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.add s₂) (t₁.add (PATerm.var y))heq₂:PAProvable
((PAFormula.eq s₂ t₂).imp ((PAFormula.eq (t₁.add s₂) (t₁.add s₂)).imp (PAFormula.eq (t₁.add s₂) (t₁.add t₂))))hA:CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (s₁.add s₂) (t₁.add s₂))⊢ CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (s₁.add s₂) (t₁.add t₂))
have hB : CtxProvable [.eq s₂ t₂, .eq s₁ t₁] (.eq (.add t₁ s₂) (.add t₁ t₂)) :=
.mp (.ax (.eq_refl (.add t₁ s₂))) (.mp (.hyp (by s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.add s₂) (s₁.add s₂)).imp (PAFormula.eq (s₁.add s₂) (t₁.add s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.add s₂) (t₁.add (PATerm.var y))heq₂:PAProvable
((PAFormula.eq s₂ t₂).imp ((PAFormula.eq (t₁.add s₂) (t₁.add s₂)).imp (PAFormula.eq (t₁.add s₂) (t₁.add t₂))))hA:CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (s₁.add s₂) (t₁.add s₂))⊢ PAFormula.eq s₂ t₂ ∈ [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] simp All goals completed! 🐙)) (.ax heq₂)) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.add s₂) (s₁.add s₂)).imp (PAFormula.eq (s₁.add s₂) (t₁.add s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.add s₂) (t₁.add (PATerm.var y))heq₂:PAProvable
((PAFormula.eq s₂ t₂).imp ((PAFormula.eq (t₁.add s₂) (t₁.add s₂)).imp (PAFormula.eq (t₁.add s₂) (t₁.add t₂))))hA:CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (s₁.add s₂) (t₁.add s₂))hB:CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (t₁.add s₂) (t₁.add t₂))⊢ CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (s₁.add s₂) (t₁.add t₂))
exact .mp hB (.mp hA (.ax (pa_eq_trans (.add s₁ s₂) (.add t₁ s₂) (.add t₁ t₂)))) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.add s₂) ((PATerm.var x).add s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.add s₂) (s₁.add s₂)).imp (PAFormula.eq (s₁.add s₂) (t₁.add s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.add s₂) (t₁.add (PATerm.var y))heq₂:PAProvable
((PAFormula.eq s₂ t₂).imp ((PAFormula.eq (t₁.add s₂) (t₁.add s₂)).imp (PAFormula.eq (t₁.add s₂) (t₁.add t₂))))hctx:CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (s₁.add s₂) (t₁.add t₂))⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.add s₂) (t₁.add t₂))))
exact ctx_nil_iff.mp (ctx_deduction (ctx_deduction hctx)) All goals completed! 🐙private theorem pa_eq_mul (s₁ t₁ s₂ t₂ : PATerm) :
PAProvable (.imp (.eq s₁ t₁) (.imp (.eq s₂ t₂) (.eq (.mul s₁ s₂) (.mul t₁ t₂)))) := by s₁:PATermt₁:PATerms₂:PATermt₂:PATerm⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
let x := max s₁.freshVar s₂.freshVar s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVar⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
have hs₁x : s₁.hasVar x = false := hasVar_false_of_freshVar_le (Nat.le_max_left ..) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = false⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
have hs₂x : s₂.hasVar x = false := hasVar_false_of_freshVar_le (Nat.le_max_right ..) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = false⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
let φ₁ : PAFormula := .eq (.mul s₁ s₂) (.mul (.var x) s₂) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
have heq₁ := PAProvable.eq_subst x s₁ t₁ φ₁ rfl rfl s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)heq₁:PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.subst x s₁ φ₁).imp (PAFormula.subst x t₁ φ₁)))⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
simp only [φ₁, PAFormula.subst, PATerm.subst, beq_self_eq_true, ↓reduceIte,
term_subst_eq_self_of_hasVar_false s₁ hs₁x, term_subst_eq_self_of_hasVar_false t₁ hs₁x,
term_subst_eq_self_of_hasVar_false s₁ hs₂x, term_subst_eq_self_of_hasVar_false t₁ hs₂x] at heq₁ s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.mul s₂) (s₁.mul s₂)).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))))⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
let y := max t₁.freshVar s₂.freshVar s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.mul s₂) (s₁.mul s₂)).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))))y:ℕ := max t₁.freshVar s₂.freshVar⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
have ht₁y : t₁.hasVar y = false := hasVar_false_of_freshVar_le (Nat.le_max_left ..) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.mul s₂) (s₁.mul s₂)).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = false⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
have hs₂y : s₂.hasVar y = false := hasVar_false_of_freshVar_le (Nat.le_max_right ..) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.mul s₂) (s₁.mul s₂)).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = false⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
let φ₂ : PAFormula := .eq (.mul t₁ s₂) (.mul t₁ (.var y)) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.mul s₂) (s₁.mul s₂)).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.mul s₂) (t₁.mul (PATerm.var y))⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
have heq₂ := PAProvable.eq_subst y s₂ t₂ φ₂ rfl rfl s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.mul s₂) (s₁.mul s₂)).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.mul s₂) (t₁.mul (PATerm.var y))heq₂:PAProvable ((PAFormula.eq s₂ t₂).imp ((PAFormula.subst y s₂ φ₂).imp (PAFormula.subst y t₂ φ₂)))⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
simp only [φ₂, PAFormula.subst, PATerm.subst, beq_self_eq_true, ↓reduceIte,
term_subst_eq_self_of_hasVar_false s₂ ht₁y, term_subst_eq_self_of_hasVar_false t₂ ht₁y,
term_subst_eq_self_of_hasVar_false s₂ hs₂y, term_subst_eq_self_of_hasVar_false t₂ hs₂y] at heq₂ s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.mul s₂) (s₁.mul s₂)).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.mul s₂) (t₁.mul (PATerm.var y))heq₂:PAProvable
((PAFormula.eq s₂ t₂).imp ((PAFormula.eq (t₁.mul s₂) (t₁.mul s₂)).imp (PAFormula.eq (t₁.mul s₂) (t₁.mul t₂))))⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
have hctx : CtxProvable [.eq s₂ t₂, .eq s₁ t₁] (.eq (.mul s₁ s₂) (.mul t₁ t₂)) := by
have hA : CtxProvable [.eq s₂ t₂, .eq s₁ t₁] (.eq (.mul s₁ s₂) (.mul t₁ s₂)) :=
.mp (.ax (.eq_refl (.mul s₁ s₂))) (.mp (.hyp (by s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.mul s₂) (s₁.mul s₂)).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.mul s₂) (t₁.mul (PATerm.var y))heq₂:PAProvable
((PAFormula.eq s₂ t₂).imp ((PAFormula.eq (t₁.mul s₂) (t₁.mul s₂)).imp (PAFormula.eq (t₁.mul s₂) (t₁.mul t₂))))⊢ PAFormula.eq s₁ t₁ ∈ [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] simp All goals completed! 🐙)) (.ax heq₁)) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.mul s₂) (s₁.mul s₂)).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.mul s₂) (t₁.mul (PATerm.var y))heq₂:PAProvable
((PAFormula.eq s₂ t₂).imp ((PAFormula.eq (t₁.mul s₂) (t₁.mul s₂)).imp (PAFormula.eq (t₁.mul s₂) (t₁.mul t₂))))hA:CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))⊢ CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))
have hB : CtxProvable [.eq s₂ t₂, .eq s₁ t₁] (.eq (.mul t₁ s₂) (.mul t₁ t₂)) :=
.mp (.ax (.eq_refl (.mul t₁ s₂))) (.mp (.hyp (by s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.mul s₂) (s₁.mul s₂)).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.mul s₂) (t₁.mul (PATerm.var y))heq₂:PAProvable
((PAFormula.eq s₂ t₂).imp ((PAFormula.eq (t₁.mul s₂) (t₁.mul s₂)).imp (PAFormula.eq (t₁.mul s₂) (t₁.mul t₂))))hA:CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))⊢ PAFormula.eq s₂ t₂ ∈ [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] simp All goals completed! 🐙)) (.ax heq₂)) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.mul s₂) (s₁.mul s₂)).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.mul s₂) (t₁.mul (PATerm.var y))heq₂:PAProvable
((PAFormula.eq s₂ t₂).imp ((PAFormula.eq (t₁.mul s₂) (t₁.mul s₂)).imp (PAFormula.eq (t₁.mul s₂) (t₁.mul t₂))))hA:CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))hB:CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (t₁.mul s₂) (t₁.mul t₂))⊢ CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))
exact .mp hB (.mp hA (.ax (pa_eq_trans (.mul s₁ s₂) (.mul t₁ s₂) (.mul t₁ t₂)))) s₁:PATermt₁:PATerms₂:PATermt₂:PATermx:ℕ := max s₁.freshVar s₂.freshVarhs₁x:PATerm.hasVar x s₁ = falsehs₂x:PATerm.hasVar x s₂ = falseφ₁:PAFormula := PAFormula.eq (s₁.mul s₂) ((PATerm.var x).mul s₂)heq₁:PAProvable
((PAFormula.eq s₁ t₁).imp ((PAFormula.eq (s₁.mul s₂) (s₁.mul s₂)).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul s₂))))y:ℕ := max t₁.freshVar s₂.freshVarht₁y:PATerm.hasVar y t₁ = falsehs₂y:PATerm.hasVar y s₂ = falseφ₂:PAFormula := PAFormula.eq (t₁.mul s₂) (t₁.mul (PATerm.var y))heq₂:PAProvable
((PAFormula.eq s₂ t₂).imp ((PAFormula.eq (t₁.mul s₂) (t₁.mul s₂)).imp (PAFormula.eq (t₁.mul s₂) (t₁.mul t₂))))hctx:CtxProvable [PAFormula.eq s₂ t₂, PAFormula.eq s₁ t₁] (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))⊢ PAProvable ((PAFormula.eq s₁ t₁).imp ((PAFormula.eq s₂ t₂).imp (PAFormula.eq (s₁.mul s₂) (t₁.mul t₂))))
exact ctx_nil_iff.mp (ctx_deduction (ctx_deduction hctx)) All goals completed! 🐙private theorem pa_exists_var_eq (B : ℕ) (t : PATerm) :
let y := max B t.freshVar
PAProvable (.ex y (.eq (.var y) t)) := by B:ℕt:PATerm⊢ let y := max B t.freshVar;
PAProvable (PAFormula.ex y (PAFormula.eq (PATerm.var y) t))
intro y B:ℕt:PATermy:ℕ := max B t.freshVar⊢ PAProvable (PAFormula.ex y (PAFormula.eq (PATerm.var y) t))
have hty : t.hasVar y = false := hasVar_false_of_freshVar_le (Nat.le_max_right ..) B:ℕt:PATermy:ℕ := max B t.freshVarhty:PATerm.hasVar y t = false⊢ PAProvable (PAFormula.ex y (PAFormula.eq (PATerm.var y) t))
let ψ : PAFormula := .eq (.var y) t B:ℕt:PATermy:ℕ := max B t.freshVarhty:PATerm.hasVar y t = falseψ:PAFormula := PAFormula.eq (PATerm.var y) t⊢ PAProvable (PAFormula.ex y (PAFormula.eq (PATerm.var y) t))
have hsub : ψ.subst y t = .eq t t := by B:ℕt:PATerm⊢ let y := max B t.freshVar;
PAProvable (PAFormula.ex y (PAFormula.eq (PATerm.var y) t))
simp [ψ, PAFormula.subst, PATerm.subst, term_subst_eq_self_of_hasVar_false t hty] B:ℕt:PATermy:ℕ := max B t.freshVarhty:PATerm.hasVar y t = falseψ:PAFormula := PAFormula.eq (PATerm.var y) thsub:PAFormula.subst y t ψ = PAFormula.eq t t⊢ PAProvable (PAFormula.ex y (PAFormula.eq (PATerm.var y) t))
have hex := PAProvable.ex_intro y t ψ rfl B:ℕt:PATermy:ℕ := max B t.freshVarhty:PATerm.hasVar y t = falseψ:PAFormula := PAFormula.eq (PATerm.var y) thsub:PAFormula.subst y t ψ = PAFormula.eq t thex:PAProvable ((PAFormula.subst y t ψ).imp (PAFormula.ex y ψ))⊢ PAProvable (PAFormula.ex y (PAFormula.eq (PATerm.var y) t))
rw [hsub B:ℕt:PATermy:ℕ := max B t.freshVarhty:PATerm.hasVar y t = falseψ:PAFormula := PAFormula.eq (PATerm.var y) thsub:PAFormula.subst y t ψ = PAFormula.eq t thex:PAProvable ((PAFormula.eq t t).imp (PAFormula.ex y ψ))⊢ PAProvable (PAFormula.ex y (PAFormula.eq (PATerm.var y) t))] at hex B:ℕt:PATermy:ℕ := max B t.freshVarhty:PATerm.hasVar y t = falseψ:PAFormula := PAFormula.eq (PATerm.var y) thsub:PAFormula.subst y t ψ = PAFormula.eq t thex:PAProvable ((PAFormula.eq t t).imp (PAFormula.ex y ψ))⊢ PAProvable (PAFormula.ex y (PAFormula.eq (PATerm.var y) t))
exact .mp (.eq_refl t) hex All goals completed! 🐙Section 3: Countable Formula Enumeration and Henkin–Lindenbaum Saturation
private def encodeTerm : PATerm → ℕ
| .zero => 0
| .var x => Nat.pair 0 x + 1
| .succ t => Nat.pair 1 (encodeTerm t) + 1
| .add t₁ t₂ => Nat.pair 2 (Nat.pair (encodeTerm t₁) (encodeTerm t₂)) + 1
| .mul t₁ t₂ => Nat.pair 3 (Nat.pair (encodeTerm t₁) (encodeTerm t₂)) + 1private def decodeTerm : ℕ → PATerm
| 0 => .zero
| n + 1 =>
let p := Nat.unpair n
let q := Nat.unpair p.2
match p.1 with
| 0 => .var p.2
| 1 => .succ (decodeTerm p.2)
| 2 => .add (decodeTerm q.1) (decodeTerm q.2)
| 3 => .mul (decodeTerm q.1) (decodeTerm q.2)
| _ => .zero
termination_by k => k
decreasing_by
· n:ℕp:ℕ × ℕ := Nat.unpair nq:ℕ × ℕ := Nat.unpair p.2⊢ (Nat.unpair n).2 < n.succ exact Nat.lt_succ_of_le (Nat.unpair_right_le n) All goals completed! 🐙
· n:ℕp:ℕ × ℕ := Nat.unpair nq:ℕ × ℕ := Nat.unpair p.2⊢ (Nat.unpair (Nat.unpair n).2).1 < n.succ exact Nat.lt_succ_of_le (le_trans (Nat.unpair_left_le _) (Nat.unpair_right_le n)) All goals completed! 🐙
· n:ℕp:ℕ × ℕ := Nat.unpair nq:ℕ × ℕ := Nat.unpair p.2⊢ (Nat.unpair (Nat.unpair n).2).2 < n.succ exact Nat.lt_succ_of_le (le_trans (Nat.unpair_right_le _) (Nat.unpair_right_le n)) All goals completed! 🐙
· n:ℕp:ℕ × ℕ := Nat.unpair nq:ℕ × ℕ := Nat.unpair p.2⊢ (Nat.unpair (Nat.unpair n).2).1 < n.succ exact Nat.lt_succ_of_le (le_trans (Nat.unpair_left_le _) (Nat.unpair_right_le n)) All goals completed! 🐙
· n:ℕp:ℕ × ℕ := Nat.unpair nq:ℕ × ℕ := Nat.unpair p.2⊢ (Nat.unpair (Nat.unpair n).2).2 < n.succ exact Nat.lt_succ_of_le (le_trans (Nat.unpair_right_le _) (Nat.unpair_right_le n)) All goals completed! 🐙private theorem decodeTerm_encodeTerm (t : PATerm) : decodeTerm (encodeTerm t) = t := by t:PATerm⊢ decodeTerm (encodeTerm t) = t
induction t with
| zero => zero ⊢ decodeTerm (encodeTerm PATerm.zero) = PATerm.zero simp [encodeTerm, decodeTerm] All goals completed! 🐙
| var x => var x:ℕ⊢ decodeTerm (encodeTerm (PATerm.var x)) = PATerm.var x simp [encodeTerm, decodeTerm, Nat.unpair_pair] All goals completed! 🐙
| succ t ih => succ t:PATermih:decodeTerm (encodeTerm t) = t⊢ decodeTerm (encodeTerm t.succ) = t.succ simp [encodeTerm, decodeTerm, Nat.unpair_pair, ih] All goals completed! 🐙
| add t₁ t₂ ih₁ ih₂ => add t₁:PATermt₂:PATermih₁:decodeTerm (encodeTerm t₁) = t₁ih₂:decodeTerm (encodeTerm t₂) = t₂⊢ decodeTerm (encodeTerm (t₁.add t₂)) = t₁.add t₂ simp [encodeTerm, decodeTerm, Nat.unpair_pair, ih₁, ih₂] All goals completed! 🐙
| mul t₁ t₂ ih₁ ih₂ => mul t₁:PATermt₂:PATermih₁:decodeTerm (encodeTerm t₁) = t₁ih₂:decodeTerm (encodeTerm t₂) = t₂⊢ decodeTerm (encodeTerm (t₁.mul t₂)) = t₁.mul t₂ simp [encodeTerm, decodeTerm, Nat.unpair_pair, ih₁, ih₂] All goals completed! 🐙private def encodeForm : PAFormula → ℕ
| .bot => 0
| .eq t₁ t₂ => Nat.pair 0 (Nat.pair (encodeTerm t₁) (encodeTerm t₂)) + 1
| .and φ ψ => Nat.pair 1 (Nat.pair (encodeForm φ) (encodeForm ψ)) + 1
| .or φ ψ => Nat.pair 2 (Nat.pair (encodeForm φ) (encodeForm ψ)) + 1
| .imp φ ψ => Nat.pair 3 (Nat.pair (encodeForm φ) (encodeForm ψ)) + 1
| .all x φ => Nat.pair 4 (Nat.pair x (encodeForm φ)) + 1
| .ex x φ => Nat.pair 5 (Nat.pair x (encodeForm φ)) + 1private def decodeForm : ℕ → PAFormula
| 0 => .bot
| n + 1 =>
let p := Nat.unpair n
let q := Nat.unpair p.2
match p.1 with
| 0 => .eq (decodeTerm q.1) (decodeTerm q.2)
| 1 => .and (decodeForm q.1) (decodeForm q.2)
| 2 => .or (decodeForm q.1) (decodeForm q.2)
| 3 => .imp (decodeForm q.1) (decodeForm q.2)
| 4 => .all q.1 (decodeForm q.2)
| 5 => .ex q.1 (decodeForm q.2)
| _ => .bot
termination_by k => k
decreasing_by
all_goals
first
| exact Nat.lt_succ_of_le (le_trans (Nat.unpair_left_le _) (Nat.unpair_right_le n)) n:ℕp:ℕ × ℕ := Nat.unpair nq:ℕ × ℕ := Nat.unpair p.2⊢ (Nat.unpair (Nat.unpair n).2).2 < n.succ
| exact Nat.lt_succ_of_le (le_trans (Nat.unpair_right_le _) (Nat.unpair_right_le n)) All goals completed! 🐙private theorem decodeForm_encodeForm (φ : PAFormula) : decodeForm (encodeForm φ) = φ := by φ:PAFormula⊢ decodeForm (encodeForm φ) = φ
induction φ with
| bot => bot ⊢ decodeForm (encodeForm PAFormula.bot) = PAFormula.bot simp [encodeForm, decodeForm] All goals completed! 🐙
| eq t₁ t₂ => eq t₁:PATermt₂:PATerm⊢ decodeForm (encodeForm (PAFormula.eq t₁ t₂)) = PAFormula.eq t₁ t₂
simp [encodeForm, decodeForm, Nat.unpair_pair, decodeTerm_encodeTerm] All goals completed! 🐙
| and _ _ ih₁ ih₂ => and φ✝:PAFormulaψ✝:PAFormulaih₁:decodeForm (encodeForm φ✝) = φ✝ih₂:decodeForm (encodeForm ψ✝) = ψ✝⊢ decodeForm (encodeForm (φ✝.and ψ✝)) = φ✝.and ψ✝ simp [encodeForm, decodeForm, Nat.unpair_pair, ih₁, ih₂] All goals completed! 🐙
| or _ _ ih₁ ih₂ => or φ✝:PAFormulaψ✝:PAFormulaih₁:decodeForm (encodeForm φ✝) = φ✝ih₂:decodeForm (encodeForm ψ✝) = ψ✝⊢ decodeForm (encodeForm (φ✝.or ψ✝)) = φ✝.or ψ✝ simp [encodeForm, decodeForm, Nat.unpair_pair, ih₁, ih₂] All goals completed! 🐙
| imp _ _ ih₁ ih₂ => imp φ✝:PAFormulaψ✝:PAFormulaih₁:decodeForm (encodeForm φ✝) = φ✝ih₂:decodeForm (encodeForm ψ✝) = ψ✝⊢ decodeForm (encodeForm (φ✝.imp ψ✝)) = φ✝.imp ψ✝ simp [encodeForm, decodeForm, Nat.unpair_pair, ih₁, ih₂] All goals completed! 🐙
| all _ _ ih => all x✝:ℕφ✝:PAFormulaih:decodeForm (encodeForm φ✝) = φ✝⊢ decodeForm (encodeForm (PAFormula.all x✝ φ✝)) = PAFormula.all x✝ φ✝ simp [encodeForm, decodeForm, Nat.unpair_pair, ih] All goals completed! 🐙
| ex _ _ ih => ex x✝:ℕφ✝:PAFormulaih:decodeForm (encodeForm φ✝) = φ✝⊢ decodeForm (encodeForm (PAFormula.ex x✝ φ✝)) = PAFormula.ex x✝ φ✝ simp [encodeForm, decodeForm, Nat.unpair_pair, ih] All goals completed! 🐙private def maxVarList : List PAFormula → ℕ
| [] => 0
| φ :: rest => max φ.maxVar (maxVarList rest)private theorem maxVar_le_maxVarList {Δ : List PAFormula} {φ : PAFormula} (h : φ ∈ Δ) :
φ.maxVar ≤ maxVarList Δ := by Δ:List PAFormulaφ:PAFormulah:φ ∈ Δ⊢ φ.maxVar ≤ maxVarList Δ
induction Δ with
| nil => nil φ:PAFormulah:φ ∈ []⊢ φ.maxVar ≤ maxVarList [] cases h All goals completed! 🐙
| cons δ rest ih => cons φ:PAFormulaδ:PAFormularest:List PAFormulaih:φ ∈ rest → φ.maxVar ≤ maxVarList resth:φ ∈ δ :: rest⊢ φ.maxVar ≤ maxVarList (δ :: rest)
rcases List.mem_cons.mp h with rfl | hm cons.inl φ:PAFormularest:List PAFormulaih:φ ∈ rest → φ.maxVar ≤ maxVarList resth:φ ∈ φ :: rest⊢ φ.maxVar ≤ maxVarList (φ :: rest)cons.inr φ:PAFormulaδ:PAFormularest:List PAFormulaih:φ ∈ rest → φ.maxVar ≤ maxVarList resth:φ ∈ δ :: resthm:φ ∈ rest⊢ φ.maxVar ≤ maxVarList (δ :: rest)
· cons.inl φ:PAFormularest:List PAFormulaih:φ ∈ rest → φ.maxVar ≤ maxVarList resth:φ ∈ φ :: rest⊢ φ.maxVar ≤ maxVarList (φ :: rest) exact Nat.le_max_left .. All goals completed! 🐙
· cons.inr φ:PAFormulaδ:PAFormularest:List PAFormulaih:φ ∈ rest → φ.maxVar ≤ maxVarList resth:φ ∈ δ :: resthm:φ ∈ rest⊢ φ.maxVar ≤ maxVarList (δ :: rest) exact le_trans (ih hm) (Nat.le_max_right ..) All goals completed! 🐙private theorem henkin_step_consistent {Δ : List PAFormula} (x : ℕ) (ψ : PAFormula)
(hcons : ¬ CtxProvable Δ .bot) :
let w := max (maxVarList Δ) (PAFormula.ex x ψ).maxVar
¬ CtxProvable ((.imp (.ex x ψ) (ψ.subst x (.var w))) :: Δ) .bot := by Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.bot⊢ let w := max (maxVarList Δ) (PAFormula.ex x ψ).maxVar;
¬CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.bot
intro w hbot Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.bot⊢ False
apply hcons Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.bot⊢ CtxProvable Δ PAFormula.bot
let θ := PAFormula.imp (.ex x ψ) (ψ.subst x (.var w)) Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)⊢ CtxProvable Δ PAFormula.bot
have hθ_not : CtxProvable Δ θ.not := ctx_deduction hbot Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.not⊢ CtxProvable Δ PAFormula.bot
have hex : CtxProvable Δ (.ex x ψ) := by Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.bot⊢ let w := max (maxVarList Δ) (PAFormula.ex x ψ).maxVar;
¬CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.bot
refine ctx_by_contra ?_ Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.not⊢ CtxProvable ((PAFormula.ex x ψ).not :: Δ) PAFormula.bot
have h1 : CtxProvable [.ex x ψ, (PAFormula.ex x ψ).not] (ψ.subst x (.var w)) :=
ctx_exfalso _ (.mp (φ := PAFormula.ex x ψ) (.hyp (by Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.not⊢ PAFormula.ex x ψ ∈ [PAFormula.ex x ψ, (PAFormula.ex x ψ).not] simp All goals completed! 🐙)) (.hyp (by Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.not⊢ (PAFormula.ex x ψ).imp PAFormula.bot ∈ [PAFormula.ex x ψ, (PAFormula.ex x ψ).not] simp All goals completed! 🐙))) Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.noth1:CtxProvable [PAFormula.ex x ψ, (PAFormula.ex x ψ).not] (PAFormula.subst x (PATerm.var w) ψ)⊢ CtxProvable ((PAFormula.ex x ψ).not :: Δ) PAFormula.bot
have h2 : CtxProvable [(PAFormula.ex x ψ).not] θ := ctx_deduction h1 Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.noth1:CtxProvable [PAFormula.ex x ψ, (PAFormula.ex x ψ).not] (PAFormula.subst x (PATerm.var w) ψ)h2:CtxProvable [(PAFormula.ex x ψ).not] θ⊢ CtxProvable ((PAFormula.ex x ψ).not :: Δ) PAFormula.bot
have h3 : CtxProvable ((PAFormula.ex x ψ).not :: Δ) θ :=
ctx_mono (fun _ hm ↦ by Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.noth1:CtxProvable [PAFormula.ex x ψ, (PAFormula.ex x ψ).not] (PAFormula.subst x (PATerm.var w) ψ)h2:CtxProvable [(PAFormula.ex x ψ).not] θx✝:PAFormulahm:x✝ ∈ [(PAFormula.ex x ψ).not]⊢ x✝ ∈ (PAFormula.ex x ψ).not :: Δ simp [List.mem_singleton.mp hm] All goals completed! 🐙) h2 Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.noth1:CtxProvable [PAFormula.ex x ψ, (PAFormula.ex x ψ).not] (PAFormula.subst x (PATerm.var w) ψ)h2:CtxProvable [(PAFormula.ex x ψ).not] θh3:CtxProvable ((PAFormula.ex x ψ).not :: Δ) θ⊢ CtxProvable ((PAFormula.ex x ψ).not :: Δ) PAFormula.bot
have h4 : CtxProvable ((PAFormula.ex x ψ).not :: Δ) θ.not :=
ctx_mono (fun _ hm ↦ List.mem_cons_of_mem _ hm) hθ_not Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.noth1:CtxProvable [PAFormula.ex x ψ, (PAFormula.ex x ψ).not] (PAFormula.subst x (PATerm.var w) ψ)h2:CtxProvable [(PAFormula.ex x ψ).not] θh3:CtxProvable ((PAFormula.ex x ψ).not :: Δ) θh4:CtxProvable ((PAFormula.ex x ψ).not :: Δ) θ.not⊢ CtxProvable ((PAFormula.ex x ψ).not :: Δ) PAFormula.bot
exact .mp h3 h4 Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.nothex:CtxProvable Δ (PAFormula.ex x ψ)⊢ CtxProvable Δ PAFormula.bot
have hn_sub : CtxProvable Δ (ψ.subst x (.var w)).not := by Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.bot⊢ let w := max (maxVarList Δ) (PAFormula.ex x ψ).maxVar;
¬CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.bot
refine ctx_deduction ?_ Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.nothex:CtxProvable Δ (PAFormula.ex x ψ)⊢ CtxProvable (PAFormula.subst x (PATerm.var w) ψ :: Δ) PAFormula.bot
have h1 : CtxProvable (ψ.subst x (.var w) :: Δ) θ :=
.mp (.hyp (List.mem_cons_self ..)) (.ax (.imp_k _ _)) Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.nothex:CtxProvable Δ (PAFormula.ex x ψ)h1:CtxProvable (PAFormula.subst x (PATerm.var w) ψ :: Δ) θ⊢ CtxProvable (PAFormula.subst x (PATerm.var w) ψ :: Δ) PAFormula.bot
have h2 : CtxProvable (ψ.subst x (.var w) :: Δ) θ.not :=
ctx_mono (fun _ hm ↦ List.mem_cons_of_mem _ hm) hθ_not Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.nothex:CtxProvable Δ (PAFormula.ex x ψ)h1:CtxProvable (PAFormula.subst x (PATerm.var w) ψ :: Δ) θh2:CtxProvable (PAFormula.subst x (PATerm.var w) ψ :: Δ) θ.not⊢ CtxProvable (PAFormula.subst x (PATerm.var w) ψ :: Δ) PAFormula.bot
exact .mp h1 h2 Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.nothex:CtxProvable Δ (PAFormula.ex x ψ)hn_sub:CtxProvable Δ (PAFormula.subst x (PATerm.var w) ψ).not⊢ CtxProvable Δ PAFormula.bot
have hfresh : ∀ γ ∈ Δ, γ.hasFree w = false := fun γ hγ ↦
hasFree_false_of_maxVar_le (le_trans (maxVar_le_maxVarList hγ) (Nat.le_max_left ..)) Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.nothex:CtxProvable Δ (PAFormula.ex x ψ)hn_sub:CtxProvable Δ (PAFormula.subst x (PATerm.var w) ψ).nothfresh:∀ γ ∈ Δ, PAFormula.hasFree w γ = false⊢ CtxProvable Δ PAFormula.bot
have hall : CtxProvable Δ (.all w (ψ.subst x (.var w)).not) := ctx_gen w hfresh hn_sub Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.nothex:CtxProvable Δ (PAFormula.ex x ψ)hn_sub:CtxProvable Δ (PAFormula.subst x (PATerm.var w) ψ).nothfresh:∀ γ ∈ Δ, PAFormula.hasFree w γ = falsehall:CtxProvable Δ (PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not)⊢ CtxProvable Δ PAFormula.bot
have hn_ex : CtxProvable Δ (PAFormula.ex x ψ).not :=
.mp hall (.ax (pa_all_not_subst_imp_not_ex (Nat.le_max_right ..))) Δ:List PAFormulax:ℕψ:PAFormulahcons:¬CtxProvable Δ PAFormula.botw:ℕ := max (maxVarList Δ) (PAFormula.ex x ψ).maxVarhbot:CtxProvable ((PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ) :: Δ) PAFormula.botθ:PAFormula := (PAFormula.ex x ψ).imp (PAFormula.subst x (PATerm.var w) ψ)hθ_not:CtxProvable Δ θ.nothex:CtxProvable Δ (PAFormula.ex x ψ)hn_sub:CtxProvable Δ (PAFormula.subst x (PATerm.var w) ψ).nothfresh:∀ γ ∈ Δ, PAFormula.hasFree w γ = falsehall:CtxProvable Δ (PAFormula.all w (PAFormula.subst x (PATerm.var w) ψ).not)hn_ex:CtxProvable Δ (PAFormula.ex x ψ).not⊢ CtxProvable Δ PAFormula.bot
exact .mp hex hn_ex All goals completed! 🐙
Add Henkin witness if ψ is existential.
private def extendWithWitness (ψ : PAFormula) (Δ : List PAFormula) : List PAFormula :=
match ψ with
| .ex x χ =>
let w := max (maxVarList (ψ :: Δ)) (PAFormula.ex x χ).maxVar
(.imp (.ex x χ) (χ.subst x (.var w))) :: ψ :: Δ
| _ => ψ :: Δ
Single-pass Henkin–Lindenbaum chain starting from [φ₀].
private noncomputable def henkinChain (φ₀ : PAFormula) : ℕ → List PAFormula
| 0 => [φ₀]
| n + 1 =>
let Δ := henkinChain φ₀ n
let ψ := decodeForm n
open Classical in
if CtxProvable (ψ :: Δ) .bot then
ψ.not :: Δ
else
extendWithWitness ψ Δprivate theorem henkinChain_subset_succ (φ₀ : PAFormula) (n : ℕ) :
∀ α ∈ henkinChain φ₀ n, α ∈ henkinChain φ₀ (n + 1) := by φ₀:PAFormulan:ℕ⊢ ∀ α ∈ henkinChain φ₀ n, α ∈ henkinChain φ₀ (n + 1)
intro α hα φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ n⊢ α ∈ henkinChain φ₀ (n + 1)
simp only [henkinChain] φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ n⊢ α ∈
if CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot then (decodeForm n).not :: henkinChain φ₀ n
else extendWithWitness (decodeForm n) (henkinChain φ₀ n)
split_ifs pos φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot⊢ α ∈ (decodeForm n).not :: henkinChain φ₀ nneg φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot⊢ α ∈ extendWithWitness (decodeForm n) (henkinChain φ₀ n)
· pos φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot⊢ α ∈ (decodeForm n).not :: henkinChain φ₀ n exact List.mem_cons_of_mem _ hα All goals completed! 🐙
· neg φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot⊢ α ∈ extendWithWitness (decodeForm n) (henkinChain φ₀ n) unfold extendWithWitness neg φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot⊢ α ∈
match decodeForm n with
| PAFormula.ex x χ =>
have w := max (maxVarList (decodeForm n :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: decodeForm n :: henkinChain φ₀ n
| x => decodeForm n :: henkinChain φ₀ n
cases decodeForm n neg.bot φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot⊢ α ∈
match PAFormula.bot with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.bot :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.bot :: henkinChain φ₀ n
| x => PAFormula.bot :: henkinChain φ₀ nneg.eq φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bott₁✝:PATermt₂✝:PATerm⊢ α ∈
match PAFormula.eq t₁✝ t₂✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ n
| x => PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ nneg.and φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botφ✝:PAFormulaψ✝:PAFormula⊢ α ∈
match φ✝.and ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.and ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.and ψ✝ :: henkinChain φ₀ n
| x => φ✝.and ψ✝ :: henkinChain φ₀ nneg.or φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botφ✝:PAFormulaψ✝:PAFormula⊢ α ∈
match φ✝.or ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.or ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.or ψ✝ :: henkinChain φ₀ n
| x => φ✝.or ψ✝ :: henkinChain φ₀ nneg.imp φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botφ✝:PAFormulaψ✝:PAFormula⊢ α ∈
match φ✝.imp ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.imp ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.imp ψ✝ :: henkinChain φ₀ n
| x => φ✝.imp ψ✝ :: henkinChain φ₀ nneg.all φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botx✝:ℕφ✝:PAFormula⊢ α ∈
match PAFormula.all x✝ φ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.all x✝ φ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.all x✝ φ✝ :: henkinChain φ₀ n
| x => PAFormula.all x✝ φ✝ :: henkinChain φ₀ nneg.ex φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botx✝:ℕφ✝:PAFormula⊢ α ∈
match PAFormula.ex x✝ φ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n
| x => PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n <;> neg.bot φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot⊢ α ∈
match PAFormula.bot with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.bot :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.bot :: henkinChain φ₀ n
| x => PAFormula.bot :: henkinChain φ₀ nneg.eq φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bott₁✝:PATermt₂✝:PATerm⊢ α ∈
match PAFormula.eq t₁✝ t₂✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ n
| x => PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ nneg.and φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botφ✝:PAFormulaψ✝:PAFormula⊢ α ∈
match φ✝.and ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.and ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.and ψ✝ :: henkinChain φ₀ n
| x => φ✝.and ψ✝ :: henkinChain φ₀ nneg.or φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botφ✝:PAFormulaψ✝:PAFormula⊢ α ∈
match φ✝.or ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.or ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.or ψ✝ :: henkinChain φ₀ n
| x => φ✝.or ψ✝ :: henkinChain φ₀ nneg.imp φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botφ✝:PAFormulaψ✝:PAFormula⊢ α ∈
match φ✝.imp ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.imp ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.imp ψ✝ :: henkinChain φ₀ n
| x => φ✝.imp ψ✝ :: henkinChain φ₀ nneg.all φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botx✝:ℕφ✝:PAFormula⊢ α ∈
match PAFormula.all x✝ φ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.all x✝ φ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.all x✝ φ✝ :: henkinChain φ₀ n
| x => PAFormula.all x✝ φ✝ :: henkinChain φ₀ nneg.ex φ₀:PAFormulan:ℕα:PAFormulahα:α ∈ henkinChain φ₀ nh✝:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botx✝:ℕφ✝:PAFormula⊢ α ∈
match PAFormula.ex x✝ φ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n
| x => PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n simp [hα] All goals completed! 🐙private theorem henkinChain_mono (φ₀ : PAFormula) {m n : ℕ} (h : m ≤ n) :
∀ α ∈ henkinChain φ₀ m, α ∈ henkinChain φ₀ n := by φ₀:PAFormulam:ℕn:ℕh:m ≤ n⊢ ∀ α ∈ henkinChain φ₀ m, α ∈ henkinChain φ₀ n
induction h with
| refl => refl φ₀:PAFormulam:ℕn:ℕ⊢ ∀ α ∈ henkinChain φ₀ m, α ∈ henkinChain φ₀ m exact fun _ hα ↦ hα All goals completed! 🐙
| step _ ih => step φ₀:PAFormulam:ℕn:ℕm✝:ℕa✝:m.le m✝ih:∀ α ∈ henkinChain φ₀ m, α ∈ henkinChain φ₀ m✝⊢ ∀ α ∈ henkinChain φ₀ m, α ∈ henkinChain φ₀ m✝.succ exact fun α hα ↦ henkinChain_subset_succ φ₀ _ α (ih α hα) All goals completed! 🐙private theorem henkinChain_consistent {φ₀ : PAFormula} (h₀ : ¬ CtxProvable [φ₀] .bot) :
∀ n, ¬ CtxProvable (henkinChain φ₀ n) .bot := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bot⊢ ∀ (n : ℕ), ¬CtxProvable (henkinChain φ₀ n) PAFormula.bot
intro n φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕ⊢ ¬CtxProvable (henkinChain φ₀ n) PAFormula.bot
induction n with
| zero => zero φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bot⊢ ¬CtxProvable (henkinChain φ₀ 0) PAFormula.bot exact h₀ All goals completed! 🐙
| succ n ih => succ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bot⊢ ¬CtxProvable (henkinChain φ₀ (n + 1)) PAFormula.bot
simp only [henkinChain] succ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bot⊢ ¬CtxProvable
(if CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot then (decodeForm n).not :: henkinChain φ₀ n
else extendWithWitness (decodeForm n) (henkinChain φ₀ n))
PAFormula.bot
split_ifs with hbot_ψ pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot⊢ ¬CtxProvable ((decodeForm n).not :: henkinChain φ₀ n) PAFormula.botneg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot⊢ ¬CtxProvable (extendWithWitness (decodeForm n) (henkinChain φ₀ n)) PAFormula.bot
· pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot⊢ ¬CtxProvable ((decodeForm n).not :: henkinChain φ₀ n) PAFormula.bot have hnψ : CtxProvable (henkinChain φ₀ n) (decodeForm n).not := ctx_deduction hbot_ψ pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bothnψ:CtxProvable (henkinChain φ₀ n) (decodeForm n).not⊢ ¬CtxProvable ((decodeForm n).not :: henkinChain φ₀ n) PAFormula.bot
intro hbot pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bothnψ:CtxProvable (henkinChain φ₀ n) (decodeForm n).nothbot:CtxProvable ((decodeForm n).not :: henkinChain φ₀ n) PAFormula.bot⊢ False
exact ih (.mp hnψ (ctx_deduction hbot)) All goals completed! 🐙
· neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot⊢ ¬CtxProvable (extendWithWitness (decodeForm n) (henkinChain φ₀ n)) PAFormula.bot unfold extendWithWitness neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bot⊢ ¬CtxProvable
(match decodeForm n with
| PAFormula.ex x χ =>
have w := max (maxVarList (decodeForm n :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: decodeForm n :: henkinChain φ₀ n
| x => decodeForm n :: henkinChain φ₀ n)
PAFormula.bot
cases hdec : decodeForm n with
| ex x χ => neg.ex φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botx:ℕχ:PAFormulahdec:decodeForm n = PAFormula.ex x χ⊢ ¬CtxProvable
(match PAFormula.ex x χ with
| PAFormula.ex x_1 χ_1 =>
have w := max (maxVarList (PAFormula.ex x χ :: henkinChain φ₀ n)) (PAFormula.ex x_1 χ_1).maxVar;
(PAFormula.ex x_1 χ_1).imp (PAFormula.subst x_1 (PATerm.var w) χ_1) :: PAFormula.ex x χ :: henkinChain φ₀ n
| x_1 => PAFormula.ex x χ :: henkinChain φ₀ n)
PAFormula.bot
rw [hdec neg.ex φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.botx:ℕχ:PAFormulahbot_ψ:¬CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) PAFormula.bothdec:decodeForm n = PAFormula.ex x χ⊢ ¬CtxProvable
(match PAFormula.ex x χ with
| PAFormula.ex x_1 χ_1 =>
have w := max (maxVarList (PAFormula.ex x χ :: henkinChain φ₀ n)) (PAFormula.ex x_1 χ_1).maxVar;
(PAFormula.ex x_1 χ_1).imp (PAFormula.subst x_1 (PATerm.var w) χ_1) :: PAFormula.ex x χ :: henkinChain φ₀ n
| x_1 => PAFormula.ex x χ :: henkinChain φ₀ n)
PAFormula.bot] at hbot_ψ neg.ex φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.botx:ℕχ:PAFormulahbot_ψ:¬CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) PAFormula.bothdec:decodeForm n = PAFormula.ex x χ⊢ ¬CtxProvable
(match PAFormula.ex x χ with
| PAFormula.ex x_1 χ_1 =>
have w := max (maxVarList (PAFormula.ex x χ :: henkinChain φ₀ n)) (PAFormula.ex x_1 χ_1).maxVar;
(PAFormula.ex x_1 χ_1).imp (PAFormula.subst x_1 (PATerm.var w) χ_1) :: PAFormula.ex x χ :: henkinChain φ₀ n
| x_1 => PAFormula.ex x χ :: henkinChain φ₀ n)
PAFormula.bot
exact henkin_step_consistent x χ hbot_ψ All goals completed! 🐙
| _ => neg.all φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botx✝:ℕφ✝:PAFormulahdec:decodeForm n = PAFormula.all x✝ φ✝⊢ ¬CtxProvable
(match PAFormula.all x✝ φ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.all x✝ φ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.all x✝ φ✝ :: henkinChain φ₀ n
| x => PAFormula.all x✝ φ✝ :: henkinChain φ₀ n)
PAFormula.botneg.imp φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botφ✝:PAFormulaψ✝:PAFormulahdec:decodeForm n = φ✝.imp ψ✝⊢ ¬CtxProvable
(match φ✝.imp ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.imp ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.imp ψ✝ :: henkinChain φ₀ n
| x => φ✝.imp ψ✝ :: henkinChain φ₀ n)
PAFormula.botneg.or φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botφ✝:PAFormulaψ✝:PAFormulahdec:decodeForm n = φ✝.or ψ✝⊢ ¬CtxProvable
(match φ✝.or ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.or ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.or ψ✝ :: henkinChain φ₀ n
| x => φ✝.or ψ✝ :: henkinChain φ₀ n)
PAFormula.botneg.and φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.botφ✝:PAFormulaψ✝:PAFormulahdec:decodeForm n = φ✝.and ψ✝⊢ ¬CtxProvable
(match φ✝.and ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.and ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.and ψ✝ :: henkinChain φ₀ n
| x => φ✝.and ψ✝ :: henkinChain φ₀ n)
PAFormula.botneg.eq φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bott₁✝:PATermt₂✝:PATermhdec:decodeForm n = PAFormula.eq t₁✝ t₂✝⊢ ¬CtxProvable
(match PAFormula.eq t₁✝ t₂✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ n
| x => PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ n)
PAFormula.botneg.bot φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕih:¬CtxProvable (henkinChain φ₀ n) PAFormula.bothbot_ψ:¬CtxProvable (decodeForm n :: henkinChain φ₀ n) PAFormula.bothdec:decodeForm n = PAFormula.bot⊢ ¬CtxProvable
(match PAFormula.bot with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.bot :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.bot :: henkinChain φ₀ n
| x => PAFormula.bot :: henkinChain φ₀ n)
PAFormula.bot
rwa [hdec] at hbot_ψ All goals completed! 🐙
Maximal consistent Henkin-saturated theory extending φ₀.
private def henkinTheory (φ₀ : PAFormula) : Set PAFormula :=
{ α | ∃ n, α ∈ henkinChain φ₀ n }private theorem henkinTheory_mem_zero (φ₀ : PAFormula) :
φ₀ ∈ henkinTheory φ₀ :=
⟨0, List.mem_singleton.mpr rfl⟩private theorem henkinTheory_not_bot {φ₀ : PAFormula} (h₀ : ¬ CtxProvable [φ₀] .bot) :
PAFormula.bot ∉ henkinTheory φ₀ := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bot⊢ PAFormula.bot ∉ henkinTheory φ₀
rintro ⟨n, hn⟩ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botn:ℕhn:PAFormula.bot ∈ henkinChain φ₀ n⊢ False
exact henkinChain_consistent h₀ n (.hyp hn) All goals completed! 🐙private theorem henkinTheory_complete (φ₀ : PAFormula) (ψ : PAFormula) :
ψ ∈ henkinTheory φ₀ ∨ ψ.not ∈ henkinTheory φ₀ := by φ₀:PAFormulaψ:PAFormula⊢ ψ ∈ henkinTheory φ₀ ∨ ψ.not ∈ henkinTheory φ₀
let n := encodeForm ψ φ₀:PAFormulaψ:PAFormulan:ℕ := encodeForm ψ⊢ ψ ∈ henkinTheory φ₀ ∨ ψ.not ∈ henkinTheory φ₀
have hdec : decodeForm n = ψ := decodeForm_encodeForm ψ φ₀:PAFormulaψ:PAFormulan:ℕ := encodeForm ψhdec:decodeForm n = ψ⊢ ψ ∈ henkinTheory φ₀ ∨ ψ.not ∈ henkinTheory φ₀
by_cases hbot : CtxProvable (ψ :: henkinChain φ₀ n) .bot pos φ₀:PAFormulaψ:PAFormulan:ℕ := encodeForm ψhdec:decodeForm n = ψhbot:CtxProvable (ψ :: henkinChain φ₀ n) PAFormula.bot⊢ ψ ∈ henkinTheory φ₀ ∨ ψ.not ∈ henkinTheory φ₀neg φ₀:PAFormulaψ:PAFormulan:ℕ := encodeForm ψhdec:decodeForm n = ψhbot:¬CtxProvable (ψ :: henkinChain φ₀ n) PAFormula.bot⊢ ψ ∈ henkinTheory φ₀ ∨ ψ.not ∈ henkinTheory φ₀
· pos φ₀:PAFormulaψ:PAFormulan:ℕ := encodeForm ψhdec:decodeForm n = ψhbot:CtxProvable (ψ :: henkinChain φ₀ n) PAFormula.bot⊢ ψ ∈ henkinTheory φ₀ ∨ ψ.not ∈ henkinTheory φ₀ refine Or.inr ⟨n + 1, ?_⟩ pos φ₀:PAFormulaψ:PAFormulan:ℕ := encodeForm ψhdec:decodeForm n = ψhbot:CtxProvable (ψ :: henkinChain φ₀ n) PAFormula.bot⊢ ψ.not ∈ henkinChain φ₀ (n + 1)
simp only [henkinChain, hdec, hbot, ↓reduceIte] pos φ₀:PAFormulaψ:PAFormulan:ℕ := encodeForm ψhdec:decodeForm n = ψhbot:CtxProvable (ψ :: henkinChain φ₀ n) PAFormula.bot⊢ ψ.not ∈ ψ.not :: henkinChain φ₀ n
exact List.mem_cons_self .. All goals completed! 🐙
· neg φ₀:PAFormulaψ:PAFormulan:ℕ := encodeForm ψhdec:decodeForm n = ψhbot:¬CtxProvable (ψ :: henkinChain φ₀ n) PAFormula.bot⊢ ψ ∈ henkinTheory φ₀ ∨ ψ.not ∈ henkinTheory φ₀ refine Or.inl ⟨n + 1, ?_⟩ neg φ₀:PAFormulaψ:PAFormulan:ℕ := encodeForm ψhdec:decodeForm n = ψhbot:¬CtxProvable (ψ :: henkinChain φ₀ n) PAFormula.bot⊢ ψ ∈ henkinChain φ₀ (n + 1)
simp only [henkinChain, hdec, hbot, ↓reduceIte] neg φ₀:PAFormulaψ:PAFormulan:ℕ := encodeForm ψhdec:decodeForm n = ψhbot:¬CtxProvable (ψ :: henkinChain φ₀ n) PAFormula.bot⊢ ψ ∈ extendWithWitness ψ (henkinChain φ₀ n)
unfold extendWithWitness neg φ₀:PAFormulaψ:PAFormulan:ℕ := encodeForm ψhdec:decodeForm n = ψhbot:¬CtxProvable (ψ :: henkinChain φ₀ n) PAFormula.bot⊢ ψ ∈
match ψ with
| PAFormula.ex x χ =>
have w := max (maxVarList (ψ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: ψ :: henkinChain φ₀ n
| x => ψ :: henkinChain φ₀ n
cases ψ neg.bot φ₀:PAFormulan:ℕ := encodeForm PAFormula.bothdec:decodeForm n = PAFormula.bothbot:¬CtxProvable (PAFormula.bot :: henkinChain φ₀ n) PAFormula.bot⊢ PAFormula.bot ∈
match PAFormula.bot with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.bot :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.bot :: henkinChain φ₀ n
| x => PAFormula.bot :: henkinChain φ₀ nneg.eq φ₀:PAFormulat₁✝:PATermt₂✝:PATermn:ℕ := encodeForm (PAFormula.eq t₁✝ t₂✝)hdec:decodeForm n = PAFormula.eq t₁✝ t₂✝hbot:¬CtxProvable (PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ n) PAFormula.bot⊢ PAFormula.eq t₁✝ t₂✝ ∈
match PAFormula.eq t₁✝ t₂✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ n
| x => PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ nneg.and φ₀:PAFormulaφ✝:PAFormulaψ✝:PAFormulan:ℕ := encodeForm (φ✝.and ψ✝)hdec:decodeForm n = φ✝.and ψ✝hbot:¬CtxProvable (φ✝.and ψ✝ :: henkinChain φ₀ n) PAFormula.bot⊢ φ✝.and ψ✝ ∈
match φ✝.and ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.and ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.and ψ✝ :: henkinChain φ₀ n
| x => φ✝.and ψ✝ :: henkinChain φ₀ nneg.or φ₀:PAFormulaφ✝:PAFormulaψ✝:PAFormulan:ℕ := encodeForm (φ✝.or ψ✝)hdec:decodeForm n = φ✝.or ψ✝hbot:¬CtxProvable (φ✝.or ψ✝ :: henkinChain φ₀ n) PAFormula.bot⊢ φ✝.or ψ✝ ∈
match φ✝.or ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.or ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.or ψ✝ :: henkinChain φ₀ n
| x => φ✝.or ψ✝ :: henkinChain φ₀ nneg.imp φ₀:PAFormulaφ✝:PAFormulaψ✝:PAFormulan:ℕ := encodeForm (φ✝.imp ψ✝)hdec:decodeForm n = φ✝.imp ψ✝hbot:¬CtxProvable (φ✝.imp ψ✝ :: henkinChain φ₀ n) PAFormula.bot⊢ φ✝.imp ψ✝ ∈
match φ✝.imp ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.imp ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.imp ψ✝ :: henkinChain φ₀ n
| x => φ✝.imp ψ✝ :: henkinChain φ₀ nneg.all φ₀:PAFormulax✝:ℕφ✝:PAFormulan:ℕ := encodeForm (PAFormula.all x✝ φ✝)hdec:decodeForm n = PAFormula.all x✝ φ✝hbot:¬CtxProvable (PAFormula.all x✝ φ✝ :: henkinChain φ₀ n) PAFormula.bot⊢ PAFormula.all x✝ φ✝ ∈
match PAFormula.all x✝ φ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.all x✝ φ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.all x✝ φ✝ :: henkinChain φ₀ n
| x => PAFormula.all x✝ φ✝ :: henkinChain φ₀ nneg.ex φ₀:PAFormulax✝:ℕφ✝:PAFormulan:ℕ := encodeForm (PAFormula.ex x✝ φ✝)hdec:decodeForm n = PAFormula.ex x✝ φ✝hbot:¬CtxProvable (PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n) PAFormula.bot⊢ PAFormula.ex x✝ φ✝ ∈
match PAFormula.ex x✝ φ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n
| x => PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n <;> neg.bot φ₀:PAFormulan:ℕ := encodeForm PAFormula.bothdec:decodeForm n = PAFormula.bothbot:¬CtxProvable (PAFormula.bot :: henkinChain φ₀ n) PAFormula.bot⊢ PAFormula.bot ∈
match PAFormula.bot with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.bot :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.bot :: henkinChain φ₀ n
| x => PAFormula.bot :: henkinChain φ₀ nneg.eq φ₀:PAFormulat₁✝:PATermt₂✝:PATermn:ℕ := encodeForm (PAFormula.eq t₁✝ t₂✝)hdec:decodeForm n = PAFormula.eq t₁✝ t₂✝hbot:¬CtxProvable (PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ n) PAFormula.bot⊢ PAFormula.eq t₁✝ t₂✝ ∈
match PAFormula.eq t₁✝ t₂✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ n
| x => PAFormula.eq t₁✝ t₂✝ :: henkinChain φ₀ nneg.and φ₀:PAFormulaφ✝:PAFormulaψ✝:PAFormulan:ℕ := encodeForm (φ✝.and ψ✝)hdec:decodeForm n = φ✝.and ψ✝hbot:¬CtxProvable (φ✝.and ψ✝ :: henkinChain φ₀ n) PAFormula.bot⊢ φ✝.and ψ✝ ∈
match φ✝.and ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.and ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.and ψ✝ :: henkinChain φ₀ n
| x => φ✝.and ψ✝ :: henkinChain φ₀ nneg.or φ₀:PAFormulaφ✝:PAFormulaψ✝:PAFormulan:ℕ := encodeForm (φ✝.or ψ✝)hdec:decodeForm n = φ✝.or ψ✝hbot:¬CtxProvable (φ✝.or ψ✝ :: henkinChain φ₀ n) PAFormula.bot⊢ φ✝.or ψ✝ ∈
match φ✝.or ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.or ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.or ψ✝ :: henkinChain φ₀ n
| x => φ✝.or ψ✝ :: henkinChain φ₀ nneg.imp φ₀:PAFormulaφ✝:PAFormulaψ✝:PAFormulan:ℕ := encodeForm (φ✝.imp ψ✝)hdec:decodeForm n = φ✝.imp ψ✝hbot:¬CtxProvable (φ✝.imp ψ✝ :: henkinChain φ₀ n) PAFormula.bot⊢ φ✝.imp ψ✝ ∈
match φ✝.imp ψ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (φ✝.imp ψ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: φ✝.imp ψ✝ :: henkinChain φ₀ n
| x => φ✝.imp ψ✝ :: henkinChain φ₀ nneg.all φ₀:PAFormulax✝:ℕφ✝:PAFormulan:ℕ := encodeForm (PAFormula.all x✝ φ✝)hdec:decodeForm n = PAFormula.all x✝ φ✝hbot:¬CtxProvable (PAFormula.all x✝ φ✝ :: henkinChain φ₀ n) PAFormula.bot⊢ PAFormula.all x✝ φ✝ ∈
match PAFormula.all x✝ φ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.all x✝ φ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.all x✝ φ✝ :: henkinChain φ₀ n
| x => PAFormula.all x✝ φ✝ :: henkinChain φ₀ nneg.ex φ₀:PAFormulax✝:ℕφ✝:PAFormulan:ℕ := encodeForm (PAFormula.ex x✝ φ✝)hdec:decodeForm n = PAFormula.ex x✝ φ✝hbot:¬CtxProvable (PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n) PAFormula.bot⊢ PAFormula.ex x✝ φ✝ ∈
match PAFormula.ex x✝ φ✝ with
| PAFormula.ex x χ =>
have w := max (maxVarList (PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar;
(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) :: PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n
| x => PAFormula.ex x✝ φ✝ :: henkinChain φ₀ n simp All goals completed! 🐙private theorem henkinChain_fin_subset {φ₀ : PAFormula} (Γ : List PAFormula)
(hΓ : ∀ γ ∈ Γ, γ ∈ henkinTheory φ₀) :
∃ N, ∀ γ ∈ Γ, γ ∈ henkinChain φ₀ N := by φ₀:PAFormulaΓ:List PAFormulahΓ:∀ γ ∈ Γ, γ ∈ henkinTheory φ₀⊢ ∃ N, ∀ γ ∈ Γ, γ ∈ henkinChain φ₀ N
induction Γ with
| nil => nil φ₀:PAFormulahΓ:∀ γ ∈ [], γ ∈ henkinTheory φ₀⊢ ∃ N, ∀ γ ∈ [], γ ∈ henkinChain φ₀ N exact ⟨0, fun _ hm ↦ False.elim (List.not_mem_nil hm)⟩ All goals completed! 🐙
| cons δ rest ih => cons φ₀:PAFormulaδ:PAFormularest:List PAFormulaih:(∀ γ ∈ rest, γ ∈ henkinTheory φ₀) → ∃ N, ∀ γ ∈ rest, γ ∈ henkinChain φ₀ NhΓ:∀ γ ∈ δ :: rest, γ ∈ henkinTheory φ₀⊢ ∃ N, ∀ γ ∈ δ :: rest, γ ∈ henkinChain φ₀ N
obtain ⟨n₁, hn₁⟩ := hΓ δ (List.mem_cons_self ..) cons φ₀:PAFormulaδ:PAFormularest:List PAFormulaih:(∀ γ ∈ rest, γ ∈ henkinTheory φ₀) → ∃ N, ∀ γ ∈ rest, γ ∈ henkinChain φ₀ NhΓ:∀ γ ∈ δ :: rest, γ ∈ henkinTheory φ₀n₁:ℕhn₁:δ ∈ henkinChain φ₀ n₁⊢ ∃ N, ∀ γ ∈ δ :: rest, γ ∈ henkinChain φ₀ N
obtain ⟨n₂, hn₂⟩ := ih fun γ hγ ↦ hΓ γ (List.mem_cons_of_mem _ hγ) cons φ₀:PAFormulaδ:PAFormularest:List PAFormulaih:(∀ γ ∈ rest, γ ∈ henkinTheory φ₀) → ∃ N, ∀ γ ∈ rest, γ ∈ henkinChain φ₀ NhΓ:∀ γ ∈ δ :: rest, γ ∈ henkinTheory φ₀n₁:ℕhn₁:δ ∈ henkinChain φ₀ n₁n₂:ℕhn₂:∀ γ ∈ rest, γ ∈ henkinChain φ₀ n₂⊢ ∃ N, ∀ γ ∈ δ :: rest, γ ∈ henkinChain φ₀ N
refine ⟨max n₁ n₂, fun γ hγ ↦ ?_⟩ cons φ₀:PAFormulaδ:PAFormularest:List PAFormulaih:(∀ γ ∈ rest, γ ∈ henkinTheory φ₀) → ∃ N, ∀ γ ∈ rest, γ ∈ henkinChain φ₀ NhΓ:∀ γ ∈ δ :: rest, γ ∈ henkinTheory φ₀n₁:ℕhn₁:δ ∈ henkinChain φ₀ n₁n₂:ℕhn₂:∀ γ ∈ rest, γ ∈ henkinChain φ₀ n₂γ:PAFormulahγ:γ ∈ δ :: rest⊢ γ ∈ henkinChain φ₀ (max n₁ n₂)
rcases List.mem_cons.mp hγ with heq | hm cons.inl φ₀:PAFormulaδ:PAFormularest:List PAFormulaih:(∀ γ ∈ rest, γ ∈ henkinTheory φ₀) → ∃ N, ∀ γ ∈ rest, γ ∈ henkinChain φ₀ NhΓ:∀ γ ∈ δ :: rest, γ ∈ henkinTheory φ₀n₁:ℕhn₁:δ ∈ henkinChain φ₀ n₁n₂:ℕhn₂:∀ γ ∈ rest, γ ∈ henkinChain φ₀ n₂γ:PAFormulahγ:γ ∈ δ :: restheq:γ = δ⊢ γ ∈ henkinChain φ₀ (max n₁ n₂)cons.inr φ₀:PAFormulaδ:PAFormularest:List PAFormulaih:(∀ γ ∈ rest, γ ∈ henkinTheory φ₀) → ∃ N, ∀ γ ∈ rest, γ ∈ henkinChain φ₀ NhΓ:∀ γ ∈ δ :: rest, γ ∈ henkinTheory φ₀n₁:ℕhn₁:δ ∈ henkinChain φ₀ n₁n₂:ℕhn₂:∀ γ ∈ rest, γ ∈ henkinChain φ₀ n₂γ:PAFormulahγ:γ ∈ δ :: resthm:γ ∈ rest⊢ γ ∈ henkinChain φ₀ (max n₁ n₂)
· cons.inl φ₀:PAFormulaδ:PAFormularest:List PAFormulaih:(∀ γ ∈ rest, γ ∈ henkinTheory φ₀) → ∃ N, ∀ γ ∈ rest, γ ∈ henkinChain φ₀ NhΓ:∀ γ ∈ δ :: rest, γ ∈ henkinTheory φ₀n₁:ℕhn₁:δ ∈ henkinChain φ₀ n₁n₂:ℕhn₂:∀ γ ∈ rest, γ ∈ henkinChain φ₀ n₂γ:PAFormulahγ:γ ∈ δ :: restheq:γ = δ⊢ γ ∈ henkinChain φ₀ (max n₁ n₂) subst heq cons.inl φ₀:PAFormularest:List PAFormulaih:(∀ γ ∈ rest, γ ∈ henkinTheory φ₀) → ∃ N, ∀ γ ∈ rest, γ ∈ henkinChain φ₀ Nn₁:ℕn₂:ℕhn₂:∀ γ ∈ rest, γ ∈ henkinChain φ₀ n₂γ:PAFormulahΓ:∀ γ_1 ∈ γ :: rest, γ_1 ∈ henkinTheory φ₀hn₁:γ ∈ henkinChain φ₀ n₁hγ:γ ∈ γ :: rest⊢ γ ∈ henkinChain φ₀ (max n₁ n₂)
exact henkinChain_mono φ₀ (Nat.le_max_left ..) _ hn₁ All goals completed! 🐙
· cons.inr φ₀:PAFormulaδ:PAFormularest:List PAFormulaih:(∀ γ ∈ rest, γ ∈ henkinTheory φ₀) → ∃ N, ∀ γ ∈ rest, γ ∈ henkinChain φ₀ NhΓ:∀ γ ∈ δ :: rest, γ ∈ henkinTheory φ₀n₁:ℕhn₁:δ ∈ henkinChain φ₀ n₁n₂:ℕhn₂:∀ γ ∈ rest, γ ∈ henkinChain φ₀ n₂γ:PAFormulahγ:γ ∈ δ :: resthm:γ ∈ rest⊢ γ ∈ henkinChain φ₀ (max n₁ n₂) exact henkinChain_mono φ₀ (Nat.le_max_right ..) γ (hn₂ γ hm) All goals completed! 🐙private theorem henkinTheory_closed {φ₀ : PAFormula} (h₀ : ¬ CtxProvable [φ₀] .bot)
{Γ : List PAFormula} {α : PAFormula} (hprov : CtxProvable Γ α)
(hΓ : ∀ γ ∈ Γ, γ ∈ henkinTheory φ₀) :
α ∈ henkinTheory φ₀ := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botΓ:List PAFormulaα:PAFormulahprov:CtxProvable Γ αhΓ:∀ γ ∈ Γ, γ ∈ henkinTheory φ₀⊢ α ∈ henkinTheory φ₀
obtain ⟨N, hN⟩ := henkinChain_fin_subset Γ hΓ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botΓ:List PAFormulaα:PAFormulahprov:CtxProvable Γ αhΓ:∀ γ ∈ Γ, γ ∈ henkinTheory φ₀N:ℕhN:∀ γ ∈ Γ, γ ∈ henkinChain φ₀ N⊢ α ∈ henkinTheory φ₀
have hctx : CtxProvable (henkinChain φ₀ N) α := ctx_mono hN hprov φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botΓ:List PAFormulaα:PAFormulahprov:CtxProvable Γ αhΓ:∀ γ ∈ Γ, γ ∈ henkinTheory φ₀N:ℕhN:∀ γ ∈ Γ, γ ∈ henkinChain φ₀ Nhctx:CtxProvable (henkinChain φ₀ N) α⊢ α ∈ henkinTheory φ₀
rcases henkinTheory_complete φ₀ α with hα | hnα inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botΓ:List PAFormulaα:PAFormulahprov:CtxProvable Γ αhΓ:∀ γ ∈ Γ, γ ∈ henkinTheory φ₀N:ℕhN:∀ γ ∈ Γ, γ ∈ henkinChain φ₀ Nhctx:CtxProvable (henkinChain φ₀ N) αhα:α ∈ henkinTheory φ₀⊢ α ∈ henkinTheory φ₀inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botΓ:List PAFormulaα:PAFormulahprov:CtxProvable Γ αhΓ:∀ γ ∈ Γ, γ ∈ henkinTheory φ₀N:ℕhN:∀ γ ∈ Γ, γ ∈ henkinChain φ₀ Nhctx:CtxProvable (henkinChain φ₀ N) αhnα:α.not ∈ henkinTheory φ₀⊢ α ∈ henkinTheory φ₀
· inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botΓ:List PAFormulaα:PAFormulahprov:CtxProvable Γ αhΓ:∀ γ ∈ Γ, γ ∈ henkinTheory φ₀N:ℕhN:∀ γ ∈ Γ, γ ∈ henkinChain φ₀ Nhctx:CtxProvable (henkinChain φ₀ N) αhα:α ∈ henkinTheory φ₀⊢ α ∈ henkinTheory φ₀ exact hα All goals completed! 🐙
· inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botΓ:List PAFormulaα:PAFormulahprov:CtxProvable Γ αhΓ:∀ γ ∈ Γ, γ ∈ henkinTheory φ₀N:ℕhN:∀ γ ∈ Γ, γ ∈ henkinChain φ₀ Nhctx:CtxProvable (henkinChain φ₀ N) αhnα:α.not ∈ henkinTheory φ₀⊢ α ∈ henkinTheory φ₀ obtain ⟨M, hM⟩ := hnα inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botΓ:List PAFormulaα:PAFormulahprov:CtxProvable Γ αhΓ:∀ γ ∈ Γ, γ ∈ henkinTheory φ₀N:ℕhN:∀ γ ∈ Γ, γ ∈ henkinChain φ₀ Nhctx:CtxProvable (henkinChain φ₀ N) αM:ℕhM:α.not ∈ henkinChain φ₀ M⊢ α ∈ henkinTheory φ₀
let K := max N M inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botΓ:List PAFormulaα:PAFormulahprov:CtxProvable Γ αhΓ:∀ γ ∈ Γ, γ ∈ henkinTheory φ₀N:ℕhN:∀ γ ∈ Γ, γ ∈ henkinChain φ₀ Nhctx:CtxProvable (henkinChain φ₀ N) αM:ℕhM:α.not ∈ henkinChain φ₀ MK:ℕ := max N M⊢ α ∈ henkinTheory φ₀
have h₁ : CtxProvable (henkinChain φ₀ K) α :=
ctx_mono (henkinChain_mono φ₀ (Nat.le_max_left ..)) hctx inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botΓ:List PAFormulaα:PAFormulahprov:CtxProvable Γ αhΓ:∀ γ ∈ Γ, γ ∈ henkinTheory φ₀N:ℕhN:∀ γ ∈ Γ, γ ∈ henkinChain φ₀ Nhctx:CtxProvable (henkinChain φ₀ N) αM:ℕhM:α.not ∈ henkinChain φ₀ MK:ℕ := max N Mh₁:CtxProvable (henkinChain φ₀ K) α⊢ α ∈ henkinTheory φ₀
have h₂ : α.not ∈ henkinChain φ₀ K :=
henkinChain_mono φ₀ (Nat.le_max_right ..) _ hM inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botΓ:List PAFormulaα:PAFormulahprov:CtxProvable Γ αhΓ:∀ γ ∈ Γ, γ ∈ henkinTheory φ₀N:ℕhN:∀ γ ∈ Γ, γ ∈ henkinChain φ₀ Nhctx:CtxProvable (henkinChain φ₀ N) αM:ℕhM:α.not ∈ henkinChain φ₀ MK:ℕ := max N Mh₁:CtxProvable (henkinChain φ₀ K) αh₂:α.not ∈ henkinChain φ₀ K⊢ α ∈ henkinTheory φ₀
exact False.elim (henkinChain_consistent h₀ K (.mp h₁ (.hyp h₂))) All goals completed! 🐙private theorem henkinTheory_ax {φ₀ : PAFormula} (h₀ : ¬ CtxProvable [φ₀] .bot)
{α : PAFormula} (hp : PAProvable α) : α ∈ henkinTheory φ₀ :=
henkinTheory_closed h₀ (Γ := []) (.ax hp) (fun _ hm ↦ False.elim (List.not_mem_nil hm))private theorem henkinTheory_mp {φ₀ : PAFormula} (h₀ : ¬ CtxProvable [φ₀] .bot)
{α β : PAFormula} (hα : α ∈ henkinTheory φ₀) (himp : .imp α β ∈ henkinTheory φ₀) :
β ∈ henkinTheory φ₀ :=
henkinTheory_closed h₀ (Γ := [α, .imp α β])
(.mp (φ := α) (.hyp (by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botα:PAFormulaβ:PAFormulahα:α ∈ henkinTheory φ₀himp:α.imp β ∈ henkinTheory φ₀⊢ α ∈ [α, α.imp β] simp All goals completed! 🐙)) (.hyp (by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botα:PAFormulaβ:PAFormulahα:α ∈ henkinTheory φ₀himp:α.imp β ∈ henkinTheory φ₀⊢ α.imp β ∈ [α, α.imp β] simp All goals completed! 🐙))) (by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botα:PAFormulaβ:PAFormulahα:α ∈ henkinTheory φ₀himp:α.imp β ∈ henkinTheory φ₀⊢ ∀ γ ∈ [α, α.imp β], γ ∈ henkinTheory φ₀
intro γ hγ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botα:PAFormulaβ:PAFormulahα:α ∈ henkinTheory φ₀himp:α.imp β ∈ henkinTheory φ₀γ:PAFormulahγ:γ ∈ [α, α.imp β]⊢ γ ∈ henkinTheory φ₀
rcases List.mem_cons.mp hγ with heq | hγ' inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botα:PAFormulaβ:PAFormulahα:α ∈ henkinTheory φ₀himp:α.imp β ∈ henkinTheory φ₀γ:PAFormulahγ:γ ∈ [α, α.imp β]heq:γ = α⊢ γ ∈ henkinTheory φ₀inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botα:PAFormulaβ:PAFormulahα:α ∈ henkinTheory φ₀himp:α.imp β ∈ henkinTheory φ₀γ:PAFormulahγ:γ ∈ [α, α.imp β]hγ':γ ∈ [α.imp β]⊢ γ ∈ henkinTheory φ₀
· inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botα:PAFormulaβ:PAFormulahα:α ∈ henkinTheory φ₀himp:α.imp β ∈ henkinTheory φ₀γ:PAFormulahγ:γ ∈ [α, α.imp β]heq:γ = α⊢ γ ∈ henkinTheory φ₀ subst heq inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botβ:PAFormulaγ:PAFormulahα:γ ∈ henkinTheory φ₀himp:γ.imp β ∈ henkinTheory φ₀hγ:γ ∈ [γ, γ.imp β]⊢ γ ∈ henkinTheory φ₀; exact hα All goals completed! 🐙
· inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botα:PAFormulaβ:PAFormulahα:α ∈ henkinTheory φ₀himp:α.imp β ∈ henkinTheory φ₀γ:PAFormulahγ:γ ∈ [α, α.imp β]hγ':γ ∈ [α.imp β]⊢ γ ∈ henkinTheory φ₀ rw [List.mem_singleton.mp hγ' inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botα:PAFormulaβ:PAFormulahα:α ∈ henkinTheory φ₀himp:α.imp β ∈ henkinTheory φ₀γ:PAFormulahγ:γ ∈ [α, α.imp β]hγ':γ ∈ [α.imp β]⊢ α.imp β ∈ henkinTheory φ₀] inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botα:PAFormulaβ:PAFormulahα:α ∈ henkinTheory φ₀himp:α.imp β ∈ henkinTheory φ₀γ:PAFormulahγ:γ ∈ [α, α.imp β]hγ':γ ∈ [α.imp β]⊢ α.imp β ∈ henkinTheory φ₀
exact himp All goals completed! 🐙)private theorem henkinTheory_witness {φ₀ : PAFormula} (h₀ : ¬ CtxProvable [φ₀] .bot)
{x : ℕ} {χ : PAFormula} (hex : .ex x χ ∈ henkinTheory φ₀) :
∃ w : ℕ, (PAFormula.ex x χ).maxVar ≤ w ∧ χ.subst x (.var w) ∈ henkinTheory φ₀ := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀⊢ ∃ w, (PAFormula.ex x χ).maxVar ≤ w ∧ PAFormula.subst x (PATerm.var w) χ ∈ henkinTheory φ₀
let n := encodeForm (.ex x χ) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀n:ℕ := encodeForm (PAFormula.ex x χ)⊢ ∃ w, (PAFormula.ex x χ).maxVar ≤ w ∧ PAFormula.subst x (PATerm.var w) χ ∈ henkinTheory φ₀
have hdec : decodeForm n = .ex x χ := decodeForm_encodeForm (.ex x χ) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀n:ℕ := encodeForm (PAFormula.ex x χ)hdec:decodeForm n = PAFormula.ex x χ⊢ ∃ w, (PAFormula.ex x χ).maxVar ≤ w ∧ PAFormula.subst x (PATerm.var w) χ ∈ henkinTheory φ₀
by_cases hbot : CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) .bot pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀n:ℕ := encodeForm (PAFormula.ex x χ)hdec:decodeForm n = PAFormula.ex x χhbot:CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) PAFormula.bot⊢ ∃ w, (PAFormula.ex x χ).maxVar ≤ w ∧ PAFormula.subst x (PATerm.var w) χ ∈ henkinTheory φ₀neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀n:ℕ := encodeForm (PAFormula.ex x χ)hdec:decodeForm n = PAFormula.ex x χhbot:¬CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) PAFormula.bot⊢ ∃ w, (PAFormula.ex x χ).maxVar ≤ w ∧ PAFormula.subst x (PATerm.var w) χ ∈ henkinTheory φ₀
· pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀n:ℕ := encodeForm (PAFormula.ex x χ)hdec:decodeForm n = PAFormula.ex x χhbot:CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) PAFormula.bot⊢ ∃ w, (PAFormula.ex x χ).maxVar ≤ w ∧ PAFormula.subst x (PATerm.var w) χ ∈ henkinTheory φ₀ have hn : (PAFormula.ex x χ).not ∈ henkinTheory φ₀ := by
refine ⟨n + 1, ?_⟩ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀n:ℕ := encodeForm (PAFormula.ex x χ)hdec:decodeForm n = PAFormula.ex x χhbot:CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) PAFormula.bot⊢ (PAFormula.ex x χ).not ∈ henkinChain φ₀ (n + 1)
simp only [henkinChain, hdec, hbot, ↓reduceIte] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀n:ℕ := encodeForm (PAFormula.ex x χ)hdec:decodeForm n = PAFormula.ex x χhbot:CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) PAFormula.bot⊢ (PAFormula.ex x χ).not ∈ (PAFormula.ex x χ).not :: henkinChain φ₀ n
exact List.mem_cons_self .. pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀n:ℕ := encodeForm (PAFormula.ex x χ)hdec:decodeForm n = PAFormula.ex x χhbot:CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) PAFormula.bothn:(PAFormula.ex x χ).not ∈ henkinTheory φ₀⊢ ∃ w, (PAFormula.ex x χ).maxVar ≤ w ∧ PAFormula.subst x (PATerm.var w) χ ∈ henkinTheory φ₀
exact False.elim (henkinTheory_not_bot h₀ (henkinTheory_mp h₀ hex hn)) All goals completed! 🐙
· neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀n:ℕ := encodeForm (PAFormula.ex x χ)hdec:decodeForm n = PAFormula.ex x χhbot:¬CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) PAFormula.bot⊢ ∃ w, (PAFormula.ex x χ).maxVar ≤ w ∧ PAFormula.subst x (PATerm.var w) χ ∈ henkinTheory φ₀ let w := max (maxVarList (PAFormula.ex x χ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀n:ℕ := encodeForm (PAFormula.ex x χ)hdec:decodeForm n = PAFormula.ex x χhbot:¬CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) PAFormula.botw:ℕ := max (maxVarList (PAFormula.ex x χ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar⊢ ∃ w, (PAFormula.ex x χ).maxVar ≤ w ∧ PAFormula.subst x (PATerm.var w) χ ∈ henkinTheory φ₀
have himp : PAFormula.imp (.ex x χ) (χ.subst x (.var w)) ∈ henkinTheory φ₀ := by
refine ⟨n + 1, ?_⟩ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀n:ℕ := encodeForm (PAFormula.ex x χ)hdec:decodeForm n = PAFormula.ex x χhbot:¬CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) PAFormula.botw:ℕ := max (maxVarList (PAFormula.ex x χ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar⊢ (PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) ∈ henkinChain φ₀ (n + 1)
simp only [henkinChain, hdec, hbot, ↓reduceIte, extendWithWitness] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀n:ℕ := encodeForm (PAFormula.ex x χ)hdec:decodeForm n = PAFormula.ex x χhbot:¬CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) PAFormula.botw:ℕ := max (maxVarList (PAFormula.ex x χ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar⊢ (PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) ∈
(PAFormula.ex x χ).imp
(PAFormula.subst x
(PATerm.var (max (maxVarList (PAFormula.ex x χ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVar)) χ) ::
PAFormula.ex x χ :: henkinChain φ₀ n
exact List.mem_cons_self .. neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕχ:PAFormulahex:PAFormula.ex x χ ∈ henkinTheory φ₀n:ℕ := encodeForm (PAFormula.ex x χ)hdec:decodeForm n = PAFormula.ex x χhbot:¬CtxProvable (PAFormula.ex x χ :: henkinChain φ₀ n) PAFormula.botw:ℕ := max (maxVarList (PAFormula.ex x χ :: henkinChain φ₀ n)) (PAFormula.ex x χ).maxVarhimp:(PAFormula.ex x χ).imp (PAFormula.subst x (PATerm.var w) χ) ∈ henkinTheory φ₀⊢ ∃ w, (PAFormula.ex x χ).maxVar ≤ w ∧ PAFormula.subst x (PATerm.var w) χ ∈ henkinTheory φ₀
exact ⟨w, Nat.le_max_right .., henkinTheory_mp h₀ hex himp⟩ All goals completed! 🐙Section 4: Quotient Henkin Model, Truth Lemma, and Completeness
section HenkinModelvariable {φ₀ : PAFormula}private def HenkinSetoid (h₀ : ¬ CtxProvable [φ₀] .bot) : Setoid PATerm where
r s t := PAFormula.eq s t ∈ henkinTheory φ₀
iseqv := {
refl := fun t ↦ henkinTheory_ax h₀ (.eq_refl t)
symm := fun {s t} h ↦ henkinTheory_mp h₀ h (henkinTheory_ax h₀ (pa_eq_symm s t))
trans := fun {r s t} h₁ h₂ ↦
henkinTheory_mp h₀ h₂ (henkinTheory_mp h₀ h₁ (henkinTheory_ax h₀ (pa_eq_trans r s t)))
}private abbrev HenkinCarrier (h₀ : ¬ CtxProvable [φ₀] .bot) : Type :=
Quotient (HenkinSetoid h₀)private instance instPAStructureHenkin (h₀ : ¬ CtxProvable [φ₀] .bot) :
PAStructure (HenkinCarrier h₀) where
zero := Quotient.mk (HenkinSetoid h₀) .zero
succ := Quotient.lift (fun t ↦ Quotient.mk (HenkinSetoid h₀) (.succ t))
fun s t hst ↦ Quotient.sound (henkinTheory_mp h₀ hst (henkinTheory_ax h₀ (pa_eq_succ s t)))
add := Quotient.lift₂ (fun s t ↦ Quotient.mk (HenkinSetoid h₀) (.add s t))
fun s₁ s₂ t₁ t₂ h₁ h₂ ↦ Quotient.sound
(henkinTheory_mp h₀ h₂ (henkinTheory_mp h₀ h₁ (henkinTheory_ax h₀ (pa_eq_add s₁ t₁ s₂ t₂))))
mul := Quotient.lift₂ (fun s t ↦ Quotient.mk (HenkinSetoid h₀) (.mul s t))
fun s₁ s₂ t₁ t₂ h₁ h₂ ↦ Quotient.sound
(henkinTheory_mp h₀ h₂ (henkinTheory_mp h₀ h₁ (henkinTheory_ax h₀ (pa_eq_mul s₁ t₁ s₂ t₂))))private theorem evalIn_henkin_vsubst (h₀ : ¬ CtxProvable [φ₀] .bot) (ρ : ℕ → ℕ) (t : PATerm) :
PATerm.evalIn (fun x ↦ Quotient.mk (HenkinSetoid h₀) (.var (ρ x))) t =
Quotient.mk (HenkinSetoid h₀) (t.vsubst ρ) := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botρ:ℕ → ℕt:PATerm⊢ PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) t = ⟦PATerm.vsubst ρ t⟧
induction t with
| var _ var φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botρ:ℕ → ℕx✝:ℕ⊢ PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PATerm.var x✝) = ⟦PATerm.vsubst ρ (PATerm.var x✝)⟧ | zero zero φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botρ:ℕ → ℕ⊢ PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) PATerm.zero = ⟦PATerm.vsubst ρ PATerm.zero⟧ => zero φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botρ:ℕ → ℕ⊢ PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) PATerm.zero = ⟦PATerm.vsubst ρ PATerm.zero⟧var φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botρ:ℕ → ℕx✝:ℕ⊢ PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PATerm.var x✝) = ⟦PATerm.vsubst ρ (PATerm.var x✝)⟧ rfl All goals completed! 🐙
| succ _ ih => succ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botρ:ℕ → ℕt✝:PATermih:PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) t✝ = ⟦PATerm.vsubst ρ t✝⟧⊢ PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) t✝.succ = ⟦PATerm.vsubst ρ t✝.succ⟧
simp only [PATerm.evalIn, ih, PATerm.vsubst] succ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botρ:ℕ → ℕt✝:PATermih:PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) t✝ = ⟦PATerm.vsubst ρ t✝⟧⊢ PAStructure.succ ⟦PATerm.vsubst ρ t✝⟧ = ⟦(PATerm.vsubst ρ t✝).succ⟧
rfl All goals completed! 🐙
| add _ _ ih₁ ih₂ => add φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botρ:ℕ → ℕt₁✝:PATermt₂✝:PATermih₁:PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) t₁✝ = ⟦PATerm.vsubst ρ t₁✝⟧ih₂:PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) t₂✝ = ⟦PATerm.vsubst ρ t₂✝⟧⊢ PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (t₁✝.add t₂✝) = ⟦PATerm.vsubst ρ (t₁✝.add t₂✝)⟧
simp only [PATerm.evalIn, ih₁, ih₂, PATerm.vsubst] add φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botρ:ℕ → ℕt₁✝:PATermt₂✝:PATermih₁:PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) t₁✝ = ⟦PATerm.vsubst ρ t₁✝⟧ih₂:PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) t₂✝ = ⟦PATerm.vsubst ρ t₂✝⟧⊢ PAStructure.add ⟦PATerm.vsubst ρ t₁✝⟧ ⟦PATerm.vsubst ρ t₂✝⟧ = ⟦(PATerm.vsubst ρ t₁✝).add (PATerm.vsubst ρ t₂✝)⟧
rfl All goals completed! 🐙
| mul _ _ ih₁ ih₂ => mul φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botρ:ℕ → ℕt₁✝:PATermt₂✝:PATermih₁:PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) t₁✝ = ⟦PATerm.vsubst ρ t₁✝⟧ih₂:PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) t₂✝ = ⟦PATerm.vsubst ρ t₂✝⟧⊢ PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (t₁✝.mul t₂✝) = ⟦PATerm.vsubst ρ (t₁✝.mul t₂✝)⟧
simp only [PATerm.evalIn, ih₁, ih₂, PATerm.vsubst] mul φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botρ:ℕ → ℕt₁✝:PATermt₂✝:PATermih₁:PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) t₁✝ = ⟦PATerm.vsubst ρ t₁✝⟧ih₂:PATerm.evalIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) t₂✝ = ⟦PATerm.vsubst ρ t₂✝⟧⊢ PAStructure.mul ⟦PATerm.vsubst ρ t₁✝⟧ ⟦PATerm.vsubst ρ t₂✝⟧ = ⟦(PATerm.vsubst ρ t₁✝).mul (PATerm.vsubst ρ t₂✝)⟧
rfl All goals completed! 🐙private theorem exists_var_rep (h₀ : ¬ CtxProvable [φ₀] .bot) (B : ℕ) (a : HenkinCarrier h₀) :
∃ w : ℕ, B ≤ w ∧ Quotient.mk (HenkinSetoid h₀) (.var w) = a := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botB:ℕa:HenkinCarrier h₀⊢ ∃ w, B ≤ w ∧ ⟦PATerm.var w⟧ = a
obtain ⟨t, rfl⟩ := Quotient.exists_rep a φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botB:ℕt:PATerm⊢ ∃ w, B ≤ w ∧ ⟦PATerm.var w⟧ = ⟦t⟧
let y := max B t.freshVar φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botB:ℕt:PATermy:ℕ := max B t.freshVar⊢ ∃ w, B ≤ w ∧ ⟦PATerm.var w⟧ = ⟦t⟧
have hex : PAFormula.ex y (.eq (.var y) t) ∈ henkinTheory φ₀ :=
henkinTheory_ax h₀ (pa_exists_var_eq B t) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botB:ℕt:PATermy:ℕ := max B t.freshVarhex:PAFormula.ex y (PAFormula.eq (PATerm.var y) t) ∈ henkinTheory φ₀⊢ ∃ w, B ≤ w ∧ ⟦PATerm.var w⟧ = ⟦t⟧
obtain ⟨w, hw, hsub⟩ := henkinTheory_witness h₀ hex φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botB:ℕt:PATermy:ℕ := max B t.freshVarhex:PAFormula.ex y (PAFormula.eq (PATerm.var y) t) ∈ henkinTheory φ₀w:ℕhw:(PAFormula.ex y (PAFormula.eq (PATerm.var y) t)).maxVar ≤ whsub:PAFormula.subst y (PATerm.var w) (PAFormula.eq (PATerm.var y) t) ∈ henkinTheory φ₀⊢ ∃ w, B ≤ w ∧ ⟦PATerm.var w⟧ = ⟦t⟧
have hty : t.hasVar y = false := hasVar_false_of_freshVar_le (Nat.le_max_right ..) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botB:ℕt:PATermy:ℕ := max B t.freshVarhex:PAFormula.ex y (PAFormula.eq (PATerm.var y) t) ∈ henkinTheory φ₀w:ℕhw:(PAFormula.ex y (PAFormula.eq (PATerm.var y) t)).maxVar ≤ whsub:PAFormula.subst y (PATerm.var w) (PAFormula.eq (PATerm.var y) t) ∈ henkinTheory φ₀hty:PATerm.hasVar y t = false⊢ ∃ w, B ≤ w ∧ ⟦PATerm.var w⟧ = ⟦t⟧
have ht_w : t.subst y (.var w) = t := term_subst_eq_self_of_hasVar_false (.var w) hty φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botB:ℕt:PATermy:ℕ := max B t.freshVarhex:PAFormula.ex y (PAFormula.eq (PATerm.var y) t) ∈ henkinTheory φ₀w:ℕhw:(PAFormula.ex y (PAFormula.eq (PATerm.var y) t)).maxVar ≤ whsub:PAFormula.subst y (PATerm.var w) (PAFormula.eq (PATerm.var y) t) ∈ henkinTheory φ₀hty:PATerm.hasVar y t = falseht_w:t.subst y (PATerm.var w) = t⊢ ∃ w, B ≤ w ∧ ⟦PATerm.var w⟧ = ⟦t⟧
simp only [PAFormula.subst, PATerm.subst, beq_self_eq_true, ↓reduceIte, ht_w] at hsub φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botB:ℕt:PATermy:ℕ := max B t.freshVarhex:PAFormula.ex y (PAFormula.eq (PATerm.var y) t) ∈ henkinTheory φ₀w:ℕhw:(PAFormula.ex y (PAFormula.eq (PATerm.var y) t)).maxVar ≤ whty:PATerm.hasVar y t = falseht_w:t.subst y (PATerm.var w) = thsub:PAFormula.eq (PATerm.var w) t ∈ henkinTheory φ₀⊢ ∃ w, B ≤ w ∧ ⟦PATerm.var w⟧ = ⟦t⟧
have hBw : B ≤ w := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botB:ℕa:HenkinCarrier h₀⊢ ∃ w, B ≤ w ∧ ⟦PATerm.var w⟧ = a
simp only [PAFormula.maxVar, Nat.max_le] at hw φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botB:ℕt:PATermy:ℕ := max B t.freshVarhex:PAFormula.ex y (PAFormula.eq (PATerm.var y) t) ∈ henkinTheory φ₀w:ℕhty:PATerm.hasVar y t = falseht_w:t.subst y (PATerm.var w) = thsub:PAFormula.eq (PATerm.var w) t ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PATerm.var y).freshVar ≤ w ∧ t.freshVar ≤ w⊢ B ≤ w
have : B ≤ y := Nat.le_max_left .. φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botB:ℕt:PATermy:ℕ := max B t.freshVarhex:PAFormula.ex y (PAFormula.eq (PATerm.var y) t) ∈ henkinTheory φ₀w:ℕhty:PATerm.hasVar y t = falseht_w:t.subst y (PATerm.var w) = thsub:PAFormula.eq (PATerm.var w) t ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PATerm.var y).freshVar ≤ w ∧ t.freshVar ≤ wthis:B ≤ y⊢ B ≤ w
omega φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botB:ℕt:PATermy:ℕ := max B t.freshVarhex:PAFormula.ex y (PAFormula.eq (PATerm.var y) t) ∈ henkinTheory φ₀w:ℕhw:(PAFormula.ex y (PAFormula.eq (PATerm.var y) t)).maxVar ≤ whty:PATerm.hasVar y t = falseht_w:t.subst y (PATerm.var w) = thsub:PAFormula.eq (PATerm.var w) t ∈ henkinTheory φ₀hBw:B ≤ w⊢ ∃ w, B ≤ w ∧ ⟦PATerm.var w⟧ = ⟦t⟧
exact ⟨w, hBw, Quotient.sound hsub⟩ All goals completed! 🐙private theorem henkin_truth_vsubst (h₀ : ¬ CtxProvable [φ₀] .bot) (φ : PAFormula) :
∀ {ρ : ℕ → ℕ}, SafeFor ρ φ →
(PAFormula.HoldsIn (fun x ↦ Quotient.mk (HenkinSetoid h₀) (.var (ρ x))) φ ↔
φ.vsubst ρ ∈ henkinTheory φ₀) := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
induction φ with
| bot => bot φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bot⊢ ∀ {ρ : ℕ → ℕ},
SafeFor ρ PAFormula.bot →
(PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) PAFormula.bot ↔ PAFormula.vsubst ρ PAFormula.bot ∈ henkinTheory φ₀)
intro ρ _ bot φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botρ:ℕ → ℕa✝:SafeFor ρ PAFormula.bot⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) PAFormula.bot ↔ PAFormula.vsubst ρ PAFormula.bot ∈ henkinTheory φ₀
exact ⟨False.elim, fun h ↦ henkinTheory_not_bot h₀ h⟩ All goals completed! 🐙
| eq t₁ t₂ => eq φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bott₁:PATermt₂:PATerm⊢ ∀ {ρ : ℕ → ℕ},
SafeFor ρ (PAFormula.eq t₁ t₂) →
(PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.eq t₁ t₂) ↔
PAFormula.vsubst ρ (PAFormula.eq t₁ t₂) ∈ henkinTheory φ₀)
intro ρ _ eq φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bott₁:PATermt₂:PATermρ:ℕ → ℕa✝:SafeFor ρ (PAFormula.eq t₁ t₂)⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.eq t₁ t₂) ↔
PAFormula.vsubst ρ (PAFormula.eq t₁ t₂) ∈ henkinTheory φ₀
simp only [PAFormula.HoldsIn, evalIn_henkin_vsubst, PAFormula.vsubst, Quotient.eq] eq φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bott₁:PATermt₂:PATermρ:ℕ → ℕa✝:SafeFor ρ (PAFormula.eq t₁ t₂)⊢ (HenkinSetoid h₀) (PATerm.vsubst ρ t₁) (PATerm.vsubst ρ t₂) ↔
PAFormula.eq (PATerm.vsubst ρ t₁) (PATerm.vsubst ρ t₂) ∈ henkinTheory φ₀
rfl All goals completed! 🐙
| and φ ψ ih₁ ih₂ => and φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)⊢ ∀ {ρ : ℕ → ℕ},
SafeFor ρ (φ.and ψ) →
(PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (φ.and ψ) ↔ PAFormula.vsubst ρ (φ.and ψ) ∈ henkinTheory φ₀)
intro ρ hsafe and φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.and ψ)⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (φ.and ψ) ↔ PAFormula.vsubst ρ (φ.and ψ) ∈ henkinTheory φ₀
have hs₁ : SafeFor ρ φ :=
safeFor_mono hsafe (Nat.le_max_left ..) (fun x hx ↦ by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.and ψ)x:ℕhx:PAFormula.hasFree x φ = true⊢ PAFormula.hasFree x (φ.and ψ) = true simp [PAFormula.hasFree, hx] All goals completed! 🐙) and φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.and ψ)hs₁:SafeFor ρ φ⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (φ.and ψ) ↔ PAFormula.vsubst ρ (φ.and ψ) ∈ henkinTheory φ₀
have hs₂ : SafeFor ρ ψ :=
safeFor_mono hsafe (Nat.le_max_right ..) (fun x hx ↦ by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.and ψ)hs₁:SafeFor ρ φx:ℕhx:PAFormula.hasFree x ψ = true⊢ PAFormula.hasFree x (φ.and ψ) = true simp [PAFormula.hasFree, hx] All goals completed! 🐙) and φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.and ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψ⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (φ.and ψ) ↔ PAFormula.vsubst ρ (φ.and ψ) ∈ henkinTheory φ₀
simp only [PAFormula.HoldsIn, ih₁ hs₁, ih₂ hs₂, PAFormula.vsubst] and φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.and ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψ⊢ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∧ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀ ↔
(PAFormula.vsubst ρ φ).and (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀
refine ⟨fun ⟨h₁, h₂⟩ ↦ henkinTheory_mp h₀ h₂
(henkinTheory_mp h₀ h₁ (henkinTheory_ax h₀ (.and_intro _ _))), fun h ↦
⟨henkinTheory_mp h₀ h (henkinTheory_ax h₀ (.and_left _ _)),
henkinTheory_mp h₀ h (henkinTheory_ax h₀ (.and_right _ _))⟩⟩ All goals completed! 🐙
| or φ ψ ih₁ ih₂ => or φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)⊢ ∀ {ρ : ℕ → ℕ},
SafeFor ρ (φ.or ψ) →
(PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (φ.or ψ) ↔ PAFormula.vsubst ρ (φ.or ψ) ∈ henkinTheory φ₀)
intro ρ hsafe or φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (φ.or ψ) ↔ PAFormula.vsubst ρ (φ.or ψ) ∈ henkinTheory φ₀
have hs₁ : SafeFor ρ φ :=
safeFor_mono hsafe (Nat.le_max_left ..) (fun x hx ↦ by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)x:ℕhx:PAFormula.hasFree x φ = true⊢ PAFormula.hasFree x (φ.or ψ) = true simp [PAFormula.hasFree, hx] All goals completed! 🐙) or φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φ⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (φ.or ψ) ↔ PAFormula.vsubst ρ (φ.or ψ) ∈ henkinTheory φ₀
have hs₂ : SafeFor ρ ψ :=
safeFor_mono hsafe (Nat.le_max_right ..) (fun x hx ↦ by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φx:ℕhx:PAFormula.hasFree x ψ = true⊢ PAFormula.hasFree x (φ.or ψ) = true simp [PAFormula.hasFree, hx] All goals completed! 🐙) or φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψ⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (φ.or ψ) ↔ PAFormula.vsubst ρ (φ.or ψ) ∈ henkinTheory φ₀
simp only [PAFormula.HoldsIn, ih₁ hs₁, ih₂ hs₂, PAFormula.vsubst] or φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψ⊢ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∨ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀ ↔
(PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀
refine ⟨fun h ↦ ?_, fun hor ↦ ?_⟩ or.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∨ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀⊢ (PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀or.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψhor:(PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀⊢ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∨ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀
· or.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∨ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀⊢ (PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀ rcases h with h₁ | h₂ or.refine_1.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh₁:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀⊢ (PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀or.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh₂:PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀⊢ (PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀
· or.refine_1.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh₁:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀⊢ (PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀ exact henkinTheory_mp h₀ h₁ (henkinTheory_ax h₀ (.or_left _ _)) All goals completed! 🐙
· or.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh₂:PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀⊢ (PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀ exact henkinTheory_mp h₀ h₂ (henkinTheory_ax h₀ (.or_right _ _)) All goals completed! 🐙
· or.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψhor:(PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀⊢ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∨ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀ rcases henkinTheory_complete φ₀ (φ.vsubst ρ) with h₁ | hn₁ or.refine_2.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψhor:(PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀h₁:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀⊢ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∨ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀or.refine_2.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψhor:(PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀⊢ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∨ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀
· or.refine_2.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψhor:(PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀h₁:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀⊢ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∨ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀ exact Or.inl h₁ All goals completed! 🐙
· or.refine_2.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψhor:(PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀⊢ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∨ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀ rcases henkinTheory_complete φ₀ (ψ.vsubst ρ) with h₂ | hn₂ or.refine_2.inr.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψhor:(PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀h₂:PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀⊢ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∨ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀or.refine_2.inr.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψhor:(PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀hn₂:(PAFormula.vsubst ρ ψ).not ∈ henkinTheory φ₀⊢ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∨ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀
· or.refine_2.inr.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψhor:(PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀h₂:PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀⊢ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∨ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀ exact Or.inr h₂ All goals completed! 🐙
· or.refine_2.inr.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψhor:(PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀hn₂:(PAFormula.vsubst ρ ψ).not ∈ henkinTheory φ₀⊢ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ ∨ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀ exfalso or.refine_2.inr.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψhor:(PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀hn₂:(PAFormula.vsubst ρ ψ).not ∈ henkinTheory φ₀⊢ False
have helim := henkinTheory_ax h₀ (.or_elim (φ.vsubst ρ) (ψ.vsubst ρ) .bot) or.refine_2.inr.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.or ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψhor:(PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀hn₂:(PAFormula.vsubst ρ ψ).not ∈ henkinTheory φ₀helim:((PAFormula.vsubst ρ φ).imp PAFormula.bot).imp
(((PAFormula.vsubst ρ ψ).imp PAFormula.bot).imp
(((PAFormula.vsubst ρ φ).or (PAFormula.vsubst ρ ψ)).imp PAFormula.bot)) ∈
henkinTheory φ₀⊢ False
exact henkinTheory_not_bot h₀
(henkinTheory_mp h₀ hor (henkinTheory_mp h₀ hn₂ (henkinTheory_mp h₀ hn₁ helim))) All goals completed! 🐙
| imp φ ψ ih₁ ih₂ => imp φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)⊢ ∀ {ρ : ℕ → ℕ},
SafeFor ρ (φ.imp ψ) →
(PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (φ.imp ψ) ↔ PAFormula.vsubst ρ (φ.imp ψ) ∈ henkinTheory φ₀)
intro ρ hsafe imp φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (φ.imp ψ) ↔ PAFormula.vsubst ρ (φ.imp ψ) ∈ henkinTheory φ₀
have hs₁ : SafeFor ρ φ :=
safeFor_mono hsafe (Nat.le_max_left ..) (fun x hx ↦ by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)x:ℕhx:PAFormula.hasFree x φ = true⊢ PAFormula.hasFree x (φ.imp ψ) = true simp [PAFormula.hasFree, hx] All goals completed! 🐙) imp φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φ⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (φ.imp ψ) ↔ PAFormula.vsubst ρ (φ.imp ψ) ∈ henkinTheory φ₀
have hs₂ : SafeFor ρ ψ :=
safeFor_mono hsafe (Nat.le_max_right ..) (fun x hx ↦ by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φx:ℕhx:PAFormula.hasFree x ψ = true⊢ PAFormula.hasFree x (φ.imp ψ) = true simp [PAFormula.hasFree, hx] All goals completed! 🐙) imp φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψ⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (φ.imp ψ) ↔ PAFormula.vsubst ρ (φ.imp ψ) ∈ henkinTheory φ₀
simp only [PAFormula.HoldsIn, ih₁ hs₁, ih₂ hs₂, PAFormula.vsubst] imp φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψ⊢ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ → PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀ ↔
(PAFormula.vsubst ρ φ).imp (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀
refine ⟨fun h ↦ ?_, fun himp h₁ ↦ henkinTheory_mp h₀ h₁ himp⟩ imp φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ → PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀⊢ (PAFormula.vsubst ρ φ).imp (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀
rcases henkinTheory_complete φ₀ (φ.vsubst ρ) with h₁ | hn₁ imp.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ → PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀h₁:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀⊢ (PAFormula.vsubst ρ φ).imp (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀imp.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ → PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀⊢ (PAFormula.vsubst ρ φ).imp (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀
· imp.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ → PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀h₁:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀⊢ (PAFormula.vsubst ρ φ).imp (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀ exact henkinTheory_mp h₀ (h h₁) (henkinTheory_ax h₀ (.imp_k _ _)) All goals completed! 🐙
· imp.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ → PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀⊢ (PAFormula.vsubst ρ φ).imp (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀ have hctx : CtxProvable [(φ.vsubst ρ).not] (.imp (φ.vsubst ρ) (ψ.vsubst ρ)) :=
ctx_deduction (ctx_exfalso _ (.mp (φ := φ.vsubst ρ) (.hyp (by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ → PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀⊢ PAFormula.vsubst ρ φ ∈ [PAFormula.vsubst ρ φ, (PAFormula.vsubst ρ φ).not] simp All goals completed! 🐙)) (.hyp (by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ → PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀⊢ (PAFormula.vsubst ρ φ).imp PAFormula.bot ∈ [PAFormula.vsubst ρ φ, (PAFormula.vsubst ρ φ).not] simp All goals completed! 🐙)))) imp.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ → PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀hctx:CtxProvable [(PAFormula.vsubst ρ φ).not] ((PAFormula.vsubst ρ φ).imp (PAFormula.vsubst ρ ψ))⊢ (PAFormula.vsubst ρ φ).imp (PAFormula.vsubst ρ ψ) ∈ henkinTheory φ₀
exact henkinTheory_closed h₀ hctx (fun γ hγ ↦ by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ → PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀hctx:CtxProvable [(PAFormula.vsubst ρ φ).not] ((PAFormula.vsubst ρ φ).imp (PAFormula.vsubst ρ ψ))γ:PAFormulahγ:γ ∈ [(PAFormula.vsubst ρ φ).not]⊢ γ ∈ henkinTheory φ₀ rw [List.mem_singleton.mp hγ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ → PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀hctx:CtxProvable [(PAFormula.vsubst ρ φ).not] ((PAFormula.vsubst ρ φ).imp (PAFormula.vsubst ρ ψ))γ:PAFormulahγ:γ ∈ [(PAFormula.vsubst ρ φ).not]⊢ (PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaψ:PAFormulaih₁:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ih₂:∀ {ρ : ℕ → ℕ}, SafeFor ρ ψ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) ψ ↔ PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (φ.imp ψ)hs₁:SafeFor ρ φhs₂:SafeFor ρ ψh:PAFormula.vsubst ρ φ ∈ henkinTheory φ₀ → PAFormula.vsubst ρ ψ ∈ henkinTheory φ₀hn₁:(PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀hctx:CtxProvable [(PAFormula.vsubst ρ φ).not] ((PAFormula.vsubst ρ φ).imp (PAFormula.vsubst ρ ψ))γ:PAFormulahγ:γ ∈ [(PAFormula.vsubst ρ φ).not]⊢ (PAFormula.vsubst ρ φ).not ∈ henkinTheory φ₀; exact hn₁ All goals completed! 🐙)
| all y φ ih => all φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)⊢ ∀ {ρ : ℕ → ℕ},
SafeFor ρ (PAFormula.all y φ) →
(PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.all y φ) ↔
PAFormula.vsubst ρ (PAFormula.all y φ) ∈ henkinTheory φ₀)
intro ρ hsafe all φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.all y φ) ↔
PAFormula.vsubst ρ (PAFormula.all y φ) ∈ henkinTheory φ₀
let ψ' := φ.vsubst (Function.update ρ y y) all φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φ⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.all y φ) ↔
PAFormula.vsubst ρ (PAFormula.all y φ) ∈ henkinTheory φ₀
have hno_cap : ∀ x, φ.hasFree x = true → x ≠ y → ρ x ≠ y := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
intro x hx hxy φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ y⊢ ρ x ≠ y
have hall_free : (PAFormula.all y φ).hasFree x = true := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
simp [PAFormula.hasFree, Ne.symm hxy, hx] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = true⊢ ρ x ≠ y
rcases hsafe x hall_free with heq | hge inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = trueheq:ρ x = x⊢ ρ x ≠ yinr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = truehge:(PAFormula.all y φ).maxVar ≤ ρ x⊢ ρ x ≠ y
· inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = trueheq:ρ x = x⊢ ρ x ≠ y rw [heq inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = trueheq:ρ x = x⊢ x ≠ y] inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = trueheq:ρ x = x⊢ x ≠ y; exact hxy All goals completed! 🐙
· inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = truehge:(PAFormula.all y φ).maxVar ≤ ρ x⊢ ρ x ≠ y simp only [PAFormula.maxVar, Nat.max_le] at hge inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = truehge:y + 1 ≤ ρ x ∧ φ.maxVar ≤ ρ x⊢ ρ x ≠ y
omega all φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ y⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.all y φ) ↔
PAFormula.vsubst ρ (PAFormula.all y φ) ∈ henkinTheory φ₀
have hsafe_base : ∀ x, φ.hasFree x = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ x := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
intro x hx hxy φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ y⊢ ρ x = x ∨ φ.maxVar ≤ ρ x
have hall_free : (PAFormula.all y φ).hasFree x = true := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
simp [PAFormula.hasFree, Ne.symm hxy, hx] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = true⊢ ρ x = x ∨ φ.maxVar ≤ ρ x
rcases hsafe x hall_free with heq | hge inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = trueheq:ρ x = x⊢ ρ x = x ∨ φ.maxVar ≤ ρ xinr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = truehge:(PAFormula.all y φ).maxVar ≤ ρ x⊢ ρ x = x ∨ φ.maxVar ≤ ρ x
· inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = trueheq:ρ x = x⊢ ρ x = x ∨ φ.maxVar ≤ ρ x exact Or.inl heq All goals completed! 🐙
· inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = truehge:(PAFormula.all y φ).maxVar ≤ ρ x⊢ ρ x = x ∨ φ.maxVar ≤ ρ x simp only [PAFormula.maxVar, Nat.max_le] at hge inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhall_free:PAFormula.hasFree x (PAFormula.all y φ) = truehge:y + 1 ≤ ρ x ∧ φ.maxVar ≤ ρ x⊢ ρ x = x ∨ φ.maxVar ≤ ρ x
exact Or.inr hge.2 all φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ x⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.all y φ) ↔
PAFormula.vsubst ρ (PAFormula.all y φ) ∈ henkinTheory φ₀
have hmax_le : φ.maxVar ≤ ψ'.maxVar := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
refine maxVar_le_vsubst_maxVar fun x hx ↦ ?_ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = true⊢ x ≤ Function.update ρ y y x
by_cases hxy : x = y pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:x = y⊢ x ≤ Function.update ρ y y xneg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = y⊢ x ≤ Function.update ρ y y x
· pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:x = y⊢ x ≤ Function.update ρ y y x subst hxy pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕx:ℕhx:PAFormula.hasFree x φ = truehsafe:SafeFor ρ (PAFormula.all x φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ x x) φhno_cap:∀ (x_1 : ℕ), PAFormula.hasFree x_1 φ = true → x_1 ≠ x → ρ x_1 ≠ xhsafe_base:∀ (x_1 : ℕ), PAFormula.hasFree x_1 φ = true → x_1 ≠ x → ρ x_1 = x_1 ∨ φ.maxVar ≤ ρ x_1⊢ x ≤ Function.update ρ x x x; simp All goals completed! 🐙
· neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = y⊢ x ≤ Function.update ρ y y x simp only [Function.update_of_ne hxy] neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = y⊢ x ≤ ρ x
rcases hsafe_base x hx hxy with heq | hge neg.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = yheq:ρ x = x⊢ x ≤ ρ xneg.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = yhge:φ.maxVar ≤ ρ x⊢ x ≤ ρ x
· neg.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = yheq:ρ x = x⊢ x ≤ ρ x omega All goals completed! 🐙
· neg.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = yhge:φ.maxVar ≤ ρ x⊢ x ≤ ρ x exact le_trans (Nat.le_of_lt (lt_maxVar_of_hasFree hx)) hge all φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVar⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.all y φ) ↔
PAFormula.vsubst ρ (PAFormula.all y φ) ∈ henkinTheory φ₀
simp only [PAFormula.HoldsIn, PAFormula.vsubst] all φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVar⊢ (∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ) ↔
PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀
refine ⟨fun hsem ↦ ?_, fun hall a ↦ ?_⟩ all.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ⊢ PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀all.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)⊢ PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
· all.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ⊢ PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀ rcases henkinTheory_complete φ₀ (.all y ψ') with hmem | hnmem all.refine_1.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhmem:PAFormula.all y ψ' ∈ henkinTheory φ₀⊢ PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀⊢ PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀
· all.refine_1.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhmem:PAFormula.all y ψ' ∈ henkinTheory φ₀⊢ PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀ exact hmem All goals completed! 🐙
· all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀⊢ PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀ exfalso all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀⊢ False
have hex : PAFormula.ex y ψ'.not ∈ henkinTheory φ₀ :=
henkinTheory_mp h₀ hnmem (henkinTheory_ax h₀ (pa_de_morgan_all y ψ')) all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀⊢ False
obtain ⟨w, hw, hsub⟩ := henkinTheory_witness h₀ hex all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhw:(PAFormula.ex y ψ'.not).maxVar ≤ whsub:PAFormula.subst y (PATerm.var w) ψ'.not ∈ henkinTheory φ₀⊢ False
simp only [PAFormula.maxVar, Nat.max_le] at hw all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhsub:PAFormula.subst y (PATerm.var w) ψ'.not ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ w⊢ False
have hw_φ : φ.maxVar ≤ w := le_trans hmax_le hw.2.1 all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhsub:PAFormula.subst y (PATerm.var w) ψ'.not ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whw_φ:φ.maxVar ≤ w⊢ False
have hsub_eq : ψ'.subst y (.var w) = φ.vsubst (Function.update ρ y w) :=
vsubst_subst_var hno_cap all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhsub:PAFormula.subst y (PATerm.var w) ψ'.not ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whw_φ:φ.maxVar ≤ whsub_eq:PAFormula.subst y (PATerm.var w) ψ' = PAFormula.vsubst (Function.update ρ y w) φ⊢ False
simp only [PAFormula.subst, hsub_eq] at hsub all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whw_φ:φ.maxVar ≤ whsub_eq:PAFormula.subst y (PATerm.var w) ψ' = PAFormula.vsubst (Function.update ρ y w) φhsub:(PAFormula.vsubst (Function.update ρ y w) φ).imp PAFormula.bot ∈ henkinTheory φ₀⊢ False
have hval := hsem (Quotient.mk (HenkinSetoid h₀) (.var w)) all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whw_φ:φ.maxVar ≤ whsub_eq:PAFormula.subst y (PATerm.var w) ψ' = PAFormula.vsubst (Function.update ρ y w) φhsub:(PAFormula.vsubst (Function.update ρ y w) φ).imp PAFormula.bot ∈ henkinTheory φ₀hval:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧) φ⊢ False
have hfun : Function.update (fun x ↦ Quotient.mk (HenkinSetoid h₀) (.var (ρ x))) y
(Quotient.mk (HenkinSetoid h₀) (.var w)) =
fun x ↦ Quotient.mk (HenkinSetoid h₀) (.var (Function.update ρ y w x)) := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
funext x φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whw_φ:φ.maxVar ≤ whsub_eq:PAFormula.subst y (PATerm.var w) ψ' = PAFormula.vsubst (Function.update ρ y w) φhsub:(PAFormula.vsubst (Function.update ρ y w) φ).imp PAFormula.bot ∈ henkinTheory φ₀hval:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧) φx:ℕ⊢ Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ x = ⟦PATerm.var (Function.update ρ y w x)⟧
by_cases hxy : x = y pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whw_φ:φ.maxVar ≤ whsub_eq:PAFormula.subst y (PATerm.var w) ψ' = PAFormula.vsubst (Function.update ρ y w) φhsub:(PAFormula.vsubst (Function.update ρ y w) φ).imp PAFormula.bot ∈ henkinTheory φ₀hval:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧) φx:ℕhxy:x = y⊢ Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ x = ⟦PATerm.var (Function.update ρ y w x)⟧neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whw_φ:φ.maxVar ≤ whsub_eq:PAFormula.subst y (PATerm.var w) ψ' = PAFormula.vsubst (Function.update ρ y w) φhsub:(PAFormula.vsubst (Function.update ρ y w) φ).imp PAFormula.bot ∈ henkinTheory φ₀hval:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧) φx:ℕhxy:¬x = y⊢ Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ x = ⟦PATerm.var (Function.update ρ y w x)⟧
· pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whw_φ:φ.maxVar ≤ whsub_eq:PAFormula.subst y (PATerm.var w) ψ' = PAFormula.vsubst (Function.update ρ y w) φhsub:(PAFormula.vsubst (Function.update ρ y w) φ).imp PAFormula.bot ∈ henkinTheory φ₀hval:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧) φx:ℕhxy:x = y⊢ Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ x = ⟦PATerm.var (Function.update ρ y w x)⟧ subst hxy pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕw:ℕhw_φ:φ.maxVar ≤ wx:ℕhsafe:SafeFor ρ (PAFormula.all x φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ x x) φhno_cap:∀ (x_1 : ℕ), PAFormula.hasFree x_1 φ = true → x_1 ≠ x → ρ x_1 ≠ xhsafe_base:∀ (x_1 : ℕ), PAFormula.hasFree x_1 φ = true → x_1 ≠ x → ρ x_1 = x_1 ∨ φ.maxVar ≤ ρ x_1hmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) x a) φhnmem:(PAFormula.all x ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex x ψ'.not ∈ henkinTheory φ₀hw:x + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whsub_eq:PAFormula.subst x (PATerm.var w) ψ' = PAFormula.vsubst (Function.update ρ x w) φhsub:(PAFormula.vsubst (Function.update ρ x w) φ).imp PAFormula.bot ∈ henkinTheory φ₀hval:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) x ⟦PATerm.var w⟧) φ⊢ Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) x ⟦PATerm.var w⟧ x = ⟦PATerm.var (Function.update ρ x w x)⟧; simp All goals completed! 🐙
· neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whw_φ:φ.maxVar ≤ whsub_eq:PAFormula.subst y (PATerm.var w) ψ' = PAFormula.vsubst (Function.update ρ y w) φhsub:(PAFormula.vsubst (Function.update ρ y w) φ).imp PAFormula.bot ∈ henkinTheory φ₀hval:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧) φx:ℕhxy:¬x = y⊢ Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ x = ⟦PATerm.var (Function.update ρ y w x)⟧ simp [hxy] all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whw_φ:φ.maxVar ≤ whsub_eq:PAFormula.subst y (PATerm.var w) ψ' = PAFormula.vsubst (Function.update ρ y w) φhsub:(PAFormula.vsubst (Function.update ρ y w) φ).imp PAFormula.bot ∈ henkinTheory φ₀hval:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧) φhfun:Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ = fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧⊢ False
rw [hfun, all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whw_φ:φ.maxVar ≤ whsub_eq:PAFormula.subst y (PATerm.var w) ψ' = PAFormula.vsubst (Function.update ρ y w) φhsub:(PAFormula.vsubst (Function.update ρ y w) φ).imp PAFormula.bot ∈ henkinTheory φ₀hval:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φhfun:Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ = fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧⊢ False ih (safeFor_update_fresh hsafe_base hw_φ) all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whw_φ:φ.maxVar ≤ whsub_eq:PAFormula.subst y (PATerm.var w) ψ' = PAFormula.vsubst (Function.update ρ y w) φhsub:(PAFormula.vsubst (Function.update ρ y w) φ).imp PAFormula.bot ∈ henkinTheory φ₀hval:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hfun:Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ = fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧⊢ False] at hval all.refine_1.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhsem:∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φhnmem:(PAFormula.all y ψ').not ∈ henkinTheory φ₀hex:PAFormula.ex y ψ'.not ∈ henkinTheory φ₀w:ℕhw:y + 1 ≤ w ∧ ψ'.maxVar ≤ w ∧ 0 ≤ whw_φ:φ.maxVar ≤ whsub_eq:PAFormula.subst y (PATerm.var w) ψ' = PAFormula.vsubst (Function.update ρ y w) φhsub:(PAFormula.vsubst (Function.update ρ y w) φ).imp PAFormula.bot ∈ henkinTheory φ₀hval:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hfun:Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ = fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧⊢ False
exact henkinTheory_not_bot h₀ (henkinTheory_mp h₀ hval hsub) All goals completed! 🐙
· all.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)⊢ PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ obtain ⟨w, hw, hrep⟩ := exists_var_rep h₀ (max φ.maxVar ψ'.maxVar) a all.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = a⊢ PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
have hw_φ : φ.maxVar ≤ w := le_trans (Nat.le_max_left ..) hw all.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ w⊢ PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
have hw_ψ' : ψ'.maxVar ≤ w := le_trans (Nat.le_max_right ..) hw all.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ w⊢ PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
have helim := henkinTheory_ax h₀ (.all_elim y (.var w) ψ' (freeFor_var_of_maxVar_le y hw_ψ')) all.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whelim:(PAFormula.all y ψ').imp (PAFormula.subst y (PATerm.var w) ψ') ∈ henkinTheory φ₀⊢ PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
have hinst : ψ'.subst y (.var w) ∈ henkinTheory φ₀ := henkinTheory_mp h₀ hall helim all.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whelim:(PAFormula.all y ψ').imp (PAFormula.subst y (PATerm.var w) ψ') ∈ henkinTheory φ₀hinst:PAFormula.subst y (PATerm.var w) ψ' ∈ henkinTheory φ₀⊢ PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
rw [vsubst_subst_var hno_cap all.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whelim:(PAFormula.all y ψ').imp (PAFormula.subst y (PATerm.var w) ψ') ∈ henkinTheory φ₀hinst:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀⊢ PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ] at hinst all.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whelim:(PAFormula.all y ψ').imp (PAFormula.subst y (PATerm.var w) ψ') ∈ henkinTheory φ₀hinst:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀⊢ PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
have hhold := (ih (safeFor_update_fresh hsafe_base hw_φ)).mpr hinst all.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whelim:(PAFormula.all y ψ').imp (PAFormula.subst y (PATerm.var w) ψ') ∈ henkinTheory φ₀hinst:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φ⊢ PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
have hfun : (fun x ↦ Quotient.mk (HenkinSetoid h₀) (.var (Function.update ρ y w x))) =
Function.update (fun x ↦ Quotient.mk (HenkinSetoid h₀) (.var (ρ x))) y a := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
funext x φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whelim:(PAFormula.all y ψ').imp (PAFormula.subst y (PATerm.var w) ψ') ∈ henkinTheory φ₀hinst:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φx:ℕ⊢ ⟦PATerm.var (Function.update ρ y w x)⟧ = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a x
by_cases hxy : x = y pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whelim:(PAFormula.all y ψ').imp (PAFormula.subst y (PATerm.var w) ψ') ∈ henkinTheory φ₀hinst:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φx:ℕhxy:x = y⊢ ⟦PATerm.var (Function.update ρ y w x)⟧ = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a xneg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whelim:(PAFormula.all y ψ').imp (PAFormula.subst y (PATerm.var w) ψ') ∈ henkinTheory φ₀hinst:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φx:ℕhxy:¬x = y⊢ ⟦PATerm.var (Function.update ρ y w x)⟧ = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a x
· pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whelim:(PAFormula.all y ψ').imp (PAFormula.subst y (PATerm.var w) ψ') ∈ henkinTheory φ₀hinst:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φx:ℕhxy:x = y⊢ ⟦PATerm.var (Function.update ρ y w x)⟧ = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a x subst hxy pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕa:Quotient (HenkinSetoid h₀)w:ℕhrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ wx:ℕhsafe:SafeFor ρ (PAFormula.all x φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ x x) φhno_cap:∀ (x_1 : ℕ), PAFormula.hasFree x_1 φ = true → x_1 ≠ x → ρ x_1 ≠ xhsafe_base:∀ (x_1 : ℕ), PAFormula.hasFree x_1 φ = true → x_1 ≠ x → ρ x_1 = x_1 ∨ φ.maxVar ≤ ρ x_1hmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all x (PAFormula.vsubst (Function.update ρ x x) φ) ∈ henkinTheory φ₀hw:max φ.maxVar ψ'.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whelim:(PAFormula.all x ψ').imp (PAFormula.subst x (PATerm.var w) ψ') ∈ henkinTheory φ₀hinst:PAFormula.vsubst (Function.update ρ x w) φ ∈ henkinTheory φ₀hhold:PAFormula.HoldsIn (fun x_1 ↦ ⟦PATerm.var (Function.update ρ x w x_1)⟧) φ⊢ ⟦PATerm.var (Function.update ρ x w x)⟧ = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) x a x; simp [hrep] All goals completed! 🐙
· neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whelim:(PAFormula.all y ψ').imp (PAFormula.subst y (PATerm.var w) ψ') ∈ henkinTheory φ₀hinst:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φx:ℕhxy:¬x = y⊢ ⟦PATerm.var (Function.update ρ y w x)⟧ = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a x simp [hxy] all.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.all y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhall:PAFormula.all y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀a:Quotient (HenkinSetoid h₀)w:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whelim:(PAFormula.all y ψ').imp (PAFormula.subst y (PATerm.var w) ψ') ∈ henkinTheory φ₀hinst:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φhfun:(fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a⊢ PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
rwa [hfun] at hhold All goals completed! 🐙
| ex y φ ih => ex φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)⊢ ∀ {ρ : ℕ → ℕ},
SafeFor ρ (PAFormula.ex y φ) →
(PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.ex y φ) ↔
PAFormula.vsubst ρ (PAFormula.ex y φ) ∈ henkinTheory φ₀)
intro ρ hsafe ex φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.ex y φ) ↔
PAFormula.vsubst ρ (PAFormula.ex y φ) ∈ henkinTheory φ₀
let ψ' := φ.vsubst (Function.update ρ y y) ex φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φ⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.ex y φ) ↔
PAFormula.vsubst ρ (PAFormula.ex y φ) ∈ henkinTheory φ₀
have hno_cap : ∀ x, φ.hasFree x = true → x ≠ y → ρ x ≠ y := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
intro x hx hxy φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ y⊢ ρ x ≠ y
have hex_free : (PAFormula.ex y φ).hasFree x = true := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
simp [PAFormula.hasFree, Ne.symm hxy, hx] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = true⊢ ρ x ≠ y
rcases hsafe x hex_free with heq | hge inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = trueheq:ρ x = x⊢ ρ x ≠ yinr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = truehge:(PAFormula.ex y φ).maxVar ≤ ρ x⊢ ρ x ≠ y
· inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = trueheq:ρ x = x⊢ ρ x ≠ y rw [heq inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = trueheq:ρ x = x⊢ x ≠ y] inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = trueheq:ρ x = x⊢ x ≠ y; exact hxy All goals completed! 🐙
· inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = truehge:(PAFormula.ex y φ).maxVar ≤ ρ x⊢ ρ x ≠ y simp only [PAFormula.maxVar, Nat.max_le] at hge inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = truehge:y + 1 ≤ ρ x ∧ φ.maxVar ≤ ρ x⊢ ρ x ≠ y
omega ex φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ y⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.ex y φ) ↔
PAFormula.vsubst ρ (PAFormula.ex y φ) ∈ henkinTheory φ₀
have hsafe_base : ∀ x, φ.hasFree x = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ x := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
intro x hx hxy φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ y⊢ ρ x = x ∨ φ.maxVar ≤ ρ x
have hex_free : (PAFormula.ex y φ).hasFree x = true := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
simp [PAFormula.hasFree, Ne.symm hxy, hx] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = true⊢ ρ x = x ∨ φ.maxVar ≤ ρ x
rcases hsafe x hex_free with heq | hge inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = trueheq:ρ x = x⊢ ρ x = x ∨ φ.maxVar ≤ ρ xinr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = truehge:(PAFormula.ex y φ).maxVar ≤ ρ x⊢ ρ x = x ∨ φ.maxVar ≤ ρ x
· inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = trueheq:ρ x = x⊢ ρ x = x ∨ φ.maxVar ≤ ρ x exact Or.inl heq All goals completed! 🐙
· inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = truehge:(PAFormula.ex y φ).maxVar ≤ ρ x⊢ ρ x = x ∨ φ.maxVar ≤ ρ x simp only [PAFormula.maxVar, Nat.max_le] at hge inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yx:ℕhx:PAFormula.hasFree x φ = truehxy:x ≠ yhex_free:PAFormula.hasFree x (PAFormula.ex y φ) = truehge:y + 1 ≤ ρ x ∧ φ.maxVar ≤ ρ x⊢ ρ x = x ∨ φ.maxVar ≤ ρ x
exact Or.inr hge.2 ex φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ x⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.ex y φ) ↔
PAFormula.vsubst ρ (PAFormula.ex y φ) ∈ henkinTheory φ₀
have hmax_le : φ.maxVar ≤ ψ'.maxVar := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
refine maxVar_le_vsubst_maxVar fun x hx ↦ ?_ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = true⊢ x ≤ Function.update ρ y y x
by_cases hxy : x = y pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:x = y⊢ x ≤ Function.update ρ y y xneg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = y⊢ x ≤ Function.update ρ y y x
· pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:x = y⊢ x ≤ Function.update ρ y y x subst hxy pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕx:ℕhx:PAFormula.hasFree x φ = truehsafe:SafeFor ρ (PAFormula.ex x φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ x x) φhno_cap:∀ (x_1 : ℕ), PAFormula.hasFree x_1 φ = true → x_1 ≠ x → ρ x_1 ≠ xhsafe_base:∀ (x_1 : ℕ), PAFormula.hasFree x_1 φ = true → x_1 ≠ x → ρ x_1 = x_1 ∨ φ.maxVar ≤ ρ x_1⊢ x ≤ Function.update ρ x x x; simp All goals completed! 🐙
· neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = y⊢ x ≤ Function.update ρ y y x simp only [Function.update_of_ne hxy] neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = y⊢ x ≤ ρ x
rcases hsafe_base x hx hxy with heq | hge neg.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = yheq:ρ x = x⊢ x ≤ ρ xneg.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = yhge:φ.maxVar ≤ ρ x⊢ x ≤ ρ x
· neg.inl φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = yheq:ρ x = x⊢ x ≤ ρ x omega All goals completed! 🐙
· neg.inr φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xx:ℕhx:PAFormula.hasFree x φ = truehxy:¬x = yhge:φ.maxVar ≤ ρ x⊢ x ≤ ρ x exact le_trans (Nat.le_of_lt (lt_maxVar_of_hasFree hx)) hge ex φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVar⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) (PAFormula.ex y φ) ↔
PAFormula.vsubst ρ (PAFormula.ex y φ) ∈ henkinTheory φ₀
simp only [PAFormula.HoldsIn, PAFormula.vsubst] ex φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVar⊢ (∃ a, PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ) ↔
PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀
refine ⟨?_, fun hex ↦ ?_⟩ ex.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVar⊢ (∃ a, PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ) →
PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀ex.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀⊢ ∃ a, PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
· ex.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVar⊢ (∃ a, PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ) →
PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀ rintro ⟨a, ha⟩ ex.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)ha:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ⊢ PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀
obtain ⟨w, hw, hrep⟩ := exists_var_rep h₀ (max φ.maxVar ψ'.maxVar) a ex.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)ha:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φw:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = a⊢ PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀
have hw_φ : φ.maxVar ≤ w := le_trans (Nat.le_max_left ..) hw ex.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)ha:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φw:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ w⊢ PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀
have hw_ψ' : ψ'.maxVar ≤ w := le_trans (Nat.le_max_right ..) hw ex.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)ha:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φw:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ w⊢ PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀
have hfun : Function.update (fun x ↦ Quotient.mk (HenkinSetoid h₀) (.var (ρ x))) y a =
fun x ↦ Quotient.mk (HenkinSetoid h₀) (.var (Function.update ρ y w x)) := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
funext x φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)ha:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φw:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ wx:ℕ⊢ Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a x = ⟦PATerm.var (Function.update ρ y w x)⟧
by_cases hxy : x = y pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)ha:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φw:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ wx:ℕhxy:x = y⊢ Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a x = ⟦PATerm.var (Function.update ρ y w x)⟧neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)ha:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φw:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ wx:ℕhxy:¬x = y⊢ Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a x = ⟦PATerm.var (Function.update ρ y w x)⟧
· pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)ha:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φw:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ wx:ℕhxy:x = y⊢ Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a x = ⟦PATerm.var (Function.update ρ y w x)⟧ subst hxy pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕa:Quotient (HenkinSetoid h₀)w:ℕhrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ wx:ℕhsafe:SafeFor ρ (PAFormula.ex x φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ x x) φhno_cap:∀ (x_1 : ℕ), PAFormula.hasFree x_1 φ = true → x_1 ≠ x → ρ x_1 ≠ xhsafe_base:∀ (x_1 : ℕ), PAFormula.hasFree x_1 φ = true → x_1 ≠ x → ρ x_1 = x_1 ∨ φ.maxVar ≤ ρ x_1hmax_le:φ.maxVar ≤ ψ'.maxVarha:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) x a) φhw:max φ.maxVar ψ'.maxVar ≤ whw_ψ':ψ'.maxVar ≤ w⊢ Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) x a x = ⟦PATerm.var (Function.update ρ x w x)⟧; simp [hrep] All goals completed! 🐙
· neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)ha:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φw:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ wx:ℕhxy:¬x = y⊢ Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a x = ⟦PATerm.var (Function.update ρ y w x)⟧ simp [hxy] ex.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)ha:PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φw:ℕhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whfun:Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a = fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧⊢ PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀
rw [hfun, ex.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)w:ℕha:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φhw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whfun:Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a = fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧⊢ PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀ ih (safeFor_update_fresh hsafe_base hw_φ) ex.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)w:ℕha:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whfun:Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a = fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧⊢ PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀] at ha ex.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)w:ℕha:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whfun:Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a = fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧⊢ PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀
rw [← vsubst_subst_var hno_cap ex.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)w:ℕha:PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀hw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whfun:Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a = fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧⊢ PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀] at ha ex.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)w:ℕha:PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀hw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whfun:Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a = fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧⊢ PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀
have hintro := henkinTheory_ax h₀ (.ex_intro y (.var w) ψ' (freeFor_var_of_maxVar_le y hw_ψ')) ex.refine_1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVara:Quotient (HenkinSetoid h₀)w:ℕha:PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀hw:max φ.maxVar ψ'.maxVar ≤ whrep:⟦PATerm.var w⟧ = ahw_φ:φ.maxVar ≤ whw_ψ':ψ'.maxVar ≤ whfun:Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a = fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧hintro:(PAFormula.subst y (PATerm.var w) ψ').imp (PAFormula.ex y ψ') ∈ henkinTheory φ₀⊢ PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀
exact henkinTheory_mp h₀ ha hintro All goals completed! 🐙
· ex.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀⊢ ∃ a, PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ obtain ⟨w, hw, hsub⟩ := henkinTheory_witness h₀ hex ex.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀w:ℕhw:(PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ)).maxVar ≤ whsub:PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀⊢ ∃ a, PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
simp only [PAFormula.maxVar, Nat.max_le] at hw ex.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀w:ℕhsub:PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PAFormula.vsubst (Function.update ρ y y) φ).maxVar ≤ w⊢ ∃ a, PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
have hw_φ : φ.maxVar ≤ w := le_trans hmax_le hw.2 ex.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀w:ℕhsub:PAFormula.subst y (PATerm.var w) (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PAFormula.vsubst (Function.update ρ y y) φ).maxVar ≤ whw_φ:φ.maxVar ≤ w⊢ ∃ a, PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
rw [vsubst_subst_var hno_cap ex.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀w:ℕhsub:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PAFormula.vsubst (Function.update ρ y y) φ).maxVar ≤ whw_φ:φ.maxVar ≤ w⊢ ∃ a, PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ] at hsub ex.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀w:ℕhsub:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PAFormula.vsubst (Function.update ρ y y) φ).maxVar ≤ whw_φ:φ.maxVar ≤ w⊢ ∃ a, PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
have hhold := (ih (safeFor_update_fresh hsafe_base hw_φ)).mpr hsub ex.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀w:ℕhsub:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PAFormula.vsubst (Function.update ρ y y) φ).maxVar ≤ whw_φ:φ.maxVar ≤ whhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φ⊢ ∃ a, PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y a) φ
refine ⟨Quotient.mk (HenkinSetoid h₀) (.var w), ?_⟩ ex.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀w:ℕhsub:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PAFormula.vsubst (Function.update ρ y y) φ).maxVar ≤ whw_φ:φ.maxVar ≤ whhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φ⊢ PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧) φ
have hfun : (fun x ↦ Quotient.mk (HenkinSetoid h₀) (.var (Function.update ρ y w x))) =
Function.update (fun x ↦ Quotient.mk (HenkinSetoid h₀) (.var (ρ x))) y
(Quotient.mk (HenkinSetoid h₀) (.var w)) := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ ∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)
funext x φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀w:ℕhsub:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PAFormula.vsubst (Function.update ρ y y) φ).maxVar ≤ whw_φ:φ.maxVar ≤ whhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φx:ℕ⊢ ⟦PATerm.var (Function.update ρ y w x)⟧ = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ x
by_cases hxy : x = y pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀w:ℕhsub:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PAFormula.vsubst (Function.update ρ y y) φ).maxVar ≤ whw_φ:φ.maxVar ≤ whhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φx:ℕhxy:x = y⊢ ⟦PATerm.var (Function.update ρ y w x)⟧ = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ xneg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀w:ℕhsub:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PAFormula.vsubst (Function.update ρ y y) φ).maxVar ≤ whw_φ:φ.maxVar ≤ whhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φx:ℕhxy:¬x = y⊢ ⟦PATerm.var (Function.update ρ y w x)⟧ = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ x
· pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀w:ℕhsub:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PAFormula.vsubst (Function.update ρ y y) φ).maxVar ≤ whw_φ:φ.maxVar ≤ whhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φx:ℕhxy:x = y⊢ ⟦PATerm.var (Function.update ρ y w x)⟧ = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ x subst hxy pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕw:ℕhw_φ:φ.maxVar ≤ wx:ℕhsafe:SafeFor ρ (PAFormula.ex x φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ x x) φhno_cap:∀ (x_1 : ℕ), PAFormula.hasFree x_1 φ = true → x_1 ≠ x → ρ x_1 ≠ xhsafe_base:∀ (x_1 : ℕ), PAFormula.hasFree x_1 φ = true → x_1 ≠ x → ρ x_1 = x_1 ∨ φ.maxVar ≤ ρ x_1hmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex x (PAFormula.vsubst (Function.update ρ x x) φ) ∈ henkinTheory φ₀hsub:PAFormula.vsubst (Function.update ρ x w) φ ∈ henkinTheory φ₀hw:x + 1 ≤ w ∧ (PAFormula.vsubst (Function.update ρ x x) φ).maxVar ≤ whhold:PAFormula.HoldsIn (fun x_1 ↦ ⟦PATerm.var (Function.update ρ x w x_1)⟧) φ⊢ ⟦PATerm.var (Function.update ρ x w x)⟧ = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) x ⟦PATerm.var w⟧ x; simp All goals completed! 🐙
· neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀w:ℕhsub:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PAFormula.vsubst (Function.update ρ y y) φ).maxVar ≤ whw_φ:φ.maxVar ≤ whhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φx:ℕhxy:¬x = y⊢ ⟦PATerm.var (Function.update ρ y w x)⟧ = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧ x simp [hxy] ex.refine_2 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.boty:ℕφ:PAFormulaih:∀ {ρ : ℕ → ℕ}, SafeFor ρ φ → (PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (ρ x)⟧) φ ↔ PAFormula.vsubst ρ φ ∈ henkinTheory φ₀)ρ:ℕ → ℕhsafe:SafeFor ρ (PAFormula.ex y φ)ψ':PAFormula := PAFormula.vsubst (Function.update ρ y y) φhno_cap:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x ≠ yhsafe_base:∀ (x : ℕ), PAFormula.hasFree x φ = true → x ≠ y → ρ x = x ∨ φ.maxVar ≤ ρ xhmax_le:φ.maxVar ≤ ψ'.maxVarhex:PAFormula.ex y (PAFormula.vsubst (Function.update ρ y y) φ) ∈ henkinTheory φ₀w:ℕhsub:PAFormula.vsubst (Function.update ρ y w) φ ∈ henkinTheory φ₀hw:y + 1 ≤ w ∧ (PAFormula.vsubst (Function.update ρ y y) φ).maxVar ≤ whw_φ:φ.maxVar ≤ whhold:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) φhfun:(fun x ↦ ⟦PATerm.var (Function.update ρ y w x)⟧) = Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧⊢ PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var (ρ x)⟧) y ⟦PATerm.var w⟧) φ
rwa [hfun] at hhold All goals completed! 🐙private theorem henkin_truth_id (h₀ : ¬ CtxProvable [φ₀] .bot) (φ : PAFormula) :
PAFormula.HoldsIn (fun x ↦ Quotient.mk (HenkinSetoid h₀) (.var x)) φ ↔
φ ∈ henkinTheory φ₀ := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormula⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) φ ↔ φ ∈ henkinTheory φ₀
have h := henkin_truth_vsubst h₀ φ (safeFor_id φ) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulah:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var (id x)⟧) φ ↔ PAFormula.vsubst id φ ∈ henkinTheory φ₀⊢ PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) φ ↔ φ ∈ henkinTheory φ₀
rwa [vsubst_id] at h All goals completed! 🐙private theorem henkin_holds_of_provable (h₀ : ¬ CtxProvable [φ₀] .bot) {φ : PAFormula}
(hp : PAProvable φ) :
PAFormula.HoldsIn (fun x ↦ Quotient.mk (HenkinSetoid h₀) (.var x)) φ :=
(henkin_truth_id h₀ φ).mpr (henkinTheory_ax h₀ hp)private instance instPAModelHenkin (h₀ : ¬ CtxProvable [φ₀] .bot) :
PAModel (HenkinCarrier h₀) where
zero_ne_succ a := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀⊢ PAStructure.succ a ≠ PAStructure.zero
have h := henkin_holds_of_provable h₀ (.gen 0 .pa_zero_ne_succ) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀h:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) (PAFormula.all 0 (PAFormula.eq (PATerm.var 0).succ PATerm.zero).not)⊢ PAStructure.succ a ≠ PAStructure.zero
exact h a All goals completed! 🐙
succ_inj {a b} hab := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀hab:PAStructure.succ a = PAStructure.succ b⊢ a = b
have h := henkin_holds_of_provable h₀ (.gen 0 (.gen 1 .pa_succ_inj)) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀hab:PAStructure.succ a = PAStructure.succ bh:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
(PAFormula.all 0
(PAFormula.all 1
((PAFormula.eq (PATerm.var 0).succ (PATerm.var 1).succ).imp (PAFormula.eq (PATerm.var 0) (PATerm.var 1)))))⊢ a = b
have h1 := h a b φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀hab:PAStructure.succ a = PAStructure.succ bh:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
(PAFormula.all 0
(PAFormula.all 1
((PAFormula.eq (PATerm.var 0).succ (PATerm.var 1).succ).imp (PAFormula.eq (PATerm.var 0) (PATerm.var 1)))))h1:PAFormula.HoldsIn (Function.update (Function.update (fun x ↦ ⟦PATerm.var x⟧) 0 a) 1 b)
((PAFormula.eq (PATerm.var 0).succ (PATerm.var 1).succ).imp (PAFormula.eq (PATerm.var 0) (PATerm.var 1)))⊢ a = b
have h01 : (0 : ℕ) ≠ 1 := by decide φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀hab:PAStructure.succ a = PAStructure.succ bh:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
(PAFormula.all 0
(PAFormula.all 1
((PAFormula.eq (PATerm.var 0).succ (PATerm.var 1).succ).imp (PAFormula.eq (PATerm.var 0) (PATerm.var 1)))))h1:PAFormula.HoldsIn (Function.update (Function.update (fun x ↦ ⟦PATerm.var x⟧) 0 a) 1 b)
((PAFormula.eq (PATerm.var 0).succ (PATerm.var 1).succ).imp (PAFormula.eq (PATerm.var 0) (PATerm.var 1)))h01:0 ≠ 1⊢ a = b
simp only [PAFormula.HoldsIn, PATerm.evalIn, Function.update_self,
Function.update_of_ne h01] at h1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀hab:PAStructure.succ a = PAStructure.succ bh:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
(PAFormula.all 0
(PAFormula.all 1
((PAFormula.eq (PATerm.var 0).succ (PATerm.var 1).succ).imp (PAFormula.eq (PATerm.var 0) (PATerm.var 1)))))h01:0 ≠ 1h1:PAStructure.succ a = PAStructure.succ b → a = b⊢ a = b
exact h1 hab All goals completed! 🐙
add_zero a := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀⊢ PAStructure.add a PAStructure.zero = a
have h := henkin_holds_of_provable h₀ (.gen 0 .pa_add_zero) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀h:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
(PAFormula.all 0 (PAFormula.eq ((PATerm.var 0).add PATerm.zero) (PATerm.var 0)))⊢ PAStructure.add a PAStructure.zero = a
exact h a All goals completed! 🐙
add_succ a b := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀⊢ PAStructure.add a (PAStructure.succ b) = PAStructure.succ (PAStructure.add a b)
have h := henkin_holds_of_provable h₀ (.gen 0 (.gen 1 .pa_add_succ)) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀h:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
(PAFormula.all 0
(PAFormula.all 1 (PAFormula.eq ((PATerm.var 0).add (PATerm.var 1).succ) ((PATerm.var 0).add (PATerm.var 1)).succ)))⊢ PAStructure.add a (PAStructure.succ b) = PAStructure.succ (PAStructure.add a b)
have h1 := h a b φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀h:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
(PAFormula.all 0
(PAFormula.all 1 (PAFormula.eq ((PATerm.var 0).add (PATerm.var 1).succ) ((PATerm.var 0).add (PATerm.var 1)).succ)))h1:PAFormula.HoldsIn (Function.update (Function.update (fun x ↦ ⟦PATerm.var x⟧) 0 a) 1 b)
(PAFormula.eq ((PATerm.var 0).add (PATerm.var 1).succ) ((PATerm.var 0).add (PATerm.var 1)).succ)⊢ PAStructure.add a (PAStructure.succ b) = PAStructure.succ (PAStructure.add a b)
have h01 : (0 : ℕ) ≠ 1 := by decide φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀h:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
(PAFormula.all 0
(PAFormula.all 1 (PAFormula.eq ((PATerm.var 0).add (PATerm.var 1).succ) ((PATerm.var 0).add (PATerm.var 1)).succ)))h1:PAFormula.HoldsIn (Function.update (Function.update (fun x ↦ ⟦PATerm.var x⟧) 0 a) 1 b)
(PAFormula.eq ((PATerm.var 0).add (PATerm.var 1).succ) ((PATerm.var 0).add (PATerm.var 1)).succ)h01:0 ≠ 1⊢ PAStructure.add a (PAStructure.succ b) = PAStructure.succ (PAStructure.add a b)
simp only [PAFormula.HoldsIn, PATerm.evalIn, Function.update_self,
Function.update_of_ne h01] at h1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀h:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
(PAFormula.all 0
(PAFormula.all 1 (PAFormula.eq ((PATerm.var 0).add (PATerm.var 1).succ) ((PATerm.var 0).add (PATerm.var 1)).succ)))h01:0 ≠ 1h1:PAStructure.add a (PAStructure.succ b) = PAStructure.succ (PAStructure.add a b)⊢ PAStructure.add a (PAStructure.succ b) = PAStructure.succ (PAStructure.add a b)
exact h1 All goals completed! 🐙
mul_zero a := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀⊢ PAStructure.mul a PAStructure.zero = PAStructure.zero
have h := henkin_holds_of_provable h₀ (.gen 0 .pa_mul_zero) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀h:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) (PAFormula.all 0 (PAFormula.eq ((PATerm.var 0).mul PATerm.zero) PATerm.zero))⊢ PAStructure.mul a PAStructure.zero = PAStructure.zero
exact h a All goals completed! 🐙
mul_succ a b := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀⊢ PAStructure.mul a (PAStructure.succ b) = PAStructure.add (PAStructure.mul a b) a
have h := henkin_holds_of_provable h₀ (.gen 0 (.gen 1 .pa_mul_succ)) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀h:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
(PAFormula.all 0
(PAFormula.all 1
(PAFormula.eq ((PATerm.var 0).mul (PATerm.var 1).succ) (((PATerm.var 0).mul (PATerm.var 1)).add (PATerm.var 0)))))⊢ PAStructure.mul a (PAStructure.succ b) = PAStructure.add (PAStructure.mul a b) a
have h1 := h a b φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀h:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
(PAFormula.all 0
(PAFormula.all 1
(PAFormula.eq ((PATerm.var 0).mul (PATerm.var 1).succ) (((PATerm.var 0).mul (PATerm.var 1)).add (PATerm.var 0)))))h1:PAFormula.HoldsIn (Function.update (Function.update (fun x ↦ ⟦PATerm.var x⟧) 0 a) 1 b)
(PAFormula.eq ((PATerm.var 0).mul (PATerm.var 1).succ) (((PATerm.var 0).mul (PATerm.var 1)).add (PATerm.var 0)))⊢ PAStructure.mul a (PAStructure.succ b) = PAStructure.add (PAStructure.mul a b) a
have h01 : (0 : ℕ) ≠ 1 := by decide φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀h:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
(PAFormula.all 0
(PAFormula.all 1
(PAFormula.eq ((PATerm.var 0).mul (PATerm.var 1).succ) (((PATerm.var 0).mul (PATerm.var 1)).add (PATerm.var 0)))))h1:PAFormula.HoldsIn (Function.update (Function.update (fun x ↦ ⟦PATerm.var x⟧) 0 a) 1 b)
(PAFormula.eq ((PATerm.var 0).mul (PATerm.var 1).succ) (((PATerm.var 0).mul (PATerm.var 1)).add (PATerm.var 0)))h01:0 ≠ 1⊢ PAStructure.mul a (PAStructure.succ b) = PAStructure.add (PAStructure.mul a b) a
simp only [PAFormula.HoldsIn, PATerm.evalIn, Function.update_self,
Function.update_of_ne h01] at h1 φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.bota:HenkinCarrier h₀b:HenkinCarrier h₀h:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
(PAFormula.all 0
(PAFormula.all 1
(PAFormula.eq ((PATerm.var 0).mul (PATerm.var 1).succ) (((PATerm.var 0).mul (PATerm.var 1)).add (PATerm.var 0)))))h01:0 ≠ 1h1:PAStructure.mul a (PAStructure.succ b) = PAStructure.add (PAStructure.mul a b) a⊢ PAStructure.mul a (PAStructure.succ b) = PAStructure.add (PAStructure.mul a b) a
exact h1 All goals completed! 🐙
ind x φ v hbase hstep a := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀⊢ PAFormula.HoldsIn (Function.update v x a) φ
have hex_ρ : ∀ z : ℕ, ∃ w : ℕ, max φ.maxVar (x + 1) ≤ w ∧
Quotient.mk (HenkinSetoid h₀) (.var w) = v z :=
fun z ↦ exists_var_rep h₀ (max φ.maxVar (x + 1)) (v z) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀hex_ρ:∀ (z : ℕ), ∃ w, max φ.maxVar (x + 1) ≤ w ∧ ⟦PATerm.var w⟧ = v z⊢ PAFormula.HoldsIn (Function.update v x a) φ
choose ρ hρ_ge hρ_eq using hex_ρ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v z⊢ PAFormula.HoldsIn (Function.update v x a) φ
let ψ := φ.vsubst (Function.update ρ x x) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φ⊢ PAFormula.HoldsIn (Function.update v x a) φ
let v₀ : ℕ → HenkinCarrier h₀ := fun z ↦ Quotient.mk (HenkinSetoid h₀) (.var z) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧⊢ PAFormula.HoldsIn (Function.update v x a) φ
have hiff : ∀ b : HenkinCarrier h₀,
PAFormula.HoldsIn (Function.update v x b) φ ↔
PAFormula.HoldsIn (Function.update v₀ x b) ψ := by
intro b φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀⊢ PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψ
obtain ⟨w, hw, hrep⟩ := exists_var_rep h₀ (max φ.maxVar ψ.maxVar) b φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = b⊢ PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψ
have hw_φ : φ.maxVar ≤ w := le_trans (Nat.le_max_left ..) hw φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ w⊢ PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψ
have hw_ψ : ψ.maxVar ≤ w := le_trans (Nat.le_max_right ..) hw φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ w⊢ PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψ
have hv_eq : Function.update v x b =
fun z ↦ Quotient.mk (HenkinSetoid h₀) (.var (Function.update ρ x w z)) := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀⊢ PAFormula.HoldsIn (Function.update v x a) φ
funext z φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ wz:ℕ⊢ Function.update v x b z = ⟦PATerm.var (Function.update ρ x w z)⟧
by_cases hzx : z = x pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ wz:ℕhzx:z = x⊢ Function.update v x b z = ⟦PATerm.var (Function.update ρ x w z)⟧neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ wz:ℕhzx:¬z = x⊢ Function.update v x b z = ⟦PATerm.var (Function.update ρ x w z)⟧
· pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ wz:ℕhzx:z = x⊢ Function.update v x b z = ⟦PATerm.var (Function.update ρ x w z)⟧ subst hzx pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulav:ℕ → HenkinCarrier h₀a:HenkinCarrier h₀ρ:ℕ → ℕhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ wz:ℕhbase:PAFormula.HoldsIn (Function.update v z PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v z a) φ → PAFormula.HoldsIn (Function.update v z (PAStructure.succ a)) φhρ_ge:∀ (z_1 : ℕ), max φ.maxVar (z + 1) ≤ ρ z_1ψ:PAFormula := PAFormula.vsubst (Function.update ρ z z) φhw:max φ.maxVar ψ.maxVar ≤ whw_ψ:ψ.maxVar ≤ w⊢ Function.update v z b z = ⟦PATerm.var (Function.update ρ z w z)⟧; simp [hrep] All goals completed! 🐙
· neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ wz:ℕhzx:¬z = x⊢ Function.update v x b z = ⟦PATerm.var (Function.update ρ x w z)⟧ simp [hzx, hρ_eq z] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧⊢ PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψ
have hv₀_eq : Function.update v₀ x b =
fun z ↦ Quotient.mk (HenkinSetoid h₀) (.var (Function.update id x w z)) := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀⊢ PAFormula.HoldsIn (Function.update v x a) φ
funext z φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧z:ℕ⊢ Function.update v₀ x b z = ⟦PATerm.var (Function.update id x w z)⟧
by_cases hzx : z = x pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧z:ℕhzx:z = x⊢ Function.update v₀ x b z = ⟦PATerm.var (Function.update id x w z)⟧neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧z:ℕhzx:¬z = x⊢ Function.update v₀ x b z = ⟦PATerm.var (Function.update id x w z)⟧
· pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧z:ℕhzx:z = x⊢ Function.update v₀ x b z = ⟦PATerm.var (Function.update id x w z)⟧ subst hzx pos φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botφ:PAFormulav:ℕ → HenkinCarrier h₀a:HenkinCarrier h₀ρ:ℕ → ℕhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ wz:ℕhbase:PAFormula.HoldsIn (Function.update v z PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v z a) φ → PAFormula.HoldsIn (Function.update v z (PAStructure.succ a)) φhρ_ge:∀ (z_1 : ℕ), max φ.maxVar (z + 1) ≤ ρ z_1ψ:PAFormula := PAFormula.vsubst (Function.update ρ z z) φhw:max φ.maxVar ψ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v z b = fun z_1 ↦ ⟦PATerm.var (Function.update ρ z w z_1)⟧⊢ Function.update v₀ z b z = ⟦PATerm.var (Function.update id z w z)⟧; simp [hrep] All goals completed! 🐙
· neg φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧z:ℕhzx:¬z = x⊢ Function.update v₀ x b z = ⟦PATerm.var (Function.update id x w z)⟧ simp [hzx, v₀] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧⊢ PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψ
have hsafe_φ : SafeFor (Function.update ρ x w) φ :=
safeFor_update_fresh (fun z _ _ ↦ Or.inr (le_trans (Nat.le_max_left ..) (hρ_ge z))) hw_φ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φ⊢ PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψ
have hsafe_ψ : SafeFor (Function.update id x w) ψ :=
safeFor_update_fresh (fun _ _ _ ↦ Or.inl rfl) hw_ψ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φhsafe_ψ:SafeFor (Function.update id x w) ψ⊢ PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψ
have hno_cap : ∀ z, φ.hasFree z = true → z ≠ x → ρ z ≠ x := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀⊢ PAFormula.HoldsIn (Function.update v x a) φ
intro z _ _ φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φhsafe_ψ:SafeFor (Function.update id x w) ψz:ℕa✝¹:PAFormula.hasFree z φ = truea✝:z ≠ x⊢ ρ z ≠ x
have hge := hρ_ge z φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φhsafe_ψ:SafeFor (Function.update id x w) ψz:ℕa✝¹:PAFormula.hasFree z φ = truea✝:z ≠ xhge:max φ.maxVar (x + 1) ≤ ρ z⊢ ρ z ≠ x
simp only [Nat.max_le] at hge φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φhsafe_ψ:SafeFor (Function.update id x w) ψz:ℕa✝¹:PAFormula.hasFree z φ = truea✝:z ≠ xhge:φ.maxVar ≤ ρ z ∧ x + 1 ≤ ρ z⊢ ρ z ≠ x
omega φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φhsafe_ψ:SafeFor (Function.update id x w) ψhno_cap:∀ (z : ℕ), PAFormula.hasFree z φ = true → z ≠ x → ρ z ≠ x⊢ PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψ
have heq_form : ψ.vsubst (Function.update id x w) = φ.vsubst (Function.update ρ x w) := by φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀⊢ PAFormula.HoldsIn (Function.update v x a) φ
rw [vsubst_update_id_eq_subst, φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φhsafe_ψ:SafeFor (Function.update id x w) ψhno_cap:∀ (z : ℕ), PAFormula.hasFree z φ = true → z ≠ x → ρ z ≠ x⊢ PAFormula.subst x (PATerm.var w) ψ = PAFormula.vsubst (Function.update ρ x w) φ vsubst_subst_var hno_cap φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φhsafe_ψ:SafeFor (Function.update id x w) ψhno_cap:∀ (z : ℕ), PAFormula.hasFree z φ = true → z ≠ x → ρ z ≠ x⊢ PAFormula.vsubst (Function.update ρ x w) φ = PAFormula.vsubst (Function.update ρ x w) φ] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φhsafe_ψ:SafeFor (Function.update id x w) ψhno_cap:∀ (z : ℕ), PAFormula.hasFree z φ = true → z ≠ x → ρ z ≠ xheq_form:PAFormula.vsubst (Function.update id x w) ψ = PAFormula.vsubst (Function.update ρ x w) φ⊢ PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψ
rw [hv_eq, φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φhsafe_ψ:SafeFor (Function.update id x w) ψhno_cap:∀ (z : ℕ), PAFormula.hasFree z φ = true → z ≠ x → ρ z ≠ xheq_form:PAFormula.vsubst (Function.update id x w) ψ = PAFormula.vsubst (Function.update ρ x w) φ⊢ PAFormula.HoldsIn (fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψ hv₀_eq, φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φhsafe_ψ:SafeFor (Function.update id x w) ψhno_cap:∀ (z : ℕ), PAFormula.hasFree z φ = true → z ≠ x → ρ z ≠ xheq_form:PAFormula.vsubst (Function.update id x w) ψ = PAFormula.vsubst (Function.update ρ x w) φ⊢ PAFormula.HoldsIn (fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧) φ ↔
PAFormula.HoldsIn (fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧) ψ henkin_truth_vsubst h₀ φ hsafe_φ, φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φhsafe_ψ:SafeFor (Function.update id x w) ψhno_cap:∀ (z : ℕ), PAFormula.hasFree z φ = true → z ≠ x → ρ z ≠ xheq_form:PAFormula.vsubst (Function.update id x w) ψ = PAFormula.vsubst (Function.update ρ x w) φ⊢ PAFormula.vsubst (Function.update ρ x w) φ ∈ henkinTheory φ₀ ↔
PAFormula.HoldsIn (fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧) ψ henkin_truth_vsubst h₀ ψ hsafe_ψ, φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φhsafe_ψ:SafeFor (Function.update id x w) ψhno_cap:∀ (z : ℕ), PAFormula.hasFree z φ = true → z ≠ x → ρ z ≠ xheq_form:PAFormula.vsubst (Function.update id x w) ψ = PAFormula.vsubst (Function.update ρ x w) φ⊢ PAFormula.vsubst (Function.update ρ x w) φ ∈ henkinTheory φ₀ ↔
PAFormula.vsubst (Function.update id x w) ψ ∈ henkinTheory φ₀
heq_form φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧b:HenkinCarrier h₀w:ℕhw:max φ.maxVar ψ.maxVar ≤ whrep:⟦PATerm.var w⟧ = bhw_φ:φ.maxVar ≤ whw_ψ:ψ.maxVar ≤ whv_eq:Function.update v x b = fun z ↦ ⟦PATerm.var (Function.update ρ x w z)⟧hv₀_eq:Function.update v₀ x b = fun z ↦ ⟦PATerm.var (Function.update id x w z)⟧hsafe_φ:SafeFor (Function.update ρ x w) φhsafe_ψ:SafeFor (Function.update id x w) ψhno_cap:∀ (z : ℕ), PAFormula.hasFree z φ = true → z ≠ x → ρ z ≠ xheq_form:PAFormula.vsubst (Function.update id x w) ψ = PAFormula.vsubst (Function.update ρ x w) φ⊢ PAFormula.vsubst (Function.update ρ x w) φ ∈ henkinTheory φ₀ ↔
PAFormula.vsubst (Function.update ρ x w) φ ∈ henkinTheory φ₀] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧hiff:∀ (b : HenkinCarrier h₀), PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψ⊢ PAFormula.HoldsIn (Function.update v x a) φ
have hind := henkin_holds_of_provable h₀ (.pa_ind x ψ) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧hiff:∀ (b : HenkinCarrier h₀), PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψhind:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧)
((PAFormula.subst x PATerm.zero ψ).imp
((PAFormula.all x (ψ.imp (PAFormula.subst x (PATerm.var x).succ ψ))).imp (PAFormula.all x ψ)))⊢ PAFormula.HoldsIn (Function.update v x a) φ
simp only [PAFormula.HoldsIn] at hind φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧hiff:∀ (b : HenkinCarrier h₀), PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψhind:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) (PAFormula.subst x PATerm.zero ψ) →
(∀ (a : Quotient (HenkinSetoid h₀)),
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψ →
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) (PAFormula.subst x (PATerm.var x).succ ψ)) →
∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψ⊢ PAFormula.HoldsIn (Function.update v x a) φ
have hbase_ψ : PAFormula.HoldsIn v₀ (ψ.subst x .zero) := by
rw [holdsIn_subst v₀ (freeFor_zero x ψ) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧hiff:∀ (b : HenkinCarrier h₀), PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψhind:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) (PAFormula.subst x PATerm.zero ψ) →
(∀ (a : Quotient (HenkinSetoid h₀)),
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψ →
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) (PAFormula.subst x (PATerm.var x).succ ψ)) →
∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψ⊢ PAFormula.HoldsIn (Function.update v₀ x (PATerm.evalIn v₀ PATerm.zero)) ψ] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧hiff:∀ (b : HenkinCarrier h₀), PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψhind:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) (PAFormula.subst x PATerm.zero ψ) →
(∀ (a : Quotient (HenkinSetoid h₀)),
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψ →
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) (PAFormula.subst x (PATerm.var x).succ ψ)) →
∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψ⊢ PAFormula.HoldsIn (Function.update v₀ x (PATerm.evalIn v₀ PATerm.zero)) ψ
exact (hiff PAStructure.zero).mp hbase φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧hiff:∀ (b : HenkinCarrier h₀), PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψhind:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) (PAFormula.subst x PATerm.zero ψ) →
(∀ (a : Quotient (HenkinSetoid h₀)),
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψ →
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) (PAFormula.subst x (PATerm.var x).succ ψ)) →
∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψhbase_ψ:PAFormula.HoldsIn v₀ (PAFormula.subst x PATerm.zero ψ)⊢ PAFormula.HoldsIn (Function.update v x a) φ
have hstep_ψ : ∀ b : HenkinCarrier h₀,
PAFormula.HoldsIn (Function.update v₀ x b) ψ →
PAFormula.HoldsIn (Function.update v₀ x b) (ψ.subst x (.succ (.var x))) := by
intro b hb φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧hiff:∀ (b : HenkinCarrier h₀), PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψhind:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) (PAFormula.subst x PATerm.zero ψ) →
(∀ (a : Quotient (HenkinSetoid h₀)),
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψ →
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) (PAFormula.subst x (PATerm.var x).succ ψ)) →
∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψhbase_ψ:PAFormula.HoldsIn v₀ (PAFormula.subst x PATerm.zero ψ)b:HenkinCarrier h₀hb:PAFormula.HoldsIn (Function.update v₀ x b) ψ⊢ PAFormula.HoldsIn (Function.update v₀ x b) (PAFormula.subst x (PATerm.var x).succ ψ)
rw [holdsIn_subst (Function.update v₀ x b) (freeFor_succ_self x ψ) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧hiff:∀ (b : HenkinCarrier h₀), PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψhind:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) (PAFormula.subst x PATerm.zero ψ) →
(∀ (a : Quotient (HenkinSetoid h₀)),
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψ →
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) (PAFormula.subst x (PATerm.var x).succ ψ)) →
∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψhbase_ψ:PAFormula.HoldsIn v₀ (PAFormula.subst x PATerm.zero ψ)b:HenkinCarrier h₀hb:PAFormula.HoldsIn (Function.update v₀ x b) ψ⊢ PAFormula.HoldsIn
(Function.update (Function.update v₀ x b) x (PATerm.evalIn (Function.update v₀ x b) (PATerm.var x).succ)) ψ] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧hiff:∀ (b : HenkinCarrier h₀), PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψhind:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) (PAFormula.subst x PATerm.zero ψ) →
(∀ (a : Quotient (HenkinSetoid h₀)),
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψ →
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) (PAFormula.subst x (PATerm.var x).succ ψ)) →
∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψhbase_ψ:PAFormula.HoldsIn v₀ (PAFormula.subst x PATerm.zero ψ)b:HenkinCarrier h₀hb:PAFormula.HoldsIn (Function.update v₀ x b) ψ⊢ PAFormula.HoldsIn
(Function.update (Function.update v₀ x b) x (PATerm.evalIn (Function.update v₀ x b) (PATerm.var x).succ)) ψ
simp only [PATerm.evalIn, Function.update_self, Function.update_idem] φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧hiff:∀ (b : HenkinCarrier h₀), PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψhind:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) (PAFormula.subst x PATerm.zero ψ) →
(∀ (a : Quotient (HenkinSetoid h₀)),
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψ →
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) (PAFormula.subst x (PATerm.var x).succ ψ)) →
∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψhbase_ψ:PAFormula.HoldsIn v₀ (PAFormula.subst x PATerm.zero ψ)b:HenkinCarrier h₀hb:PAFormula.HoldsIn (Function.update v₀ x b) ψ⊢ PAFormula.HoldsIn (Function.update v₀ x (PAStructure.succ b)) ψ
exact (hiff (PAStructure.succ b)).mp (hstep b ((hiff b).mpr hb)) φ₀:PAFormulah₀:¬CtxProvable [φ₀] PAFormula.botx:ℕφ:PAFormulav:ℕ → HenkinCarrier h₀hbase:PAFormula.HoldsIn (Function.update v x PAStructure.zero) φhstep:∀ (a : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v x a) φ → PAFormula.HoldsIn (Function.update v x (PAStructure.succ a)) φa:HenkinCarrier h₀ρ:ℕ → ℕhρ_ge:∀ (z : ℕ), max φ.maxVar (x + 1) ≤ ρ zhρ_eq:∀ (z : ℕ), ⟦PATerm.var (ρ z)⟧ = v zψ:PAFormula := PAFormula.vsubst (Function.update ρ x x) φv₀:ℕ → HenkinCarrier h₀ := fun z ↦ ⟦PATerm.var z⟧hiff:∀ (b : HenkinCarrier h₀), PAFormula.HoldsIn (Function.update v x b) φ ↔ PAFormula.HoldsIn (Function.update v₀ x b) ψhind:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) (PAFormula.subst x PATerm.zero ψ) →
(∀ (a : Quotient (HenkinSetoid h₀)),
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψ →
PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) (PAFormula.subst x (PATerm.var x).succ ψ)) →
∀ (a : Quotient (HenkinSetoid h₀)), PAFormula.HoldsIn (Function.update (fun x ↦ ⟦PATerm.var x⟧) x a) ψhbase_ψ:PAFormula.HoldsIn v₀ (PAFormula.subst x PATerm.zero ψ)hstep_ψ:∀ (b : HenkinCarrier h₀),
PAFormula.HoldsIn (Function.update v₀ x b) ψ →
PAFormula.HoldsIn (Function.update v₀ x b) (PAFormula.subst x (PATerm.var x).succ ψ)⊢ PAFormula.HoldsIn (Function.update v x a) φ
exact (hiff a).mpr (hind hbase_ψ hstep_ψ a) All goals completed! 🐙end HenkinModel
Gödel–Henkin soundness and completeness for first-order Peano Arithmetic (PAProvable):
a PAFormula is provable in PAProvable if and only if it holds in every first-order PAModel
M (Type) under every variable assignment.
theorem paProvable_iff_holdsIn_all_models (φ : PAFormula) :
PAProvable φ ↔
∀ (M : Type) [PAStructure M] [PAModel M] (v : ℕ → M), PAFormula.HoldsIn v φ := by φ:PAFormula⊢ PAProvable φ ↔ ∀ (M : Type) [inst : PAStructure M] [PAModel M] (v : ℕ → M), PAFormula.HoldsIn v φ
refine ⟨fun h M _ _ v ↦ paProvable_sound h v, fun hall ↦ ?_⟩ φ:PAFormulahall:∀ (M : Type) [inst : PAStructure M] [PAModel M] (v : ℕ → M), PAFormula.HoldsIn v φ⊢ PAProvable φ
by_contra hnp φ:PAFormulahall:∀ (M : Type) [inst : PAStructure M] [PAModel M] (v : ℕ → M), PAFormula.HoldsIn v φhnp:¬PAProvable φ⊢ False
have hcons : ¬ CtxProvable [φ.not] .bot := by φ:PAFormula⊢ PAProvable φ ↔ ∀ (M : Type) [inst : PAStructure M] [PAModel M] (v : ℕ → M), PAFormula.HoldsIn v φ
intro hbot φ:PAFormulahall:∀ (M : Type) [inst : PAStructure M] [PAModel M] (v : ℕ → M), PAFormula.HoldsIn v φhnp:¬PAProvable φhbot:CtxProvable [φ.not] PAFormula.bot⊢ False
exact hnp (ctx_nil_iff.mp (ctx_by_contra hbot)) φ:PAFormulahall:∀ (M : Type) [inst : PAStructure M] [PAModel M] (v : ℕ → M), PAFormula.HoldsIn v φhnp:¬PAProvable φhcons:¬CtxProvable [φ.not] PAFormula.bot⊢ False
have hn_mem : φ.not ∈ henkinTheory φ.not := henkinTheory_mem_zero φ.not φ:PAFormulahall:∀ (M : Type) [inst : PAStructure M] [PAModel M] (v : ℕ → M), PAFormula.HoldsIn v φhnp:¬PAProvable φhcons:¬CtxProvable [φ.not] PAFormula.bothn_mem:φ.not ∈ henkinTheory φ.not⊢ False
have hn_sem : PAFormula.HoldsIn (fun x ↦ Quotient.mk (HenkinSetoid hcons) (.var x)) φ.not :=
(henkin_truth_id hcons φ.not).mpr hn_mem φ:PAFormulahall:∀ (M : Type) [inst : PAStructure M] [PAModel M] (v : ℕ → M), PAFormula.HoldsIn v φhnp:¬PAProvable φhcons:¬CtxProvable [φ.not] PAFormula.bothn_mem:φ.not ∈ henkinTheory φ.nothn_sem:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) φ.not⊢ False
have hp_sem : PAFormula.HoldsIn (fun x ↦ Quotient.mk (HenkinSetoid hcons) (.var x)) φ :=
hall (HenkinCarrier hcons) (fun x ↦ Quotient.mk (HenkinSetoid hcons) (.var x)) φ:PAFormulahall:∀ (M : Type) [inst : PAStructure M] [PAModel M] (v : ℕ → M), PAFormula.HoldsIn v φhnp:¬PAProvable φhcons:¬CtxProvable [φ.not] PAFormula.bothn_mem:φ.not ∈ henkinTheory φ.nothn_sem:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) φ.nothp_sem:PAFormula.HoldsIn (fun x ↦ ⟦PATerm.var x⟧) φ⊢ False
exact hn_sem hp_sem All goals completed! 🐙end ConjectureMachines.Semantics.PA