From d3d1868f514a9934e4c03e70c6b25df0cdd6ed25 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 21 May 2026 01:50:35 +0900 Subject: [PATCH 01/14] rename --- .../FirstOrder/Basic/Syntax/Formula.lean | 2 +- .../Bootstrapping/Syntax/Formula/Typed.lean | 2 +- Foundation/LinearLogic/MLL.lean | 2 +- Foundation/Logic/LogicSymbol.lean | 55 ++++++++++++++++--- Foundation/Modal/Formula/NNFormula.lean | 2 +- .../Propositional/Boolean/NNFormula.lean | 2 +- .../Propositional/Formula/NNFormula.lean | 2 +- 7 files changed, 53 insertions(+), 14 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Syntax/Formula.lean b/Foundation/FirstOrder/Basic/Syntax/Formula.lean index fa61b5ed0..0c903ed3f 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Formula.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Formula.lean @@ -88,7 +88,7 @@ instance : DeMorgan (Semiformula L ξ n) where and := fun _ _ => rfl or := fun _ _ => rfl -instance : NegInvolutive (Semiformula L ξ n) where +instance : TildeInvolutive (Semiformula L ξ n) where neg_involutive := neg_neg instance : Quantifier (Semiformula L ξ) where diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Typed.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Typed.lean index 948cb1137..71044de8b 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Typed.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Typed.lean @@ -133,7 +133,7 @@ instance : DeMorgan (Semiformula V L n) where or _ _ := by ext; simp imply _ _ := by ext; simp; rfl -instance : NegInvolutive (Semiformula V L n) where +instance : TildeInvolutive (Semiformula V L n) where neg_involutive _ := by ext; simp @[simp] lemma neg_all (φ : Semiformula V L (n + 1)) : ∼(∀⁰ φ) = ∃⁰ (∼φ) := by ext; simp diff --git a/Foundation/LinearLogic/MLL.lean b/Foundation/LinearLogic/MLL.lean index de52ae7aa..68650514b 100644 --- a/Foundation/LinearLogic/MLL.lean +++ b/Foundation/LinearLogic/MLL.lean @@ -58,7 +58,7 @@ instance : MultiplicativeConnective.DeMorgan Formula where | φ ⅋ ψ => simp [neg_neg φ, neg_neg ψ] | φ ⨂ ψ => simp [neg_neg φ, neg_neg ψ] -instance : NegInvolutive Formula where +instance : TildeInvolutive Formula where neg_involutive := neg_neg lemma lolli_def (φ ψ : Formula) : φ ⊸ ψ = ∼φ ⅋ ψ := rfl diff --git a/Foundation/Logic/LogicSymbol.lean b/Foundation/Logic/LogicSymbol.lean index 43f300fcd..118f6acb4 100644 --- a/Foundation/Logic/LogicSymbol.lean +++ b/Foundation/Logic/LogicSymbol.lean @@ -23,7 +23,7 @@ namespace LO class LogicalConnective (α : Type*) extends Top α, Bot α, Tilde α, Arrow α, Wedge α, Vee α -class NegInvolutive (F : Type*) [Tilde F] where +class TildeInvolutive (F : Type*) [Tilde F] where neg_involutive (φ : F) : ∼∼φ = φ class DeMorgan (F : Type*) [LogicalConnective F] where @@ -33,9 +33,10 @@ class DeMorgan (F : Type*) [LogicalConnective F] where and (φ ψ : F) : ∼(φ ⋏ ψ) = ∼φ ⋎ ∼ψ or (φ ψ : F) : ∼(φ ⋎ ψ) = ∼φ ⋏ ∼ψ -alias DeMorgan.neg := NegInvolutive.neg_involutive +alias DeMorgan.neg := TildeInvolutive.neg_involutive -attribute [simp] NegInvolutive.neg_involutive DeMorgan.verum DeMorgan.falsum DeMorgan.and DeMorgan.or +attribute [simp, grind =] TildeInvolutive.neg_involutive +attribute [simp, grind =] DeMorgan.verum DeMorgan.falsum DeMorgan.and DeMorgan.or /-- Introducing `∼φ` as an abbreviation of `φ 🡒 ⊥`. -/ class NegAbbrev (F : Type*) [Tilde F] [Arrow F] [Bot F] where @@ -51,6 +52,20 @@ class ŁukasiewiczAbbrev (F : Type*) [LogicalConnective F] extends NegAbbrev F w attribute [grind =] ŁukasiewiczAbbrev.and ŁukasiewiczAbbrev.or ŁukasiewiczAbbrev.top +section tilde + +variable {α : Type*} [Tilde α] [TildeInvolutive α] + +@[simp] lemma TildeInvolutive.tilde_injective : Function.Injective (Tilde.tilde : α → α) := by + intro φ ψ h + simpa using congr_arg (∼·) h + +def Tilde.invol : α ↪ α := ⟨Tilde.tilde, TildeInvolutive.tilde_injective⟩ + +@[simp] lemma Tilde.invol_app (φ : α) : Tilde.invol φ = ∼φ := rfl + +end tilde + namespace LogicalConnective section @@ -92,7 +107,7 @@ instance : DeMorgan Prop where and := fun _ _ => by simp [-not_and, not_and_or] or := fun _ _ => by simp [not_or] -instance : NegInvolutive Prop where +instance : TildeInvolutive Prop where neg_involutive := fun _ => by simp class HomClass (F : Type*) (α β : outParam Type*) [LogicalConnective α] [LogicalConnective β] [FunLike F α β] where @@ -103,7 +118,7 @@ class HomClass (F : Type*) (α β : outParam Type*) [LogicalConnective α] [Logi map_and : ∀ (f : F) (φ ψ : α), f (φ ⋏ ψ) = f φ ⋏ f ψ map_or : ∀ (f : F) (φ ψ : α), f (φ ⋎ ψ) = f φ ⋎ f ψ -attribute [simp] HomClass.map_top HomClass.map_bot HomClass.map_neg HomClass.map_imply HomClass.map_and HomClass.map_or +attribute [simp, grind =] HomClass.map_top HomClass.map_bot HomClass.map_neg HomClass.map_imply HomClass.map_and HomClass.map_or namespace HomClass @@ -355,7 +370,7 @@ lemma tilde_def (l : List α) : ∼l = l.map (∼·) := rfl | nil => simp [*] | cons a as ih => simp [*, List.cons_append] -@[simp] lemma mem_tilde_iff [NegInvolutive α] {a : α} {l : List α} : a ∈ ∼l ↔ ∼a ∈ l := by +@[simp] lemma mem_tilde_iff [TildeInvolutive α] {a : α} {l : List α} : a ∈ ∼l ↔ ∼a ∈ l := by induction l with | nil => simp [*] | cons b bs ih => @@ -363,12 +378,12 @@ lemma tilde_def (l : List α) : ∼l = l.map (∼·) := rfl simp [ih, this] constructor <;> {rintro rfl; simp} -instance [NegInvolutive α] : NegInvolutive (List α) where +instance [TildeInvolutive α] : TildeInvolutive (List α) where neg_involutive l := by induction l with | nil => simp [*] | cons a as ih => - simp [ih, NegInvolutive.neg_involutive a] + simp [ih, TildeInvolutive.neg_involutive a] end tilde @@ -551,6 +566,30 @@ open Classical variable {α : Type*} +section tilde + +variable [Tilde α] [TildeInvolutive α] + +instance : Tilde (Finset α) := ⟨fun l ↦ l.map Tilde.invol⟩ + +lemma tilde_def (s : Finset α) : ∼s = s.map Tilde.invol := rfl + +@[simp] lemma mem_tilde_iff {a : α} {s : Finset α} : a ∈ ∼s ↔ ∼a ∈ s := by + simp [tilde_def]; grind + +instance : TildeInvolutive (Finset α) where + neg_involutive s := by ext a; simp + +@[simp] lemma tilde_empty : ∼(∅ : Finset α) = ∅ := rfl + +@[simp] lemma tilde_insert (a : α) (s : Finset α) : ∼(insert a s) = insert (∼a) (∼s) := by + simp [tilde_def] + +@[simp] lemma tilde_union (s t : Finset α) : ∼(s ∪ t) = ∼s ∪ ∼t := by + simp [tilde_def, Finset.map_union] + +end tilde + noncomputable def conj [Top α] [Wedge α] (s : Finset α) : α := s.toList.conj₂ noncomputable def conj' [Top α] [Wedge α] (s : Finset ι) (f : ι → α) : α := s.toList.conj' f diff --git a/Foundation/Modal/Formula/NNFormula.lean b/Foundation/Modal/Formula/NNFormula.lean index f7abd635d..1da385fd4 100644 --- a/Foundation/Modal/Formula/NNFormula.lean +++ b/Foundation/Modal/Formula/NNFormula.lean @@ -103,7 +103,7 @@ instance : ModalDeMorgan (NNFormula α) where neg_dia := by tauto; neg_box := by tauto; -instance : NegInvolutive (NNFormula α) where +instance : TildeInvolutive (NNFormula α) where neg_involutive := by grind; section toString diff --git a/Foundation/Propositional/Boolean/NNFormula.lean b/Foundation/Propositional/Boolean/NNFormula.lean index 69286d5fc..786a0b2cf 100644 --- a/Foundation/Propositional/Boolean/NNFormula.lean +++ b/Foundation/Propositional/Boolean/NNFormula.lean @@ -16,7 +16,7 @@ namespace NNFormula section val -variable {F : Type*} [LogicalConnective F] [DeMorgan F] [NegInvolutive F] (v : α → F) +variable {F : Type*} [LogicalConnective F] [DeMorgan F] [TildeInvolutive F] (v : α → F) def valAux : NNFormula α → F | .atom a => v a diff --git a/Foundation/Propositional/Formula/NNFormula.lean b/Foundation/Propositional/Formula/NNFormula.lean index 321c35db8..ed5e483a8 100644 --- a/Foundation/Propositional/Formula/NNFormula.lean +++ b/Foundation/Propositional/Formula/NNFormula.lean @@ -93,7 +93,7 @@ instance : DeMorgan (NNFormula α) where or := by simp imply := by simp [imp_eq] -instance : NegInvolutive (NNFormula α) where +instance : TildeInvolutive (NNFormula α) where neg_involutive := by simp def complexity : NNFormula α → ℕ From b2e070ba7349f3f93d9b4c4eb6a7cca8f901e500 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 21 May 2026 01:50:48 +0900 Subject: [PATCH 02/14] Derivation2 --- Foundation/FirstOrder/Basic/Calculus.lean | 46 ++--- Foundation/FirstOrder/Basic/Calculus2.lean | 192 +++++++++++------- .../LinearLogic/FirstOrder/Formula.lean | 2 +- Foundation/Logic/Calculus.lean | 58 +++--- Foundation/Modal/Entailment/Basic.lean | 2 +- Foundation/SecondOrder/Syntax/Formula.lean | 2 +- 6 files changed, 174 insertions(+), 128 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index 63e679b20..c1c2962f0 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -51,7 +51,7 @@ end Sequent inductive Derivation : Sequent L → Type _ | identity (r : L.Rel k) (v) : Derivation [.rel r v, .nrel r v] | cut : Derivation (φ :: Γ) → Derivation (∼φ :: Δ) → Derivation (Γ ++ Δ) -| wk : Derivation Δ → Δ ⊆ Γ → Derivation Γ +| contraction : Derivation Δ → Δ ⊆ Γ → Derivation Γ | verum : Derivation [⊤] | or : Derivation (φ :: ψ :: Γ) → Derivation (φ ⋎ ψ :: Γ) | and : Derivation (φ :: Γ) → Derivation (ψ :: Γ) → Derivation (φ ⋏ ψ :: Γ) @@ -65,14 +65,14 @@ namespace Derivation open Rewriting LawfulSyntacticRewriting def height {Δ : Sequent L} : ⊢ᴸᴷ¹ Δ → ℕ - | identity _ _ => 0 - | cut dp dn => max dp.height dn.height + 1 - | wk d _ => d.height + 1 - | verum => 0 - | or d => d.height + 1 - | and dp dq => max (height dp) (height dq) + 1 - | all d => d.height + 1 - | exs d => d.height + 1 + | identity _ _ => 0 + | cut dp dn => max dp.height dn.height + 1 + | contraction d _ => d.height + 1 + | verum => 0 + | or d => d.height + 1 + | and dp dq => max (height dp) (height dq) + 1 + | all d => d.height + 1 + | exs d => d.height + 1 section height @@ -82,7 +82,7 @@ section height @[simp] lemma height_cut {φ} (dp : ⊢ᴸᴷ¹ φ :: Δ) (dn : ⊢ᴸᴷ¹ (∼φ) :: Δ) : height (cut dp dn) = (max (height dp) (height dn)).succ := rfl -@[simp] lemma height_wk (d : ⊢ᴸᴷ¹ Δ) (h : Δ ⊆ Γ) : height (wk d h) = d.height.succ := rfl +@[simp] lemma height_contraction (d : ⊢ᴸᴷ¹ Δ) (h : Δ ⊆ Γ) : height (contraction d h) = d.height.succ := rfl @[simp] lemma height_verum : height (verum : ⊢ᴸᴷ¹ ([⊤] : Sequent L)) = 0 := rfl @@ -102,16 +102,16 @@ protected abbrev cast (d : ⊢ᴸᴷ¹ Δ) (e : Δ = Γ := by simp) : ⊢ᴸᴷ @[simp] lemma height_cast (d : ⊢ᴸᴷ¹ Δ) (e : Δ = Γ) : height (Derivation.cast d e) = height d := by rcases e with rfl; simp [Derivation.cast] -def weakening (d : ⊢ᴸᴷ¹ Δ) (h : Δ ⊆ Γ := by simp) : ⊢ᴸᴷ¹ Γ := wk d h +def contra (d : ⊢ᴸᴷ¹ Δ) (h : Δ ⊆ Γ := by simp) : ⊢ᴸᴷ¹ Γ := contraction d h -def top (h : ⊤ ∈ Δ := by simp) : ⊢ᴸᴷ¹ Δ := verum.wk (by simp [h]) +def top (h : ⊤ ∈ Δ := by simp) : ⊢ᴸᴷ¹ Δ := verum.contraction (by simp [h]) def identity' (r : L.Rel k) (v) (hpos : Semiformula.rel r v ∈ Δ := by simp) (hneg : Semiformula.nrel r v ∈ Δ := by simp) : ⊢ᴸᴷ¹ Δ := - (identity r v).wk (by simp [hpos, hneg]) + (identity r v).contraction (by simp [hpos, hneg]) -def tensor {φ ψ} (dφ : ⊢ᴸᴷ¹ φ :: Γ) (dψ : ⊢ᴸᴷ¹ ψ :: Δ) : ⊢ᴸᴷ¹ φ ⋏ ψ :: (Γ ++ Δ) := and dφ.weakening dψ.weakening +def tensor {φ ψ} (dφ : ⊢ᴸᴷ¹ φ :: Γ) (dψ : ⊢ᴸᴷ¹ ψ :: Δ) : ⊢ᴸᴷ¹ φ ⋏ ψ :: (Γ ++ Δ) := and dφ.contra dψ.contra -def rotate (d : ⊢ᴸᴷ¹ φ :: Γ) : ⊢ᴸᴷ¹ Γ ++ [φ] := d.weakening +def rotate (d : ⊢ᴸᴷ¹ φ :: Γ) : ⊢ᴸᴷ¹ Γ ++ [φ] := d.contra def eta : (φ : Proposition L) → ⊢ᴸᴷ¹ [φ, ∼φ] | .rel R v | .nrel R v => identity' R v @@ -129,7 +129,7 @@ def eta : (φ : Proposition L) → ⊢ᴸᴷ¹ [φ, ∼φ] termination_by φ => φ.complexity def close (φ : Proposition L) (hp : φ ∈ Δ := by simp) (hn : ∼φ ∈ Δ := by simp) : ⊢ᴸᴷ¹ Δ := - eta φ |>.weakening (by simp [hp, hn]) + eta φ |>.contra (by simp [hp, hn]) lemma of_isClosed {Γ : Sequent L} (h : Γ.IsClosed) : Nonempty (⊢ᴸᴷ¹ Γ) := by rcases h with ⟨φ, hp, hn⟩ @@ -139,7 +139,7 @@ instance : OneSidedLK (Derivation (L := L)) where verum := verum and d₁ d₂ := d₁.and d₂ or d := d.or - wk d ss := d.wk ss + contraction d ss := d.contraction ss identity φ := eta φ instance : OneSidedLK.Cut (Derivation (L := L)) where @@ -151,7 +151,7 @@ def rewrite {Γ} (f : ℕ → SyntacticTerm L) : ⊢ᴸᴷ¹ Γ → ⊢ᴸᴷ¹ have d₁ : ⊢ᴸᴷ¹ Rew.rewrite f ▹ φ :: Γ.map (app (Rew.rewrite f)) := (d₁.rewrite f).cast have d₂ : ⊢ᴸᴷ¹ ∼(Rew.rewrite f ▹ φ) :: Δ.map (app (Rew.rewrite f)) := (d₂.rewrite f).cast d₁.cut d₂ |>.cast - | wk d ss => d.rewrite f |>.wk (List.map_subset _ ss) + | contraction d ss => d.rewrite f |>.contraction (List.map_subset _ ss) | verum => verum | or d => (d.rewrite f).or | and d₁ d₂ => (d₁.rewrite f).and (d₂.rewrite f) @@ -189,7 +189,7 @@ def lMap (Φ : L₁ →ᵥ L₂) {Γ} : ⊢ᴸᴷ¹ Γ → ⊢ᴸᴷ¹ Γ.map (. have : ⊢ᴸᴷ¹ (Γ.map (.lMap Φ) ++ Δ.map (.lMap Φ) : Sequent L₂) := cut (φ := .lMap Φ φ) (Derivation.cast (lMap Φ d) (by simp)) (Derivation.cast (lMap Φ dn) (by simp)) Derivation.cast this (by simp) - | wk (Δ := Δ) (Γ := Γ) d ss => (lMap Φ d).wk (List.map_subset _ ss) + | contraction (Δ := Δ) (Γ := Γ) d ss => (lMap Φ d).contraction (List.map_subset _ ss) | verum => by simpa using verum | or (Γ := Γ) (φ := φ) (ψ := ψ) d => by have : ⊢ᴸᴷ¹ (.lMap Φ φ ⋎ .lMap Φ ψ :: Γ.map (.lMap Φ) : Sequent L₂) := @@ -233,17 +233,17 @@ def genelalizeByNewver {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ def exOfInstances (v : List (SyntacticTerm L)) (φ : Semiproposition L 1) (h : ⊢ᴸᴷ¹ v.map (φ/[·]) ++ Γ) : ⊢ᴸᴷ¹ (∃⁰ φ) :: Γ := by induction' v with t v ih generalizing Γ - · exact weakening h (List.subset_cons_self _ _) - · exact (ih (Γ := (∃⁰ φ) :: Γ) ((exs h).wk (by simp))).wk (by simp) + · exact contra h (List.subset_cons_self _ _) + · exact (ih (Γ := (∃⁰ φ) :: Γ) ((exs h).contraction (by simp))).contraction (by simp) def exOfInstances' (v : List (SyntacticTerm L)) (φ : Semiproposition L 1) (h : ⊢ᴸᴷ¹ (∃⁰ φ) :: v.map (φ/[·]) ++ Γ) : ⊢ᴸᴷ¹ (∃⁰ φ) :: Γ := - (exOfInstances (Γ := (∃⁰ φ) :: Γ) v φ (h.wk <| by simp)).wk (by simp) + (exOfInstances (Γ := (∃⁰ φ) :: Γ) v φ (h.contraction <| by simp)).contraction (by simp) def allNvar {Δ : Sequent L} {φ} (h : ∀⁰ φ ∈ Δ) : ⊢ᴸᴷ¹ φ/[&Δ.newVar] :: Δ → ⊢ᴸᴷ¹ Δ := fun b ↦ let b : ⊢ᴸᴷ¹ (∀⁰ φ) :: Δ := b.genelalizeByNewver (by simpa [Semiformula.FVar?] using Sequent.not_fvar?_newVar h) (fun _ ↦ Sequent.not_fvar?_newVar) - b.wk (by simp [h]) + b.contraction (by simp [h]) end Derivation diff --git a/Foundation/FirstOrder/Basic/Calculus2.lean b/Foundation/FirstOrder/Basic/Calculus2.lean index 06839c941..c29e317ff 100644 --- a/Foundation/FirstOrder/Basic/Calculus2.lean +++ b/Foundation/FirstOrder/Basic/Calculus2.lean @@ -4,98 +4,144 @@ public import Foundation.FirstOrder.Basic.Calculus /-! # Alternative definition of proof -/ -/- - namespace LO.FirstOrder -variable {L : Language} [L.DecidableEq] +variable {L : Language} + +variable (L) + +abbrev Sequent2 := Finset (Proposition L) + +variable {L} + +namespace Sequent2 + +def emb (Γ : Finset (Sentence L)) : Sequent2 L := Γ.map ⟨Rewriting.emb, Rewriting.emb_injective⟩ + +@[simp] lemma emb_empty : emb (∅ : Finset (Sentence L)) = ∅ := by simp [emb] + +@[simp] lemma emb_insert [L.DecidableEq] (φ : Sentence L) (Γ : Finset (Sentence L)) : + emb (insert φ Γ) = insert ↑φ (emb Γ) := by simp [emb] + +@[simp] lemma emb_neg (Γ : Finset (Sentence L)) : emb (∼Γ) = ∼(emb Γ) := by + ext φ + suffices (∃ a, ∼a ∈ Γ ∧ Rewriting.emb a = φ) ↔ ∃ a ∈ Γ, Rewriting.emb a = ∼φ by + simpa [emb] + constructor + · grind + · rintro ⟨x, hx, eq⟩ + refine ⟨∼x, by simpa using hx, by simp [eq]⟩ + +def shifts (Γ : Sequent2 L) : Sequent2 L := Γ.map ⟨Rewriting.shift, LawfulSyntacticRewriting.shift_injective⟩ + +@[simp] lemma shifts_empty : shifts (∅ : Sequent2 L) = ∅ := by simp [shifts] + +@[simp] lemma shifts_insert [L.DecidableEq] (φ : Proposition L) (Γ : Finset (Proposition L)) : + shifts (insert φ Γ) = insert (Rewriting.shift φ) (shifts Γ) := by simp [shifts] + +@[simp] lemma shifts_toFinset_eq_shifts [L.DecidableEq] (Γ : Sequent L) : + (Γ⁺).toFinset = shifts Γ.toFinset := by ext φ; simp [shifts, Rewriting.shifts] + +@[simp] lemma neg_toFinset [L.DecidableEq] (Γ : Sequent L) : + (∼Γ).toFinset = ∼Γ.toFinset := by ext φ; simp + +@[simp] lemma map_emb_toFinset_eq [L.DecidableEq] {Γ : List (Sentence L)} : + (Γ.map Rewriting.emb).toFinset = emb Γ.toFinset := by ext; simp [emb] + +end Sequent2 + +variable [L.DecidableEq] section derivation2 inductive Derivation2 : Finset (Proposition L) → Type _ -| wk {Δ Γ} : Derivation2 Δ → Δ ⊆ Γ → Derivation2 Γ -| shift {Γ} : Derivation2 Γ → Derivation2 (Γ.image Rewriting.shift) -| identity (Γ) (φ : Proposition L) : φ ∈ Γ → ∼φ ∈ Γ → Derivation2 Γ -| cut {Γ φ} : Derivation2 (insert φ Γ) → Derivation2 (insert (∼φ) Δ) → Derivation2 (Γ ∪ Δ) -| verum {Γ} : ⊤ ∈ Γ → Derivation2 Γ -| and {Γ} {φ ψ : Proposition L} : φ ⋏ ψ ∈ Γ → Derivation2 (insert φ Γ) → Derivation2 (insert ψ Γ) → Derivation2 Γ -| or {Γ} {φ ψ : Proposition L} : φ ⋎ ψ ∈ Γ → Derivation2 (insert φ (insert ψ Γ)) → Derivation2 Γ -| all {Γ} {φ : Semiproposition L 1} : ∀⁰ φ ∈ Γ → Derivation2 (insert (Rewriting.free φ) (Γ.image Rewriting.shift)) → Derivation2 Γ -| exs {Γ} {φ : Semiproposition L 1} : ∃⁰ φ ∈ Γ → (t : SyntacticTerm L) → Derivation2 (insert (φ/[t]) Γ) → Derivation2 Γ +| identity (φ) : Derivation2 {φ, ∼φ} +| cut : Derivation2 (insert φ Γ) → Derivation2 (insert (∼φ) Δ) → Derivation2 (Γ ∪ Δ) +| contraction : Derivation2 Δ → Δ ⊆ Γ → Derivation2 Γ +| verum : Derivation2 {⊤} +| or : Derivation2 (insert φ (insert ψ Γ)) → Derivation2 (insert (φ ⋎ ψ) Γ) +| and : Derivation2 (insert φ Γ) → Derivation2 (insert ψ Γ) → Derivation2 (insert (φ ⋏ ψ) Γ) +| all : Derivation2 (insert (Rewriting.free φ) (Sequent2.shifts Γ)) → Derivation2 (insert (∀⁰ φ) Γ) +| exs : Derivation2 (insert (φ/[t]) Γ) → Derivation2 (insert (∃⁰ φ) Γ) +structure Theory.Proof2 (T : Theory L) (σ : Sentence L) where + axioms : Finset (Sentence L) + axioms_mem : ∀ ψ ∈ axioms, ψ ∈ T + derivation : Derivation2 (Sequent2.emb (insert σ (∼axioms))) -scoped infix:45 " ⟹₂" => Derivation2 +namespace Derivation2 -abbrev Derivable2 (𝓢 : Schema L) (Γ : Finset (Proposition L)) := Nonempty (𝓢 ⟹₂ Γ) +def cast {Γ Δ : Sequent2 L} (d : Derivation2 Γ) (h : Γ = Δ := by simp) : Derivation2 Δ := by subst h; exact d -scoped infix:45 " ⟹₂! " => Derivable2 +def contra {Γ Δ : Sequent2 L} (d : Derivation2 Δ) (h : Δ ⊆ Γ := by simp) : Derivation2 Γ := d.contraction h -abbrev Derivable2SingleConseq (𝓢 : Schema L) (φ : Proposition L) : Prop := 𝓢 ⟹₂! {φ} +end Derivation2 -scoped infix: 45 " ⊢!₂! " => Derivable2SingleConseq - -variable {𝓢 : Schema L} +variable {T : Theory L} lemma shifts_toFinset_eq_image_shift (Γ : Sequent L) : (Rewriting.shifts Γ).toFinset = Γ.toFinset.image Rewriting.shift := by ext φ; simp [Rewriting.shifts] -def Derivation.toDerivation2 (𝓢) {Γ : Sequent L} : 𝓢 ⟹ Γ → 𝓢 ⟹₂ Γ.toFinset - | Derivation.axL R v => Derivation2.closed _ (Semiformula.rel R v) (by simp) (by simp) - | Derivation.axm (φ := φ) h => Derivation2.axm φ h (by simp) - | Derivation.verum => Derivation2.verum (by simp) - | Derivation.and (Γ := Γ) (φ := φ) (ψ := ψ) dp dq => - Derivation2.and (φ := φ) (ψ := ψ) (by simp) - (Derivation2.wk (Derivation.toDerivation2 𝓢 dp) (by simp)) - (Derivation2.wk (Derivation.toDerivation2 𝓢 dq) (by simp)) - | Derivation.or (Γ := Γ) (φ := φ) (ψ := ψ) dpq => - Derivation2.or (φ := φ) (ψ := ψ) (by simp) - (Derivation2.wk (Derivation.toDerivation2 𝓢 dpq) - (by simp)) - | Derivation.all (Γ := Γ) (φ := φ) dp => - Derivation2.all (φ := φ) (by simp) - (Derivation2.wk (Derivation.toDerivation2 𝓢 dp) - (by simpa using Finset.insert_subset_insert _ (by simp [shifts_toFinset_eq_image_shift]))) - | Derivation.exs (Γ := Γ) (φ := φ) t dp => - Derivation2.exs (φ := φ) (by simp) t - (Derivation2.wk (Derivation.toDerivation2 𝓢 dp) (by simp)) - | Derivation.wk d h => - Derivation2.wk (Derivation.toDerivation2 𝓢 d) (List.toFinset_mono h) - | Derivation.cut (Γ := Γ) (φ := φ) d₁ d₂ => - Derivation2.cut (φ := φ) - (Derivation2.wk (Derivation.toDerivation2 𝓢 d₁) (by simp)) - (Derivation2.wk (Derivation.toDerivation2 𝓢 d₂) (by simp)) - -noncomputable def Derivation2.toDerivation {Γ : Finset (Proposition L)} : 𝓢 ⟹₂ Γ → 𝓢 ⟹ Γ.toList - | Derivation2.closed Γ φ hp hn => Derivation.em (φ := φ) (by simp [hp]) (by simp [hn]) - | Derivation2.axm φ hp h => Tait.wk (Derivation.axm hp) (by simp_all) - | Derivation2.verum h => Tait.verum' (by simp [h]) - | Derivation2.and (φ := φ) (ψ := ψ) h dp dq => - Tait.and' (φ := φ) (ψ := ψ) (by simp [h]) - (Tait.wk dp.toDerivation <| by intro x; simp) - (Tait.wk dq.toDerivation <| by intro x; simp) - | Derivation2.or (φ := φ) (ψ := ψ) h dpq => - Tait.or' (φ := φ) (ψ := ψ) (by simp [h]) (Tait.wk dpq.toDerivation <| by intro x; simp) - | Derivation2.all (φ := φ) h d => - Derivation.all' (φ := φ) (by simp [h]) (Tait.wk d.toDerivation <| by intro x; simp [Rewriting.shifts]) - | Derivation2.exs (φ := φ) h t d => - Derivation.exs' (φ := φ) (by simp [h]) t (Tait.wk d.toDerivation <| by intro x; simp) - | Derivation2.wk d h => - Tait.wk d.toDerivation (by intro x; simpa using @h x) - | Derivation2.shift d => - Tait.wk (Derivation.shift d.toDerivation) <| by intro x; simp [Rewriting.shifts] - | Derivation2.cut (φ := φ) d dn => - Tait.cut (φ := φ) - (Tait.wk d.toDerivation <| by intro x; simp) - (Tait.wk dn.toDerivation <| by intro x; simp) - -lemma derivable_iff_derivable2 {Γ : List (Proposition L)} : 𝓢 ⟹! Γ ↔ 𝓢 ⟹₂! Γ.toFinset := by +def Derivation.toDerivation2 {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → Derivation2 Γ.toFinset + | .identity R v => (Derivation2.identity (.rel R v)).cast + | .cut (Γ := Γ) (Δ := Δ) (φ := φ) d₁ d₂ => + let b₁ : Derivation2 (insert φ Γ.toFinset) := d₁.toDerivation2.cast + let b₂ : Derivation2 (insert (∼φ) Δ.toFinset) := d₂.toDerivation2.cast + (b₁.cut b₂).cast + | .contraction d h => d.toDerivation2.contra (List.toFinset_mono h) + | .verum => Derivation2.verum.cast + | .and (Γ := Γ) (φ := φ) (ψ := ψ) d₁ d₂ => + let b₁ : Derivation2 (insert φ Γ.toFinset) := d₁.toDerivation2.cast + let b₂ : Derivation2 (insert ψ Γ.toFinset) := d₂.toDerivation2.cast + (b₁.and b₂).cast + | .or (Γ := Γ) (φ := φ) (ψ := ψ) d => + let b : Derivation2 (insert φ (insert ψ Γ.toFinset)) := d.toDerivation2.cast + b.or.cast + | .all (Γ := Γ) (φ := φ) dp => + let b : Derivation2 (insert (Rewriting.free φ) (Sequent2.shifts Γ.toFinset)) := dp.toDerivation2.cast + b.all.cast + | .exs (Γ := Γ) (φ := φ) (t := t) d => + let b : Derivation2 (insert (φ/[t]) Γ.toFinset) := d.toDerivation2.cast + b.exs.cast + +noncomputable def Derivation2.toDerivation {Γ : Sequent2 L} : Derivation2 Γ → ⊢ᴸᴷ¹ Γ.toList +| .identity φ => (Derivation.eta φ).contra +| .cut (Γ := Γ) (Δ := Δ) (φ := φ) d₁ d₂ => + let b₁ : ⊢ᴸᴷ¹ φ :: Γ.toList := d₁.toDerivation.contra (by intro _; simp) + let b₂ : ⊢ᴸᴷ¹ (∼φ) :: Δ.toList := d₂.toDerivation.contra (by intro _; simp) + (b₁.cut b₂).contra (by intro _; simp) +| .contraction d h => d.toDerivation.contra (by intro _; simp; grind) +| .verum => Derivation.verum.contra +| .and (Γ := Γ) (φ := φ) (ψ := ψ) d₁ d₂ => + let b₁ : ⊢ᴸᴷ¹ φ :: Γ.toList := d₁.toDerivation.contra (by intro _; simp) + let b₂ : ⊢ᴸᴷ¹ ψ :: Γ.toList := d₂.toDerivation.contra (by intro _; simp) + (b₁.and b₂).contra (by intro _; simp) +| .or (Γ := Γ) (φ := φ) (ψ := ψ) d => + let b : ⊢ᴸᴷ¹ φ :: ψ :: Γ.toList := d.toDerivation.contra (by intro _; simp) + b.or.contra (by intro _; simp) +| .all (Γ := Γ) (φ := φ) d => + let b : ⊢ᴸᴷ¹ (Rewriting.free φ) :: Γ.toList⁺ := + d.toDerivation.contra (by intro _; simp [Rewriting.shifts, Sequent2.shifts]) + b.all.contra (by intro _; simp) +| .exs (Γ := Γ) (φ := φ) (t := t) d => + let b : ⊢ᴸᴷ¹ (φ/[t]) :: Γ.toList := d.toDerivation.contra (by intro _; simp) + b.exs.contra (by intro _; simp) + +lemma derivable_iff_derivable2 {Γ : Sequent L} : + Nonempty (⊢ᴸᴷ¹ Γ) ↔ Nonempty (Derivation2 Γ.toFinset) := by constructor - · rintro ⟨d⟩; exact ⟨by simpa using Derivation.toDerivation2 𝓢 d⟩ - · rintro ⟨d⟩; exact ⟨.wk d.toDerivation (by intro x; simp)⟩ + · rintro ⟨d⟩; exact ⟨by simpa using d.toDerivation2⟩ + · rintro ⟨d⟩; exact ⟨d.toDerivation.contra (by intro _; simp)⟩ -def provable_iff_derivable2 {φ} : 𝓢 ⊢ φ ↔ 𝓢 ⊢!₂! φ := derivable_iff_derivable2 +lemma provable_iff_provable2 {φ} : T ⊢ φ ↔ Nonempty (T.Proof2 φ) := by + constructor + · rintro ⟨d⟩ + exact ⟨⟨d.axioms.toFinset, by simpa using d.axioms_mem, + d.derivation.toDerivation2.contra (by simp)⟩⟩ + · rintro ⟨d⟩ + exact ⟨d.axioms.toList, by simpa using d.axioms_mem, + d.derivation.toDerivation.contra (by intro _; simp [Sequent2.emb]; grind)⟩ end derivation2 end LO.FirstOrder --/ diff --git a/Foundation/LinearLogic/FirstOrder/Formula.lean b/Foundation/LinearLogic/FirstOrder/Formula.lean index 103b4a2a6..2c7667f62 100644 --- a/Foundation/LinearLogic/FirstOrder/Formula.lean +++ b/Foundation/LinearLogic/FirstOrder/Formula.lean @@ -155,7 +155,7 @@ lemma neg_neg {n} (φ : Semiformula L ξ n) : ∼∼φ = φ := by | ∀⁰ φ => simp [neg_neg φ] | ∃⁰ φ => simp [neg_neg φ] -instance : NegInvolutive (Semiformula L ξ n) := ⟨neg_neg⟩ +instance : TildeInvolutive (Semiformula L ξ n) := ⟨neg_neg⟩ /-- Usual logical connectives are defined to align with `⊤` and `⊥` -/ instance : LogicalConnective (Semiformula L ξ n) where diff --git a/Foundation/Logic/Calculus.lean b/Foundation/Logic/Calculus.lean index 55a6addad..2b09c10c4 100644 --- a/Foundation/Logic/Calculus.lean +++ b/Foundation/Logic/Calculus.lean @@ -18,41 +18,41 @@ namespace LO /-! ## One-sided $\mathbf{LK}$ -/ -class OneSidedLK {F : Type*} [LogicalConnective F] [DeMorgan F] [NegInvolutive F] (𝔇 : List F → Type*) where +class OneSidedLK {F : Type*} [LogicalConnective F] [DeMorgan F] [TildeInvolutive F] (𝔇 : List F → Type*) where identity (φ) : 𝔇 [φ, ∼φ] - wk : 𝔇 Δ → Δ ⊆ Γ → 𝔇 Γ + contraction : 𝔇 Δ → Δ ⊆ Γ → 𝔇 Γ verum : 𝔇 [⊤] and : 𝔇 (φ :: Γ) → 𝔇 (ψ :: Γ) → 𝔇 (φ ⋏ ψ :: Γ) or : 𝔇 (φ :: ψ :: Γ) → 𝔇 (φ ⋎ ψ :: Γ) class OneSidedLK.Cut - {F : Type*} [LogicalConnective F] [DeMorgan F] [NegInvolutive F] (𝔇 : List F → Type*) extends OneSidedLK 𝔇 where + {F : Type*} [LogicalConnective F] [DeMorgan F] [TildeInvolutive F] (𝔇 : List F → Type*) extends OneSidedLK 𝔇 where cut : 𝔇 (φ :: Γ) → 𝔇 (∼φ :: Δ) → 𝔇 (Γ ++ Δ) namespace OneSidedLK -variable {F : Type*} [LogicalConnective F] [DeMorgan F] [NegInvolutive F] {𝔇 : List F → Type*} [OneSidedLK 𝔇] +variable {F : Type*} [LogicalConnective F] [DeMorgan F] [TildeInvolutive F] {𝔇 : List F → Type*} [OneSidedLK 𝔇] def cast (b : 𝔇 Γ) (h : Γ = Δ := by simp) : 𝔇 Δ := h ▸ b -def weakening (d : 𝔇 Γ) (h : Γ ⊆ Δ := by simp) : 𝔇 Δ := wk d (by simp [h]) +def contra (d : 𝔇 Γ) (h : Γ ⊆ Δ := by simp) : 𝔇 Δ := contraction d (by simp [h]) -def rotate (d : 𝔇 (φ :: Γ)) : 𝔇 (Γ ++ [φ]) := weakening d +def rotate (d : 𝔇 (φ :: Γ)) : 𝔇 (Γ ++ [φ]) := contra d -def close (φ : F) (hp : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : 𝔇 Γ := wk (identity φ) (by simp_all) +def close (φ : F) (hp : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : 𝔇 Γ := contraction (identity φ) (by simp_all) -def top (h : ⊤ ∈ Γ := by simp) : 𝔇 Γ := wk verum (by simp [h]) +def top (h : ⊤ ∈ Γ := by simp) : 𝔇 Γ := contraction verum (by simp [h]) def tensor {φ ψ : F} (dφ : 𝔇 (φ :: Γ)) (dψ : 𝔇 (ψ :: Δ)) : 𝔇 (φ ⋏ ψ :: Γ ++ Δ) := - and (wk dφ (by simp)) (wk dψ (by simp)) + and (contraction dφ (by simp)) (contraction dψ (by simp)) -def swap₁ (d : 𝔇 (φ₂ :: φ₁ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: Γ) := wk d (by simp) +def swap₁ (d : 𝔇 (φ₂ :: φ₁ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: Γ) := contraction d (by simp) def swap₂ (d : 𝔇 (φ₃ :: φ₁ :: φ₂ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: φ₃ :: Γ) := - wk d (by grind) + contraction d (by grind) def swap₃ (d : 𝔇 (φ₄ :: φ₁ :: φ₂ :: φ₃ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: φ₃ :: φ₄ :: Γ) := - wk d (by grind) + contraction d (by grind) alias cut := OneSidedLK.Cut.cut @@ -60,7 +60,7 @@ def eCut [Cut 𝔇] (d₁ : 𝔇 (φ :: Γ)) (d₂ : 𝔇 (ψ :: Δ)) (e : ∼φ def disj₂ {Γ Δ : List F} [Cut 𝔇] : 𝔇 (Γ ++ Δ) → 𝔇 (⋁Γ :: Δ) := fun d ↦ match Γ with - | [] => weakening d + | [] => contra d | [φ] => d | [φ, ψ] => or d | φ :: ψ :: χ :: Γ => by @@ -69,7 +69,7 @@ def disj₂ {Γ Δ : List F} [Cut 𝔇] : 𝔇 (Γ ++ Δ) → 𝔇 (⋁Γ :: Δ) have d₁ : 𝔇 ((φ ⋎ ψ) ⋎ Φ :: Δ) := disj₂ this have d₂ : 𝔇 [(∼φ ⋏ ∼ψ) ⋏ ∼Φ, φ ⋎ ψ ⋎ Φ] := have : 𝔇 [φ, ψ ⋎ Φ, (∼φ ⋏ ∼ψ) ⋏ ∼Φ] := - weakening <| or <| rotate <| rotate <| + contra <| or <| rotate <| rotate <| tensor (tensor (rotate (identity (𝔇 := 𝔇) φ)) (rotate (identity ψ))) (rotate (identity Φ)) rotate <| or <| this exact eCut d₂ d₁ @@ -77,7 +77,7 @@ def disj₂ {Γ Δ : List F} [Cut 𝔇] : 𝔇 (Γ ++ Δ) → 𝔇 (⋁Γ :: Δ) def conj₂ {Γ Δ : List F} (d : (φ : F) → φ ∈ Γ → 𝔇 (φ :: Δ)) : 𝔇 (⋀Γ :: Δ) := match Γ with - | [] => weakening verum + | [] => contra verum | [φ] => d φ (by simp) | φ :: ψ :: Γ => have : 𝔇 (⋀(ψ :: Γ) :: Δ) := conj₂ (Γ := ψ :: Γ) (fun χ h ↦ d χ (by simp_all)) @@ -93,7 +93,7 @@ namespace PrincipalEntailment variable {P : Type*} [Entailment P F] {𝓟 : P} [PrincipalEntailment 𝔇 𝓟] -omit [LogicalConnective F] [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] in +omit [LogicalConnective F] [DeMorgan F] [TildeInvolutive F] [OneSidedLK 𝔇] in lemma provable_iff : 𝓟 ⊢ φ ↔ Nonempty (𝔇 [φ]) := by simpa using OneSidedLK.PrincipalEntailment.equiv.nonempty_congr @@ -105,8 +105,8 @@ instance : Entailment.ModusPonens 𝓟 where let b₁ := equiv b₁ let b₂ := equiv b₂ have : 𝔇 [∼(φ 🡒 ψ), ∼φ, ψ] := cast (tensor (𝔇 := 𝔇) (identity φ) (identity (∼ψ))) (by simp [DeMorgan.imply]) - have : 𝔇 [∼φ, ψ] := wk (cut b₁ this) (by simp) - have : 𝔇 [ψ] := wk (cut b₂ this) (by simp) + have : 𝔇 [∼φ, ψ] := contraction (cut b₁ this) (by simp) + have : 𝔇 [ψ] := contraction (cut b₂ this) (by simp) equiv.symm <| cast this instance : Entailment.Cl 𝓟 where @@ -167,7 +167,7 @@ abbrev Pullback (𝔇 : List F → Type*) {G : Type*} [LogicalConnective G] (f : namespace Pullback -variable {G : Type*} [LogicalConnective G] [DeMorgan G] [NegInvolutive G] {f : G →ˡᶜ F} +variable {G : Type*} [LogicalConnective G] [DeMorgan G] [TildeInvolutive G] {f : G →ˡᶜ F} def cast (d : 𝔇 Δ) (h : Δ = Γ.map f := by simp) : Pullback 𝔇 f Γ := by unfold Pullback @@ -177,7 +177,7 @@ def uncast (d : Pullback 𝔇 f Γ) (h : Δ = Γ.map f := by simp) : 𝔇 Δ := instance oneSidedLK [OneSidedLK 𝔇] : OneSidedLK (Pullback 𝔇 f) where identity φ := cast <| identity (f φ) - wk {Δ Γ} d h := cast (wk d (List.map_subset f h) : 𝔇 (Γ.map f)) (by simp) + contraction {Δ Γ} d h := cast (contraction d (List.map_subset f h) : 𝔇 (Γ.map f)) (by simp) verum := cast verum and d₁ d₂ := cast <| and d₁ d₂ or d := cast <| or d @@ -192,10 +192,10 @@ instance {P : Type*} [Entailment P F] (𝓟 : P) [PrincipalEntailment 𝔇 𝓟] PrincipalEntailment (Pullback 𝔇 f) (Entailment.pullback 𝓟 f) where equiv {φ} := PrincipalEntailment.equiv (φ := f φ) -omit [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] [DeMorgan G] [NegInvolutive G] in +omit [DeMorgan F] [TildeInvolutive F] [OneSidedLK 𝔇] [DeMorgan G] [TildeInvolutive G] in @[simp] lemma nonempty_iff {Γ} : Nonempty (Pullback 𝔇 f Γ) ↔ Nonempty (𝔇 (Γ.map f)) := by simp [Pullback] -omit [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] [DeMorgan G] [NegInvolutive G] in +omit [DeMorgan F] [TildeInvolutive F] [OneSidedLK 𝔇] [DeMorgan G] [TildeInvolutive G] in @[simp] lemma isEmpty_iff {Γ} : IsEmpty (Pullback 𝔇 f Γ) ↔ IsEmpty (𝔇 (Γ.map f)) := by simp [Pullback] end Pullback @@ -208,7 +208,7 @@ namespace ContextualEntailment variable {S : Type*} [Entailment S F] [AdjunctiveSet F S] [ContextualEntailment 𝔇 S] -omit [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] in +omit [DeMorgan F] [TildeInvolutive F] [OneSidedLK 𝔇] in lemma provable_iff {𝓢 : S} : 𝓢 ⊢ φ ↔ ∃ Γ : List F, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (𝔇 (φ :: ∼Γ)) := by simpa using equiv.nonempty_congr @@ -234,8 +234,8 @@ instance (𝓢 : S) : Entailment.ModusPonens 𝓢 where let ⟨Γ₁, b₁⟩ := equiv b₁ let ⟨Γ₂, b₂⟩ := equiv b₂ have : 𝔇 [∼(φ 🡒 ψ), ∼φ, ψ] := cast (tensor (𝔇 := 𝔇) (identity φ) (identity (∼ψ))) (by simp [DeMorgan.imply]) - have : 𝔇 (∼φ :: ψ :: ∼↑Γ₁) := wk (cut b₁ this) (by simp) - have : 𝔇 (ψ :: ∼↑Γ₁ ++ ∼↑Γ₂) := wk (cut b₂ this) (by simp) + have : 𝔇 (∼φ :: ψ :: ∼↑Γ₁) := contraction (cut b₁ this) (by simp) + have : 𝔇 (ψ :: ∼↑Γ₁ ++ ∼↑Γ₂) := contraction (cut b₂ this) (by simp) equiv.symm ⟨⟨Γ₁ ++ Γ₂, by simp; grind⟩, cast this⟩ instance : Entailment.StrongCut S S where @@ -258,7 +258,7 @@ instance : Entailment.DeductiveExplosion S where equiv.symm ⟨ Γ, have : 𝔇 [∼⊥] := cast verum (by simp) - wk (cut b this) (by simp) ⟩ + contraction (cut b this) (by simp) ⟩ lemma inconsistent_iff {𝓢 : S} : Entailment.Inconsistent 𝓢 ↔ ∃ Γ : List F, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (𝔇 (∼Γ)) := calc @@ -270,7 +270,7 @@ lemma inconsistent_iff {𝓢 : S} : have : 𝔇 [(∼⊥ : F)] := cast verum exact ⟨Γ, hΓ, ⟨cast (cut d this)⟩⟩ · rintro ⟨Γ, hΓ, ⟨d⟩⟩ - exact ⟨Γ, hΓ, ⟨wk d (by simp)⟩⟩ + exact ⟨Γ, hΓ, ⟨contraction d (by simp)⟩⟩ instance cl (𝓢 : S) : Entailment.Cl 𝓢 where negEquiv {φ} := Entailment.cast @@ -334,7 +334,7 @@ lemma iff_context {𝓢 : S} {𝓟 : P} [PrincipalEntailment 𝔇 𝓟] : · rintro h have ⟨Γ, hΓ, ⟨d⟩⟩ := provable_iff.mp h have : 𝓟 ⊢ ⋀Γ 🡒 φ := by - have : 𝔇 (∼Γ ++ [φ]) := weakening d + have : 𝔇 (∼Γ ++ [φ]) := contra d have : Nonempty (𝔇 [⋀Γ 🡒 φ]) := by simpa [DeMorgan.imply] using Nonempty.intro (or <| disj₂ this) exact PrincipalEntailment.provable_iff.mpr this refine ⟨⟨Γ, by simpa using hΓ, this.some⟩⟩ @@ -343,7 +343,7 @@ lemma iff_context {𝓢 : S} {𝓟 : P} [PrincipalEntailment 𝔇 𝓟] : have d : 𝔇 [⋁(∼Γ) ⋎ φ] := cast (PrincipalEntailment.equiv this) (by simp [DeMorgan.imply]) have : 𝔇 (⋀Γ ⋏ ∼φ :: φ :: ∼Γ) := have : 𝔇 (⋀Γ :: ∼Γ) := conj₂ fun φ h ↦ close φ (by simp) (by simp [h]) - weakening <| tensor this (rotate <| identity φ) + contra <| tensor this (rotate <| identity φ) have : 𝔇 (φ :: ∼Γ) := eCut d this refine provable_iff.mpr ⟨Γ, h, ⟨this⟩⟩ diff --git a/Foundation/Modal/Entailment/Basic.lean b/Foundation/Modal/Entailment/Basic.lean index c9093124d..f8a462c46 100644 --- a/Foundation/Modal/Entailment/Basic.lean +++ b/Foundation/Modal/Entailment/Basic.lean @@ -697,7 +697,7 @@ variable [DecidableEq F] variable {φ ψ χ : F} {Γ Δ : List F} variable {𝓢 : S} -instance [Entailment.Minimal 𝓢] [ModalDeMorgan F] [NegInvolutive F] [HasAxiomDNE 𝓢] : HasDiaDuality 𝓢 := ⟨by +instance [Entailment.Minimal 𝓢] [ModalDeMorgan F] [TildeInvolutive F] [HasAxiomDNE 𝓢] : HasDiaDuality 𝓢 := ⟨by intro φ; rw [Axioms.DiaDuality, ModalDeMorgan.neg_box, DeMorgan.neg]; exact E_Id; diff --git a/Foundation/SecondOrder/Syntax/Formula.lean b/Foundation/SecondOrder/Syntax/Formula.lean index b71e6ee6a..b9c9b27ba 100644 --- a/Foundation/SecondOrder/Syntax/Formula.lean +++ b/Foundation/SecondOrder/Syntax/Formula.lean @@ -138,7 +138,7 @@ lemma neg_neg (φ : Semiformula L Ξ ξ N n) : ∼∼φ = φ := | ∀¹ φ => by simp [neg_neg φ] | ∃¹ φ => by simp [neg_neg φ] -instance : NegInvolutive (Semiformula L Ξ ξ N n) := ⟨neg_neg⟩ +instance : TildeInvolutive (Semiformula L Ξ ξ N n) := ⟨neg_neg⟩ @[simp] lemma and_inj {φ₁ φ₂ ψ₁ ψ₂ : Semiformula L Ξ ξ N n} : φ₁ ⋏ φ₂ = ψ₁ ⋏ ψ₂ ↔ φ₁ = ψ₁ ∧ φ₂ = ψ₂ := iff_of_eq (by apply and.injEq) From 7163167edc58ba637eaeada4f6f64100601e050e Mon Sep 17 00:00:00 2001 From: palalansouki Date: Wed, 27 May 2026 02:20:04 +0900 Subject: [PATCH 03/14] le --- Foundation/FirstOrder/Basic/CutFree.lean | 6 ++--- Foundation/FirstOrder/Basic/Soundness.lean | 2 +- Foundation/FirstOrder/Hauptsatz.lean | 24 +++++++++---------- .../NegationTranslation/GoedelGentzen.lean | 2 +- Foundation/FirstOrder/Order/Le.lean | 22 ++++++++--------- 5 files changed, 28 insertions(+), 28 deletions(-) diff --git a/Foundation/FirstOrder/Basic/CutFree.lean b/Foundation/FirstOrder/Basic/CutFree.lean index 4b200bdcb..17c71875d 100644 --- a/Foundation/FirstOrder/Basic/CutFree.lean +++ b/Foundation/FirstOrder/Basic/CutFree.lean @@ -22,7 +22,7 @@ inductive IsCutFree : {Γ : Sequent L} → ⊢ᴸᴷ¹ Γ → Prop | and {dφ : ⊢ᴸᴷ¹ φ :: Γ} {dψ : ⊢ᴸᴷ¹ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) | all {d : ⊢ᴸᴷ¹ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all | exs (t) {d : ⊢ᴸᴷ¹ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs -| wk {d : ⊢ᴸᴷ¹ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) +| contraction {d : ⊢ᴸᴷ¹ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.contraction ss) attribute [simp] IsCutFree.identity IsCutFree.verum @@ -41,8 +41,8 @@ variable {Γ Δ : Sequent L} @[simp] lemma isCutFree_exs_iff {d : ⊢ᴸᴷ¹ φ/[t] :: Γ} : IsCutFree d.exs ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .exs t⟩ -@[simp] lemma isCutFree_wk_iff {d : ⊢ᴸᴷ¹ Δ} {ss : Δ ⊆ Γ} : - IsCutFree (d.wk ss) ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .wk _⟩ +@[simp] lemma isCutFree_contraction_iff {d : ⊢ᴸᴷ¹ Δ} {ss : Δ ⊆ Γ} : + IsCutFree (d.contraction ss) ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .contraction _⟩ @[simp] lemma IsCutFree.cast {d : ⊢ᴸᴷ¹ Γ} {e : Γ = Δ} : IsCutFree (.cast d e) ↔ IsCutFree d := by rcases e; rfl diff --git a/Foundation/FirstOrder/Basic/Soundness.lean b/Foundation/FirstOrder/Basic/Soundness.lean index ee8d80f1f..b414756d6 100644 --- a/Foundation/FirstOrder/Basic/Soundness.lean +++ b/Foundation/FirstOrder/Basic/Soundness.lean @@ -47,7 +47,7 @@ lemma sound {M : Type*} [s : Structure L M] [Nonempty M] (f : ℕ → M) {Γ : S rcases this with (hp | ⟨ψ, hq, hhq⟩) · exact ⟨∃⁰ φ, by simp, t.val ![] f, hp⟩ · exact ⟨ψ, by simp [hq], hhq⟩ - | wk (Δ := Δ) (Γ := Γ) d ss => by + | contraction (Δ := Δ) (Γ := Γ) d ss => by have : ∃ φ ∈ Δ, Evalf f φ := sound f d rcases this with ⟨φ, hp, h⟩ exact ⟨φ, ss hp, h⟩ diff --git a/Foundation/FirstOrder/Hauptsatz.lean b/Foundation/FirstOrder/Hauptsatz.lean index 7f3c48edc..83db9baba 100644 --- a/Foundation/FirstOrder/Hauptsatz.lean +++ b/Foundation/FirstOrder/Hauptsatz.lean @@ -17,7 +17,7 @@ variable {L : Language} inductive Positive (Ξ : Sequent L) : Sequent L → Type _ | or : Positive Ξ (φ :: ψ :: Γ) → Positive Ξ (φ ⋎ ψ :: Γ) | exs : Positive Ξ (φ/[t] :: Γ) → Positive Ξ ((∃⁰ φ) :: Γ) -| wk : Positive Ξ Δ → Δ ⊆ Γ → Positive Ξ Γ +| contraction : Positive Ξ Δ → Δ ⊆ Γ → Positive Ξ Γ | protected id : Positive Ξ Ξ infix:45 " ⟶⁺ " => Positive @@ -26,22 +26,22 @@ namespace Positive variable {Ξ Γ Δ : Sequent L} -def ofSubset (ss : Ξ ⊆ Γ) : Ξ ⟶⁺ Γ := wk .id ss +def ofSubset (ss : Ξ ⊆ Γ) : Ξ ⟶⁺ Γ := contraction .id ss def trans {Ξ Γ Δ : Sequent L} : Ξ ⟶⁺ Γ → Γ ⟶⁺ Δ → Ξ ⟶⁺ Δ | b, or d => or (b.trans d) | b, exs d => exs (b.trans d) - | b, wk d h => wk (b.trans d) h + | b, contraction d h => contraction (b.trans d) h | b, .id => b def cons {Ξ Γ : Sequent L} (φ) : Ξ ⟶⁺ Γ → φ :: Ξ ⟶⁺ φ :: Γ | or (Γ := Γ) (φ := ψ) (ψ := χ) d => - have : φ :: Ξ ⟶⁺ ψ :: χ :: φ :: Γ := wk (cons φ d) (by simp; tauto) - wk (or this) (by simp) + have : φ :: Ξ ⟶⁺ ψ :: χ :: φ :: Γ := contraction (cons φ d) (by simp; tauto) + contraction (or this) (by simp) | exs (Ξ := Ξ) (Γ := Γ) (φ := ψ) (t := t) d => - have : φ :: Ξ ⟶⁺ ψ/[t] :: φ :: Γ := wk (cons φ d) (by simp) - wk this.exs (by simp) - | wk d h => wk (d.cons φ) (by simp [h]) + have : φ :: Ξ ⟶⁺ ψ/[t] :: φ :: Γ := contraction (cons φ d) (by simp) + contraction this.exs (by simp) + | contraction d h => contraction (d.cons φ) (by simp [h]) | .id => .id def append {Ξ Γ : Sequent L} : (Δ : Sequent L) → Ξ ⟶⁺ Γ → Δ ++ Ξ ⟶⁺ Δ ++ Γ @@ -51,13 +51,13 @@ def append {Ξ Γ : Sequent L} : (Δ : Sequent L) → Ξ ⟶⁺ Γ → Δ ++ Ξ def add {Γ Δ Ξ Θ : Sequent L} : Γ ⟶⁺ Δ → Ξ ⟶⁺ Θ → Γ ++ Ξ ⟶⁺ Δ ++ Θ | or d, b => or (d.add b) | exs d, b => exs (d.add b) - | wk d h, b => wk (d.add b) (by simp [h]) + | contraction d h, b => contraction (d.add b) (by simp [h]) | .id, b => b.append Γ def graft {Ξ Γ : Sequent L} (b : ⊢ᴸᴷ¹ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴸᴷ¹ Γ | or d => .or (d.graft b) | exs d => .exs (d.graft b) - | wk d h => .wk (d.graft b) h + | contraction d h => .contraction (d.graft b) h | .id => b lemma graft_isCutFree_of_isCutFree {b : ⊢ᴸᴷ¹ Ξ} {d : Ξ ⟶⁺ Γ} (hb : Derivation.IsCutFree b) : Derivation.IsCutFree (d.graft b) := by @@ -103,7 +103,7 @@ def minLeLeft (p q : ℙ) : p ⊓ q ≼ p := ofSubset (by simp [inf_def]) def minLeRight (p q : ℙ) : p ⊓ q ≼ q := ofSubset (by simp [inf_def]) def leMinOfle (srp : r ≼ p) (srq : r ≼ q) : r ≼ p ⊓ q := ⟨ - let d : ∼p ++ ∼q ⟶⁺ ∼r := .wk (srp.val.add srq.val) (by simp) + let d : ∼p ++ ∼q ⟶⁺ ∼r := .contraction (srp.val.add srq.val) (by simp) neg_inf_p_eq _ _ ▸ d⟩ def leMinRightOfLe (s : q ≼ p) : q ≼ p ⊓ q := leMinOfle s (.refl q) @@ -187,7 +187,7 @@ def explosion {p : ℙ} (b : p ⊩ ⊥) : (φ : Propositionᵢ L) → p ⊩ φ | ⊥ => b | .rel R v => let ⟨d, hd⟩ := b.falsumEquiv - relEquiv.symm ⟨.wk d (by simp), by simp [hd]⟩ + relEquiv.symm ⟨.contraction d (by simp), by simp [hd]⟩ | φ ⋏ ψ => andEquiv.symm ⟨b.explosion φ, b.explosion ψ⟩ | φ ⋎ ψ => orEquiv.symm <| .inl <| b.explosion φ | φ 🡒 ψ => implyEquiv.symm fun q sqp dφ ↦ (b.monotone sqp).explosion ψ diff --git a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean index f2c064447..08cf69e94 100644 --- a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean +++ b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean @@ -182,7 +182,7 @@ def gödelGentzen {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → (∼Γ)ᴺ ⊢[Λ]! ⊥ FiniteContext.weakening (by simp) <| Entailment.C_trans (of <| Entailment.K_left (negDoubleNegation φ)) (deduct ihp) have b₂ : (∼(Γ ++ Δ))ᴺ ⊢[Λ]! ∼φᴺ := FiniteContext.weakening (by simp) <| deduct ihn b₁ ⨀ b₂ - | wk (Γ := Γ) (Δ := Δ) d h => + | contraction (Γ := Γ) (Δ := Δ) d h => FiniteContext.weakening (List.map_subset _ <| List.map_subset _ h) (gödelGentzen d) diff --git a/Foundation/FirstOrder/Order/Le.lean b/Foundation/FirstOrder/Order/Le.lean index 872088afc..dc3b192f1 100644 --- a/Foundation/FirstOrder/Order/Le.lean +++ b/Foundation/FirstOrder/Order/Le.lean @@ -1,6 +1,6 @@ module -public import Foundation.FirstOrder.Completeness.Corollaries +public import Foundation.FirstOrder.Completeness @[expose] public section namespace LO @@ -17,20 +17,20 @@ lemma le_eq (t₁ t₂ : Semiterm L μ n) : LT.le.operator ![t₁, t₂] = “!! simp [Operator.operator, Operator.or, LT.le, ←TransitiveRewriting.comp_app] namespace Order -variable {T : Theory L} [𝗘𝗤 ⪯ T] +variable {T : Theory L} [𝗘𝗤 L ⪯ T] noncomputable def leIffEqOrLt : T ⊢ “∀ x y, x ≤ y ↔ x = y ∨ x < y” := - complete - (consequence_iff.mpr $ fun _ _ _ _ => by simp [models_iff, Semiformula.Operator.LE.def_of_Eq_of_LT]) + Theory.Proof.small_complete + <| consequence_iff.mpr fun _ ↦ by simp [models_iff, Semiformula.Operator.LE.def_of_Eq_of_LT] -lemma provOf (φ : Sentence L) +lemma complete (φ : Sentence L) (H : ∀ (M : Type (max u w)) - [Nonempty M] [LT M] - [Structure L M] [Structure.Eq L M] [Structure.LT L M] - [M ⊧ₘ* T], - M ⊧ₘ φ) : - T ⊨ φ := consequence_iff_consequence.{u, w}.mp <| consequence_iff_eq.mpr fun M _ _ _ hT => - letI : (Structure.Model L M) ⊧ₘ* T := Structure.ElementaryEquiv.modelsTheory.mp hT + [Nonempty M] [LT M] + [Structure L M] [Structure.Eq L M] [Structure.LT L M] + [M↓[L] ⊧* T], + M↓[L] ⊧ φ) : + T ⊢ φ := Theory.Proof.complete <| consequence_iff_eq.mpr fun M _ _ _ hT ↦ + letI : (Structure.Model L M)↓[L] ⊧* T := Structure.ElementaryEquiv.modelsTheory.mp hT Structure.ElementaryEquiv.models.mpr (H (Structure.Model L M)) end Order From 68def055b531c72ef4ecc4a6ea5e92aeb73f83f3 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Wed, 27 May 2026 03:15:07 +0900 Subject: [PATCH 04/14] R0 --- .../Arithmetic/Basic/Hierarchy.lean | 4 +- .../FirstOrder/Arithmetic/Basic/Misc.lean | 12 +- .../FirstOrder/Arithmetic/Basic/Model.lean | 62 +++++------ .../FirstOrder/Arithmetic/Basic/Monotone.lean | 6 +- .../FirstOrder/Arithmetic/Omega1/Basic.lean | 2 +- .../Arithmetic/PeanoMinus/Basic.lean | 34 +++--- Foundation/FirstOrder/Arithmetic/Q/Basic.lean | 16 +-- .../FirstOrder/Arithmetic/R0/Basic.lean | 105 +++++++++--------- .../FirstOrder/Arithmetic/Schemata.lean | 2 +- .../FirstOrder/Basic/Semantics/Semantics.lean | 2 + Foundation/FirstOrder/SetTheory/Z.lean | 16 +-- 11 files changed, 128 insertions(+), 133 deletions(-) diff --git a/Foundation/FirstOrder/Arithmetic/Basic/Hierarchy.lean b/Foundation/FirstOrder/Arithmetic/Basic/Hierarchy.lean index 98f3d5dad..176d0e1da 100644 --- a/Foundation/FirstOrder/Arithmetic/Basic/Hierarchy.lean +++ b/Foundation/FirstOrder/Arithmetic/Basic/Hierarchy.lean @@ -256,7 +256,7 @@ lemma sigma_of_sigma_ex {φ : Semiformula L ξ (n + 1)} : Hierarchy 𝚺 s (∃ set_option linter.flexible false in lemma rew (ω : Rew L ξ₁ n₁ ξ₂ n₂) {φ : Semiformula L ξ₁ n₁} : Hierarchy Γ s φ → Hierarchy Γ s (ω ▹ φ) := by - intro h; induction h generalizing n₂ <;> try simp [*, Semiformula.rew_rel, Semiformula.rew_nrel] + intro h; induction h generalizing n₂ <;> try simp [*] case sigma ih => exact (ih _).accum _ case pi ih => exact (ih _).accum _ case dummy_pi ih => exact (ih _).dummy_pi @@ -476,7 +476,7 @@ end Arithmetic abbrev ArithmeticTheory.SoundOnHierarchy (T : ArithmeticTheory) (Γ : Polarity) (k : ℕ) := T.SoundOn (Arithmetic.Hierarchy Γ k) lemma ArithmeticTheory.soundOnHierarchy (T : ArithmeticTheory) (Γ : Polarity) (k : ℕ) [T.SoundOnHierarchy Γ k] : - T ⊢ σ → Arithmetic.Hierarchy Γ k σ → ℕ ⊧ₘ σ := SoundOn.sound + T ⊢ σ → Arithmetic.Hierarchy Γ k σ → ℕ↓[ℒₒᵣ] ⊧ σ := SoundOn.sound instance (T : ArithmeticTheory) [T.SoundOnHierarchy 𝚺 1] : Entailment.Consistent T := T.consistent_of_sound (Arithmetic.Hierarchy 𝚺 1) (by simp) diff --git a/Foundation/FirstOrder/Arithmetic/Basic/Misc.lean b/Foundation/FirstOrder/Arithmetic/Basic/Misc.lean index c2399c981..6f6af070c 100644 --- a/Foundation/FirstOrder/Arithmetic/Basic/Misc.lean +++ b/Foundation/FirstOrder/Arithmetic/Basic/Misc.lean @@ -135,14 +135,12 @@ def bexsLTSucc (t : Semiterm L ξ n) (φ : Semiformula L ξ (n + 1)) : Semiformu variable {M : Type*} {s : Structure L M} [LT M] [One M] [Add M] [Structure.LT L M] [Structure.One L M] [Structure.Add L M] -variable {t : Semiterm L ξ n} {φ : Semiformula L ξ (n + 1)} - -lemma eval_ballLTSucc {e ε} : - Eval s e ε (φ.ballLTSucc t) ↔ ∀ x < t.val s e ε + 1, Eval s (x :> e) ε φ := by +lemma eval_ballLTSucc {φ : Semiformula L ξ (n + 1)} {t : Semiterm L ξ n} {fv bv} : + (φ.ballLTSucc t).Eval (M := M) fv bv ↔ ∀ x < t.val (M := M) fv bv + 1, φ.Eval (M := M) (x :> fv) bv := by simp [ballLTSucc, Semiterm.Operator.numeral] -lemma eval_bexsLTSucc {e ε} : - Eval s e ε (φ.bexsLTSucc t) ↔ ∃ x < t.val s e ε + 1, Eval s (x :> e) ε φ := by +lemma eval_bexsLTSucc {φ : Semiformula L ξ (n + 1)} {t : Semiterm L ξ n} {fv bv} : + (φ.bexsLTSucc t).Eval (M := M) fv bv ↔ ∃ x < t.val (M := M) fv bv + 1, φ.Eval (M := M) (x :> fv) bv := by simp [bexsLTSucc, Semiterm.Operator.numeral] end Semiformula @@ -167,8 +165,6 @@ macro_rules end BinderNotation -abbrev ArithmeticTheory := Theory ℒₒᵣ - end FirstOrder end LO diff --git a/Foundation/FirstOrder/Arithmetic/Basic/Model.lean b/Foundation/FirstOrder/Arithmetic/Basic/Model.lean index ec33dc820..73f32608e 100644 --- a/Foundation/FirstOrder/Arithmetic/Basic/Model.lean +++ b/Foundation/FirstOrder/Arithmetic/Basic/Model.lean @@ -5,15 +5,15 @@ public import Foundation.FirstOrder.Arithmetic.Basic.Misc @[expose] public section namespace LO.FirstOrder.Arithmetic -private lemma consequence_of_aux (T : ArithmeticTheory) [𝗘𝗤 ⪯ T] (φ : Sentence ℒₒᵣ) +private lemma complete_aux (T : ArithmeticTheory) [𝗘𝗤 ℒₒᵣ ⪯ T] (φ : Sentence ℒₒᵣ) (H : ∀ (M : Type w) [ORingStructure M] [Structure ℒₒᵣ M] [Structure.ORing ℒₒᵣ M] - [M ⊧ₘ* T], - M ⊧ₘ φ) : - T ⊨ φ := consequence_iff_consequence.{_, w}.mp <| consequence_iff_eq.mpr fun M _ _ _ hT => - letI : Structure.Model ℒₒᵣ M ⊧ₘ* T := Structure.ElementaryEquiv.modelsTheory.mp hT + [M↓[ℒₒᵣ] ⊧* T], + M↓[ℒₒᵣ] ⊧ φ) : + T ⊢ φ := Theory.Proof.complete <| consequence_iff_eq.mpr fun M _ _ _ hT ↦ + letI : (Structure.Model ℒₒᵣ M)↓[ℒₒᵣ] ⊧* T := Structure.ElementaryEquiv.modelsTheory.mp hT Structure.ElementaryEquiv.models.mpr (H (Structure.Model ℒₒᵣ M)) open Language @@ -23,38 +23,40 @@ section semantics variable (M : Type*) [ORingStructure M] instance standardModel : Structure ℒₒᵣ M where - func := fun _ f => + func := fun _ f ↦ match f with - | ORing.Func.zero => fun _ => 0 - | ORing.Func.one => fun _ => 1 - | ORing.Func.add => fun v => v 0 + v 1 - | ORing.Func.mul => fun v => v 0 * v 1 - rel := fun _ r => + | ORing.Func.zero => fun _ ↦ 0 + | ORing.Func.one => fun _ ↦ 1 + | ORing.Func.add => fun v ↦ v 0 + v 1 + | ORing.Func.mul => fun v ↦ v 0 * v 1 + rel := fun _ r ↦ match r with - | ORing.Rel.eq => fun v => v 0 = v 1 - | ORing.Rel.lt => fun v => v 0 < v 1 + | ORing.Rel.eq => fun v ↦ v 0 = v 1 + | ORing.Rel.lt => fun v ↦ v 0 < v 1 -instance : Structure.Eq ℒₒᵣ M := - ⟨by intro a b; simp [standardModel, Semiformula.Operator.val, Semiformula.Operator.Eq.sentence_eq, Semiformula.eval_rel]⟩ +instance : Structure.Eq ℒₒᵣ M where + eq a b := by + unfold standardModel + simp [Semiformula.Operator.val, Semiformula.Operator.Eq.sentence_eq] instance : Structure.Zero ℒₒᵣ M := ⟨rfl⟩ instance : Structure.One ℒₒᵣ M := ⟨rfl⟩ -instance : Structure.Add ℒₒᵣ M := ⟨fun _ _ => rfl⟩ +instance : Structure.Add ℒₒᵣ M := ⟨fun _ _ ↦ rfl⟩ -instance : Structure.Mul ℒₒᵣ M := ⟨fun _ _ => rfl⟩ +instance : Structure.Mul ℒₒᵣ M := ⟨fun _ _ ↦ rfl⟩ -instance : Structure.Eq ℒₒᵣ M := ⟨fun _ _ => iff_of_eq rfl⟩ +instance : Structure.Eq ℒₒᵣ M := ⟨fun _ _ ↦ iff_of_eq rfl⟩ -instance : Structure.LT ℒₒᵣ M := ⟨fun _ _ => iff_of_eq rfl⟩ +instance : Structure.LT ℒₒᵣ M := ⟨fun _ _ ↦ iff_of_eq rfl⟩ instance : ORing ℒₒᵣ := ORing.mk lemma standardModel_unique' (s : Structure ℒₒᵣ M) (hZero : Structure.Zero ℒₒᵣ M) (hOne : Structure.One ℒₒᵣ M) (hAdd : Structure.Add ℒₒᵣ M) (hMul : Structure.Mul ℒₒᵣ M) (hEq : Structure.Eq ℒₒᵣ M) (hLT : Structure.LT ℒₒᵣ M) : s = standardModel M := Structure.ext - (funext₃ fun k f _ => + (funext₃ fun k f _ ↦ match k, f with | _, Language.Zero.zero => by simp [Matrix.empty_eq] | _, Language.One.one => by simp [Matrix.empty_eq] @@ -72,31 +74,29 @@ lemma standardModel_unique (s : Structure ℒₒᵣ M) end semantics -lemma consequence_of_models (T : ArithmeticTheory) [𝗘𝗤 ⪯ T] (φ : Sentence ℒₒᵣ) (H : ∀ (M : Type*) [ORingStructure M] [M ⊧ₘ* T], M ⊧ₘ φ) : - T ⊨ φ := consequence_of_aux T φ fun M _ s _ _ ↦ by +/-- provable_of_models -/ +lemma complete (T : ArithmeticTheory) [𝗘𝗤 ℒₒᵣ ⪯ T] (φ : Sentence ℒₒᵣ) (H : ∀ (M : Type*) [ORingStructure M] [M↓[ℒₒᵣ] ⊧* T], M↓[ℒₒᵣ] ⊧ φ) : + T ⊢ φ := complete_aux T φ fun M _ s _ _ ↦ by rcases standardModel_unique M s exact H M -lemma provable_of_models (T : ArithmeticTheory) [𝗘𝗤 ⪯ T] (φ : Sentence ℒₒᵣ) (H : ∀ (M : Type*) [ORingStructure M] [M ⊧ₘ* T], M ⊧ₘ φ) : - T ⊢ φ := complete <| consequence_of_models _ _ H - -lemma weakerThan_of_models (T S : ArithmeticTheory) [𝗘𝗤 ⪯ S] +lemma weakerThan_of_models (T S : ArithmeticTheory) [𝗘𝗤 ℒₒᵣ ⪯ S] (H : ∀ (M : Type*) [ORingStructure M] - [M ⊧ₘ* S], - M ⊧ₘ* T) : T ⪯ S := - Entailment.weakerThan_iff.mpr fun h ↦ complete <| consequence_of_models _ _ fun M _ _ ↦ sound! h (H M) + [M↓[ℒₒᵣ] ⊧* S], + M↓[ℒₒᵣ] ⊧* T) : T ⪯ S := + Entailment.weakerThan_iff.mpr fun h ↦ complete _ _ fun M _ _ ↦ Theory.Proof.sound h (H M) end Arithmetic class ArithmeticTheory.SoundOn (T : ArithmeticTheory) (F : Sentence ℒₒᵣ → Prop) where - sound : ∀ {σ}, T ⊢ σ → F σ → ℕ ⊧ₘ σ + sound : ∀ {σ}, T ⊢ σ → F σ → ℕ↓[ℒₒᵣ] ⊧ σ namespace ArithmeticTheory variable (T : ArithmeticTheory) (F : Sentence ℒₒᵣ → Prop) -instance [ℕ ⊧ₘ* T] : T.SoundOn F := ⟨fun b _ ↦ consequence_iff.mp (sound! b) ℕ inferInstance⟩ +instance [ℕ↓[ℒₒᵣ] ⊧* T] : T.SoundOn F := ⟨fun b _ ↦ consequence_iff.mp (Theory.Proof.sound b) ℕ inferInstance⟩ lemma consistent_of_sound [SoundOn T F] (hF : F ⊥) : Entailment.Consistent T := Entailment.consistent_iff_unprovable_bot.mpr fun b ↦ SoundOn.sound b hF diff --git a/Foundation/FirstOrder/Arithmetic/Basic/Monotone.lean b/Foundation/FirstOrder/Arithmetic/Basic/Monotone.lean index f56a3f1b8..a08711f10 100644 --- a/Foundation/FirstOrder/Arithmetic/Basic/Monotone.lean +++ b/Foundation/FirstOrder/Arithmetic/Basic/Monotone.lean @@ -14,9 +14,9 @@ namespace Monotone variable {L : Language} {M : Type*} [LE M] [Structure L M] [Monotone L M] -lemma term_monotone (t : Semiterm L ξ n) {e₁ e₂ : Fin n → M} {ε₁ ε₂ : ξ → M} - (he : ∀ i, e₁ i ≤ e₂ i) (hε : ∀ i, ε₁ i ≤ ε₂ i) : - t.valm M e₁ ε₁ ≤ t.valm M e₂ ε₂ := by +lemma term_monotone (t : Semiterm L ξ n) {fv₁ fv₂ : Fin n → M} {bv₁ bv₂ : ξ → M} + (he : ∀ i, fv₁ i ≤ fv₂ i) (hε : ∀ i, bv₁ i ≤ bv₂ i) : + t.val fv₁ bv₁ ≤ t.val fv₂ bv₂ := by induction t <;> simp [*, Semiterm.val_func, Monotone.monotone] end Monotone diff --git a/Foundation/FirstOrder/Arithmetic/Omega1/Basic.lean b/Foundation/FirstOrder/Arithmetic/Omega1/Basic.lean index bdfdcfbea..9de80e190 100644 --- a/Foundation/FirstOrder/Arithmetic/Omega1/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/Omega1/Basic.lean @@ -41,7 +41,7 @@ instance : V ⊧ₘ* 𝗜𝚺₀ := ModelsTheory.of_add_left V 𝗜𝚺₀ 𝝮 instance : V ⊧ₘ* 𝝮₁ := ModelsTheory.of_add_right V 𝗜𝚺₀ 𝝮₁ lemma exists_exponential_sq_length (x : V) : ∃ y, Exponential (‖x‖^2) y := - models_Omega1_iff.mp (ModelsTheory.models V Omega1.omega) x + models_Omega1_iff.mp (Theory.models V Omega1.omega) x lemma exists_unique_exponential_sq_length (x : V) : ∃! y, Exponential (‖x‖^2) y := by rcases exists_exponential_sq_length x with ⟨y, h⟩ diff --git a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Basic.lean b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Basic.lean index fc1e7283d..c41f3c451 100644 --- a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Basic.lean @@ -167,55 +167,55 @@ lemma le_def {x y : M} : x ≤ y ↔ x = y ∨ x < y := iff_of_eq rfl variable [M ⊧ₘ* 𝗣𝗔⁻] protected lemma add_zero' : ∀ x : M, x + 0 = x := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.addZero + simpa [models_iff] using Theory.models M PeanoMinus.addZero protected lemma add_assoc : ∀ x y z : M, (x + y) + z = x + (y + z) := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.addAssoc + simpa [models_iff] using Theory.models M PeanoMinus.addAssoc protected lemma add_comm : ∀ x y : M, x + y = y + x := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.addComm + simpa [models_iff] using Theory.models M PeanoMinus.addComm lemma add_eq_of_lt : ∀ x y : M, x < y → ∃ z, x + z = y := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.addEqOfLt + simpa [models_iff] using Theory.models M PeanoMinus.addEqOfLt @[simp] protected lemma zero_le : ∀ x : M, 0 ≤ x := by - simpa [models_iff, Structure.le_iff_of_eq_of_lt] using ModelsTheory.models M PeanoMinus.zeroLe + simpa [models_iff, Structure.le_iff_of_eq_of_lt] using Theory.models M PeanoMinus.zeroLe lemma zero_lt_one : (0 : M) < 1 := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.zeroLtOne + simpa [models_iff] using Theory.models M PeanoMinus.zeroLtOne lemma one_le_of_zero_lt : ∀ x : M, 0 < x → 1 ≤ x := by - simpa [models_iff, Structure.le_iff_of_eq_of_lt] using ModelsTheory.models M PeanoMinus.oneLeOfZeroLt + simpa [models_iff, Structure.le_iff_of_eq_of_lt] using Theory.models M PeanoMinus.oneLeOfZeroLt lemma add_lt_add : ∀ x y z : M, x < y → x + z < y + z := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.addLtAdd + simpa [models_iff] using Theory.models M PeanoMinus.addLtAdd protected lemma mul_zero' : ∀ x : M, x * 0 = 0 := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.mulZero + simpa [models_iff] using Theory.models M PeanoMinus.mulZero protected lemma mul_one : ∀ x : M, x * 1 = x := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.mulOne + simpa [models_iff] using Theory.models M PeanoMinus.mulOne protected lemma mul_assoc : ∀ x y z : M, (x * y) * z = x * (y * z) := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.mulAssoc + simpa [models_iff] using Theory.models M PeanoMinus.mulAssoc protected lemma mul_comm : ∀ x y : M, x * y = y * x := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.mulComm + simpa [models_iff] using Theory.models M PeanoMinus.mulComm lemma mul_lt_mul : ∀ x y z : M, x < y → 0 < z → x * z < y * z := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.mulLtMul + simpa [models_iff] using Theory.models M PeanoMinus.mulLtMul lemma mul_add_distr : ∀ x y z : M, x * (y + z) = x * y + x * z := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.distr + simpa [models_iff] using Theory.models M PeanoMinus.distr lemma lt_irrefl : ∀ x : M, ¬x < x := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.ltIrrefl + simpa [models_iff] using Theory.models M PeanoMinus.ltIrrefl protected lemma lt_trans : ∀ x y z : M, x < y → y < z → x < z := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.ltTrans + simpa [models_iff] using Theory.models M PeanoMinus.ltTrans lemma lt_tri : ∀ x y : M, x < y ∨ x = y ∨ y < x := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.ltTri + simpa [models_iff] using Theory.models M PeanoMinus.ltTri scoped instance : AddCommMonoid M where add_assoc := Arithmetic.add_assoc diff --git a/Foundation/FirstOrder/Arithmetic/Q/Basic.lean b/Foundation/FirstOrder/Arithmetic/Q/Basic.lean index ae76cef2e..55f1caa1f 100644 --- a/Foundation/FirstOrder/Arithmetic/Q/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/Q/Basic.lean @@ -58,29 +58,29 @@ end RobinsonQ variable {M : Type*} [ORingStructure M] [M ⊧ₘ* 𝗤] @[simp] protected lemma succ_ne_zero : ∀ a : M, a + 1 ≠ 0 := by - simpa [models_iff] using ModelsTheory.models M RobinsonQ.succNeZero + simpa [models_iff] using Theory.models M RobinsonQ.succNeZero lemma succ_inj {a b : M} : a + 1 = b + 1 → a = b := by - have := by simpa [models_iff] using ModelsTheory.models M RobinsonQ.succInj + have := by simpa [models_iff] using Theory.models M RobinsonQ.succInj exact this a b @[simp] protected lemma add_zero {a : M} : a + 0 = a := by - have := by simpa [models_iff] using ModelsTheory.models M RobinsonQ.addZero + have := by simpa [models_iff] using Theory.models M RobinsonQ.addZero exact this a protected lemma add_succ (a b : M) : a + (b + 1) = a + b + 1 := by - have := by simpa [models_iff] using ModelsTheory.models M RobinsonQ.addSucc + have := by simpa [models_iff] using Theory.models M RobinsonQ.addSucc exact this a b @[simp] protected lemma mul_zero (a : M) : a * 0 = 0 := by - have := by simpa [models_iff] using ModelsTheory.models M RobinsonQ.mulZero + have := by simpa [models_iff] using Theory.models M RobinsonQ.mulZero exact this a protected lemma mul_succ : ∀ a b : M, a * (b + 1) = a * b + a := by - simpa [models_iff] using ModelsTheory.models M RobinsonQ.mulSucc + simpa [models_iff] using Theory.models M RobinsonQ.mulSucc lemma zero_or_succ (a : M) : a = 0 ∨ ∃ b : M, a = b + 1 := by - have := by simpa [models_iff] using ModelsTheory.models M RobinsonQ.zeroOrSucc + have := by simpa [models_iff] using Theory.models M RobinsonQ.zeroOrSucc exact this a lemma exists_succ_of_ne_zero {a : M} (ha : a ≠ 0) : ∃ b : M, a = b + 1 := by @@ -92,7 +92,7 @@ lemma exists_succ_of_ne_zero' {a : M} (ha : a ≠ 0) : ∃ b : M, b + 1 = a := b use b; protected lemma lt_def {a b : M} : a < b ↔ ∃ c : M, a + (c + 1) = b := by - have := by simpa [models_iff] using ModelsTheory.models M RobinsonQ.ltDef + have := by simpa [models_iff] using Theory.models M RobinsonQ.ltDef exact this a b @[simp] diff --git a/Foundation/FirstOrder/Arithmetic/R0/Basic.lean b/Foundation/FirstOrder/Arithmetic/R0/Basic.lean index 19d801976..fabcb3453 100644 --- a/Foundation/FirstOrder/Arithmetic/R0/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/R0/Basic.lean @@ -13,7 +13,7 @@ noncomputable section namespace LO.FirstOrder.Arithmetic inductive R0 : ArithmeticTheory - | equal : ∀ φ ∈ 𝗘𝗤, R0 φ + | equal : ∀ φ ∈ 𝗘𝗤 ℒₒᵣ, R0 φ | Ω₁ (n m : ℕ) : R0 “↑n + ↑m = ↑(n + m)” | Ω₂ (n m : ℕ) : R0 “↑n * ↑m = ↑(n * m)” | Ω₃ (n m : ℕ) : n ≠ m → R0 “↑n ≠ ↑m” @@ -23,14 +23,14 @@ notation "𝗥₀" => R0 namespace R0 -instance : 𝗘𝗤 ⪯ 𝗥₀ := Entailment.WeakerThan.ofSubset <| fun φ hp ↦ R0.equal φ hp +instance : 𝗘𝗤 ℒₒᵣ ⪯ 𝗥₀ := Entailment.WeakerThan.ofSubset <| fun φ hp ↦ R0.equal φ hp -instance : ℕ ⊧ₘ* 𝗥₀ := ⟨by +instance : ℕ↓[ℒₒᵣ] ⊧* 𝗥₀ := ⟨by intro σ h rcases h <;> try { simp [models_iff]; done } case equal h => - have : ℕ ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - simpa [models_iff] using modelsTheory_iff.mp this h + have : ℕ↓[ℒₒᵣ] ⊧* (𝗘𝗤 ℒₒᵣ : ArithmeticTheory) := inferInstance + simpa [models_iff] using models_theory_iff.mp this _ h case Ω₃ h => simpa [models_iff, ←le_iff_eq_or_lt] using h⟩ @@ -38,21 +38,21 @@ end R0 section model -variable {M : Type*} [ORingStructure M] [M ⊧ₘ* 𝗥₀] +variable {M : Type*} [ORingStructure M] [M↓[ℒₒᵣ] ⊧* 𝗥₀] open Language ORingStructure lemma numeral_add_numeral (n m : ℕ) : (numeral n : M) + numeral m = numeral (n + m) := by - simpa [models_iff] using ModelsTheory.models M (R0.Ω₁ n m) + simpa [models_iff] using Theory.models M _ (R0.Ω₁ n m) lemma numeral_mul_numeral (n m : ℕ) : (numeral n : M) * numeral m = numeral (n * m) := by - simpa [models_iff] using ModelsTheory.models M (R0.Ω₂ n m) + simpa [models_iff] using Theory.models M _ (R0.Ω₂ n m) lemma numeral_ne_numeral_of_ne {n m : ℕ} (h : n ≠ m) : (numeral n : M) ≠ numeral m := by - simpa [models_iff] using ModelsTheory.models M (R0.Ω₃ n m h) + simpa [models_iff] using Theory.models M _ (R0.Ω₃ n m h) lemma lt_numeral_iff {x : M} {n : ℕ} : x < numeral n ↔ ∃ i : Fin n, x = numeral i := by - have := by simpa [models_iff] using ModelsTheory.models M (R0.Ω₄ n) + have := by simpa [models_iff] using Theory.models M _ (R0.Ω₄ n) constructor · intro hx rcases (this x).mp hx with ⟨i, hi, rfl⟩ @@ -73,18 +73,19 @@ lemma lt_numeral_iff {x : M} {n : ℕ} : x < numeral n ↔ ∃ i : Fin n, x = nu open Hierarchy -lemma val_numeral {n} : ∀ (t : Semiterm ℒₒᵣ ξ n), - ∀ v f, Semiterm.valm M (fun x ↦ numeral (v x)) (fun x ↦ numeral (f x)) t = numeral (Semiterm.valm ℕ v f t) - | #_, _, _ => by simp - | &x, _, _ => by simp - | Semiterm.func Language.Zero.zero _, e, f => by simp - | Semiterm.func Language.One.one _, e, f => by simp - | Semiterm.func Language.Add.add v, e, f => by simp [Semiterm.val_func, val_numeral (v 0), val_numeral (v 1), numeral_add_numeral] - | Semiterm.func Language.Mul.mul v, e, f => by simp [Semiterm.val_func, val_numeral (v 0), val_numeral (v 1), numeral_mul_numeral] - -lemma bold_sigma_one_completeness {n} {φ : Semiformula ℒₒᵣ ξ n} (hp : Hierarchy 𝚺 1 φ) {e f} : - Semiformula.Evalm ℕ e f φ → Semiformula.Evalm M (fun x ↦ numeral (e x)) (fun x ↦ numeral (f x)) φ := by - revert e +lemma val_numeral {n ξ} (bv : Fin n → ℕ) (fv : ξ → ℕ) (t : Semiterm ℒₒᵣ ξ n) : + t.val (M := M) (numeral ∘ bv) (numeral ∘ fv) = numeral (t.val bv fv) := + match t with + | #_ => by simp + | &_ => by simp + | .func Language.Zero.zero _ => by simp [Matrix.empty_eq] + | .func Language.One.one _ => by simp [Matrix.empty_eq] + | .func Language.Add.add v => by simp [Semiterm.val_func, val_numeral _ _ (v 0), val_numeral _ _ (v 1), numeral_add_numeral] + | .func Language.Mul.mul v => by simp [Semiterm.val_func, val_numeral _ _ (v 0), val_numeral _ _ (v 1), numeral_mul_numeral] + +lemma bold_sigma_one_completeness {n} {φ : Semiformula ℒₒᵣ ξ n} (hp : Hierarchy 𝚺 1 φ) {bv : Fin n → ℕ} {fv : ξ → ℕ} : + φ.Eval bv fv → φ.Eval (M := M) (numeral ∘ bv) (numeral ∘ fv) := by + revert bv apply sigma₁_induction' hp case hVerum => simp case hFalsum => simp @@ -92,51 +93,47 @@ lemma bold_sigma_one_completeness {n} {φ : Semiformula ℒₒᵣ ξ n} (hp : Hi case hNEQ => intro n t₁ t₂ e; simp [val_numeral] case hLT => intro n t₁ t₂ e; simp [val_numeral] case hNLT => intro n t₁ t₂ e; simp [val_numeral] - case hAnd => - simp only [LogicalConnective.HomClass.map_and, LogicalConnective.Prop.and_eq, and_imp] - intro n φ ψ _ _ ihp ihq e hp hq - exact ⟨ihp hp, ihq hq⟩ - case hOr => - simp only [LogicalConnective.HomClass.map_or, LogicalConnective.Prop.or_eq] - rintro n φ ψ _ _ ihp ihq e (hp | hq) - · left; exact ihp hp - · right; exact ihq hq + case hAnd => simp; grind + case hOr => simp; grind case hBall => - simp only [Semiformula.eval_ball, Nat.succ_eq_add_one, Semiformula.eval_operator_two, - Semiterm.val_bvar, Matrix.cons_val_zero, Semiterm.val_bShift, Structure.LT.lt, val_numeral] - intro n t φ _ ihp e hp x hx + intro n t φ _ ihp bv + suffices + (∀ x < t.val bv fv, (φ.Eval (x :> bv) fv)) → + ∀ x < numeral (t.val bv fv), (φ.Eval (x :> numeral ∘ bv) (numeral ∘ fv)) by + simpa [val_numeral] + intro hp x hx rcases lt_numeral_iff.mp hx with ⟨x, rfl⟩ - simpa [Matrix.comp_vecCons'] using ihp (hp x (by simp)) + simpa [Matrix.comp_vecCons''] using ihp (hp x (by simp)) case hExs => simp only [Semiformula.eval_ex, Nat.succ_eq_add_one, forall_exists_index] intro n φ _ ihp e x hp - exact ⟨numeral x, by simpa [Matrix.comp_vecCons'] using ihp hp⟩ + exact ⟨numeral x, by simpa [Matrix.comp_vecCons''] using ihp hp⟩ lemma R0.model_complete {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : - ℕ ⊧ₘ σ → M ⊧ₘ σ := by - suffices Semiformula.Evalbm ℕ ![] σ → Semiformula.Evalbm M ![] σ by simpa [models_iff] + ℕ↓[ℒₒᵣ] ⊧ σ → M↓[ℒₒᵣ] ⊧ σ := by + suffices σ.Evalb (M := ℕ) ![] → σ.Evalb (M := M) ![] by simpa [models_iff] intro h simpa [Matrix.empty_eq, Empty.eq_elim] using bold_sigma_one_completeness hσ h variable (M) lemma nat_extention_sigmaOne {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : - ℕ ⊧ₘ σ → M ⊧ₘ σ := fun h ↦ by + ℕ↓[ℒₒᵣ] ⊧ σ → M↓[ℒₒᵣ] ⊧ σ := fun h ↦ by simpa [Matrix.empty_eq] using R0.model_complete (M := M) hσ h lemma nat_extention_piOne {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚷 1 σ) : - M ⊧ₘ σ → ℕ ⊧ₘ σ := by + M↓[ℒₒᵣ] ⊧ σ → ℕ↓[ℒₒᵣ] ⊧ σ := by contrapose simpa using nat_extention_sigmaOne M (σ := ∼σ) (by simpa using hσ) variable {M} -lemma bold_sigma_one_completeness' {n} {σ : Semisentence ℒₒᵣ n} (hσ : Hierarchy 𝚺 1 σ) {e} : - Semiformula.Evalbm ℕ e σ → Semiformula.Evalbm M (fun x ↦ numeral (e x)) σ := fun h ↦ by - simpa [Empty.eq_elim] using bold_sigma_one_completeness (M := M) (φ := σ) hσ (f := Empty.elim) (e := e) h +lemma bold_sigma_one_completeness' {n} {σ : Semisentence ℒₒᵣ n} (hσ : Hierarchy 𝚺 1 σ) {bv} : + σ.Evalb (M := ℕ) bv → σ.Evalb (M := M) (numeral ∘ bv) := fun h ↦ by + simpa [Empty.eq_elim] using bold_sigma_one_completeness (M := M) (φ := σ) hσ (fv := Empty.elim) (bv := bv) h instance consistent : Entailment.Consistent 𝗥₀ := - let : ℕ ⊧ₘ* 𝗥₀ := inferInstance + let : ℕ↓[ℒₒᵣ] ⊧* 𝗥₀ := inferInstance Sound.consistent_of_satisfiable ⟨_, this⟩ end model @@ -144,15 +141,15 @@ end model variable {T : ArithmeticTheory} [𝗥₀ ⪯ T] theorem sigma_one_completeness {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : - ℕ ⊧ₘ σ → T ⊢ σ := fun H => - haveI : 𝗘𝗤 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗥₀) inferInstance inferInstance - provable_of_models.{0} _ _ <| fun M _ _ ↦ by - haveI : M ⊧ₘ* 𝗥₀ := ModelsTheory.of_provably_subtheory M 𝗥₀ T inferInstance + ℕ↓[ℒₒᵣ] ⊧ σ → T ⊢ σ := fun H => + haveI : 𝗘𝗤 _ ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗥₀) inferInstance inferInstance + complete.{0} _ _ <| fun M _ _ ↦ by + haveI : M↓[ℒₒᵣ] ⊧* 𝗥₀ := ModelsTheory.of_provably_subtheory M 𝗥₀ T inferInstance exact R0.model_complete hσ H open Classical in theorem sigma_one_completeness_iff [T.SoundOnHierarchy 𝚺 1] {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : - ℕ ⊧ₘ σ ↔ T ⊢ σ := + ℕ↓[ℒₒᵣ] ⊧ σ ↔ T ⊢ σ := haveI : 𝗥₀ ⪯ T := Entailment.WeakerThan.trans (𝓣 := T) inferInstance inferInstance ⟨fun h ↦ sigma_one_completeness hσ h, fun h ↦ T.soundOnHierarchy 𝚺 1 h (by simp [hσ])⟩ @@ -226,12 +223,12 @@ def cases' {P : OmegaAddOne → Sort*} | .none => top set_option linter.flexible false in -instance : OmegaAddOne ⊧ₘ* 𝗥₀ := ⟨by +instance : OmegaAddOne↓[ℒₒᵣ] ⊧* 𝗥₀ := ⟨by intro σ h rcases h <;> simp [models_iff] case equal h => - have : OmegaAddOne ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h + have : OmegaAddOne↓[ℒₒᵣ] ⊧* (𝗘𝗤 _ : ArithmeticTheory) := inferInstance + exact models_theory_iff.mp this _ h case Ω₃ h => exact h case Ω₄ n => intro x @@ -242,8 +239,8 @@ end OmegaAddOne end Countermodel lemma unprovable_addZero : 𝗥₀ ⊬ “∀ x, x + 0 = x” := - unprovable_of_countermodel (M := Countermodel.OmegaAddOne) <| by - simpa [models_iff] using Countermodel.OmegaAddOne.exists_add_zero_ne_self + unprovable_of_countermodel _ (M := Countermodel.OmegaAddOne) <| by + simpa [notModels_iff] using Countermodel.OmegaAddOne.exists_add_zero_ne_self end R0 diff --git a/Foundation/FirstOrder/Arithmetic/Schemata.lean b/Foundation/FirstOrder/Arithmetic/Schemata.lean index 6eb7e087d..837e16ee2 100644 --- a/Foundation/FirstOrder/Arithmetic/Schemata.lean +++ b/Foundation/FirstOrder/Arithmetic/Schemata.lean @@ -111,7 +111,7 @@ private lemma induction_eval {φ : Semiformula ℒₒᵣ ℕ 1} (hp : C φ) (v) (∀ x, Semiformula.Evalm V ![x] v φ → Semiformula.Evalm V ![x + 1] v φ) → ∀ x, Semiformula.Evalm V ![x] v φ := by have : V ⊧ₘ .univCl (succInd φ) := - ModelsTheory.models (T := InductionScheme _ C) V (by simpa using mem_InductionScheme_of_mem hp) + Theory.models (T := InductionScheme _ C) V (by simpa using mem_InductionScheme_of_mem hp) revert v simpa [models_iff, Semiformula.eval_univCl, succInd, Semiformula.eval_substs, Semiformula.eval_rew_q Rew.toS, Function.comp, Matrix.constant_eq_singleton] using this diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index 741b99d0f..1ab5cbfc3 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -523,6 +523,8 @@ lemma struc_models_iff_models {s : Struc L} : s ⊧ σ ↔ s.Dom↓[L] ⊧ σ := lemma models_iff : M↓[L] ⊧ σ ↔ σ.Realize M := by rfl +lemma notModels_iff : M↓[L] ⊭ σ ↔ ¬σ.Realize M := by rfl + lemma models_iff_proposition {φ : Proposition L} : M↓[L] ⊧ φ.univCl ↔ ∀ f : ℕ → M, φ.Evalf f := by simp [models_iff] diff --git a/Foundation/FirstOrder/SetTheory/Z.lean b/Foundation/FirstOrder/SetTheory/Z.lean index 973c7363a..f89dae431 100644 --- a/Foundation/FirstOrder/SetTheory/Z.lean +++ b/Foundation/FirstOrder/SetTheory/Z.lean @@ -18,7 +18,7 @@ variable {V : Type*} [SetStructure V] [Nonempty V] [V ⊧ₘ* 𝗭] /-! ## Axiom of extentionality -/ lemma mem_ext_iff {x y : V} : x = y ↔ ∀ z, z ∈ x ↔ z ∈ y := by - have := by simpa [models_iff, Axiom.extentionality] using ModelsTheory.models V Zermelo.axiom_of_extentionality + have := by simpa [models_iff, Axiom.extentionality] using Theory.models V Zermelo.axiom_of_extentionality exact this x y alias ⟨_, mem_ext⟩ := mem_ext_iff @@ -51,7 +51,7 @@ lemma SSubset.of_subset_of_not_mem_of_mem {x y z : V} (ss : x ⊆ y) (hzx : z /-! ## Axiom of empty set -/ -lemma empty_exists : ∃ e : V, IsEmpty e := by simpa [models_iff] using ModelsTheory.models V Zermelo.axiom_of_empty_set +lemma empty_exists : ∃ e : V, IsEmpty e := by simpa [models_iff] using Theory.models V Zermelo.axiom_of_empty_set lemma empty_existsUnique : ∃! e : V, IsEmpty e := by rcases empty_exists (V := V) with ⟨e, he⟩ @@ -86,7 +86,7 @@ lemma eq_empty_or_isNonempty (x : V) : x = ∅ ∨ IsNonempty x := by /-! ## Axiom of pairing -/ lemma pairing_exists : ∀ x y : V, ∃ z : V, ∀ w, w ∈ z ↔ w = x ∨ w = y := by - simpa [models_iff, Axiom.pairing] using ModelsTheory.models V Zermelo.axiom_of_pairing + simpa [models_iff, Axiom.pairing] using Theory.models V Zermelo.axiom_of_pairing lemma pairing_existsUnique (x y : V) : ∃! z : V, ∀ w, w ∈ z ↔ w = x ∨ w = y := by rcases pairing_exists x y with ⟨p, hp⟩ @@ -132,7 +132,7 @@ instance singleton.definable : ℒₛₑₜ-function₁[V] Singleton.singleton : /-! ## Axiom of union -/ lemma union_exists : ∀ x : V, ∃ y : V, ∀ z, z ∈ y ↔ ∃ w ∈ x, z ∈ w := by - simpa [models_iff, Axiom.union] using ModelsTheory.models V Zermelo.axiom_of_union + simpa [models_iff, Axiom.union] using Theory.models V Zermelo.axiom_of_union lemma union_existsUnique (x : V) : ∃! y : V, ∀ z, z ∈ y ↔ ∃ w ∈ x, z ∈ w := by rcases union_exists x with ⟨u, hu⟩ @@ -245,7 +245,7 @@ lemma pair_eq_doubleton (x y : V) : {x, y} = doubleton x y := by ext; simp /-! ## Axiom of power set -/ lemma power_exists : ∀ x : V, ∃ y : V, ∀ z, z ∈ y ↔ z ⊆ x := by - simpa [models_iff, Axiom.power] using ModelsTheory.models V Zermelo.axiom_of_power_set + simpa [models_iff, Axiom.power] using Theory.models V Zermelo.axiom_of_power_set lemma power_existsUnique (x : V) : ∃! y : V, ∀ z, z ∈ y ↔ z ⊆ x := by rcases power_exists x with ⟨p, hp⟩ @@ -280,7 +280,7 @@ lemma separation_exists_eval (x : V) (φ : Semiformula ℒₛₑₜ V 1) : ∃ y have : Inhabited V := inhabited_of_nonempty inferInstance let f := φ.enumarateFVar let ψ := (Rew.rewriteMap φ.idxOfFVar) ▹ φ - have := by simpa [models_iff, Semiformula.eval_univCl, Axiom.separationSchema] using ModelsTheory.models V (Zermelo.axiom_of_separation ψ) + have := by simpa [models_iff, Semiformula.eval_univCl, Axiom.separationSchema] using Theory.models V (Zermelo.axiom_of_separation ψ) simpa [ψ, f, Semiformula.eval_rewriteMap, Matrix.constant_eq_singleton] using this f x lemma separation_exists (x : V) (P : V → Prop) (hP : ℒₛₑₜ-predicate P) : ∃ y : V, ∀ z : V, z ∈ y ↔ z ∈ x ∧ P z := by @@ -619,7 +619,7 @@ lemma IsInductive.zero {I : V} (hI : IsInductive I) : ∅ ∈ I := hI.1 lemma IsInductive.succ {I : V} (hI : IsInductive I) {x : V} (hx : x ∈ I) : succ x ∈ I := hI.2 x hx lemma isInductive_exists : ∃ I : V, IsInductive I := by - simpa [models_iff, Axiom.infinity] using ModelsTheory.models V Zermelo.axiom_of_infinity + simpa [models_iff, Axiom.infinity] using Theory.models V Zermelo.axiom_of_infinity lemma omega_existsUnique : ∃! ω : V, ∀ x, x ∈ ω ↔ ∀ I : V, IsInductive I → x ∈ I := by rcases isInductive_exists (V := V) with ⟨I, hI⟩ @@ -729,7 +729,7 @@ lemma naturalNumber_induction (P : V → Prop) (hP : ℒₛₑₜ-predicate P) /-! ## Axiom of foundation -/ lemma foundation : ∀ x : V, [IsNonempty x] → ∃ y ∈ x, ∀ z ∈ x, z ∉ y := by - simpa [models_iff, Axiom.foundation] using ModelsTheory.models V Zermelo.axiom_of_foundation + simpa [models_iff, Axiom.foundation] using Theory.models V Zermelo.axiom_of_foundation lemma foundation' (x : V) [IsNonempty x] : ∃ y ∈ x, x ∩ y = ∅ := by rcases foundation x with ⟨y, hyx, H⟩ From aff078919cfc394153ddac4a546ae90c9745de8a Mon Sep 17 00:00:00 2001 From: palalansouki Date: Fri, 29 May 2026 03:40:24 +0900 Subject: [PATCH 05/14] definability --- .../Arithmetic/Definability/Absoluteness.lean | 64 +++++++-------- .../Definability/BoundedDefinable.lean | 54 ++++++------- .../Arithmetic/Definability/Definable.lean | 58 +++++++------- .../Arithmetic/Definability/Hierarchy.lean | 32 ++++---- .../Arithmetic/PeanoMinus/Basic.lean | 77 ++++++++++--------- .../FirstOrder/Arithmetic/PeanoMinus/Q.lean | 17 ++-- Foundation/FirstOrder/Arithmetic/Q/Basic.lean | 38 ++++----- .../Arithmetic/R0/Representation.lean | 39 +++++----- .../FirstOrder/Arithmetic/Schemata.lean | 4 +- .../FirstOrder/Arithmetic/TA/Basic.lean | 12 +-- .../FirstOrder/Arithmetic/TA/Nonstandard.lean | 30 ++++---- Foundation/FirstOrder/Basic/Operator.lean | 47 +++++------ .../FirstOrder/Basic/Semantics/Semantics.lean | 4 +- .../FirstOrder/Incompleteness/Second.lean | 4 +- Foundation/FirstOrder/Interpretation.lean | 6 +- Foundation/FirstOrder/SetTheory/Universe.lean | 4 +- 16 files changed, 249 insertions(+), 241 deletions(-) diff --git a/Foundation/FirstOrder/Arithmetic/Definability/Absoluteness.lean b/Foundation/FirstOrder/Arithmetic/Definability/Absoluteness.lean index af10365e6..96b1bf4b3 100644 --- a/Foundation/FirstOrder/Arithmetic/Definability/Absoluteness.lean +++ b/Foundation/FirstOrder/Arithmetic/Definability/Absoluteness.lean @@ -8,76 +8,78 @@ namespace LO.FirstOrder.Arithmetic open PeanoMinus R0 lemma nat_modelsWithParam_iff_models_substs {v : Fin k → ℕ} {φ : Semisentence ℒₒᵣ k} : - ℕ ⊧/v φ ↔ ℕ ⊧ₘ (φ ⇜ (fun i ↦ Semiterm.Operator.numeral ℒₒᵣ (v i))) := by - simp [models_iff] + φ.Evalb v ↔ ℕ↓[ℒₒᵣ] ⊧ (φ ⇜ (fun i ↦ Semiterm.Operator.numeral ℒₒᵣ (v i))) := by + simp [models_iff, Function.comp_def, Matrix.empty_eq] -variable (V : Type*) [ORingStructure V] [V ⊧ₘ* 𝗣𝗔⁻] +variable (V : Type*) [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] lemma modelsWithParam_iff_models_substs {v : Fin k → ℕ} {φ : Semisentence ℒₒᵣ k} : - V ⊧/(v ·) φ ↔ V ⊧ₘ (φ ⇜ (fun i ↦ Semiterm.Operator.numeral ℒₒᵣ (v i))) := by - simp [models_iff, numeral_eq_natCast] + φ.Evalb (M := V) (Nat.cast ∘ v) ↔ V↓[ℒₒᵣ] ⊧ (φ ⇜ (fun i ↦ Semiterm.Operator.numeral ℒₒᵣ (v i))) := by + simp [models_iff, Function.comp_def, Matrix.empty_eq, numeral_eq_natCast] lemma shigmaZero_absolute {k} (φ : 𝚺₀.Semisentence k) (v : Fin k → ℕ) : - ℕ ⊧/v φ.val ↔ V ⊧/(v ·) φ.val := + φ.val.Evalb v ↔ φ.val.Evalb (M := V) (Nat.cast ∘ v) := ⟨by simpa [nat_modelsWithParam_iff_models_substs, modelsWithParam_iff_models_substs] using nat_extention_sigmaOne V (by simp), by simpa [nat_modelsWithParam_iff_models_substs, modelsWithParam_iff_models_substs] using nat_extention_piOne V (by simp)⟩ lemma Defined.shigmaZero_absolute {k} {R : (Fin k → ℕ) → Prop} {R' : (Fin k → V) → Prop} {φ : 𝚺₀.Semisentence k} (hR : 𝚺₀.Defined R φ) (hR' : 𝚺₀.Defined R' φ) (v : Fin k → ℕ) : - R v ↔ R' (fun i ↦ (v i : V)) := by + R v ↔ R' (Nat.cast ∘ v) := by simpa [hR.iff, hR'.iff] using Arithmetic.shigmaZero_absolute V φ v lemma DefinedFunction.shigmaZero_absolute_func {k} {f : (Fin k → ℕ) → ℕ} {f' : (Fin k → V) → V} {φ : 𝚺₀.Semisentence (k + 1)} (hf : 𝚺₀.DefinedFunction f φ) (hf' : 𝚺₀.DefinedFunction f' φ) (v : Fin k → ℕ) : - (f v : V) = f' (fun i ↦ (v i)) := by + (f v : V) = f' (Nat.cast ∘ v) := by simpa using Defined.shigmaZero_absolute V hf hf' (f v :> v) lemma sigmaOne_upward_absolute {k} (φ : 𝚺₁.Semisentence k) (v : Fin k → ℕ) : - ℕ ⊧/v φ.val → V ⊧/(v ·) φ.val := by + φ.val.Evalb v → φ.val.Evalb (M := V) (Nat.cast ∘ v) := by simpa [nat_modelsWithParam_iff_models_substs, modelsWithParam_iff_models_substs] using nat_extention_sigmaOne V (by simp) lemma piOne_downward_absolute {k} (φ : 𝚷₁.Semisentence k) (v : Fin k → ℕ) : - V ⊧/(v ·) φ.val → ℕ ⊧/v φ.val := by + φ.val.Evalb (M := V) (Nat.cast ∘ v) → φ.val.Evalb v := by simpa [nat_modelsWithParam_iff_models_substs, modelsWithParam_iff_models_substs] using nat_extention_piOne V (by simp) lemma deltaOne_absolute {k} (φ : 𝚫₁.Semisentence k) (properNat : φ.ProperOn ℕ) (proper : φ.ProperOn V) (v : Fin k → ℕ) : - ℕ ⊧/v φ.val ↔ V ⊧/(v ·) φ.val := + φ.val.Evalb v ↔ φ.val.Evalb (M := V) (Nat.cast ∘ v) := ⟨by simpa [HierarchySymbol.Semiformula.val_sigma] using sigmaOne_upward_absolute V φ.sigma v, by simpa [proper.iff', properNat.iff'] using piOne_downward_absolute V φ.pi v⟩ lemma Defined.shigmaOne_absolute {k} {R : (Fin k → ℕ) → Prop} {R' : (Fin k → V) → Prop} {φ : 𝚫₁.Semisentence k} (hR : 𝚫₁.Defined R φ) (hR' : 𝚫₁.Defined R' φ) (v : Fin k → ℕ) : - R v ↔ R' (fun i ↦ (v i : V)) := by + R v ↔ R' (Nat.cast ∘ v) := by simpa using deltaOne_absolute V φ hR.proper hR'.proper v lemma DefinedFunction.shigmaOne_absolute_func {k} {f : (Fin k → ℕ) → ℕ} {f' : (Fin k → V) → V} {φ : 𝚺₁.Semisentence (k + 1)} (hf : 𝚺₁.DefinedFunction f φ) (hf' : 𝚺₁.DefinedFunction f' φ) (v : Fin k → ℕ) : - (f v : V) = f' (fun i ↦ (v i)) := by + (f v : V) = f' (Nat.cast ∘ v) := by simpa using Defined.shigmaOne_absolute V hf.graph_delta hf'.graph_delta (f v :> v) variable {V} lemma models_iff_of_Sigma0 {σ : Semisentence ℒₒᵣ n} (hσ : Hierarchy 𝚺 0 σ) {e : Fin n → ℕ} : - V ⊧/(e ·) σ ↔ ℕ ⊧/e σ := by - by_cases h : ℕ ⊧/e σ <;> simp [h] - · have : V ⊧/(e ·) σ := by + σ.Evalb (M := V) (Nat.cast ∘ e) ↔ σ.Evalb e := by + by_cases h : σ.Evalb e <;> simp [h] + · have : σ.Evalb (M := V) (Nat.cast ∘ e) := by simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp [Hierarchy.of_zero hσ]) h simpa [HierarchySymbol.Semiformula.val_sigma] using this - · have : ℕ ⊧/e (∼σ) := by simpa using h - have : V ⊧/(e ·) (∼σ) := by simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp [Hierarchy.of_zero hσ]) this + · have : (∼σ).Evalb (M := ℕ) e := by simpa using h + have : (∼σ).Evalb (M := V) (Nat.cast ∘ e) := by + simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp [Hierarchy.of_zero hσ]) this simpa using this lemma models_iff_of_Delta1 {σ : 𝚫₁.Semisentence n} (hσ : σ.ProperOn ℕ) (hσV : σ.ProperOn V) {e : Fin n → ℕ} : - V ⊧/(e ·) σ.val ↔ ℕ ⊧/e σ.val := by - by_cases h : ℕ ⊧/e σ.val <;> simp [h] - · have : ℕ ⊧/e σ.sigma.val := by simpa [HierarchySymbol.Semiformula.val_sigma] using h - have : V ⊧/(e ·) σ.sigma.val := by simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp) this + σ.val.Evalb (M := V) (Nat.cast ∘ e) ↔ σ.val.Evalb e := by + by_cases h : σ.val.Evalb e <;> simp [h] + · have : σ.sigma.val.Evalb e := by simpa [HierarchySymbol.Semiformula.val_sigma] using h + have : σ.sigma.val.Evalb (M := V) (Nat.cast ∘ e) := by simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp) this simpa [HierarchySymbol.Semiformula.val_sigma] using this - · have : ℕ ⊧/e (∼σ.pi.val) := by simpa [hσ.iff'] using h - have : V ⊧/(e ·) (∼σ.pi.val) := by simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp) this + · have : (∼σ.pi.val).Evalb (M := ℕ) e := by simpa [hσ.iff'] using h + have : (∼σ.pi.val).Evalb (M := V) (Nat.cast ∘ e) := by + simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp) this simpa [hσV.iff'] using this variable {T : ArithmeticTheory} [𝗣𝗔⁻ ⪯ T] [T.SoundOnHierarchy 𝚺 1] @@ -86,21 +88,21 @@ noncomputable instance : 𝗥₀ ⪯ T := Entailment.WeakerThan.trans (𝓣 := theorem sigma_one_completeness_iff_param {σ : Semisentence ℒₒᵣ n} (hσ : Hierarchy 𝚺 1 σ) {e : Fin n → ℕ} : ℕ ⊧/e σ ↔ T ⊢ (σ ⇜ fun x ↦ Semiterm.Operator.numeral ℒₒᵣ (e x)) := Iff.trans - (by simp [models_iff, Semiformula.eval_substs]) + (by simp [models_iff, Semiformula.eval_substs, Function.comp_def, Matrix.empty_eq]) (sigma_one_completeness_iff (T := T) (by simp [hσ])) -lemma models_iff_provable_of_Sigma0_param [V ⊧ₘ* T] {σ : Semisentence ℒₒᵣ n} (hσ : Hierarchy 𝚺 0 σ) {e : Fin n → ℕ} : - V ⊧/(e ·) σ ↔ T ⊢ (σ ⇜ fun x ↦ Semiterm.Operator.numeral ℒₒᵣ (e x)) := by +lemma models_iff_provable_of_Sigma0_param [V↓[ℒₒᵣ] ⊧* T] {σ : Semisentence ℒₒᵣ n} (hσ : Hierarchy 𝚺 0 σ) {e : Fin n → ℕ} : + V ⊧/(Nat.cast ∘ e) σ ↔ T ⊢ (σ ⇜ fun x ↦ Semiterm.Operator.numeral ℒₒᵣ (e x)) := by calc - V ⊧/(e ·) σ ↔ ℕ ⊧/e σ := by + V ⊧/(Nat.cast ∘ e) σ ↔ ℕ ⊧/e σ := by simp [models_iff_of_Sigma0 hσ] _ ↔ T ⊢ (σ ⇜ fun x ↦ Semiterm.Operator.numeral ℒₒᵣ (e x)) := by apply sigma_one_completeness_iff_param (by simp [Hierarchy.of_zero hσ]) -lemma models_iff_provable_of_Delta1_param [V ⊧ₘ* T] {σ : 𝚫₁.Semisentence n} (hσ : σ.ProperOn ℕ) (hσV : σ.ProperOn V) {e : Fin n → ℕ} : - V ⊧/(e ·) σ.val ↔ T ⊢ (σ.val ⇜ fun x ↦ Semiterm.Operator.numeral ℒₒᵣ (e x)) := by +lemma models_iff_provable_of_Delta1_param [V↓[ℒₒᵣ] ⊧* T] {σ : 𝚫₁.Semisentence n} (hσ : σ.ProperOn ℕ) (hσV : σ.ProperOn V) {e : Fin n → ℕ} : + V ⊧/(Nat.cast ∘ e) σ.val ↔ T ⊢ (σ.val ⇜ fun x ↦ Semiterm.Operator.numeral ℒₒᵣ (e x)) := by calc - V ⊧/(e ·) σ.val ↔ ℕ ⊧/e σ.val := by + V ⊧/(Nat.cast ∘ e) σ.val ↔ ℕ ⊧/e σ.val := by simp [models_iff_of_Delta1 hσ hσV] _ ↔ ℕ ⊧/e σ.sigma.val := by simp [HierarchySymbol.Semiformula.val_sigma] diff --git a/Foundation/FirstOrder/Arithmetic/Definability/BoundedDefinable.lean b/Foundation/FirstOrder/Arithmetic/Definability/BoundedDefinable.lean index 4b9502407..6d3124deb 100644 --- a/Foundation/FirstOrder/Arithmetic/Definability/BoundedDefinable.lean +++ b/Foundation/FirstOrder/Arithmetic/Definability/BoundedDefinable.lean @@ -16,7 +16,7 @@ variable {ℌ : HierarchySymbol} {Γ Γ' : SigmaPiDelta} variable (ℌ) class Bounded (f : (Fin k → V) → V) : Prop where - bounded : ∃ t : Semiterm ℒₒᵣ V k, ∀ v : Fin k → V, f v ≤ t.valm V v id + bounded : ∃ t : Semiterm ℒₒᵣ V k, ∀ v : Fin k → V, f v ≤ t.val v id abbrev Bounded₁ (f : V → V) : Prop := Bounded (k := 1) (fun v ↦ f (v 0)) @@ -32,23 +32,23 @@ variable {ℌ} namespace Bounded -@[simp] lemma var [V ⊧ₘ* 𝗣𝗔⁻] {k} (i : Fin k) : Bounded fun v : Fin k → V ↦ v i := ⟨#i, by intro _; simp⟩ +@[simp] lemma var [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {k} (i : Fin k) : Bounded fun v : Fin k → V ↦ v i := ⟨#i, by intro _; simp⟩ -@[simp] lemma const [V ⊧ₘ* 𝗣𝗔⁻] {k} (c : V) : Bounded (fun _ : Fin k → V ↦ c) := ⟨&c, by intro _; simp⟩ +@[simp] lemma const [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {k} (c : V) : Bounded (fun _ : Fin k → V ↦ c) := ⟨&c, by intro _; simp⟩ -@[simp] lemma term_retraction [V ⊧ₘ* 𝗣𝗔⁻] (t : Semiterm ℒₒᵣ V n) (e : Fin n → Fin k) : - Bounded fun v : Fin k → V ↦ Semiterm.valm V (fun x ↦ v (e x)) id t := - ⟨Rew.subst (fun x ↦ #(e x)) t, by intro _; simp [Semiterm.val_substs]⟩ +@[simp] lemma term_retraction [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] (t : Semiterm ℒₒᵣ V n) (e : Fin n → Fin k) : + Bounded fun v : Fin k → V ↦ t.val (fun x ↦ v (e x)) id := + ⟨Rew.subst (fun x ↦ #(e x)) t, by intro _; simp [Semiterm.val_substs, Function.comp_def]⟩ -@[simp] lemma term [V ⊧ₘ* 𝗣𝗔⁻] (t : Semiterm ℒₒᵣ V k) : Bounded fun v : Fin k → V => Semiterm.valm V v id t := +@[simp] lemma term [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] (t : Semiterm ℒₒᵣ V k) : Bounded fun v : Fin k → V => t.val v id := ⟨t, by intro _; simp⟩ lemma retraction {f : (Fin k → V) → V} (hf : Bounded f) (e : Fin k → Fin n) : Bounded fun v ↦ f (fun i ↦ v (e i)) := by rcases hf with ⟨t, ht⟩ - exact ⟨Rew.subst (fun x ↦ #(e x)) t, by intro; simp [Semiterm.val_substs, ht]⟩ + exact ⟨Rew.subst (fun x ↦ #(e x)) t, by intro _; simp [Semiterm.val_substs, Function.comp_def, ht]⟩ -lemma comp [V ⊧ₘ* 𝗣𝗔⁻] {k} {f : (Fin l → V) → V} {g : Fin l → (Fin k → V) → V} (hf : Bounded f) (hg : ∀ i, Bounded (g i)) : +lemma comp [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {k} {f : (Fin l → V) → V} {g : Fin l → (Fin k → V) → V} (hf : Bounded f) (hg : ∀ i, Bounded (g i)) : Bounded (fun v ↦ f (g · v)) where bounded := by rcases hf.bounded with ⟨tf, htf⟩ @@ -60,14 +60,14 @@ lemma comp [V ⊧ₘ* 𝗣𝗔⁻] {k} {f : (Fin l → V) → V} {g : Fin l → end Bounded -lemma Bounded₁.comp [V ⊧ₘ* 𝗣𝗔⁻] {f : V → V} {k} {g : (Fin k → V) → V} (hf : Bounded₁ f) (hg : Bounded g) : +lemma Bounded₁.comp [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {f : V → V} {k} {g : (Fin k → V) → V} (hf : Bounded₁ f) (hg : Bounded g) : Bounded (fun v ↦ f (g v)) := Bounded.comp hf (l := 1) (fun _ ↦ hg) -lemma Bounded₂.comp [V ⊧ₘ* 𝗣𝗔⁻] {f : V → V → V} {k} {g₁ g₂ : (Fin k → V) → V} +lemma Bounded₂.comp [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {f : V → V → V} {k} {g₁ g₂ : (Fin k → V) → V} (hf : Bounded₂ f) (hg₁ : Bounded g₁) (hg₂ : Bounded g₂) : Bounded (fun v ↦ f (g₁ v) (g₂ v)) := Bounded.comp hf (g := ![g₁, g₂]) (fun i ↦ by cases i using Fin.cases <;> simp [*]) -lemma Bounded₃.comp [V ⊧ₘ* 𝗣𝗔⁻] {f : V → V → V → V} {k} {g₁ g₂ g₃ : (Fin k → V) → V} +lemma Bounded₃.comp [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {f : V → V → V → V} {k} {g₁ g₂ g₃ : (Fin k → V) → V} (hf : Bounded₃ f) (hg₁ : Bounded g₁) (hg₂ : Bounded g₂) (hg₃ : Bounded g₃) : Bounded (fun v ↦ f (g₁ v) (g₂ v) (g₃ v)) := Bounded.comp hf (g := ![g₁, g₂, g₃]) (fun i ↦ by @@ -76,7 +76,7 @@ lemma Bounded₃.comp [V ⊧ₘ* 𝗣𝗔⁻] {f : V → V → V → V} {k} {g namespace Bounded₂ -variable [V ⊧ₘ* 𝗣𝗔⁻] +variable [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] instance add : Bounded₂ ((· + ·) : V → V → V) where bounded := ⟨‘x y. x + y’, by intro _; simp⟩ @@ -137,7 +137,7 @@ end DefinableBoundedFunction namespace HierarchySymbol.Definable -variable [V ⊧ₘ* 𝗣𝗔⁻] +variable [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] variable {P Q : (Fin k → V) → Prop} @@ -145,10 +145,10 @@ lemma ball_blt {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : DefinableBoundedFunction f) (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) : ℌ.Definable fun v ↦ ∀ x < f v, P v x := by rcases hf.bounded with ⟨bf, hbf⟩ - have : ℌ.Definable fun v ↦ ∃ x ≤ Semiterm.valm V v id bf, x = f v ∧ ∀ y < x, P v y := by + have : ℌ.Definable fun v ↦ ∃ x ≤ bf.val v id, x = f v ∧ ∀ y < x, P v y := by apply bexs'; apply and · exact hf.definable - · suffices ℌ.Definable fun x ↦ ∀ y < Semiterm.valm (L := ℒₒᵣ) V x id (#0), P (fun x_1 ↦ x x_1.succ) y by simpa + · suffices ℌ.Definable fun x ↦ ∀ y < (#0).val (L := ℒₒᵣ) x id, P (fun x_1 ↦ x x_1.succ) y by simpa apply ball ?_ #0 simpa using h.retraction (0 :> (·.succ.succ)) exact this.of_iff <| fun v ↦ ⟨fun h ↦ ⟨f v, hbf v, rfl, h⟩, by rintro ⟨y, hy, rfl, h⟩; exact h⟩ @@ -157,10 +157,10 @@ lemma bexs_blt {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : DefinableBoundedFunction f) (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) : ℌ.Definable fun v ↦ ∃ x < f v, P v x := by rcases hf.bounded with ⟨bf, hbf⟩ - have : ℌ.Definable fun v ↦ ∃ x ≤ Semiterm.valm V v id bf, x = f v ∧ ∃ y < x, P v y := by + have : ℌ.Definable fun v ↦ ∃ x ≤ bf.val v id, x = f v ∧ ∃ y < x, P v y := by apply bexs'; apply and · exact hf.definable - · suffices ℌ.Definable fun x ↦ ∃ y < Semiterm.valm (L := ℒₒᵣ) V x id (#0), P (fun x_1 ↦ x x_1.succ) y by simpa + · suffices ℌ.Definable fun x ↦ ∃ y < (#0).val (L := ℒₒᵣ) x id, P (fun x_1 ↦ x x_1.succ) y by simpa apply bexs ?_ #0 simpa using h.retraction (0 :> (·.succ.succ)) exact this.of_iff <| fun v ↦ ⟨fun h ↦ ⟨f v, hbf v, rfl, h⟩, by rintro ⟨y, hy, rfl, h⟩; exact h⟩ @@ -169,10 +169,10 @@ lemma ball_ble {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : DefinableBoundedFunction f) (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) : ℌ.Definable fun v ↦ ∀ x ≤ f v, P v x := by rcases hf.bounded with ⟨bf, hbf⟩ - have : ℌ.Definable fun v ↦ ∃ x ≤ Semiterm.valm V v id bf, x = f v ∧ ∀ y ≤ x, P v y := by + have : ℌ.Definable fun v ↦ ∃ x ≤ bf.val v id, x = f v ∧ ∀ y ≤ x, P v y := by apply bexs'; apply and · exact hf.definable - · suffices ℌ.Definable fun x ↦ ∀ y ≤ Semiterm.valm (L := ℒₒᵣ) V x id (#0), P (fun x_1 ↦ x x_1.succ) y by simpa + · suffices ℌ.Definable fun x ↦ ∀ y ≤ (#0).val (L := ℒₒᵣ) x id, P (fun x_1 ↦ x x_1.succ) y by simpa apply ball' ?_ #0 simpa using h.retraction (0 :> (·.succ.succ)) exact this.of_iff <| fun v ↦ ⟨fun h ↦ ⟨f v, hbf v, rfl, h⟩, by rintro ⟨y, hy, rfl, h⟩; exact h⟩ @@ -181,10 +181,10 @@ lemma bexs_ble {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : DefinableBoundedFunction f) (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) : ℌ.Definable fun v ↦ ∃ x ≤ f v, P v x := by rcases hf.bounded with ⟨bf, hbf⟩ - have : ℌ.Definable fun v ↦ ∃ x ≤ Semiterm.valm V v id bf, x = f v ∧ ∃ y ≤ x, P v y := by + have : ℌ.Definable fun v ↦ ∃ x ≤ bf.val v id, x = f v ∧ ∃ y ≤ x, P v y := by apply bexs'; apply and · exact hf.definable - · suffices ℌ.Definable fun x ↦ ∃ y ≤ Semiterm.valm (L := ℒₒᵣ) V x id (#0), P (fun x_1 ↦ x x_1.succ) y by simpa + · suffices ℌ.Definable fun x ↦ ∃ y ≤ (#0).val (L := ℒₒᵣ) x id, P (fun x_1 ↦ x x_1.succ) y by simpa apply bexs' ?_ #0 simpa using h.retraction (0 :> (·.succ.succ)) exact this.of_iff <| fun v ↦ ⟨fun h ↦ ⟨f v, hbf v, rfl, h⟩, by rintro ⟨y, hy, rfl, h⟩; exact h⟩ @@ -249,17 +249,17 @@ lemma of_iff {f g : (Fin k → V) → V} (H : DefinableBoundedFunction f) (h : have : f = g := by funext v; simp [h] rcases this; exact H -variable [V ⊧ₘ* 𝗣𝗔⁻] +variable [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] @[simp] lemma var {k} (i : Fin k) : DefinableBoundedFunction (fun v : Fin k → V ↦ v i) := ⟨by simp, by simp⟩ @[simp] lemma const {k} (c : V) : DefinableBoundedFunction (fun _ : Fin k → V ↦ c) := ⟨by simp, by simp⟩ @[simp] lemma term_retraction (t : Semiterm ℒₒᵣ V n) (e : Fin n → Fin k) : - DefinableBoundedFunction fun v : Fin k → V ↦ Semiterm.valm V (fun x ↦ v (e x)) id t := ⟨by simp, by simp⟩ + DefinableBoundedFunction fun v : Fin k → V ↦ t.val (fun x ↦ v (e x)) id := ⟨by simp, by simp⟩ @[simp] lemma term (t : Semiterm ℒₒᵣ V k) : - DefinableBoundedFunction fun v : Fin k → V ↦ Semiterm.valm V v id t := ⟨by simp, by simp⟩ + DefinableBoundedFunction fun v : Fin k → V ↦ t.val v id := ⟨by simp, by simp⟩ end DefinableBoundedFunction @@ -267,7 +267,7 @@ namespace HierarchySymbol.Definable open DefinableBoundedFunction -variable [V ⊧ₘ* 𝗣𝗔⁻] +variable [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] lemma bcomp₁ {k} {P : V → Prop} {f : (Fin k → V) → V} [hP : ℌ.DefinablePred P] (hf : DefinableBoundedFunction f) : ℌ.Definable fun v ↦ P (f v) := @@ -313,7 +313,7 @@ lemma bcomp₄_zero {k} {R : V → V → V → V → Prop} {f₁ f₂ f₃ f₄ end HierarchySymbol.Definable -variable [V ⊧ₘ* 𝗣𝗔⁻] +variable [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] lemma HierarchySymbol.DefinableFunction.bcomp {k} {F : (Fin l → V) → V} {f : Fin l → (Fin k → V) → V} (hF : ℌ.DefinableFunction F) (hf : ∀ i, DefinableBoundedFunction (f i)) : diff --git a/Foundation/FirstOrder/Arithmetic/Definability/Definable.lean b/Foundation/FirstOrder/Arithmetic/Definability/Definable.lean index 00b3fc939..dc91ab5f4 100644 --- a/Foundation/FirstOrder/Arithmetic/Definability/Definable.lean +++ b/Foundation/FirstOrder/Arithmetic/Definability/Definable.lean @@ -186,13 +186,14 @@ lemma df {R : (Fin k → V) → Prop} {φ : ℌ.Semisentence k} (h : Defined R @[simp] lemma proper {R : (Fin k → V) → Prop} {m} {φ : 𝚫-[m].Semisentence k} [h : Defined R φ] : φ.ProperOn V := h.defined.1 @[simp] lemma iff {R : (Fin k → V) → Prop} {φ : ℌ.Semisentence k} [h : Defined R φ] : - Semiformula.Evalbm V v φ.val ↔ R v := h.df _ + φ.val.Evalb v ↔ R v := h.df _ @[simp] lemma iff_delta_pi {R : (Fin k → V) → Prop} {φ : (𝚫-[m]).Semisentence k} [h : Defined R φ] : - Semiformula.Evalbm V v φ.pi.val ↔ R v := by simp [h.proper.iff'] + φ.pi.val.Evalb v ↔ R v := by + simp [h.proper.iff'] @[simp] lemma iff_delta_sigma {R : (Fin k → V) → Prop} {φ : (𝚫-[m]).Semisentence k} [h : Defined R φ] : - Semiformula.Evalbm V v φ.sigma.val ↔ R v := by simp [h.proper.iff] + φ.sigma.val.Evalb v ↔ R v := by simp [h.proper.iff] lemma of_zero {R : (Fin k → V) → Prop} {φ : 𝚺₀.Semisentence k} (h : Defined R φ) : Defined R (φ.ofZero ℌ) := Defined.mk <| match ℌ with @@ -244,7 +245,7 @@ lemma df {R : (Fin k → V) → Prop} {φ : ℌ.Semiformula V k} (h : IsDefinedB | 𝚫-[_] => h.2 lemma iff {R : (Fin k → V) → Prop} {φ : ℌ.Semiformula V k} (h : IsDefinedByWithParam R φ) {v} : - Semiformula.Evalm V v id φ.val ↔ R v := h.df _ + φ.val.Eval v id ↔ R v := h.df _ lemma proper {R : (Fin k → V) → Prop} {m} {φ : 𝚫-[m].Semiformula V k} (h : IsDefinedByWithParam R φ) : φ.ProperWithParamOn V := h.1 @@ -258,7 +259,7 @@ namespace DefinableRel @[simp] instance lt : ℌ.DefinableRel (LT.lt : V → V → Prop) := Defined.to_definable₀ (φ := .mkSigma “#0 < #1”) ⟨by intro _; simp⟩ -@[simp] instance le [V ⊧ₘ* 𝗣𝗔⁻] : ℌ.DefinableRel (LE.le : V → V → Prop) := +@[simp] instance le [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] : ℌ.DefinableRel (LE.le : V → V → Prop) := Defined.to_definable₀ (φ := .mkSigma “#0 ≤ #1”) ⟨by intro _; simp⟩ end DefinableRel @@ -277,13 +278,13 @@ namespace DefinableFunction₂ @[simp] instance hMul : ℌ.DefinableFunction₂ (HMul.hMul : V → V → V) := Defined.to_definable₀ (φ := .mkSigma “#0 = #1 * #2”) ⟨by intro _; simp⟩ -@[simp] protected instance sq [V ⊧ₘ* 𝗣𝗔⁻] : ℌ.DefinableFunction₁ fun x : V ↦ x^2 := +@[simp] protected instance sq [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] : ℌ.DefinableFunction₁ fun x : V ↦ x^2 := Defined.to_definable₀ (φ := .mkSigma “#0 = #1 * #1”) ⟨by intro _; simp [sq]⟩ -@[simp] instance pow3 [V ⊧ₘ* 𝗣𝗔⁻] : ℌ.DefinableFunction₁ fun x : V ↦ x^3 := +@[simp] instance pow3 [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] : ℌ.DefinableFunction₁ fun x : V ↦ x^3 := Defined.to_definable₀ (φ := .mkSigma “#0 = #1 * #1 * #1”) ⟨by intro _; simp [Arithmetic.pow_three]⟩ -@[simp] instance pow4 [V ⊧ₘ* 𝗣𝗔⁻] : ℌ.DefinableFunction₁ fun x : V ↦ x^4 := +@[simp] instance pow4 [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] : ℌ.DefinableFunction₁ fun x : V ↦ x^4 := Defined.to_definable₀ (φ := .mkSigma “#0 = #1 * #1 * #1 * #1”) ⟨by intro _; simp [pow_four]⟩ end DefinableFunction₂ @@ -293,7 +294,7 @@ namespace Definable lemma mk' {ℌ : HierarchySymbol} (φ : ℌ.Semiformula V k) (H : IsDefinedByWithParam P φ) : ℌ.Definable P := ⟨φ, H⟩ lemma mkPolarity {Γ : Polarity} - (φ : Semiformula ℒₒᵣ V k) (hp : Hierarchy Γ m φ) (hP : ∀ v, P v ↔ Semiformula.Evalm V v id φ) : Γ-[m].Definable P := + (φ : Semiformula ℒₒᵣ V k) (hp : Hierarchy Γ m φ) (hP : ∀ v, P v ↔ φ.Eval v id) : Γ-[m].Definable P := match Γ with | 𝚺 => ⟨.mkSigma φ hp, by intro v; simp [hP]⟩ | 𝚷 => ⟨.mkPi φ hp, by intro v; simp [hP]⟩ @@ -344,16 +345,16 @@ lemma retraction (h : ℌ.Definable P) (f : Fin k → Fin l) : rcases h with ⟨φ, h⟩ apply Definable.mk' (φ.rew <| Rew.subst fun x ↦ #(f x)) match ℌ with - | 𝚺-[_] | 𝚷-[_] => intro; simp [h.iff] - | 𝚫-[_] => exact ⟨h.proper.rew _, by intro; simp [h.iff]⟩ + | 𝚺-[_] | 𝚷-[_] => intro; simp [h.iff, Function.comp_def] + | 𝚫-[_] => exact ⟨h.proper.rew _, by intro; simp [h.iff, Function.comp_def]⟩ lemma retractiont (h : ℌ.Definable P) (f : Fin k → Semiterm ℒₒᵣ V n) : - ℌ.Definable fun v ↦ P (fun i ↦ Semiterm.valm V v id (f i)) := by + ℌ.Definable fun v ↦ P (fun i ↦ (f i).val v id) := by rcases h with ⟨φ, h⟩ exact ⟨φ.rew (Rew.subst f), match ℌ with - | 𝚺-[_] | 𝚷-[_] => by intro; simp [h.df.iff] - | 𝚫-[_] => ⟨h.proper.rew _, by intro; simp [h.df.iff]⟩⟩ + | 𝚺-[_] | 𝚷-[_] => by intro; simp [h.df.iff, Function.comp_def] + | 𝚫-[_] => ⟨h.proper.rew _, by intro; simp [h.df.iff, Function.comp_def]⟩⟩ @[simp] instance const {P : Prop} : ℌ.Definable (fun _ : Fin k → V ↦ P) := by by_cases hP : P @@ -420,7 +421,7 @@ lemma biconditional (h₁ : 𝚫-[m].Definable P) (h₂ : 𝚫-[m].Definable Q) .of_delta <| ((h₁.impDelta h₂).and (h₂.impDelta h₁)).of_iff <| by intro v; simp [iff_iff_implies_and_implies] lemma ball {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) (t : Semiterm ℒₒᵣ V k) : - ℌ.Definable fun v ↦ ∀ x < t.valm V v id, P v x := by + ℌ.Definable fun v ↦ ∀ x < t.val v id, P v x := by rcases h with ⟨φ, h⟩ match ℌ with | 𝚺-[m] => exact ⟨HierarchySymbol.Semiformula.ball t φ, by intro v; simp [h.iff]⟩ @@ -428,20 +429,20 @@ lemma ball {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w | 𝚫-[m] => exact ⟨HierarchySymbol.Semiformula.ball t φ, ⟨h.proper.ball, by intro v; simp [h.iff]⟩⟩ lemma bexs {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) (t : Semiterm ℒₒᵣ V k) : - ℌ.Definable fun v ↦ ∃ x < t.valm V v id, P v x := by + ℌ.Definable fun v ↦ ∃ x < t.val v id, P v x := by rcases h with ⟨φ, h⟩ match ℌ with | 𝚺-[m] => exact ⟨HierarchySymbol.Semiformula.bexs t φ, by intro v; simp [h.iff]⟩ | 𝚷-[m] => exact ⟨HierarchySymbol.Semiformula.bexs t φ, by intro v; simp [h.iff]⟩ | 𝚫-[m] => exact ⟨HierarchySymbol.Semiformula.bexs t φ, ⟨h.proper.bexs, by intro v; simp [h.iff]⟩⟩ -lemma ball' [V ⊧ₘ* 𝗣𝗔⁻] {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) (t : Semiterm ℒₒᵣ V k) : - ℌ.Definable fun v ↦ ∀ x ≤ t.valm V v id, P v x := by +lemma ball' [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) (t : Semiterm ℒₒᵣ V k) : + ℌ.Definable fun v ↦ ∀ x ≤ t.val v id, P v x := by apply (ball h ‘!!t + 1’).of_iff intro v; simp [lt_succ_iff_le] -lemma bexs' [V ⊧ₘ* 𝗣𝗔⁻] {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) (t : Semiterm ℒₒᵣ V k) : - ℌ.Definable fun v ↦ ∃ x ≤ t.valm V v id, P v x := by +lemma bexs' [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) (t : Semiterm ℒₒᵣ V k) : + ℌ.Definable fun v ↦ ∃ x ≤ t.val v id, P v x := by apply (bexs h ‘!!t + 1’).of_iff intro v; simp [lt_succ_iff_le] @@ -705,13 +706,14 @@ lemma of_sigmaOne .of_zero (Γ' := 𝚺) ⟨.mkSigma “x. #0 = &c”, by intro v; simp⟩ @[simp] lemma term_retraction (t : Semiterm ℒₒᵣ V n) (e : Fin n → Fin k) : - ℌ.DefinableFunction fun v : Fin k → V ↦ Semiterm.valm V (fun x ↦ v (e x)) id t := + ℌ.DefinableFunction fun v : Fin k → V ↦ t.val (fun x ↦ v (e x)) id := .of_zero (Γ' := 𝚺) - ⟨.mkSigma “x. x = !!(Rew.subst (fun x ↦ #(e x).succ) t)”, by intro v; simp [Semiterm.val_substs]⟩ + ⟨.mkSigma “x. x = !!(Rew.subst (fun x ↦ #(e x).succ) t)”, fun v ↦ by + simp [Semiterm.val_substs, Function.comp_def]⟩ @[simp] lemma term (t : Semiterm ℒₒᵣ V k) : - ℌ.DefinableFunction fun v : Fin k → V ↦ Semiterm.valm V v id t := - .of_zero (Γ' := 𝚺) ⟨.mkSigma “x. x = !!(Rew.bShift t)”, by intro v; simp [Semiterm.val_bShift']⟩ + ℌ.DefinableFunction fun v : Fin k → V ↦ t.val v id := + .of_zero (Γ' := 𝚺) ⟨.mkSigma “x. x = !!(Rew.bShift t)”, fun v ↦ by simp [Semiterm.val_bShift']⟩ lemma of_eq (g) (h : ∀ v, f v = g v) (H : ℌ.DefinableFunction f) : ℌ.DefinableFunction g := by rwa [show g = f from by funext v; simp [h]] @@ -723,7 +725,7 @@ lemma retraction {n} (hf : ℌ.DefinableFunction f) (e : Fin k → Fin n) : this.of_iff (by intro x; simp) lemma retractiont {n} (hf : ℌ.DefinableFunction f) (t : Fin k → Semiterm ℒₒᵣ V n) : - ℌ.DefinableFunction fun v ↦ f (fun i ↦ Semiterm.valm V v id (t i)) := + ℌ.DefinableFunction fun v ↦ f (fun i ↦ (t i).val v id) := have := Definable.retractiont (n := n + 1) hf (#0 :> fun i ↦ Rew.bShift (t i)) this.of_iff (by intro x; simp [Semiterm.val_bShift']) @@ -818,13 +820,13 @@ lemma bexs_lt {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} ⟨ .mkPi (∀⁰ (bf.val 🡒 (∃⁰[“#0 < #1”] φ.pi.val ⇜ (#0 :> (#·.succ.succ))))) (by simp), by intro v; simp [hbf.df.iff, hp.df.iff, hp.proper.iff'] ⟩ -lemma ball_le [V ⊧ₘ* 𝗣𝗔⁻] {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} +lemma ball_le [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : 𝚺-[m + 1].DefinableFunction f) (h : Γ-[m + 1].Definable (fun w ↦ P (w ·.succ) (w 0))) : Γ-[m + 1].Definable (fun v ↦ ∀ x ≤ f v, P v x) := by have : Γ-[m + 1].Definable (fun v ↦ ∀ x < f v + 1, P v x) := ball_lt (DefinableFunction₂.comp hf (by simp)) h exact this.of_iff <| by intro v; simp [lt_succ_iff_le] -lemma bexs_le [V ⊧ₘ* 𝗣𝗔⁻] {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} +lemma bexs_le [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : 𝚺-[m + 1].DefinableFunction f) (h : Γ-[m + 1].Definable (fun w ↦ P (w ·.succ) (w 0))) : Γ-[m + 1].Definable (fun v ↦ ∃ x ≤ f v, P v x) := by have : Γ-[m + 1].Definable (fun v ↦ ∃ x < f v + 1, P v x) := bexs_lt (DefinableFunction₂.comp hf (by simp)) h @@ -834,7 +836,7 @@ lemma ball_lt' {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : 𝚺-[m + 1].DefinableFunction f) (h : Γ-[m + 1].Definable (fun w ↦ P (w ·.succ) (w 0))) : Γ-[m + 1].Definable (fun v ↦ ∀ {x}, x < f v → P v x) := ball_lt hf h -lemma ball_le' [V ⊧ₘ* 𝗣𝗔⁻] {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} +lemma ball_le' [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : 𝚺-[m + 1].DefinableFunction f) (h : Γ-[m + 1].Definable (fun w ↦ P (w ·.succ) (w 0))) : Γ-[m + 1].Definable (fun v ↦ ∀ {x}, x ≤ f v → P v x) := ball_le hf h diff --git a/Foundation/FirstOrder/Arithmetic/Definability/Hierarchy.lean b/Foundation/FirstOrder/Arithmetic/Definability/Hierarchy.lean index b06ee6243..fa974206d 100644 --- a/Foundation/FirstOrder/Arithmetic/Definability/Hierarchy.lean +++ b/Foundation/FirstOrder/Arithmetic/Definability/Hierarchy.lean @@ -130,10 +130,10 @@ variable {M : Type*} [ORingStructure M] variable (M) def ProperOn (φ : 𝚫-[m].Semisentence n) : Prop := - ∀ (e : Fin n → M), Semiformula.Evalbm M e φ.sigma.val ↔ Semiformula.Evalbm M e φ.pi.val + ∀ (e : Fin n → M), φ.sigma.val.Evalb e ↔ φ.pi.val.Evalb e def ProperWithParamOn (φ : 𝚫-[m].Semiformula M n) : Prop := - ∀ (e : Fin n → M), Semiformula.Evalm M e id φ.sigma.val ↔ Semiformula.Evalm M e id φ.pi.val + ∀ (e : Fin n → M), φ.sigma.val.Eval e id ↔ φ.pi.val.Eval e id def ProvablyProperOn (φ : 𝚫-[m].Semisentence n) (T : Theory ℒₒᵣ) : Prop := T ⊢ ∀⁰* “!φ.sigma.val ⋯ ↔ !φ.pi.val ⋯” @@ -142,19 +142,19 @@ variable {M} lemma ProperOn.iff {φ : 𝚫-[m].Semisentence n} (h : φ.ProperOn M) (e : Fin n → M) : - Semiformula.Evalbm M e φ.sigma.val ↔ Semiformula.Evalbm M e φ.pi.val := h e + φ.sigma.val.Evalb e ↔ φ.pi.val.Evalb e := h e lemma ProperWithParamOn.iff {φ : 𝚫-[m].Semiformula M n} (h : φ.ProperWithParamOn M) (e : Fin n → M) : - Semiformula.Evalm M e id φ.sigma.val ↔ Semiformula.Evalm (L := ℒₒᵣ) M e id φ.pi.val := h e + φ.sigma.val.Eval e id ↔ φ.pi.val.Eval e id := h e lemma ProperOn.iff' {φ : 𝚫-[m].Semisentence n} (h : φ.ProperOn M) (e : Fin n → M) : - Semiformula.Evalbm M e φ.pi.val ↔ Semiformula.Evalbm M e φ.val := by simp [←h.iff, val_sigma] + φ.pi.val.Evalb e ↔ φ.val.Evalb e := by simp [←h.iff, val_sigma] lemma ProperWithParamOn.iff' {φ : 𝚫-[m].Semiformula M n} (h : φ.ProperWithParamOn M) (e : Fin n → M) : - Semiformula.Evalm M e id φ.pi.val ↔ Semiformula.Evalm (L := ℒₒᵣ) M e id φ.val := by simp [←h.iff, val_sigma] + φ.pi.val.Eval e id ↔ φ.val.Eval e id := by simp [←h.iff, val_sigma] inductive ProvablyProperOn' (T : Theory ℒₒᵣ) : {Γ : HierarchySymbol} → {n : ℕ} → (φ : Γ.Semisentence n) → Prop | sigma (φ : 𝚺-[m].Semisentence n) : φ.ProvablyProperOn' T @@ -165,9 +165,9 @@ section ProvablyProperOn variable (T : Theory ℒₒᵣ) -lemma ProvablyProperOn.ofProperOn [𝗘𝗤 ⪯ T] {φ : 𝚫-[m].Semisentence n} - (h : ∀ (M : Type w) [ORingStructure M] [M ⊧ₘ* T], φ.ProperOn M) : φ.ProvablyProperOn T := by - apply FirstOrder.Arithmetic.provable_of_models.{w} T _ ?_ +lemma ProvablyProperOn.ofProperOn [𝗘𝗤 ℒₒᵣ ⪯ T] {φ : 𝚫-[m].Semisentence n} + (h : ∀ (M : Type w) [ORingStructure M] [M↓[ℒₒᵣ] ⊧* T], φ.ProperOn M) : φ.ProvablyProperOn T := by + apply FirstOrder.Arithmetic.complete.{w} T _ ?_ intro M _ _ simpa [models_iff] using (h M).iff @@ -175,9 +175,9 @@ variable {T} lemma ProvablyProperOn.properOn {φ : 𝚫-[m].Semisentence n} (h : φ.ProvablyProperOn T) - (M : Type w) [ORingStructure M] [M ⊧ₘ* T] : φ.ProperOn M := by + (M : Type w) [ORingStructure M] [M↓[ℒₒᵣ] ⊧* T] : φ.ProperOn M := by intro v - have := by simpa [models_iff] using consequence_iff.mp (sound! h) M inferInstance + have := by simpa [models_iff] using consequence_iff.mp (Theory.Proof.sound h) M inferInstance exact this v end ProvablyProperOn @@ -357,8 +357,8 @@ lemma ProperOn.or {φ ψ : 𝚫-[m].Semisentence k} (hp : φ.ProperOn M) (hq : lemma ProperOn.neg {φ : 𝚫-[m].Semisentence k} (hp : φ.ProperOn M) : (∼φ).ProperOn M := by intro e; simp [hp.iff] -lemma ProperOn.eval_neg {φ : 𝚫-[m].Semisentence k} (hp : φ.ProperOn M) (e) : - Semiformula.Evalbm M e (∼φ).val ↔ ¬Semiformula.Evalbm M e φ.val := by +lemma ProperOn.eval_neg {φ : 𝚫-[m].Semisentence k} (hp : φ.ProperOn M) (e : Fin k → M) : + (∼φ).val.Evalb e ↔ ¬φ.val.Evalb e := by simp [←val_sigma, hp.iff] lemma ProperOn.ball {t} {φ : 𝚫-[m + 1].Semisentence (k + 1)} (hp : φ.ProperOn M) : (ball t φ).ProperOn M := by @@ -382,8 +382,8 @@ lemma ProperWithParamOn.or {φ ψ : 𝚫-[m].Semiformula M k} lemma ProperWithParamOn.neg {φ : 𝚫-[m].Semiformula M k} (hp : φ.ProperWithParamOn M) : (∼φ).ProperWithParamOn M := by intro e; simp [hp.iff] -lemma ProperWithParamOn.eval_neg {φ : 𝚫-[m].Semiformula M k} (hp : φ.ProperWithParamOn M) (e) : - Semiformula.Evalm M e id (∼φ).val ↔ ¬Semiformula.Evalm M e id φ.val := by +lemma ProperWithParamOn.eval_neg {φ : 𝚫-[m].Semiformula M k} (hp : φ.ProperWithParamOn M) (e : Fin k → M) : + (∼φ).val.Eval e id ↔ ¬φ.val.Eval e id := by simp [←val_sigma, hp.iff] lemma ProperWithParamOn.ball {t} {φ : 𝚫-[m].Semiformula M (k + 1)} @@ -396,7 +396,7 @@ lemma ProperWithParamOn.bexs {t} {φ : 𝚫-[m].Semiformula M (k + 1)} def graphDelta (φ : 𝚺-[m].Semiformula ξ (k + 1)) : 𝚫-[m].Semiformula ξ (k + 1) := match m with - | 0 => φ.ofZero _ + | 0 => φ.ofZero _ | m + 1 => mkDelta φ (mkPi “x. ∀ y, !φ.val y ⋯ → y = x”) @[simp] lemma graphDelta_val (φ : 𝚺-[m].Semiformula ξ (k + 1)) : φ.graphDelta.val = φ.val := by cases m <;> simp [graphDelta] diff --git a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Basic.lean b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Basic.lean index c41f3c451..ad37f8183 100644 --- a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Basic.lean @@ -33,7 +33,7 @@ abbrev ltTri : Sentence ℒₒᵣ := “∀ x y, x < y ∨ x = y ∨ x > end PeanoMinus.Axiom inductive PeanoMinus : ArithmeticTheory - | equal : ∀ φ ∈ 𝗘𝗤, PeanoMinus φ + | equal : ∀ φ ∈ 𝗘𝗤 ℒₒᵣ, PeanoMinus φ | addZero : PeanoMinus PeanoMinus.Axiom.addZero | addAssoc : PeanoMinus PeanoMinus.Axiom.addAssoc | addComm : PeanoMinus PeanoMinus.Axiom.addComm @@ -60,7 +60,7 @@ open FirstOrder Arithmetic Language @[simp] lemma finite : Set.Finite 𝗣𝗔⁻ := by have : 𝗣𝗔⁻ = - 𝗘𝗤 ∪ + 𝗘𝗤 ℒₒᵣ ∪ { Axiom.addZero, Axiom.addAssoc, Axiom.addComm, @@ -137,7 +137,7 @@ open FirstOrder Arithmetic Language apply Set.finite_singleton set_option linter.flexible false in -@[simp] instance : ℕ ⊧ₘ* 𝗣𝗔⁻ := ⟨by +@[simp] instance : ℕ↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := ⟨by intro σ h rcases h <;> simp [models_iff] case addAssoc => intros; exact add_assoc _ _ _ @@ -151,10 +151,10 @@ set_option linter.flexible false in case ltTrans => intro a b c; exact Nat.lt_trans case ltTri => intros; exact Nat.lt_trichotomy _ _ case equal h => - have : ℕ ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h⟩ + have : ℕ↓[ℒₒᵣ] ⊧* (𝗘𝗤 ℒₒᵣ : ArithmeticTheory) := inferInstance + exact models_theory_iff.mp this _ h⟩ -instance : 𝗘𝗤 ⪯ 𝗣𝗔⁻ := Entailment.WeakerThan.ofSubset <| fun φ hp ↦ PeanoMinus.equal φ hp +instance : 𝗘𝗤 ℒₒᵣ ⪯ 𝗣𝗔⁻ := Entailment.WeakerThan.ofSubset fun φ hp ↦ PeanoMinus.equal φ hp end PeanoMinus @@ -164,58 +164,58 @@ scoped instance : LE M := ⟨fun x y => x = y ∨ x < y⟩ lemma le_def {x y : M} : x ≤ y ↔ x = y ∨ x < y := iff_of_eq rfl -variable [M ⊧ₘ* 𝗣𝗔⁻] +variable [M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] protected lemma add_zero' : ∀ x : M, x + 0 = x := by - simpa [models_iff] using Theory.models M PeanoMinus.addZero + simpa [models_iff] using Theory.models M _ PeanoMinus.addZero protected lemma add_assoc : ∀ x y z : M, (x + y) + z = x + (y + z) := by - simpa [models_iff] using Theory.models M PeanoMinus.addAssoc + simpa [models_iff] using Theory.models M _ PeanoMinus.addAssoc protected lemma add_comm : ∀ x y : M, x + y = y + x := by - simpa [models_iff] using Theory.models M PeanoMinus.addComm + simpa [models_iff] using Theory.models M _ PeanoMinus.addComm lemma add_eq_of_lt : ∀ x y : M, x < y → ∃ z, x + z = y := by - simpa [models_iff] using Theory.models M PeanoMinus.addEqOfLt + simpa [models_iff] using Theory.models M _ PeanoMinus.addEqOfLt @[simp] protected lemma zero_le : ∀ x : M, 0 ≤ x := by - simpa [models_iff, Structure.le_iff_of_eq_of_lt] using Theory.models M PeanoMinus.zeroLe + simpa [models_iff, Structure.le_iff_of_eq_of_lt] using Theory.models M _ PeanoMinus.zeroLe lemma zero_lt_one : (0 : M) < 1 := by - simpa [models_iff] using Theory.models M PeanoMinus.zeroLtOne + simpa [models_iff] using Theory.models M _ PeanoMinus.zeroLtOne lemma one_le_of_zero_lt : ∀ x : M, 0 < x → 1 ≤ x := by - simpa [models_iff, Structure.le_iff_of_eq_of_lt] using Theory.models M PeanoMinus.oneLeOfZeroLt + simpa [models_iff, Structure.le_iff_of_eq_of_lt] using Theory.models M _ PeanoMinus.oneLeOfZeroLt lemma add_lt_add : ∀ x y z : M, x < y → x + z < y + z := by - simpa [models_iff] using Theory.models M PeanoMinus.addLtAdd + simpa [models_iff] using Theory.models M _ PeanoMinus.addLtAdd protected lemma mul_zero' : ∀ x : M, x * 0 = 0 := by - simpa [models_iff] using Theory.models M PeanoMinus.mulZero + simpa [models_iff] using Theory.models M _ PeanoMinus.mulZero protected lemma mul_one : ∀ x : M, x * 1 = x := by - simpa [models_iff] using Theory.models M PeanoMinus.mulOne + simpa [models_iff] using Theory.models M _ PeanoMinus.mulOne protected lemma mul_assoc : ∀ x y z : M, (x * y) * z = x * (y * z) := by - simpa [models_iff] using Theory.models M PeanoMinus.mulAssoc + simpa [models_iff] using Theory.models M _ PeanoMinus.mulAssoc protected lemma mul_comm : ∀ x y : M, x * y = y * x := by - simpa [models_iff] using Theory.models M PeanoMinus.mulComm + simpa [models_iff] using Theory.models M _ PeanoMinus.mulComm lemma mul_lt_mul : ∀ x y z : M, x < y → 0 < z → x * z < y * z := by - simpa [models_iff] using Theory.models M PeanoMinus.mulLtMul + simpa [models_iff] using Theory.models M _ PeanoMinus.mulLtMul lemma mul_add_distr : ∀ x y z : M, x * (y + z) = x * y + x * z := by - simpa [models_iff] using Theory.models M PeanoMinus.distr + simpa [models_iff] using Theory.models M _ PeanoMinus.distr lemma lt_irrefl : ∀ x : M, ¬x < x := by - simpa [models_iff] using Theory.models M PeanoMinus.ltIrrefl + simpa [models_iff] using Theory.models M _ PeanoMinus.ltIrrefl protected lemma lt_trans : ∀ x y z : M, x < y → y < z → x < z := by - simpa [models_iff] using Theory.models M PeanoMinus.ltTrans + simpa [models_iff] using Theory.models M _ PeanoMinus.ltTrans lemma lt_tri : ∀ x y : M, x < y ∨ x = y ∨ y < x := by - simpa [models_iff] using Theory.models M PeanoMinus.ltTri + simpa [models_iff] using Theory.models M _ PeanoMinus.ltTri scoped instance : AddCommMonoid M where add_assoc := Arithmetic.add_assoc @@ -293,10 +293,12 @@ scoped instance : CanonicallyOrderedAdd M where scoped instance : IsOrderedAddMonoid M where add_le_add_left _ _ h z := (add_le_add_iff_right z).mpr h -lemma numeral_eq_natCast : (n : ℕ) → (ORingStructure.numeral n : M) = n +lemma numeral_eq_natCast_app : (n : ℕ) → (ORingStructure.numeral n : M) = n | 0 => rfl | 1 => by simp - | n + 2 => by simp [ORingStructure.numeral, numeral_eq_natCast (n + 1), add_assoc, one_add_one_eq_two] + | n + 2 => by simp [ORingStructure.numeral, numeral_eq_natCast_app (n + 1), add_assoc, one_add_one_eq_two] + +lemma numeral_eq_natCast : (ORingStructure.numeral : ℕ → M) = Nat.cast := by ext x; exact numeral_eq_natCast_app x lemma not_neg (x : M) : ¬x < 0 := by simp @@ -324,12 +326,12 @@ lemma eq_nat_of_le_nat {n : ℕ} {x : M} : x ≤ n → ∃ m : ℕ, x = m := fun have : x < ↑(n + 1) := by simpa [←le_iff_lt_succ] using h exact eq_nat_of_lt_nat this -instance models_R0_of_models_PeanoMinus : M ⊧ₘ* 𝗥₀ := modelsTheory_iff.mpr <| by +instance models_R0_of_models_PeanoMinus : M↓[ℒₒᵣ] ⊧* 𝗥₀ := models_theory_iff.mpr <| by intro φ h rcases h case equal h => - have : M ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h + have : M↓[ℒₒᵣ] ⊧* 𝗘𝗤 ℒₒᵣ := inferInstance + exact models_theory_iff.mp this _ h case Ω₁ n m => simp [models_iff, numeral_eq_natCast] case Ω₂ n m => @@ -345,12 +347,12 @@ instance models_R0_of_models_PeanoMinus : M ⊧ₘ* 𝗥₀ := modelsTheory_iff. instance : 𝗥₀ ⪯ 𝗣𝗔⁻ := weakerThan_of_models.{0} _ _ fun _ _ _ ↦ inferInstance -instance models_RobinsonQ_of_models_PeanoMinus : M ⊧ₘ* 𝗤 := modelsTheory_iff.mpr <| by +instance models_RobinsonQ_of_models_PeanoMinus : M↓[ℒₒᵣ] ⊧* 𝗤 := models_theory_iff.mpr <| by intro φ h rcases h case equal h => - have : M ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h + have : M↓[ℒₒᵣ] ⊧* 𝗘𝗤 ℒₒᵣ := inferInstance + exact models_theory_iff.mp this _ h case addSucc h => suffices ∀ a b : M, a + (b + 1) = a + b + 1 by simpa [models_iff]; simp [add_assoc] @@ -538,8 +540,7 @@ open FirstOrder FirstOrder.Semiterm simp [Operator.npow_zero, Operator.val_comp, Matrix.empty_eq] case succ k IH => simp [Operator.npow_succ, Operator.val_comp] - simp [Matrix.fun_eq_vec_two, pow_succ] - simp [IH] + simp [pow_succ, IH] instance : Structure.Monotone ℒₒᵣ M := ⟨ fun {k} f v₁ v₂ h ↦ @@ -568,11 +569,11 @@ lemma eq_fin_of_lt_nat {n : ℕ} {x : M} (hx : x < (n : M)) : ∃ i : Fin n, x = exact ⟨⟨x, by simpa using hx⟩, by simp⟩ @[simp] lemma eval_ballLTSucc' {t : Semiterm ℒₒᵣ ξ n} {φ : Semiformula ℒₒᵣ ξ (n + 1)} : - Semiformula.Evalm M e ε (φ.ballLTSucc t) ↔ ∀ x ≤ Semiterm.valm M e ε t, Semiformula.Evalm M (x :> e) ε φ := by + (φ.ballLTSucc t).Eval e ε ↔ ∀ x ≤ t.val (M := M) e ε, φ.Eval (x :> e) ε := by simp [Semiformula.eval_ballLTSucc, lt_succ_iff_le] @[simp] lemma eval_bexsLTSucc' {t : Semiterm ℒₒᵣ ξ n} {φ : Semiformula ℒₒᵣ ξ (n + 1)} : - Semiformula.Evalm M e ε (φ.bexsLTSucc t) ↔ ∃ x ≤ Semiterm.valm M e ε t, Semiformula.Evalm M (x :> e) ε φ := by + (φ.bexsLTSucc t).Eval e ε ↔ ∃ x ≤ t.val (M := M) e ε, φ.Eval (x :> e) ε := by simp [Semiformula.eval_bexsLTSucc, lt_succ_iff_le] variable (M) @@ -590,8 +591,8 @@ variable {T : ArithmeticTheory} [𝗣𝗔⁻ ⪯ T] instance : 𝗥₀ ⪱ 𝗣𝗔⁻ := Entailment.StrictlyWeakerThan.of_unprovable_provable - R0.unprovable_addZero (Entailment.by_axm _ PeanoMinus.addZero) + R0.unprovable_addZero (Entailment.by_axm PeanoMinus.addZero) -instance (M : Type*) [ORingStructure M] [M ⊧ₘ* 𝗣𝗔⁻] : M ⊧ₘ* 𝗥₀ := models_of_subtheory (T := 𝗣𝗔⁻) inferInstance +instance (M : Type*) [ORingStructure M] [M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] : M↓[ℒₒᵣ] ⊧* 𝗥₀ := models_of_subtheory (U := 𝗣𝗔⁻) inferInstance end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Q.lean b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Q.lean index 5092521da..a9348f170 100644 --- a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Q.lean +++ b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Q.lean @@ -137,12 +137,12 @@ lemma exists_add_one_eq_self : ∃ x : OmegaAddOne, x + 1 = x := end OmegaAddOne set_option linter.flexible false in -instance : OmegaAddOne ⊧ₘ* 𝗤 := ⟨by +instance : OmegaAddOne↓[ℒₒᵣ] ⊧* 𝗤 := ⟨by intro σ h; rcases h; case equal h => - have : OmegaAddOne ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h + have : OmegaAddOne↓[ℒₒᵣ] ⊧* 𝗘𝗤 ℒₒᵣ := inferInstance + exact models_theory_iff.mp this _ h case succInj => suffices ∀ a b : OmegaAddOne, a + 1 = b + 1 → a = b by simpa [models_iff]; intro _; apply OmegaAddOne.succ_inj; @@ -152,12 +152,11 @@ instance : OmegaAddOne ⊧ₘ* 𝗤 := ⟨by end Countermodel lemma RobinsonQ.unprovable_neSucc : 𝗤 ⊬ “∀ x, x + 1 ≠ x” := - unprovable_of_countermodel (M := Countermodel.OmegaAddOne) <| by - simpa [models_iff] using Countermodel.OmegaAddOne.exists_add_one_eq_self + unprovable_of_countermodel (M := Countermodel.OmegaAddOne) 𝗤 <| by + simpa [notModels_iff] using Countermodel.OmegaAddOne.exists_add_one_eq_self -instance : 𝗤 ⪱ 𝗣𝗔⁻ := Entailment.StrictlyWeakerThan.of_unprovable_provable RobinsonQ.unprovable_neSucc $ by - apply provable_of_models.{0}; - intro _ _ _; - simp [models_iff]; +instance : 𝗤 ⪱ 𝗣𝗔⁻ := + Entailment.StrictlyWeakerThan.of_unprovable_provable RobinsonQ.unprovable_neSucc + <| complete.{0} _ _ fun _ _ _ ↦ by simp [models_iff] end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Arithmetic/Q/Basic.lean b/Foundation/FirstOrder/Arithmetic/Q/Basic.lean index 55f1caa1f..1af2c1fd7 100644 --- a/Foundation/FirstOrder/Arithmetic/Q/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/Q/Basic.lean @@ -13,7 +13,7 @@ noncomputable section namespace LO.FirstOrder.Arithmetic inductive RobinsonQ : ArithmeticTheory - | equal : ∀ φ ∈ 𝗘𝗤, RobinsonQ φ + | equal : ∀ φ ∈ 𝗘𝗤 ℒₒᵣ, RobinsonQ φ | succNeZero : RobinsonQ “∀ a, a + 1 ≠ 0” | succInj : RobinsonQ “∀ a b, a + 1 = b + 1 → a = b” | zeroOrSucc : RobinsonQ “∀ a, a = 0 ∨ ∃ b, a = b + 1” @@ -29,7 +29,7 @@ namespace RobinsonQ open ORingStructure -@[simp] instance : ℕ ⊧ₘ* 𝗤 := ⟨by +@[simp] instance : ℕ↓[ℒₒᵣ] ⊧* 𝗤 := ⟨by intro σ h cases h case ltDef => @@ -46,41 +46,41 @@ open ORingStructure simp [models_iff] omega; case equal h => - suffices ℕ ⊧/![] σ by simpa [models_iff] - have : ℕ ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h + suffices σ.Evalb ![] by simpa [models_iff] + have : ℕ↓[ℒₒᵣ] ⊧* (𝗘𝗤 ℒₒᵣ : ArithmeticTheory) := inferInstance + exact models_theory_iff.mp this _ h repeat case _ => simp [models_iff, add_assoc, mul_add]⟩ -instance : 𝗘𝗤 ⪯ 𝗤 := Entailment.WeakerThan.ofSubset <| fun φ hp ↦ equal φ hp +instance : 𝗘𝗤 ℒₒᵣ ⪯ 𝗤 := Entailment.WeakerThan.ofSubset <| fun φ hp ↦ equal φ hp end RobinsonQ -variable {M : Type*} [ORingStructure M] [M ⊧ₘ* 𝗤] +variable {M : Type*} [ORingStructure M] [M↓[ℒₒᵣ] ⊧* 𝗤] @[simp] protected lemma succ_ne_zero : ∀ a : M, a + 1 ≠ 0 := by - simpa [models_iff] using Theory.models M RobinsonQ.succNeZero + simpa [models_iff] using Theory.models M _ RobinsonQ.succNeZero lemma succ_inj {a b : M} : a + 1 = b + 1 → a = b := by - have := by simpa [models_iff] using Theory.models M RobinsonQ.succInj + have := by simpa [models_iff] using Theory.models M _ RobinsonQ.succInj exact this a b @[simp] protected lemma add_zero {a : M} : a + 0 = a := by - have := by simpa [models_iff] using Theory.models M RobinsonQ.addZero + have := by simpa [models_iff] using Theory.models M _ RobinsonQ.addZero exact this a protected lemma add_succ (a b : M) : a + (b + 1) = a + b + 1 := by - have := by simpa [models_iff] using Theory.models M RobinsonQ.addSucc + have := by simpa [models_iff] using Theory.models M _ RobinsonQ.addSucc exact this a b @[simp] protected lemma mul_zero (a : M) : a * 0 = 0 := by - have := by simpa [models_iff] using Theory.models M RobinsonQ.mulZero + have := by simpa [models_iff] using Theory.models M _ RobinsonQ.mulZero exact this a protected lemma mul_succ : ∀ a b : M, a * (b + 1) = a * b + a := by - simpa [models_iff] using Theory.models M RobinsonQ.mulSucc + simpa [models_iff] using Theory.models M _ RobinsonQ.mulSucc lemma zero_or_succ (a : M) : a = 0 ∨ ∃ b : M, a = b + 1 := by - have := by simpa [models_iff] using Theory.models M RobinsonQ.zeroOrSucc + have := by simpa [models_iff] using Theory.models M _ RobinsonQ.zeroOrSucc exact this a lemma exists_succ_of_ne_zero {a : M} (ha : a ≠ 0) : ∃ b : M, a = b + 1 := by @@ -92,7 +92,7 @@ lemma exists_succ_of_ne_zero' {a : M} (ha : a ≠ 0) : ∃ b : M, b + 1 = a := b use b; protected lemma lt_def {a b : M} : a < b ↔ ∃ c : M, a + (c + 1) = b := by - have := by simpa [models_iff] using Theory.models M RobinsonQ.ltDef + have := by simpa [models_iff] using Theory.models M _ RobinsonQ.ltDef exact this a b @[simp] @@ -303,12 +303,12 @@ lemma iff_lt_numeral_exists_numeral {n : ℕ} {x : M} : x < numeral n ↔ ∃ m namespace R0 -instance : M ⊧ₘ* 𝗥₀ := modelsTheory_iff.mpr <| by +instance : M↓[ℒₒᵣ] ⊧* 𝗥₀ := models_theory_iff.mpr <| by intro φ h rcases h case equal h => - have : M ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h + have : M↓[ℒₒᵣ] ⊧* (𝗘𝗤 ℒₒᵣ : ArithmeticTheory) := inferInstance + exact models_theory_iff.mp this _ h case Ω₁ n m => simp [models_iff, numeral_add] case Ω₂ n m => simp [models_iff, numeral_mul] case Ω₃ n m h => simp [models_iff, numeral_ne_of_ne h]; @@ -322,6 +322,6 @@ instance : 𝗥₀ ⪯ 𝗤 := weakerThan_of_models.{0} _ _ fun _ _ _ ↦ inferI instance : 𝗥₀ ⪱ 𝗤 := Entailment.StrictlyWeakerThan.of_unprovable_provable - R0.unprovable_addZero (Entailment.by_axm _ RobinsonQ.addZero) + R0.unprovable_addZero (Entailment.by_axm RobinsonQ.addZero) end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Arithmetic/R0/Representation.lean b/Foundation/FirstOrder/Arithmetic/R0/Representation.lean index 3d047aaf3..c2a8e46cd 100644 --- a/Foundation/FirstOrder/Arithmetic/R0/Representation.lean +++ b/Foundation/FirstOrder/Arithmetic/R0/Representation.lean @@ -13,7 +13,7 @@ open Mathlib Encodable Semiterm.Operator.GödelNumber section -lemma term_primrec {k f} : (t : Semiterm ℒₒᵣ ξ k) → Primrec (fun v : List.Vector ℕ k ↦ t.valm ℕ v.get f) +lemma term_primrec {k f} : (t : Semiterm ℒₒᵣ ξ k) → Primrec (fun v : List.Vector ℕ k ↦ t.val v.get f) | #x => by simpa using Primrec.vector_get.comp .id (.const _) | &x => by simpa using Primrec.const _ | .func Language.Zero.zero _ => by simpa using Primrec.const 0 @@ -24,32 +24,32 @@ lemma term_primrec {k f} : (t : Semiterm ℒₒᵣ ξ k) → Primrec (fun v : Li simpa [Semiterm.val_func] using Primrec.nat_mul.comp (term_primrec (v 0)) (term_primrec (v 1)) lemma sigma1_re (ε : ξ → ℕ) {k} {φ : Semiformula ℒₒᵣ ξ k} (hp : Hierarchy 𝚺 1 φ) : - REPred fun v : List.Vector ℕ k ↦ Semiformula.Evalm ℕ v.get ε φ := by + REPred fun v : List.Vector ℕ k ↦ φ.Eval v.get ε := by apply sigma₁_induction' hp case hVerum => simp; case hFalsum => simp case hEQ => intro n t₁ t₂ refine ComputablePred.to_re <| ComputablePred.computable_iff.mpr - <| ⟨fun v : List.Vector ℕ n ↦ decide (t₁.valm ℕ v.get ε = t₂.valm ℕ v.get ε), ?_, ?_⟩ + <| ⟨fun v : List.Vector ℕ n ↦ decide (t₁.val v.get ε = t₂.val v.get ε), ?_, ?_⟩ · apply Primrec.to_comp (Primrec.eq.comp (term_primrec t₁) (term_primrec t₂)).decide · simp case hNEQ => intro n t₁ t₂ refine ComputablePred.to_re <| ComputablePred.computable_iff.mpr - <| ⟨fun v : List.Vector ℕ n ↦ !decide (t₁.valm ℕ v.get ε = t₂.valm ℕ v.get ε), ?_, ?_⟩ + <| ⟨fun v : List.Vector ℕ n ↦ !decide (t₁.val v.get ε = t₂.val v.get ε), ?_, ?_⟩ · apply Primrec.to_comp <| Primrec.not.comp (Primrec.eq.comp (term_primrec t₁) (term_primrec t₂)).decide · simp case hLT => intro n t₁ t₂ refine ComputablePred.to_re <| ComputablePred.computable_iff.mpr - <| ⟨fun v : List.Vector ℕ n ↦ decide (t₁.valm ℕ v.get ε < t₂.valm ℕ v.get ε), ?_, ?_⟩ + <| ⟨fun v : List.Vector ℕ n ↦ decide (t₁.val v.get ε < t₂.val v.get ε), ?_, ?_⟩ · apply Primrec.to_comp (Primrec.nat_lt.comp (term_primrec t₁) (term_primrec t₂)).decide · simp case hNLT => intro n t₁ t₂ refine ComputablePred.to_re <| ComputablePred.computable_iff.mpr - <| ⟨fun v : List.Vector ℕ n ↦ !decide (t₁.valm ℕ v.get ε < t₂.valm ℕ v.get ε), ?_, ?_⟩ + <| ⟨fun v : List.Vector ℕ n ↦ !decide (t₁.val v.get ε < t₂.val v.get ε), ?_, ?_⟩ · apply Primrec.to_comp <| Primrec.not.comp (Primrec.nat_lt.comp (term_primrec t₁) (term_primrec t₂)).decide · simp case hAnd => @@ -62,20 +62,20 @@ lemma sigma1_re (ε : ξ → ℕ) {k} {φ : Semiformula ℒₒᵣ ξ k} (hp : Hi intro n t φ _ ih rcases REPred.iff'.mp ih with ⟨f, hf, H⟩ let g : List.Vector ℕ n →. Unit := fun v ↦ - Nat.rec (.some ()) (fun x ih ↦ ih.bind fun _ ↦ f (x ::ᵥ v)) (t.valm ℕ v.get ε) + Nat.rec (.some ()) (fun x ih ↦ ih.bind fun _ ↦ f (x ::ᵥ v)) (t.val v.get ε) have : Partrec g := Partrec.nat_rec (term_primrec t).to_comp (Computable.const ()) (Partrec.to₂ <| hf.comp (Primrec.to_comp <| Primrec.vector_cons.comp (Primrec.fst.comp .snd) .fst)) refine REPred.iff.mpr ⟨_, this, ?_⟩ funext v - suffices ∀ k : ℕ, (∀ x < k, Semiformula.Evalm ℕ (x :> v.get) ε φ) ↔ + suffices ∀ k : ℕ, (∀ x < k, φ.Eval (x :> v.get) ε) ↔ Part.Dom (Nat.rec (.some ()) (fun x ih ↦ ih.bind fun _ ↦ f (x ::ᵥ v)) k) by simpa [g] using this _ intro k; induction k case zero => simp case succ k ih => suffices - (∀ x < k + 1, (Semiformula.Evalm ℕ (x :> v.get) ε) φ) - ↔ (∀ x < k, (Semiformula.Evalm ℕ (x :> v.get) ε) φ) ∧ (f (k ::ᵥ v)).Dom by simpa [←ih] + (∀ x < k + 1, φ.Eval (x :> v.get) ε) + ↔ (∀ x < k, φ.Eval (x :> v.get) ε) ∧ (f (k ::ᵥ v)).Dom by simpa [←ih] constructor · intro h exact ⟨fun x hx ↦ h x (lt_trans hx (by simp)), @@ -87,7 +87,7 @@ lemma sigma1_re (ε : ξ → ℕ) {k} {φ : Semiformula ℒₒᵣ ξ k} (hp : Hi case hExs => intro n φ _ ih rcases REPred.iff'.mp ih with ⟨f, _, _⟩ - have : REPred fun vx : List.Vector ℕ n × ℕ ↦ Semiformula.Evalm ℕ (vx.2 :> vx.1.get) ε φ := by + have : REPred fun vx : List.Vector ℕ n × ℕ ↦ φ.Eval (vx.2 :> vx.1.get) ε := by simpa [List.Vector.cons_get] using ih.comp (Primrec.to_comp <| Primrec.vector_cons.comp .snd .fst) simpa using this.projection @@ -180,7 +180,7 @@ private lemma codeAux_sigma_one {k} (c : Nat.ArithPart₁.Code k) : Hierarchy @[simp] lemma natCast_nat' (n : ℕ) : Nat.cast n = n := by rfl private lemma models_codeAux {c : Code k} {f : List.Vector ℕ k →. ℕ} (hc : c.eval f) (y : ℕ) (v : Fin k → ℕ) : - Semiformula.Evalfm ℕ (y :> v) (codeAux c) ↔ f (List.Vector.ofFn v) = Part.some y := by + (codeAux c).Evalf (y :> v) ↔ f (List.Vector.ofFn v) = Part.some y := by induction hc generalizing y case zero => have : (0 : Part ℕ) = Part.some 0 := rfl @@ -198,8 +198,7 @@ private lemma models_codeAux {c : Code k} {f : List.Vector ℕ k →. ℕ} (hc : case proj => simp [codeAux, eq_comm] case comp m n c d f g _ _ ihf ihg => suffices - (∃ e' : Fin n → ℕ, (Semiformula.Evalfm ℕ (y :> e')) (codeAux c) ∧ - ∀ i, (Semiformula.Evalfm ℕ (e' i :> v)) (codeAux (d i))) + (∃ e' : Fin n → ℕ, (codeAux c).Evalf (y :> e') ∧ ∀ i, (codeAux (d i)).Evalf (e' i :> v)) ↔ (List.Vector.mOfFn (g · (List.Vector.ofFn v))).bind f = Part.some y by simp [codeAux] simpa [Semiformula.eval_rew, Function.comp_def, Matrix.empty_eq, Matrix.comp_vecCons'] @@ -226,16 +225,16 @@ private lemma models_codeAux {c : Code k} {f : List.Vector ℕ k →. ℕ} (hc : · intro h; simpa [pos_iff_ne_zero] using Nat.mem_rfind.mp (Part.eq_some_iff.mp h) lemma models_code {c : Code k} {f : List.Vector ℕ k →. ℕ} (hc : c.eval f) (y : ℕ) (v : Fin k → ℕ) : - Semiformula.Evalbm ℕ (y :> v) (code c) ↔ y ∈ f (List.Vector.ofFn v) := by + (code c).Evalb (y :> v) ↔ y ∈ f (List.Vector.ofFn v) := by simpa [code, models_iff, Semiformula.eval_rew, Matrix.empty_eq, Function.comp_def, Matrix.comp_vecCons', ←Part.eq_some_iff] using models_codeAux hc y v noncomputable def codeOfPartrec' {k} (f : List.Vector ℕ k →. ℕ) : Semisentence ℒₒᵣ (k + 1) := - code <| Classical.epsilon fun c ↦ ∀ y v, Semiformula.Evalbm ℕ (y :> v) (code c) ↔ y ∈ f (List.Vector.ofFn v) + code <| Classical.epsilon fun c ↦ ∀ y v, (code c).Evalb (y :> v) ↔ y ∈ f (List.Vector.ofFn v) lemma codeOfPartrec'_spec {k} {f : List.Vector ℕ k →. ℕ} (hf : Nat.Partrec' f) {y : ℕ} {v : Fin k → ℕ} : - ℕ ⊧/(y :> v) (codeOfPartrec' f) ↔ y ∈ f (List.Vector.ofFn v) := by - have : ∃ c, ∀ y v, Semiformula.Evalbm ℕ (y :> v) (code c) ↔ y ∈ f (List.Vector.ofFn v) := by + (codeOfPartrec' f).Evalb (y :> v) ↔ y ∈ f (List.Vector.ofFn v) := by + have : ∃ c, ∀ y v, (code c).Evalb (y :> v) ↔ y ∈ f (List.Vector.ofFn v) := by rcases Nat.ArithPart₁.exists_code (of_partrec hf) with ⟨c, hc⟩ exact ⟨c, models_code hc⟩ exact Classical.epsilon_spec this y v @@ -247,9 +246,9 @@ noncomputable def codeOfREPred (A : ℕ → Prop) : Semisentence ℒₒᵣ 1 := (codeOfPartrec' (fun v ↦ (f (v.get 0)).map fun _ ↦ 0))/[‘0’, #0] lemma codeOfREPred_spec {A : ℕ → Prop} (hp : REPred A) {x : ℕ} : - ℕ ⊧/![x] (codeOfREPred A) ↔ A x := by + (codeOfREPred A).Evalb (![x]) ↔ A x := by let f : ℕ →. Unit := fun a ↦ Part.assert (A a) fun _ ↦ Part.some () - suffices ℕ ⊧/![x] ((codeOfPartrec' fun v ↦ Part.map (fun _ ↦ 0) (f (v.get 0)))/[‘0’, #0]) ↔ A x from this + suffices (codeOfPartrec' fun v ↦ Part.map (fun _ ↦ 0) (f (v.get 0)))/[‘0’, #0].Evalb (![x]) ↔ A x from this have : Partrec fun v : List.Vector ℕ 1 ↦ (f (v.get 0)).map fun _ ↦ 0 := by refine Partrec.map (Partrec.comp hp (Primrec.to_comp <| Primrec.vector_get.comp .id (.const 0))) (Computable.const 0).to₂ simpa [Semiformula.eval_substs, Matrix.comp_vecCons', Matrix.constant_eq_singleton] diff --git a/Foundation/FirstOrder/Arithmetic/Schemata.lean b/Foundation/FirstOrder/Arithmetic/Schemata.lean index 837e16ee2..a49d69fd8 100644 --- a/Foundation/FirstOrder/Arithmetic/Schemata.lean +++ b/Foundation/FirstOrder/Arithmetic/Schemata.lean @@ -287,7 +287,7 @@ instance [V ⊧ₘ* 𝗜𝗡𝗗 𝚷 m] : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := by · infer_instance lemma mod_ISigma_of_le {n₁ n₂} (h : n₁ ≤ n₂) [V ⊧ₘ* 𝗜𝚺 n₂] : V ⊧ₘ* 𝗜𝚺 n₁ := - ModelsTheory.of_ss inferInstance (ISigma_subset_mono h) + models_of_ss inferInstance (ISigma_subset_mono h) instance [V ⊧ₘ* 𝗜𝚺₁] : V ⊧ₘ* 𝗜𝚺₀ := mod_ISigma_of_le (show 0 ≤ 1 from by simp) @@ -360,7 +360,7 @@ instance [V ⊧ₘ* 𝗜𝚺₀] : V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻 := instance [V ⊧ₘ* 𝗜𝚺₁] : V ⊧ₘ* 𝗜𝚺₀ := inferInstance abbrev mod_ISigma_of_le {n₁ n₂} (h : n₁ ≤ n₂) [V ⊧ₘ* 𝗜𝚺 n₂] : V ⊧ₘ* 𝗜𝚺 n₁ := - ModelsTheory.of_ss inferInstance (ISigma_subset_mono h) + models_of_ss inferInstance (ISigma_subset_mono h) end models diff --git a/Foundation/FirstOrder/Arithmetic/TA/Basic.lean b/Foundation/FirstOrder/Arithmetic/TA/Basic.lean index 757126f25..6c34158da 100644 --- a/Foundation/FirstOrder/Arithmetic/TA/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/TA/Basic.lean @@ -11,16 +11,16 @@ notation "𝗧𝗔" => FirstOrderTrueArith namespace TA -instance : ℕ ⊧ₘ* 𝗧𝗔 := - modelsTheory_iff.mpr fun {φ} ↦ by simp +instance : ℕ↓[ℒₒᵣ] ⊧* 𝗧𝗔 := + models_theory_iff.mpr fun {φ} ↦ by simp lemma provable_iff {φ : Sentence ℒₒᵣ} : - 𝗧𝗔 ⊢ φ ↔ ℕ ⊧ₘ φ := - ⟨fun h ↦ consequence_iff'.mp (smallSound! h) ℕ, fun h ↦ Entailment.by_axm _ h⟩ + 𝗧𝗔 ⊢ φ ↔ ℕ↓[ℒₒᵣ] ⊧ φ := + ⟨fun h ↦ consequence_iff'.mp (Theory.Proof.sound h) ℕ, fun h ↦ Entailment.by_axm h⟩ -instance (T : Theory ℒₒᵣ) [ℕ ⊧ₘ* T] : T ⪯ 𝗧𝗔 := ⟨by +instance (T : Theory ℒₒᵣ) [ℕ↓[ℒₒᵣ] ⊧* T] : T ⪯ 𝗧𝗔 := ⟨by rintro φ h - have : ℕ ⊧ₘ φ := consequence_iff'.mp (smallSound! h) ℕ + have : ℕ↓[ℒₒᵣ] ⊧ φ := consequence_iff'.mp (Theory.Proof.sound h) ℕ exact provable_iff.mpr this⟩ end TA diff --git a/Foundation/FirstOrder/Arithmetic/TA/Nonstandard.lean b/Foundation/FirstOrder/Arithmetic/TA/Nonstandard.lean index 7d345ffae..20561145d 100644 --- a/Foundation/FirstOrder/Arithmetic/TA/Nonstandard.lean +++ b/Foundation/FirstOrder/Arithmetic/TA/Nonstandard.lean @@ -13,15 +13,15 @@ local notation "ℒₒᵣ⋆" => withStar def starUnbounded (c : ℕ) : Theory ℒₒᵣ⋆ := Set.range fun n : Fin c ↦ “!!(Semiterm.Operator.numeral ℒₒᵣ⋆ n) < ⋆” def trueArithWithStarUnbounded (n : ℕ) : Theory ℒₒᵣ⋆ := - 𝗘𝗤 ∪ (Semiformula.lMap (Language.Hom.add₁ _ _) '' 𝗧𝗔) ∪ starUnbounded n + 𝗘𝗤 ℒₒᵣ⋆ ∪ (Semiformula.lMap (Language.Hom.add₁ _ _) '' 𝗧𝗔) ∪ starUnbounded n lemma trueArithWithStarUnbounded.cumulative : Cumulative trueArithWithStarUnbounded := fun c => Set.union_subset_union_right _ <| Set.range_subset_range_iff_exists_comp.mpr ⟨Fin.castSucc, by simp [Function.comp_def]⟩ -def modelStar (c : ℕ) : Structure Language.unit ℕ where - func := fun _ ⟨⟨⟩⟩ _ => c - rel := fun _ r _ => PEmpty.elim r +abbrev modelStar (c : ℕ) : Structure Language.unit ℕ where + func := fun _ ⟨⟨⟩⟩ _ ↦ c + rel := fun _ r _ ↦ PEmpty.elim r lemma satisfiable_trueArithWithStarUnbounded (c : ℕ) : Satisfiable (trueArithWithStarUnbounded c) := by letI : Structure Language.unit ℕ := modelStar c @@ -30,10 +30,10 @@ lemma satisfiable_trueArithWithStarUnbounded (c : ℕ) : Satisfiable (trueArithW haveI : Structure.Add ℒₒᵣ⋆ ℕ := ⟨fun _ _ => rfl⟩ haveI : Structure.Eq ℒₒᵣ⋆ ℕ := ⟨fun _ _ => iff_of_eq rfl⟩ haveI : Structure.LT ℒₒᵣ⋆ ℕ := ⟨fun _ _ => iff_of_eq rfl⟩ - have : ℕ ⊧ₘ* starUnbounded c := by - have : ∀ (i : Fin c), (↑i : ℕ) < Semiterm.Operator.val (L := ℒₒᵣ⋆) Semiterm.Operator.Star.star ![] := Fin.prop + have : ℕ↓[ℒₒᵣ⋆] ⊧* starUnbounded c := by + have : ∀ (i : Fin c), (↑i : ℕ) < Semiterm.Operator.Star.star.val (L := ℒₒᵣ⋆) ![] := Fin.prop simp [starUnbounded, models_iff, this] - have : ℕ ⊧ₘ* trueArithWithStarUnbounded c := by + have : ℕ↓[ℒₒᵣ⋆] ⊧* trueArithWithStarUnbounded c := by simpa [trueArithWithStarUnbounded, models_iff] using this exact satisfiable_intro ℕ this @@ -42,7 +42,7 @@ lemma satisfiable_union_trueArithWithStarUnbounded : (Compact.compact_cumulative trueArithWithStarUnbounded.cumulative).mpr satisfiable_trueArithWithStarUnbounded -instance trueArithWithStarUnbounded.eqTheory : 𝗘𝗤 ⪯ (⋃ c, trueArithWithStarUnbounded c) := +instance trueArithWithStarUnbounded.eqTheory : 𝗘𝗤 ℒₒᵣ⋆ ⪯ (⋃ c, trueArithWithStarUnbounded c) := Entailment.WeakerThan.ofSubset <| Set.subset_iUnion_of_subset 0 (Set.subset_union_of_subset_left (by simp) _) @@ -54,14 +54,14 @@ namespace Nonstandard notation "ℕ⋆" => Nonstandard -def star : ℕ⋆ := Semiterm.Operator.val (L := ℒₒᵣ⋆) Semiterm.Operator.Star.star ![] +def star : ℕ⋆ := Semiterm.Operator.Star.star.val (L := ℒₒᵣ⋆) ![] local notation "⋆" => star -lemma models_union_trueArithWithStarUnbounded : ℕ⋆ ⊧ₘ* ⋃ c, trueArithWithStarUnbounded c := ModelOfSatEq.models _ +lemma models_union_trueArithWithStarUnbounded : ℕ⋆↓[ℒₒᵣ⋆] ⊧* ⋃ c, trueArithWithStarUnbounded c := ModelOfSatEq.models _ -instance : ℕ⋆ ⊧ₘ* 𝗧𝗔 := ⟨by - have : ℕ⋆ ⊧ₘ* Semiformula.lMap (Language.Hom.add₁ _ _) '' 𝗧𝗔 := +instance : ℕ⋆↓[ℒₒᵣ] ⊧* 𝗧𝗔 := ⟨by + have : ℕ⋆↓[ℒₒᵣ⋆] ⊧* Semiformula.lMap (Language.Hom.add₁ _ _) '' 𝗧𝗔 := Semantics.ModelsSet.of_subset models_union_trueArithWithStarUnbounded (Set.subset_iUnion_of_subset 0 $ Set.subset_union_of_subset_left (by simp) _) intro σ hσ @@ -80,11 +80,11 @@ instance : ℕ⋆ ⊧ₘ* 𝗧𝗔 := ⟨by have : s.toStruc ⊧ σ := Semiformula.models_lMap.mp (this.models _ (Set.mem_image_of_mem _ hσ)) exact e ▸ this⟩ -instance : ℕ⋆ ⊧ₘ* 𝗣𝗔⁻ := - ModelsTheory.of_ss (U := 𝗧𝗔) inferInstance (Structure.subset_of_models.mpr inferInstance) +instance : ℕ⋆↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := + models_of_ss (U := 𝗧𝗔) inferInstance (Structure.subset_of_models.mpr inferInstance) lemma star_unbounded (n : ℕ) : n < ⋆ := by - have : ℕ⋆ ⊧ₘ (“!!(Semiterm.Operator.numeral ℒₒᵣ⋆ n) < ⋆” : Sentence ℒₒᵣ⋆) := + have : ℕ⋆↓[ℒₒᵣ⋆] ⊧ (“!!(Semiterm.Operator.numeral ℒₒᵣ⋆ n) < ⋆” : Sentence ℒₒᵣ⋆) := models_union_trueArithWithStarUnbounded.models _ <| Set.mem_iUnion_of_mem (n + 1) <| Set.mem_union_right _ diff --git a/Foundation/FirstOrder/Basic/Operator.lean b/Foundation/FirstOrder/Basic/Operator.lean index 9b89376e4..c2c0d9e81 100644 --- a/Foundation/FirstOrder/Basic/Operator.lean +++ b/Foundation/FirstOrder/Basic/Operator.lean @@ -601,51 +601,54 @@ attribute [simp] Zero.zero One.one Add.add Mul.mul Exp.exp Eq.eq LT.lt LE.le Mem instance [L.Eq] [L.LT] [Structure.Eq L M] [PartialOrder M] [Structure.LT L M] : Structure.LE L M := ⟨by intro a b; simpa [Operator.LE.def_of_Eq_of_LT] using le_iff_eq_or_lt.symm⟩ -variable {L} +variable {L M} -@[simp] lemma zero_eq_of_lang [L.Zero] [Zero M] [Structure.Zero L M] : - Structure.func (L := L) Language.Zero.zero ![] = (0 : M) := by - simpa [Semiterm.Operator.val, Semiterm.Operator.Zero.zero, val_func, ←Matrix.fun_eq_vec_two] using +@[simp] lemma zero_eq_of_lang [L.Zero] [Zero M] [Structure.Zero L M] (v : Fin 0 → M) : + Structure.func (L := L) Language.Zero.zero v = (0 : M) := by + simpa [Matrix.empty_eq, Semiterm.Operator.val, Semiterm.Operator.Zero.zero, ←Matrix.fun_eq_vec_two] using Structure.Zero.zero (L := L) (M := M) -@[simp] lemma one_eq_of_lang [L.One] [One M] [Structure.One L M] : - Structure.func (L := L) Language.One.one ![] = (1 : M) := by - simpa [Semiterm.Operator.val, Semiterm.Operator.One.one, val_func, ←Matrix.fun_eq_vec_two] using +@[simp] lemma one_eq_of_lang [L.One] [One M] [Structure.One L M] (v : Fin 0 → M) : + Structure.func (L := L) Language.One.one v = (1 : M) := by + simpa [Matrix.empty_eq, Semiterm.Operator.val, Semiterm.Operator.One.one, ←Matrix.fun_eq_vec_two] using Structure.One.one (L := L) (M := M) @[simp] lemma add_eq_of_lang [L.Add] [Add M] [Structure.Add L M] {v : Fin 2 → M} : Structure.func (L := L) Language.Add.add v = v 0 + v 1 := by - simpa [val_func, ←Matrix.fun_eq_vec_two] using - Structure.Add.add (L := L) (v 0) (v 1) + simpa [←Matrix.fun_eq_vec_two] using Structure.Add.add (L := L) (v 0) (v 1) @[simp] lemma mul_eq_of_lang [L.Mul] [Mul M] [Structure.Mul L M] {v : Fin 2 → M} : Structure.func (L := L) Language.Mul.mul v = v 0 * v 1 := by - simpa [val_func, ←Matrix.fun_eq_vec_two] using - Structure.Mul.mul (L := L) (v 0) (v 1) + simpa [←Matrix.fun_eq_vec_two] using Structure.Mul.mul (L := L) (v 0) (v 1) @[simp] lemma exp_eq_of_lang [L.Exp] [Exp M] [Structure.Exp L M] {v : Fin 1 → M} : Structure.func (L := L) Language.Exp.exp v = LO.Exp.exp (v 0) := by - simpa [val_func, ←Matrix.fun_eq_vec_one] using - Structure.Exp.exp (L := L) (v 0) + simpa [←Matrix.fun_eq_vec_one] using Structure.Exp.exp (L := L) (v 0) + +@[simp] lemma eq_iff_eq [Operator.Eq L] [Structure.Eq L M] {v : Fin 2 →M} : + (@Operator.Eq.eq L _).val v ↔ v 0 = v 1 := by + rw [Matrix.fun_eq_vec_two v]; simp + +@[simp] lemma lt_iff_lt [Operator.LT L] [LT M] [Structure.LT L M] {v : Fin 2 →M} : + (@Operator.LT.lt L _).val v ↔ v 0 < v 1 := by + rw [Matrix.fun_eq_vec_two v]; simp + +@[simp] lemma mem_iff_mem [Operator.Mem L] [Membership M M] [Structure.Mem L M] {v : Fin 2 →M} : + (@Operator.Mem.mem L _).val v ↔ v 0 ∈ v 1 := by + rw [Matrix.fun_eq_vec_two v]; simp lemma le_iff_of_eq_of_lt [Operator.Eq L] [Operator.LT L] [LT M] [Structure.Eq L M] [Structure.LT L M] {a b : M} : (@Operator.LE.le L _).val ![a, b] ↔ a = b ∨ a < b := by simp [Operator.LE.def_of_Eq_of_LT] @[simp] lemma eq_lang [L.Eq] [Structure.Eq L M] {v : Fin 2 → M} : - Structure.rel (L := L) Language.Eq.eq v ↔ v 0 = v 1 := by - simpa [Semiformula.Operator.Eq.sentence_eq, eval_rel, ←Matrix.fun_eq_vec_two] using - Structure.Eq.eq (L := L) (v 0) (v 1) + Structure.rel (L := L) Language.Eq.eq v ↔ v 0 = v 1 := by simpa [-eq_iff_eq] using eq_iff_eq (L := L) (v := v) @[simp] lemma lt_lang [L.LT] [LT M] [Structure.LT L M] {v : Fin 2 → M} : - Structure.rel (L := L) Language.LT.lt v ↔ v 0 < v 1 := by - simpa [Semiformula.Operator.LT.sentence_eq, eval_rel, ←Matrix.fun_eq_vec_two] using - Structure.LT.lt (L := L) (v 0) (v 1) + Structure.rel (L := L) Language.LT.lt v ↔ v 0 < v 1 := by simpa [-lt_iff_lt] using lt_iff_lt (L := L) (v := v) @[simp] lemma mem_lang [L.Mem] [Membership M M] [Structure.Mem L M] {v : Fin 2 → M} : - Structure.rel (L := L) Language.Mem.mem v ↔ v 0 ∈ v 1 := by - simpa [Semiformula.Operator.Mem.sentence_eq, eval_rel, ←Matrix.fun_eq_vec_two] using - Structure.Mem.mem (L := L) (v 0) (v 1) + Structure.rel (L := L) Language.Mem.mem v ↔ v 0 ∈ v 1 := by simpa [-mem_iff_mem] using mem_iff_mem (L := L) (v := v) lemma operator_val_ofEquiv_iff (φ : M ≃ N) {k : ℕ} {o : Semiformula.Operator L k} {v : Fin k → N} : letI : Structure L N := ofEquiv φ diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index 1ab5cbfc3..ad45b38b9 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -238,6 +238,8 @@ abbrev Evalf [s : Structure L M] (f : ξ → M) : Formula L ξ →ˡᶜ Prop := abbrev Evalb [s : Structure L M] (b : Fin n → M) : Semiformula L Empty n →ˡᶜ Prop := Eval b Empty.elim +notation:max M:90 " ⊧/" e:max => @Evalb _ M _ _ e + abbrev Realize (M : Type*) [s : Structure L M] : Sentence L →ˡᶜ Prop := Eval (s := s) ![] Empty.elim @@ -364,7 +366,7 @@ lemma eval_bShift' (φ : Semiformula L ξ n) : simp [IsEmpty.eq_elim] @[simp] lemma eval_embSubsts {ξ} {f : ξ → M} {k} (w : Fin k → Semiterm L ξ n) (σ : Semisentence L k) : - Eval b f ((@Rew.embSubsts L ξ n k w) ▹ σ) ↔ σ.Evalb (Semiterm.val b f ∘ w) := by + Eval b f ((@Rew.embSubsts L ξ n k w) ▹ σ) ↔ M ⊧/(Semiterm.val b f ∘ w) σ := by simp [eval_rew, Function.comp_def, Empty.eq_elim] section Syntactic diff --git a/Foundation/FirstOrder/Incompleteness/Second.lean b/Foundation/FirstOrder/Incompleteness/Second.lean index 78fe53208..a835ffb90 100644 --- a/Foundation/FirstOrder/Incompleteness/Second.lean +++ b/Foundation/FirstOrder/Incompleteness/Second.lean @@ -28,11 +28,11 @@ theorem inconsistent_independent [ArithmeticTheory.SoundOnHierarchy T 𝚺 1] : instance [Consistent T] : T ⪱ T + T.Con := StrictlyWeakerThan.of_unprovable_provable (φ := ↑T.consistent) (consistent_unprovable T) - (Entailment.by_axm _ (by simp [Theory.add_def])) + (Entailment.by_axm (by simp [Theory.add_def])) instance [ArithmeticTheory.SoundOnHierarchy T 𝚺 1] : T ⪱ T + T.Incon := StrictlyWeakerThan.of_unprovable_provable (φ := ∼↑T.consistent) (inconsistent_unprovable T) - (Entailment.by_axm _ (by simp [Theory.add_def])) + (Entailment.by_axm (by simp [Theory.add_def])) end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Interpretation.lean b/Foundation/FirstOrder/Interpretation.lean index 5cf6235bb..86be389c5 100644 --- a/Foundation/FirstOrder/Interpretation.lean +++ b/Foundation/FirstOrder/Interpretation.lean @@ -397,7 +397,7 @@ abbrev Model (M : Type*) [Structure L₁ M] : Type _ := π.trln.Model M open Classical in instance model_models_theory {M : Type v} [Nonempty M] [Structure L₁ M] [Structure.Eq L₁ M] (hT : M ⊧ₘ* T) : π.Model M ⊧ₘ* U := - modelsTheory_iff.mpr fun {σ} hσ ↦ + models_theory_iff.mpr fun {σ} hσ ↦ Model.translate_iff.mp <| consequence_iff'.mp (sound! (π.interpret_theory σ hσ)) M open Classical in @@ -413,7 +413,7 @@ abbrev ofWeakerThan {L : Language} [L.Eq] (T U : Theory L) [𝗘𝗤 ⪯ T] [U have : U ⪯ T := inferInstance Model.translate_iff.mpr <| by suffices M ⊧/ ![] φ by simpa [models_iff, Empty.eq_elim, Matrix.empty_eq] - have : T ⊢ φ := Entailment.weakerThan_iff.mp this (Entailment.by_axm _ (by simp [hφ])) + have : T ⊢ φ := Entailment.weakerThan_iff.mp this (Entailment.by_axm (by simp [hφ])) exact models_of_provable hT this protected instance refl {L : Language} [L.Eq] (T : Theory L) [𝗘𝗤 ⪯ T] : T ⊳ T := ofWeakerThan T T @@ -561,7 +561,7 @@ protected abbrev comp (τ : T₂ ⊳ T₃) (π : T₁ ⊳ T₂) : T₁ ⊳ T₃ suffices τ.Model (π.Model M) ⊧ₘ φ by apply Model.translate_iff.mpr <| (compDirectTranslation_Model_equiv τ.trln π).models.mpr this have : τ.Model (π.Model M) ⊧ₘ* T₃ := inferInstance - exact modelsTheory_iff.mp this hφ + exact models_theory_iff.mp this hφ end composition diff --git a/Foundation/FirstOrder/SetTheory/Universe.lean b/Foundation/FirstOrder/SetTheory/Universe.lean index 2d61e8e71..9e8fc615b 100644 --- a/Foundation/FirstOrder/SetTheory/Universe.lean +++ b/Foundation/FirstOrder/SetTheory/Universe.lean @@ -227,7 +227,7 @@ instance models_zf : Universe.{u} ⊧ₘ* 𝗭𝗙 where rcases hφ case axiom_of_equality h => have : Universe.{u} ⊧ₘ* (𝗘𝗤 : Theory ℒₛₑₜ) := inferInstance - simpa [models_iff] using modelsTheory_iff.mp this h + simpa [models_iff] using models_theory_iff.mp this h case axiom_of_empty_set => suffices ∃ x, ∀ y, y ∉ x by simpa [models_iff, Axiom.empty] exact ⟨empty, by simp⟩ @@ -311,7 +311,7 @@ instance models_ac : Universe.{u} ⊧ₘ* 𝗔𝗖 where instance models_zfc : Universe.{u} ⊧ₘ* 𝗭𝗙𝗖 := inferInstance -instance models_z : Universe.{u} ⊧ₘ* 𝗭 := ModelsTheory.of_ss inferInstance z_subset_zf +instance models_z : Universe.{u} ⊧ₘ* 𝗭 := models_of_ss inferInstance z_subset_zf instance models_zc : Universe.{u} ⊧ₘ* 𝗭𝗖 := inferInstance From 17ca9ad959722eb32ce83c0d52b9627cc100a44e Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sun, 31 May 2026 03:07:48 +0900 Subject: [PATCH 06/14] HFS --- .../Arithmetic/Exponential/Bit.lean | 34 ++-- .../Arithmetic/Exponential/Exp.lean | 8 +- .../Arithmetic/Exponential/Log.lean | 8 +- .../Arithmetic/Exponential/PPow2.lean | 6 +- .../Arithmetic/Exponential/Pow2.lean | 9 +- .../FirstOrder/Arithmetic/HFS/Basic.lean | 2 +- .../FirstOrder/Arithmetic/HFS/Coding.lean | 2 +- .../FirstOrder/Arithmetic/HFS/Fixpoint.lean | 20 +-- Foundation/FirstOrder/Arithmetic/HFS/PRF.lean | 12 +- Foundation/FirstOrder/Arithmetic/HFS/Seq.lean | 2 +- Foundation/FirstOrder/Arithmetic/HFS/Vec.lean | 6 +- .../FirstOrder/Arithmetic/IOpen/Basic.lean | 32 ++-- .../FirstOrder/Arithmetic/Induction.lean | 8 +- .../FirstOrder/Arithmetic/Omega1/Basic.lean | 22 +-- .../FirstOrder/Arithmetic/Omega1/Nuon.lean | 12 +- .../Arithmetic/PeanoMinus/Functions.lean | 6 +- .../FirstOrder/Arithmetic/Schemata.lean | 152 +++++++++--------- .../DerivabilityCondition/D1.lean | 2 +- .../DerivabilityCondition/D2.lean | 2 +- .../DerivabilityCondition/D3.lean | 2 +- .../EquationalTheory.lean | 2 +- .../DerivabilityCondition/PeanoMinus.lean | 4 +- .../FirstOrder/Bootstrapping/FixedPoint.lean | 8 +- .../Bootstrapping/Syntax/Formula/Basic.lean | 2 +- .../Bootstrapping/Syntax/Formula/Coding.lean | 2 +- .../Syntax/Formula/Functions.lean | 2 +- .../Syntax/Formula/Iteration.lean | 2 +- .../Bootstrapping/Syntax/Formula/Typed.lean | 2 +- .../Bootstrapping/Syntax/Language.lean | 4 +- .../Bootstrapping/Syntax/Proof/Basic.lean | 2 +- .../Bootstrapping/Syntax/Proof/Coding.lean | 2 +- .../Bootstrapping/Syntax/Proof/Typed.lean | 4 +- .../Bootstrapping/Syntax/Term/Basic.lean | 2 +- .../Bootstrapping/Syntax/Term/Coding.lean | 2 +- .../Bootstrapping/Syntax/Term/Functions.lean | 2 +- .../Bootstrapping/Syntax/Term/Typed.lean | 2 +- .../Bootstrapping/Syntax/Theory.lean | 2 +- .../Incompleteness/Consistency.lean | 2 +- .../FirstOrder/Incompleteness/Jeroslow.lean | 4 +- .../Incompleteness/RestrictedProvability.lean | 4 +- .../Incompleteness/RosserProvability.lean | 2 +- .../Incompleteness/WitnessComparison.lean | 2 +- .../FirstOrder/Incompleteness/Yablo.lean | 14 +- .../ProvabilityLogic/SolovaySentences.lean | 4 +- 44 files changed, 211 insertions(+), 214 deletions(-) diff --git a/Foundation/FirstOrder/Arithmetic/Exponential/Bit.lean b/Foundation/FirstOrder/Arithmetic/Exponential/Bit.lean index 2e73bb79b..65737a098 100644 --- a/Foundation/FirstOrder/Arithmetic/Exponential/Bit.lean +++ b/Foundation/FirstOrder/Arithmetic/Exponential/Bit.lean @@ -14,7 +14,7 @@ variable {V : Type*} [ORingStructure V] section -variable [V ⊧ₘ* 𝗜𝚺₁] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] section model @@ -149,20 +149,20 @@ section model scoped instance : Structure.Mem ℒₒᵣ V := ⟨by intro a b; simp [Semiformula.Operator.val, operator_mem_def]⟩ -@[simp] lemma eval_ballIn {t : Semiterm ℒₒᵣ ξ n} {p : Semiformula ℒₒᵣ ξ (n + 1)} {e ε} : - Semiformula.Evalm V e ε (ballIn t p) ↔ ∀ x ∈ t.valm V e ε, Semiformula.Evalm V (x :> e) ε p := by +@[simp] lemma eval_ballIn {t : Semiterm ℒₒᵣ ξ n} {φ : Semiformula ℒₒᵣ ξ (n + 1)} {bv : Fin n → V} {fv : ξ → V} : + (ballIn t φ).Eval (M := V) bv fv ↔ ∀ x ∈ t.val bv fv, φ.Eval (x :> bv) fv := by suffices - (∀ x < t.valm V e ε, x ∈ t.valm V e ε → Semiformula.Evalm V (x :> e) ε p) ↔ - ∀ x ∈ t.valm V e ε, Semiformula.Evalm V (x :> e) ε p by simpa [ballIn] + (∀ x < t.val bv fv, x ∈ t.val bv fv → φ.Eval (x :> bv) fv) ↔ + ∀ x ∈ t.val bv fv, φ.Eval (x :> bv) fv by simpa [ballIn] constructor · intro h x hx; exact h x (lt_of_mem hx) hx · intro h x _ hx; exact h x hx -@[simp] lemma eval_bexsIn {t : Semiterm ℒₒᵣ ξ n} {p : Semiformula ℒₒᵣ ξ (n + 1)} {e ε} : - Semiformula.Evalm V e ε (bexsIn t p) ↔ ∃ x ∈ t.valm V e ε, Semiformula.Evalm V (x :> e) ε p := by +@[simp] lemma eval_bexsIn {t : Semiterm ℒₒᵣ ξ n} {φ : Semiformula ℒₒᵣ ξ (n + 1)} {bv : Fin n → V} {fv : ξ → V} : + (bexsIn t φ).Eval (M := V) bv fv ↔ ∃ x ∈ t.val bv fv, φ.Eval (x :> bv) fv := by suffices - (∃ x < t.valm V e ε, x ∈ t.valm V e ε ∧ Semiformula.Evalm V (x :> e) ε p) ↔ - ∃ x ∈ t.valm V e ε, Semiformula.Evalm V (x :> e) ε p by simpa [bexsIn] + (∃ x < t.val bv fv, x ∈ t.val bv fv ∧ φ.Eval (x :> bv) fv) ↔ + ∃ x ∈ t.val bv fv, φ.Eval (x :> bv) fv by simpa [bexsIn] constructor · rintro ⟨x, _, hx, h⟩; exact ⟨x, hx, h⟩ · rintro ⟨x, hx, h⟩; exact ⟨x, lt_of_mem hx, hx, h⟩ @@ -195,7 +195,7 @@ section empty scoped instance : EmptyCollection V := ⟨0⟩ -omit [V ⊧ₘ* 𝗜𝚺₁] in +omit [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] in lemma emptyset_def : (∅ : V) = 0 := rfl @[simp] lemma not_mem_empty (i : V) : i ∉ (∅ : V) := by simp [emptyset_def, mem_iff_bit, Bit] @@ -489,12 +489,12 @@ end section -variable {m : ℕ} [Fact (1 ≤ m)] [V ⊧ₘ* 𝗜𝗡𝗗 𝚺 m] +variable {m : ℕ} [Fact (1 ≤ m)] [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚺 m] lemma finset_comprehension_aux (Γ : Polarity) {P : V → Prop} (hP : Γ-[m]-Predicate P) (a : V) : - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) ∃ s < Exp.exp a, ∀ i < a, i ∈ s ↔ P i := by - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) have : ∃ s < Exp.exp a, ∀ i < a, P i → i ∈ s := ⟨under a, pred_lt_self_of_pos (by simp), fun i hi _ ↦ by simpa [mem_under_iff] using hi⟩ rcases this with ⟨s, hsn, hs⟩ @@ -521,7 +521,7 @@ lemma finset_comprehension_aux (Γ : Polarity) {P : V → Prop} (hP : Γ-[m]-Pre exact ⟨t, lt_of_le_of_lt t_le_s hsn, fun i hi ↦ ⟨this i hi, ht i hi⟩⟩ theorem finset_comprehension {Γ} {P : V → Prop} (hP : Γ-[m]-Predicate P) (a : V) : - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) ∃ s < Exp.exp a, ∀ i < a, i ∈ s ↔ P i := match Γ with | 𝚺 => finset_comprehension_aux 𝚺 hP a @@ -529,9 +529,9 @@ theorem finset_comprehension {Γ} {P : V → Prop} (hP : Γ-[m]-Predicate P) (a | 𝚫 => finset_comprehension_aux 𝚺 hP.of_delta a theorem finset_comprehension_exists_unique {P : V → Prop} (hP : Γ-[m]-Predicate P) (a : V) : - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) ∃! s, s < Exp.exp a ∧ ∀ i < a, i ∈ s ↔ P i := by - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) rcases finset_comprehension hP a with ⟨s, hs, Hs⟩ exact ExistsUnique.intro s ⟨hs, Hs⟩ (by intro t ⟨ht, Ht⟩ @@ -550,7 +550,7 @@ end section -variable [V ⊧ₘ* 𝗜𝚺₁] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] instance : Fact (1 ≤ 1) := ⟨by rfl⟩ diff --git a/Foundation/FirstOrder/Arithmetic/Exponential/Exp.lean b/Foundation/FirstOrder/Arithmetic/Exponential/Exp.lean index 34bc51407..4fc81064c 100644 --- a/Foundation/FirstOrder/Arithmetic/Exponential/Exp.lean +++ b/Foundation/FirstOrder/Arithmetic/Exponential/Exp.lean @@ -19,7 +19,7 @@ variable {V : Type*} [ORingStructure V] section ISigma0 -variable [V ⊧ₘ* 𝗜𝚺₀] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] noncomputable def ext (u z : V) : V := z / u % u @@ -91,7 +91,7 @@ def Exponential.Seqₛ.def : 𝚺₀.Semisentence 3 := .mkSigma (∃ ext_u_Y <⁺ Y, !extDef ext_u_Y u Y ∧ !extDef (2 * ext_u_Y²) u² Y) ) ” instance Exponential.Seqₛ.defined : 𝚺₀-Relation₃[V] Exponential.Seqₛ via Exponential.Seqₛ.def := .mk fun v ↦ by - simp [Exponential.Seqₛ.iff, Exponential.Seqₛ.def, sq, numeral_eq_natCast] + simp [Exponential.Seqₛ.iff, Exponential.Seqₛ.def, sq] lemma Exponential.graph_iff (x y : V) : Exponential x y ↔ @@ -115,7 +115,7 @@ def _root_.LO.FirstOrder.Arithmetic.exponentialDef : 𝚺₀.Semisentence 2 := . /-- The graph of the exponential function can be defined by the $\Delta_0$-formula. -/ instance Exponential.defined : 𝚺₀-Relation[V] Exponential via exponentialDef := .mk fun v ↦ by - simp [Exponential.graph_iff, exponentialDef, pow_four, sq, numeral_eq_natCast] + simp [Exponential.graph_iff, exponentialDef, pow_four, sq] /-- The graph of the exponential function can be defined by the $\Delta_0$-formula. -/ instance exponential_definable : 𝚺₀-Relation (Exponential : V → V → Prop) := Exponential.defined.to_definable @@ -712,7 +712,7 @@ end ISigma0 section ISigma1 -variable [V ⊧ₘ* 𝗜𝚺₁] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] namespace Exponential diff --git a/Foundation/FirstOrder/Arithmetic/Exponential/Log.lean b/Foundation/FirstOrder/Arithmetic/Exponential/Log.lean index a15f2c27c..e68557e25 100644 --- a/Foundation/FirstOrder/Arithmetic/Exponential/Log.lean +++ b/Foundation/FirstOrder/Arithmetic/Exponential/Log.lean @@ -13,7 +13,7 @@ variable {V : Type*} [ORingStructure V] section ISigma0 -variable [V ⊧ₘ* 𝗜𝚺₀] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] lemma log_exists_unique_pos {y : V} (hy : 0 < y) : ∃! x, x < y ∧ ∃ y' ≤ y, Exponential x y' ∧ y < 2 * y' := by have : ∃ x < y, ∃ y' ≤ y, Exponential x y' ∧ y < 2 * y' := by @@ -71,7 +71,7 @@ lemma log_graph {x y : V} : x = log y ↔ (y = 0 → x = 0) ∧ (0 < y → x < y def _root_.LO.FirstOrder.Arithmetic.logDef : 𝚺₀.Semisentence 2 := .mkSigma “x y. (y = 0 → x = 0) ∧ (0 < y → x < y ∧ ∃ y' <⁺ y, !exponentialDef x y' ∧ y < 2 * y')” -instance log_defined : 𝚺₀-Function₁[V] log via logDef := .mk fun v ↦ by simp [logDef, log_graph, numeral_eq_natCast] +instance log_defined : 𝚺₀-Function₁[V] log via logDef := .mk fun v ↦ by simp [logDef, log_graph] instance log_definable : 𝚺₀-Function₁ (log : V → V) := log_defined.to_definable @@ -406,7 +406,7 @@ lemma fbit_eq_zero_of_le {a i : V} (hi : ‖a‖ ≤ i) : fbit a i = 0 := by sim def _root_.LO.FirstOrder.Arithmetic.fbitDef : 𝚺₀.Semisentence 3 := .mkSigma “b a i. ∃ x <⁺ a, !bexpDef x a i ∧ ∃ y <⁺ a, !divDef y a x ∧ !remDef b y 2” -instance fbit_defined : 𝚺₀-Function₂[V] fbit via fbitDef := .mk fun v ↦ by simp [fbitDef, fbit, numeral_eq_natCast] +instance fbit_defined : 𝚺₀-Function₂[V] fbit via fbitDef := .mk fun v ↦ by simp [fbitDef, fbit] instance fbit_definable : 𝚺₀-Function₂[V] fbit := fbit_defined.to_definable @@ -432,7 +432,7 @@ end ISigma0 section ISigma1 -variable [V ⊧ₘ* 𝗜𝚺₁] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] @[simp] lemma log_exponential (a : V) : log (Exp.exp a) = a := (exponential_exp a).log_eq_of_exp diff --git a/Foundation/FirstOrder/Arithmetic/Exponential/PPow2.lean b/Foundation/FirstOrder/Arithmetic/Exponential/PPow2.lean index c10afb446..df702ae05 100644 --- a/Foundation/FirstOrder/Arithmetic/Exponential/PPow2.lean +++ b/Foundation/FirstOrder/Arithmetic/Exponential/PPow2.lean @@ -11,7 +11,7 @@ $\mathrm{PPow2}(n)$ is a property that holds iff $n = 2^{2^i}$ for some $i$. namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₀] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] def SPPow2 (m : V) : Prop := ¬LenBit 1 m ∧ LenBit 2 m ∧ ∀ i ≤ m, Pow2 i → 2 < i → (LenBit i m ↔ (√i)^2 = i ∧ LenBit (√i) m) @@ -22,7 +22,7 @@ def _root_.LO.FirstOrder.Arithmetic.sppow2Def : 𝚺₀.Semisentence 1 := ” instance sppow2_defined : 𝚺₀-Predicate[V] SPPow2 via sppow2Def := .mk fun v ↦ by - simp [SPPow2, sppow2Def, sq, numeral_eq_natCast] + simp [SPPow2, sppow2Def, sq] def PPow2 (i : V) : Prop := Pow2 i ∧ ∃ m < 2 * i, SPPow2 m ∧ LenBit i m @@ -30,7 +30,7 @@ def _root_.LO.FirstOrder.Arithmetic.ppow2Def : 𝚺₀.Semisentence 1 := .mkSigma “i. !pow2Def i ∧ ∃ m < 2 * i, !sppow2Def m ∧ !lenbitDef i m” instance ppow2_defined : 𝚺₀-Predicate (PPow2 : V → Prop) via ppow2Def := .mk fun v ↦ by - simp [PPow2, ppow2Def, numeral_eq_natCast] + simp [PPow2, ppow2Def] instance ppow2_definable : 𝚺₀-Predicate (PPow2 : V → Prop) := ppow2_defined.to_definable diff --git a/Foundation/FirstOrder/Arithmetic/Exponential/Pow2.lean b/Foundation/FirstOrder/Arithmetic/Exponential/Pow2.lean index 80f5bff5e..d3f482de1 100644 --- a/Foundation/FirstOrder/Arithmetic/Exponential/Pow2.lean +++ b/Foundation/FirstOrder/Arithmetic/Exponential/Pow2.lean @@ -15,7 +15,7 @@ variable {V : Type*} [ORingStructure V] section IOpen -variable [V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻] def Pow2 (a : V) : Prop := 0 < a ∧ ∀ r ≤ a, 1 < r → r ∣ a → 2 ∣ r @@ -23,8 +23,7 @@ def _root_.LO.FirstOrder.Arithmetic.pow2Def : 𝚺₀.Semisentence 1 := .mkSigma “a. 0 < a ∧ ∀ r <⁺ a, 1 < r → r ∣ a → 2 ∣ r” instance pow2_defined : 𝚺₀-Predicate (Pow2 : V → Prop) via pow2Def := .mk fun v ↦ by - simp [Semiformula.eval_substs, Matrix.comp_vecCons', Matrix.constant_eq_singleton, - Pow2, pow2Def, le_iff_lt_succ, numeral_eq_natCast] + simp [Semiformula.eval_substs, Pow2, pow2Def, le_iff_lt_succ] instance pow2_definable : 𝚺₀-Predicate (Pow2 : V → Prop) := pow2_defined.to_definable @@ -116,7 +115,7 @@ def _root_.LO.FirstOrder.Arithmetic.lenbitDef : 𝚺₀.Semisentence 2 := .mkSigma “i a. ∃ z <⁺ a, !divDef.val z a i ∧ ¬2 ∣ z” instance lenbit_defined : 𝚺₀-Relation (LenBit : V → V → Prop) via lenbitDef := .mk fun v ↦ by - simp [lenbitDef, LenBit, numeral_eq_natCast] + simp [lenbitDef, LenBit] instance lenbit_definable : 𝚺₀-Relation (LenBit : V → V → Prop) := lenbit_defined.to_definable @@ -194,7 +193,7 @@ end IOpen section ISigma0 -variable [V ⊧ₘ* 𝗜𝚺₀] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] namespace Pow2 diff --git a/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean b/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean index 17340f50d..015f8a9fe 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean @@ -11,7 +11,7 @@ public import Foundation.FirstOrder.Arithmetic.Exponential namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] @[simp] lemma susbset_insert (x a : V) : a ⊆ insert x a := by intro z hz; simp [hz] diff --git a/Foundation/FirstOrder/Arithmetic/HFS/Coding.lean b/Foundation/FirstOrder/Arithmetic/HFS/Coding.lean index d1459dce6..17e2d7281 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/Coding.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/Coding.lean @@ -5,7 +5,7 @@ public import Foundation.FirstOrder.Arithmetic.HFS.Vec @[expose] public section namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] noncomputable def finsetArithmetizeAux : List V → V | [] => ∅ diff --git a/Foundation/FirstOrder/Arithmetic/HFS/Fixpoint.lean b/Foundation/FirstOrder/Arithmetic/HFS/Fixpoint.lean index 2dd02d56b..9aea931e8 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/Fixpoint.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/Fixpoint.lean @@ -11,7 +11,7 @@ public import Foundation.FirstOrder.Arithmetic.HFS.PRF namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] namespace Fixpoint @@ -65,7 +65,7 @@ namespace Construction variable {k : ℕ} {φ : Blueprint k} (c : Construction V φ) (v : Fin k → V) lemma eval_formula (v : Fin k.succ.succ → V) : - Semiformula.Evalbm V v φ.core.val ↔ c.Φ (v ·.succ.succ) {x | x ∈ v 1} (v 0) := c.defined.iff + φ.core.val.Evalb v ↔ c.Φ (v ·.succ.succ) {x | x ∈ v 1} (v 0) := c.defined.iff lemma succ_existsUnique (s ih : V) : ∃! u : V, ∀ x, (x ∈ u ↔ x ≤ s ∧ c.Φ v {z | z ∈ ih} x) := by @@ -98,8 +98,8 @@ lemma succ_defined : 𝚺₁.DefinedFunction (fun v : Fin (k + 2) → V ↦ c.su c.defined.proper.iff', -and_imp, BinderNotation.finSuccItr] grind -lemma eval_succDef (v) : - Semiformula.Evalbm V v φ.succDef.val ↔ v 0 = c.succ (v ·.succ.succ.succ) (v 2) (v 1) := c.succ_defined.iff +lemma eval_succDef (v : Fin (k + 3) → V) : + φ.succDef.val.Evalb v ↔ v 0 = c.succ (v ·.succ.succ.succ) (v 2) (v 1) := c.succ_defined.iff noncomputable def prConstruction : PR.Construction V φ.prBlueprint where zero := fun _ ↦ ∅ @@ -120,8 +120,8 @@ lemma limSeq_succ (s : V) : c.limSeq v (s + 1) = c.succ v s (c.limSeq v s) := by lemma termSet_defined : 𝚺₁.DefinedFunction (fun v ↦ c.limSeq (v ·.succ) (v 0)) φ.limSeqDef := .mk fun v ↦ by simp [c.prConstruction.result_defined_iff, Blueprint.limSeqDef]; rfl -@[simp] lemma eval_limSeqDef (v) : - Semiformula.Evalbm V v φ.limSeqDef.val ↔ v 0 = c.limSeq (v ·.succ.succ) (v 1) := c.termSet_defined.iff +@[simp] lemma eval_limSeqDef (v : Fin (k + 2) → V) : + φ.limSeqDef.val.Evalb v ↔ v 0 = c.limSeq (v ·.succ.succ) (v 1) := c.termSet_defined.iff instance limSeq_definable : 𝚺₁.DefinableFunction (fun v ↦ c.limSeq (v ·.succ) (v 0)) := c.termSet_defined.to_definable @@ -234,15 +234,15 @@ section lemma fixpoint_defined : 𝚺₁.Defined (fun v ↦ c.Fixpoint (v ·.succ) (v 0)) φ.fixpointDef := .mk fun v ↦ by simp [Blueprint.fixpointDef, c.eval_limSeqDef]; rfl -@[simp] lemma eval_fixpointDef (v) : - Semiformula.Evalbm V v φ.fixpointDef.val ↔ c.Fixpoint (v ·.succ) (v 0) := c.fixpoint_defined.iff +@[simp] lemma eval_fixpointDef (v : Fin (k + 1) → V) : + φ.fixpointDef.val.Evalb v ↔ c.Fixpoint (v ·.succ) (v 0) := c.fixpoint_defined.iff lemma fixpoint_definedΔ₁ [c.StrongFinite] : 𝚫₁.Defined (fun v ↦ c.Fixpoint (v ·.succ) (v 0)) φ.fixpointDefΔ₁ := ⟨by intro v; simp [Blueprint.fixpointDefΔ₁, c.eval_limSeqDef], by intro v; simp [Blueprint.fixpointDefΔ₁, c.eval_limSeqDef, fixpoint_iff]⟩ -@[simp] lemma eval_fixpointDefΔ₁ [c.StrongFinite] (v) : - Semiformula.Evalbm V v φ.fixpointDefΔ₁.val ↔ c.Fixpoint (v ·.succ) (v 0) := c.fixpoint_definedΔ₁.iff +@[simp] lemma eval_fixpointDefΔ₁ [c.StrongFinite] (v : Fin (k + 1) → V) : + φ.fixpointDefΔ₁.val.Evalb v ↔ c.Fixpoint (v ·.succ) (v 0) := c.fixpoint_definedΔ₁.iff end diff --git a/Foundation/FirstOrder/Arithmetic/HFS/PRF.lean b/Foundation/FirstOrder/Arithmetic/HFS/PRF.lean index 14591d500..32048abe5 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/PRF.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/PRF.lean @@ -11,7 +11,7 @@ public import Foundation.FirstOrder.Arithmetic.HFS.Seq namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] namespace PR @@ -68,8 +68,8 @@ private lemma cseq_iff (s : V) : c.CSeq v s ↔ lemma cseq_defined : 𝚺₁.Defined (fun v ↦ c.CSeq (v ·.succ) (v 0) : (Fin (k + 1) → V) → Prop) p.cseqDef := .mk fun v ↦ by simp [Blueprint.cseqDef, cseq_iff, c.zero_defined.iff, c.succ_defined.iff] -@[simp] lemma cseq_defined_iff (v) : - Semiformula.Evalbm V v p.cseqDef.val ↔ c.CSeq (v ·.succ) (v 0) := c.cseq_defined.iff +@[simp] lemma cseq_defined_iff (v : Fin (k + 1) → V) : + p.cseqDef.val.Evalb v ↔ c.CSeq (v ·.succ) (v 0) := c.cseq_defined.iff variable {c v} @@ -140,7 +140,7 @@ lemma CSeq.exists (l : V) : ∃ s, c.CSeq v s ∧ l + 1 = lh s := by · apply HierarchySymbol.Definable.exs apply HierarchySymbol.Definable.and · exact ⟨p.cseqDef.rew (Rew.embSubsts <| #0 :> fun i ↦ &(v i)), by - intro w; simpa [Matrix.comp_vecCons'] using c.cseq_defined_iff (w 0 :> v)⟩ + intro w; simpa [Matrix.comp_vecCons''] using c.cseq_defined_iff (w 0 :> v)⟩ · definability case zero => exact ⟨!⟦c.zero v⟧, CSeq.initial, by simp⟩ @@ -194,8 +194,8 @@ lemma result_defined : 𝚺₁.DefinedFunction (fun v ↦ c.result (v ·.succ) ( lemma result_defined_delta : 𝚫₁.DefinedFunction (fun v ↦ c.result (v ·.succ) (v 0) : (Fin (k + 1) → V) → V) p.resultDeltaDef := c.result_defined.graph_delta -@[simp] lemma result_defined_iff (v) : - Semiformula.Evalbm V v p.resultDef.val ↔ v 0 = c.result (v ·.succ.succ) (v 1) := c.result_defined.iff +@[simp] lemma result_defined_iff (v : Fin (k + 2) → V) : + p.resultDef.val.Evalb v ↔ v 0 = c.result (v ·.succ.succ) (v 1) := c.result_defined.iff instance result_definable : 𝚺₁.DefinableFunction (fun v ↦ c.result (v ·.succ) (v 0) : (Fin (k + 1) → V) → V) := c.result_defined.to_definable diff --git a/Foundation/FirstOrder/Arithmetic/HFS/Seq.lean b/Foundation/FirstOrder/Arithmetic/HFS/Seq.lean index ffcfacb98..0ebb19a6c 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/Seq.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/Seq.lean @@ -11,7 +11,7 @@ public import Foundation.FirstOrder.Arithmetic.HFS.Basic namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] def Seq (s : V) : Prop := IsMapping s ∧ ∃ l, domain s = under l diff --git a/Foundation/FirstOrder/Arithmetic/HFS/Vec.lean b/Foundation/FirstOrder/Arithmetic/HFS/Vec.lean index 906b53958..b70f6fdf9 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/Vec.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/Vec.lean @@ -11,7 +11,7 @@ public import Foundation.FirstOrder.Arithmetic.HFS.Fixpoint namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] section adjoin @@ -501,8 +501,8 @@ lemma result_defined : 𝚺₁.DefinedFunction (fun v ↦ c.result (v ·.succ) ( · intro h; symm; simpa using c.result_eq_of_graph _ h · intro h; rw [h]; exact c.result_graph _ _ -@[simp] lemma eval_resultDef (v) : - Semiformula.Evalbm V v β.resultDef.val ↔ v 0 = c.result (v ·.succ.succ) (v 1) := c.result_defined.iff +@[simp] lemma eval_resultDef (v : Fin (arity + 2) → V) : + β.resultDef.val.Evalb v ↔ v 0 = c.result (v ·.succ.succ) (v 1) := c.result_defined.iff instance result_definable : 𝚺₁.DefinableFunction (fun v ↦ c.result (v ·.succ) (v 0)) := c.result_defined.to_definable diff --git a/Foundation/FirstOrder/Arithmetic/IOpen/Basic.lean b/Foundation/FirstOrder/Arithmetic/IOpen/Basic.lean index 5bd497cf5..23c266fc8 100644 --- a/Foundation/FirstOrder/Arithmetic/IOpen/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/IOpen/Basic.lean @@ -14,33 +14,33 @@ variable {V : Type*} [ORingStructure V] section IOpen -variable [V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻] -instance : V ⊧ₘ* 𝗣𝗔⁻ := - have : V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻 := inferInstance +instance : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻 := inferInstance models_of_subtheory this -instance : V ⊧ₘ* InductionScheme ℒₒᵣ Semiformula.Open := - have : V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻 := inferInstance +instance : V↓[ℒₒᵣ] ⊧* InductionScheme ℒₒᵣ Semiformula.Open := + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻 := inferInstance models_of_subtheory this @[elab_as_elim] lemma succ_induction {P : V → Prop} - (hP : ∃ p : Semiformula ℒₒᵣ V 1, p.Open ∧ ∀ x, P x ↔ Semiformula.Evalm V ![x] id p) + (hP : ∃ φ : Semiformula ℒₒᵣ V 1, φ.Open ∧ ∀ x, P x ↔ φ.Eval ![x] id) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := InductionScheme.succ_induction (C := Semiformula.Open) (by - rcases hP with ⟨p, hp, hhp⟩ + rcases hP with ⟨φ, hp, hhp⟩ haveI : Inhabited V := Classical.inhabited_of_nonempty' - refine ⟨p.enumarateFVar, Rew.rewriteMap p.idxOfFVar ▹ p, by simp [hp], ?_⟩ + refine ⟨φ.enumarateFVar, Rew.rewriteMap φ.idxOfFVar ▹ φ, by simp [hp], ?_⟩ intro x simp only [hhp, Nat.succ_eq_add_one, Nat.reduceAdd, Semiformula.eval_rewriteMap] - exact Semiformula.eval_iff_of_funEqOn p (by + exact Semiformula.eval_iff_of_funEqOn φ (by intro z hz simp [Semiformula.enumarateFVar_idxOfFVar (Semiformula.mem_fvarList_iff_fvar?.mpr hz)])) zero succ lemma least_number {P : V → Prop} - (hP : ∃ p : Semiformula ℒₒᵣ V 1, p.Open ∧ ∀ x, P x ↔ Semiformula.Evalm V ![x] id p) + (hP : ∃ φ : Semiformula ℒₒᵣ V 1, φ.Open ∧ ∀ x, P x ↔ φ.Eval ![x] id) (zero : P 0) {a} (counterex : ¬P a) : ∃ x, P x ∧ ¬P (x + 1) := by by_contra A have : ∀ x, P x := by @@ -769,11 +769,11 @@ end IOpen /-! ### Polynomial induction -/ @[elab_as_elim] -lemma polynomial_induction [V ⊧ₘ* 𝗣𝗔⁻] (Γ m) [V ⊧ₘ* 𝗜𝗡𝗗 Γ m] +lemma polynomial_induction [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] (Γ m) [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m] {P : V → Prop} (hP : Γ-[m]-Predicate P) (zero : P 0) (even : ∀ x > 0, P x → P (2 * x)) (odd : ∀ x, P x → P (2 * x + 1)) : ∀ x, P x := by - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance - have : V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻 := models_of_subtheory this + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻 := models_of_subtheory this intro x; induction x using InductionOnHierarchy.order_induction · exact Γ · exact m @@ -787,15 +787,15 @@ lemma polynomial_induction [V ⊧ₘ* 𝗣𝗔⁻] (Γ m) [V ⊧ₘ* 𝗜𝗡 · simpa [←hx] using even (x / 2) (by by_contra A; simp at A; simp [show x = 0 from by simpa [A] using hx] at pos) (IH (x / 2) this) · simpa [←hx] using odd (x / 2) (IH (x / 2) this) -@[elab_as_elim] lemma sigma0_polynomial_induction [V ⊧ₘ* 𝗜𝚺₀] {P : V → Prop} (hP : 𝚺₀-Predicate P) +@[elab_as_elim] lemma sigma0_polynomial_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] {P : V → Prop} (hP : 𝚺₀-Predicate P) (zero : P 0) (even : ∀ x > 0, P x → P (2 * x)) (odd : ∀ x, P x → P (2 * x + 1)) : ∀ x, P x := polynomial_induction 𝚺 0 (P := P) hP zero even odd -@[elab_as_elim] lemma sigma1_polynomial_induction [V ⊧ₘ* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚺₁-Predicate P) +@[elab_as_elim] lemma sigma1_polynomial_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚺₁-Predicate P) (zero : P 0) (even : ∀ x > 0, P x → P (2 * x)) (odd : ∀ x, P x → P (2 * x + 1)) : ∀ x, P x := polynomial_induction 𝚺 1 (P := P) hP zero even odd -@[elab_as_elim] lemma pi1_polynomial_induction [V ⊧ₘ* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚷₁-Predicate P) +@[elab_as_elim] lemma pi1_polynomial_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚷₁-Predicate P) (zero : P 0) (even : ∀ x > 0, P x → P (2 * x)) (odd : ∀ x, P x → P (2 * x + 1)) : ∀ x, P x := polynomial_induction 𝚷 1 (P := P) hP zero even odd diff --git a/Foundation/FirstOrder/Arithmetic/Induction.lean b/Foundation/FirstOrder/Arithmetic/Induction.lean index 4321a9057..0d32de6fb 100644 --- a/Foundation/FirstOrder/Arithmetic/Induction.lean +++ b/Foundation/FirstOrder/Arithmetic/Induction.lean @@ -13,7 +13,7 @@ variable {V : Type*} [ORingStructure V] section ISigma1 -variable [V ⊧ₘ* 𝗜𝚺₁] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] @[elab_as_elim] lemma sigma1_pos_succ_induction {P : V → Prop} (hP : 𝚺₁-Predicate P) @@ -202,11 +202,11 @@ end ISigma1 section Induction -variable (m : ℕ) [Fact (1 ≤ m)] [V ⊧ₘ* 𝗜𝗡𝗗𝚺 m] +variable (m : ℕ) [Fact (1 ≤ m)] [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗𝚺 m] lemma sigma_or_pi_succ_induction {P Q : V → Prop} (hP : 𝚺-[m]-Predicate P) (hQ : 𝚷-[m]-Predicate Q) (zero : P 0 ∨ Q 0) (succ : ∀ x, P x ∨ Q x → P (x + 1) ∨ Q (x + 1)) : ∀ x, P x ∨ Q x := by - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) intro a have : ∃ p < Exp.exp (a + 1), ∀ x ≤ a, x ∈ p ↔ P x := by simpa [lt_succ_iff_le] using finset_comprehension hP (a + 1) @@ -229,7 +229,7 @@ lemma sigma_or_pi_succ_induction {P Q : V → Prop} (hP : 𝚺-[m]-Predicate P) lemma sigma_or_pi_order_induction {P Q : V → Prop} (hP : 𝚺-[m]-Predicate P) (hQ : 𝚷-[m]-Predicate Q) (ind : ∀ x, (∀ y < x, P y ∨ Q y) → P x ∨ Q x) : ∀ x, P x ∨ Q x := by - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) intro a have : ∃ p < Exp.exp (a + 1), ∀ x ≤ a, x ∈ p ↔ P x := by simpa [lt_succ_iff_le] using finset_comprehension hP (a + 1) diff --git a/Foundation/FirstOrder/Arithmetic/Omega1/Basic.lean b/Foundation/FirstOrder/Arithmetic/Omega1/Basic.lean index 9de80e190..3ca043870 100644 --- a/Foundation/FirstOrder/Arithmetic/Omega1/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/Omega1/Basic.lean @@ -25,23 +25,23 @@ noncomputable section variable {V : Type*} [ORingStructure V] -lemma models_Omega1_iff [V ⊧ₘ* 𝗜𝚺₀] : V ⊧ₘ Omega1.omega1 ↔ ∀ x : V, ∃ y, Exponential (‖x‖^2) y := by +lemma models_Omega1_iff [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] : V↓[ℒₒᵣ] ⊧ Omega1.omega1 ↔ ∀ x : V, ∃ y, Exponential (‖x‖^2) y := by simp [models_iff, Omega1.omega1, sq] -lemma omega1_of_ISigma1 [V ⊧ₘ* 𝗜𝚺₁] : V ⊧ₘ Omega1.omega1 := models_Omega1_iff.mpr (fun x ↦ Exponential.range_exists (‖x‖^2)) +lemma omega1_of_ISigma1 [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] : V↓[ℒₒᵣ] ⊧ Omega1.omega1 := models_Omega1_iff.mpr (fun x ↦ Exponential.range_exists (‖x‖^2)) -instance [V ⊧ₘ* 𝗜𝚺₁] : V ⊧ₘ* 𝗜𝚺₀ + 𝝮₁ := - ModelsTheory.add_iff.mpr +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ ∪ 𝝮₁ := + Semantics.ModelsSet.union_iff.mpr ⟨inferInstance, ⟨by intro _; simp only [Theory.OmegaOne.mem_iff]; rintro rfl; exact omega1_of_ISigma1⟩⟩ -variable [V ⊧ₘ* 𝗜𝚺₀ + 𝝮₁] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ ∪ 𝝮₁] -instance : V ⊧ₘ* 𝗜𝚺₀ := ModelsTheory.of_add_left V 𝗜𝚺₀ 𝝮₁ +instance : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ := ModelsTheory.of_add_left V 𝗜𝚺₀ 𝝮₁ -instance : V ⊧ₘ* 𝝮₁ := ModelsTheory.of_add_right V 𝗜𝚺₀ 𝝮₁ +instance : V↓[ℒₒᵣ] ⊧* 𝝮₁ := ModelsTheory.of_add_right V 𝗜𝚺₀ 𝝮₁ lemma exists_exponential_sq_length (x : V) : ∃ y, Exponential (‖x‖^2) y := - models_Omega1_iff.mp (Theory.models V Omega1.omega) x + models_Omega1_iff.mp (Theory.models _ _ Omega1.omega) x lemma exists_unique_exponential_sq_length (x : V) : ∃! y, Exponential (‖x‖^2) y := by rcases exists_exponential_sq_length x with ⟨y, h⟩ @@ -127,10 +127,10 @@ lemma smash_two_mul_le_sq_smash (a b : V) : a ⨳ (2 * b) ≤ (a ⨳ b) ^ 2 := b end -instance : 𝗜𝚺₀ ⪯ 𝗜𝚺₀ + 𝝮₁ := inferInstance +instance : 𝗜𝚺₀ ⪯ 𝗜𝚺₀ ∪ 𝝮₁ := inferInstance -instance : 𝗜𝚺₀ + 𝝮₁ ⪯ 𝗜𝚺₁ := weakerThan_of_models.{0} _ _ fun _ _ _ ↦ inferInstance +instance : 𝗜𝚺₀ ∪ 𝝮₁ ⪯ 𝗜𝚺₁ := weakerThan_of_models.{0} _ _ fun _ _ _ ↦ inferInstance -instance : ℕ ⊧ₘ* 𝗜𝚺₀ + 𝝮₁ := inferInstance +instance : ℕ↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ ∪ 𝝮₁ := inferInstance end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Arithmetic/Omega1/Nuon.lean b/Foundation/FirstOrder/Arithmetic/Omega1/Nuon.lean index e5c58df81..6dc920798 100644 --- a/Foundation/FirstOrder/Arithmetic/Omega1/Nuon.lean +++ b/Foundation/FirstOrder/Arithmetic/Omega1/Nuon.lean @@ -5,7 +5,7 @@ public import Foundation.FirstOrder.Arithmetic.Omega1.Basic @[expose] public section namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₀ + 𝝮₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ ∪ 𝝮₁] namespace Nuon @@ -73,7 +73,7 @@ def extDef : 𝚺₀.Semisentence 4 := .mkSigma @[simp] lemma cons_app_nine {n : ℕ} (a : α) (s : Fin n.succ.succ.succ.succ.succ.succ.succ.succ.succ → α) : (a :> s) 9 = s 8 := rfl -instance ext_defined : 𝚺₀-Function₃ (ext : V → V → V → V) via extDef := .mk fun v ↦ by simp [extDef, ext_graph, numeral_eq_natCast] +instance ext_defined : 𝚺₀-Function₃ (ext : V → V → V → V) via extDef := .mk fun v ↦ by simp [extDef, ext_graph] instance ext_Definable : 𝚺₀-Function₃ (ext : V → V → V → V) := ext_defined.to_definable @@ -491,7 +491,7 @@ def isSegmentDef : 𝚺₀.Semisentence 5 := .mkSigma set_option linter.flexible false in instance isSegmentDef_defined : 𝚺₀.Defined (V := V) (λ v ↦ IsSegment (v 0) (v 1) (v 2) (v 3) (v 4)) isSegmentDef := .mk fun v ↦ by - simp [IsSegment, isSegmentDef, numeral_eq_natCast] + simp [IsSegment, isSegmentDef] apply forall₂_congr; intro x _ constructor · rintro ⟨_, h⟩; exact h.symm @@ -511,12 +511,12 @@ def isSeriesDef : 𝚺₀.Semisentence 6 := .mkSigma ∃ y <⁺ T, !extDef y L T (l + 1) ∧ !segmentDef U L A (lI * l) lI x y” -omit [V ⊧ₘ* 𝗜𝚺₀ + 𝝮₁] in +omit [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ ∪ 𝝮₁] in lemma bexs_eq_le_iff {p : V → Prop} {b : V} : (∃ a ≤ z, a = b ∧ p a) ↔ (b ≤ z ∧ p b) := ⟨by rintro ⟨a, hp, rfl, hr⟩; exact ⟨hp, hr⟩, by rintro ⟨hp, hr⟩; exact ⟨b, hp, rfl, hr⟩⟩ -omit [V ⊧ₘ* 𝗜𝚺₀ + 𝝮₁] in +omit [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ ∪ 𝝮₁] in lemma bexs_eq_lt_iff {p : V → Prop} {b : V} : (∃ a < z, a = b ∧ p a) ↔ (b < z ∧ p b) := ⟨by rintro ⟨a, hp, rfl, hr⟩; exact ⟨hp, hr⟩, by rintro ⟨hp, hr⟩; exact ⟨b, hp, rfl, hr⟩⟩ @@ -556,7 +556,7 @@ def nuonAuxDef : 𝚺₀.Semisentence 3 := .mkSigma !seriesSegmentDef ((2 * A + 1) ^' 128) g (lg ²) A k n” instance nuonAux_defined : 𝚺₀-Relation₃ (NuonAux : V → V → V → Prop) via nuonAuxDef := .mk fun v ↦ by - simp [NuonAux, polyU, polyI, polyL, nuonAuxDef, numeral_eq_natCast] + simp [NuonAux, polyU, polyI, polyL, nuonAuxDef] instance nuonAux_definable : 𝚺₀-Relation₃ (NuonAux : V → V → V → Prop) := nuonAux_defined.to_definable diff --git a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Functions.lean b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Functions.lean index 1b08bece9..d475724b9 100644 --- a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Functions.lean +++ b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Functions.lean @@ -14,7 +14,7 @@ This file provides functions and relations defined in $\mathsf{PA^-} namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗣𝗔⁻] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] variable {a b c : V} @@ -230,8 +230,8 @@ def IsPrime (a : V) : Prop := 1 < a ∧ ∀ b ≤ a, b ∣ a → b = 1 ∨ b = a def _root_.LO.FirstOrder.Arithmetic.isPrime : 𝚺₀.Semisentence 1 := .mkSigma “x. 1 < x ∧ ∀ y <⁺ x, !dvd.val y x → y = 1 ∨ y = x” -instance isPrime_defined : 𝚺₀-Predicate (λ a : V ↦ IsPrime a) via isPrime := .mk fun v ↦ by - simp [Semiformula.eval_substs, Matrix.comp_vecCons', Matrix.constant_eq_singleton, IsPrime, isPrime] +instance isPrime_defined : 𝚺₀-Predicate (fun a : V ↦ IsPrime a) via isPrime := .mk fun v ↦ by + simp [Semiformula.eval_substs, IsPrime, isPrime] end Prime diff --git a/Foundation/FirstOrder/Arithmetic/Schemata.lean b/Foundation/FirstOrder/Arithmetic/Schemata.lean index a49d69fd8..2de4c916e 100644 --- a/Foundation/FirstOrder/Arithmetic/Schemata.lean +++ b/Foundation/FirstOrder/Arithmetic/Schemata.lean @@ -4,6 +4,7 @@ public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Functions public import Foundation.FirstOrder.Arithmetic.TA.Basic @[expose] public section + /-! # Induction schemata of Arithmetic -/ @@ -25,11 +26,11 @@ variable (L) def InductionScheme (Γ : Semiformula L ℕ 1 → Prop) : Theory L := { ψ | ∃ φ : Semiformula L ℕ 1, Γ φ ∧ ψ = .univCl (succInd φ) } -abbrev IOpen : ArithmeticTheory := 𝗣𝗔⁻ + InductionScheme ℒₒᵣ Semiformula.Open +abbrev IOpen : ArithmeticTheory := 𝗣𝗔⁻ ∪ InductionScheme ℒₒᵣ Semiformula.Open notation "𝗜𝗢𝗽𝗲𝗻" => IOpen -abbrev InductionOnHierarchy (Γ : Polarity) (k : ℕ) : ArithmeticTheory := 𝗣𝗔⁻ + InductionScheme ℒₒᵣ (Arithmetic.Hierarchy Γ k) +abbrev InductionOnHierarchy (Γ : Polarity) (k : ℕ) : ArithmeticTheory := 𝗣𝗔⁻ ∪ InductionScheme ℒₒᵣ (Arithmetic.Hierarchy Γ k) prefix:max "𝗜𝗡𝗗 " => InductionOnHierarchy @@ -49,7 +50,7 @@ notation "𝗜𝚺₁" => ISigma 1 notation "𝗜𝚷₁" => IPi 1 -abbrev Peano : ArithmeticTheory := 𝗣𝗔⁻ + InductionScheme ℒₒᵣ Set.univ +abbrev Peano : ArithmeticTheory := 𝗣𝗔⁻ ∪ InductionScheme ℒₒᵣ Set.univ notation "𝗣𝗔" => Peano @@ -66,12 +67,12 @@ lemma ISigma_subset_mono {s₁ s₂} (h : s₁ ≤ s₂) : 𝗜𝚺 s₁ ⊆ lemma ISigma_weakerThan_of_le {s₁ s₂} (h : s₁ ≤ s₂) : 𝗜𝚺 s₁ ⪯ 𝗜𝚺 s₂ := Entailment.WeakerThan.ofSubset (ISigma_subset_mono h) -instance : 𝗘𝗤 ⪯ 𝗜𝗡𝗗 Γ n := - have : 𝗘𝗤 ⪯ 𝗣𝗔⁻ := inferInstance +instance : 𝗘𝗤 ℒₒᵣ ⪯ 𝗜𝗡𝗗 Γ n := + have : 𝗘𝗤 ℒₒᵣ ⪯ 𝗣𝗔⁻ := inferInstance Entailment.WeakerThan.trans this inferInstance -instance : 𝗘𝗤 ⪯ 𝗜𝗢𝗽𝗲𝗻 := - have : 𝗘𝗤 ⪯ 𝗣𝗔⁻ := inferInstance +instance : 𝗘𝗤 ℒₒᵣ ⪯ 𝗜𝗢𝗽𝗲𝗻 := + have : 𝗘𝗤 ℒₒᵣ ⪯ 𝗣𝗔⁻ := inferInstance Entailment.WeakerThan.trans this inferInstance instance : 𝗜𝗢𝗽𝗲𝗻 ⪯ 𝗜𝗡𝗗 Γ n := @@ -104,21 +105,20 @@ variable {V : Type*} [ORingStructure V] namespace InductionScheme -variable {C : Semiformula ℒₒᵣ ℕ 1 → Prop} [V ⊧ₘ* InductionScheme ℒₒᵣ C] +variable {C : Semiformula ℒₒᵣ ℕ 1 → Prop} [V↓[ℒₒᵣ] ⊧* InductionScheme ℒₒᵣ C] -private lemma induction_eval {φ : Semiformula ℒₒᵣ ℕ 1} (hp : C φ) (v) : - Semiformula.Evalm V ![0] v φ → - (∀ x, Semiformula.Evalm V ![x] v φ → Semiformula.Evalm V ![x + 1] v φ) → - ∀ x, Semiformula.Evalm V ![x] v φ := by - have : V ⊧ₘ .univCl (succInd φ) := +private lemma induction_eval {φ : Semiformula ℒₒᵣ ℕ 1} (hp : C φ) (v : ℕ → V) : + φ.Eval ![0] v → + (∀ x, φ.Eval ![x] v → φ.Eval ![x + 1] v) → + ∀ x, φ.Eval ![x] v := by + have : V↓[ℒₒᵣ] ⊧ .univCl (succInd φ) := Theory.models (T := InductionScheme _ C) V (by simpa using mem_InductionScheme_of_mem hp) revert v - simpa [models_iff, Semiformula.eval_univCl, succInd, Semiformula.eval_substs, - Semiformula.eval_rew_q Rew.toS, Function.comp, Matrix.constant_eq_singleton] using this + simpa [models_iff, Semiformula.eval_univCl, succInd, Semiformula.eval_substs, Matrix.constant_eq_singleton] using this @[elab_as_elim] lemma succ_induction {P : V → Prop} - (hP : ∃ e : ℕ → V, ∃ φ : Semiformula ℒₒᵣ ℕ 1, C φ ∧ ∀ x, P x ↔ Semiformula.Evalm V ![x] e φ) : + (hP : ∃ e : ℕ → V, ∃ φ : Semiformula ℒₒᵣ ℕ 1, C φ ∧ ∀ x, P x ↔ φ.Eval ![x] e) : P 0 → (∀ x, P x → P (x + 1)) → ∀ x, P x := by rcases hP with ⟨e, φ, Cp, hp⟩; simpa [←hp] using induction_eval (V := V) Cp e @@ -128,16 +128,16 @@ namespace InductionOnHierarchy section -variable (Γ : Polarity) (m : ℕ) [V ⊧ₘ* 𝗜𝗡𝗗 Γ m] +variable (Γ : Polarity) (m : ℕ) [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m] -instance : V ⊧ₘ* InductionScheme ℒₒᵣ (Hierarchy Γ m) := - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance +instance : V↓[ℒₒᵣ] ⊧* InductionScheme ℒₒᵣ (Hierarchy Γ m) := + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance models_of_subtheory this lemma succ_induction {P : V → Prop} (hP : Γ-[m].DefinablePred P) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance - have : V ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory this + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance + have : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory this InductionScheme.succ_induction (P := P) (C := Hierarchy Γ m) (by rcases hP with ⟨φ, hp⟩ haveI : Inhabited V := Classical.inhabited_of_nonempty' @@ -147,8 +147,8 @@ lemma succ_induction {P : V → Prop} (hP : Γ-[m].DefinablePred P) lemma order_induction {P : V → Prop} (hP : Γ-[m].DefinablePred P) (ind : ∀ x, (∀ y < x, P y) → P x) : ∀ x, P x := by - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance - have : V ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory this + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance + have : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory this suffices ∀ x, ∀ y < x, P y by intro x; exact this (x + 1) x (by simp only [lt_add_iff_pos_right, lt_one_iff_eq_zero]) intro x; induction x using succ_induction @@ -166,8 +166,8 @@ lemma order_induction {P : V → Prop} (hP : Γ-[m].DefinablePred P) private lemma neg_succ_induction {P : V → Prop} (hP : Γ-[m].DefinablePred P) (nzero : ¬P 0) (nsucc : ∀ x, ¬P x → ¬P (x + 1)) : ∀ x, ¬P x := by - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance - have : V ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory this + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance + have : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory this by_contra A have : ∃ x, P x := by simpa using A rcases this with ⟨a, ha⟩ @@ -192,13 +192,13 @@ private lemma neg_succ_induction {P : V → Prop} (hP : Γ-[m].DefinablePred P) have : P 0 := by simpa using this a (by rfl) contradiction -instance models_InductionScheme_alt : V ⊧ₘ* InductionScheme ℒₒᵣ (Arithmetic.Hierarchy Γ.alt m) := by +instance models_InductionScheme_alt : V↓[ℒₒᵣ] ⊧* InductionScheme ℒₒᵣ (Arithmetic.Hierarchy Γ.alt m) := by suffices ∀ (φ : Semiformula ℒₒᵣ ℕ 1), Hierarchy Γ.alt m φ → ∀ (f : ℕ → V), - Semiformula.Evalm V ![0] f φ → - (∀ x, Semiformula.Evalm V ![x] f φ → Semiformula.Evalm V ![x + 1] f φ) → - ∀ x, Semiformula.Evalm V ![x] f φ by + φ.Eval ![0] f → + (∀ x, φ.Eval ![x] f → φ.Eval ![x + 1] f) → + ∀ x, φ.Eval ![x] f by simp only [InductionScheme, Semantics.ModelsSet.setOf_iff, forall_exists_index, and_imp] rintro _ φ hφ rfl simpa [models_iff, Semiformula.eval_univCl, succInd, Semiformula.eval_rew_q, @@ -206,19 +206,19 @@ instance models_InductionScheme_alt : V ⊧ₘ* InductionScheme ℒₒᵣ (Arith using this φ hφ intro φ hp v simpa using - neg_succ_induction Γ m (P := fun x ↦ ¬Semiformula.Evalm V ![x] v φ) + neg_succ_induction Γ m (P := fun x ↦ ¬φ.Eval ![x] v) (.mkPolarity (∼(Rew.rewriteMap v ▹ φ)) (by simpa using hp) (by intro x; simp [←Matrix.fun_eq_vec_one, Semiformula.eval_rewriteMap])) -instance models_alt : V ⊧ₘ* 𝗜𝗡𝗗 Γ.alt m := by - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance - have : V ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory this - simp only [InductionOnHierarchy, ModelsTheory.add_iff]; constructor <;> infer_instance +instance models_alt : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ.alt m := by + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance + have : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory this + simp only [InductionOnHierarchy, Semantics.ModelsSet.union_iff]; constructor <;> infer_instance lemma least_number {P : V → Prop} (hP : Γ-[m].DefinablePred P) {x} (h : P x) : ∃ y, P y ∧ ∀ z < y, ¬P z := by - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance - have : V ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory this + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance + have : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory this by_contra A have A : ∀ z, P z → ∃ w < z, P w := by simpa using A have : ∀ z, ∀ w < z, ¬P w := by @@ -245,14 +245,14 @@ end section -variable (Γ : SigmaPiDelta) (m : ℕ) [V ⊧ₘ* 𝗜𝗡𝗗 𝚺 m] +variable (Γ : SigmaPiDelta) (m : ℕ) [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚺 m] lemma succ_induction_sigma {P : V → Prop} (hP : Γ-[m].DefinablePred P) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := match Γ with | 𝚺 => succ_induction 𝚺 m hP zero succ | 𝚷 => - haveI : V ⊧ₘ* 𝗜𝗡𝗗 𝚷 m := models_alt 𝚺 m + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚷 m := models_alt 𝚺 m succ_induction 𝚷 m hP zero succ | 𝚫 => succ_induction 𝚺 m hP.of_delta zero succ @@ -261,7 +261,7 @@ lemma order_induction_sigma {P : V → Prop} (hP : Γ-[m].DefinablePred P) match Γ with | 𝚺 => order_induction 𝚺 m hP ind | 𝚷 => - haveI : V ⊧ₘ* 𝗜𝗡𝗗 𝚷 m := models_alt 𝚺 m + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚷 m := models_alt 𝚺 m order_induction 𝚷 m hP ind | 𝚫 => order_induction 𝚺 m hP.of_delta ind @@ -270,124 +270,122 @@ lemma least_number_sigma {P : V → Prop} (hP : Γ-[m].DefinablePred P) match Γ with | 𝚺 => least_number 𝚺 m hP h | 𝚷 => - haveI : V ⊧ₘ* 𝗜𝗡𝗗 𝚷 m := models_alt 𝚺 m + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚷 m := models_alt 𝚺 m least_number 𝚷 m hP h | 𝚫 => least_number 𝚺 m hP.of_delta h end -instance [V ⊧ₘ* 𝗜𝗡𝗗 𝚺 m] : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := by +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚺 m] : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := by rcases Γ · infer_instance · exact models_alt 𝚺 m -instance [V ⊧ₘ* 𝗜𝗡𝗗 𝚷 m] : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := by +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚷 m] : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := by rcases Γ · exact models_alt 𝚷 m · infer_instance -lemma mod_ISigma_of_le {n₁ n₂} (h : n₁ ≤ n₂) [V ⊧ₘ* 𝗜𝚺 n₂] : V ⊧ₘ* 𝗜𝚺 n₁ := +lemma mod_ISigma_of_le {n₁ n₂} (h : n₁ ≤ n₂) [V↓[ℒₒᵣ] ⊧* 𝗜𝚺 n₂] : V↓[ℒₒᵣ] ⊧* 𝗜𝚺 n₁ := models_of_ss inferInstance (ISigma_subset_mono h) -instance [V ⊧ₘ* 𝗜𝚺₁] : V ⊧ₘ* 𝗜𝚺₀ := mod_ISigma_of_le (show 0 ≤ 1 from by simp) +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ := mod_ISigma_of_le (show 0 ≤ 1 from by simp) -instance [V ⊧ₘ* 𝗜𝚺n] : V ⊧ₘ* 𝗜𝚷n := inferInstance +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚺n] : V↓[ℒₒᵣ] ⊧* 𝗜𝚷n := inferInstance -instance [V ⊧ₘ* 𝗜𝚷n] : V ⊧ₘ* 𝗜𝚺n := inferInstance +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚷n] : V↓[ℒₒᵣ] ⊧* 𝗜𝚺n := inferInstance -lemma models_ISigma_iff_models_IPi {n} : V ⊧ₘ* 𝗜𝚺 n ↔ V ⊧ₘ* 𝗜𝚷 n := +lemma models_ISigma_iff_models_IPi {n} : V↓[ℒₒᵣ] ⊧* 𝗜𝚺 n ↔ V↓[ℒₒᵣ] ⊧* 𝗜𝚷 n := ⟨fun _ ↦ inferInstance, fun _ ↦ inferInstance⟩ -instance [V ⊧ₘ* 𝗜𝚺 n] : V ⊧ₘ* 𝗜𝗡𝗗 Γ n := +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚺 n] : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ n := match Γ with | 𝚺 => inferInstance | 𝚷 => inferInstance end InductionOnHierarchy -@[elab_as_elim] lemma ISigma0.succ_induction [V ⊧ₘ* 𝗜𝚺₀] +@[elab_as_elim] lemma ISigma0.succ_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] {P : V → Prop} (hP : 𝚺₀.DefinablePred P) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := InductionOnHierarchy.succ_induction 𝚺 0 hP zero succ -@[elab_as_elim] lemma ISigma1.sigma1_succ_induction [V ⊧ₘ* 𝗜𝚺₁] +@[elab_as_elim] lemma ISigma1.sigma1_succ_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚺₁-Predicate P) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := InductionOnHierarchy.succ_induction 𝚺 1 hP zero succ -@[elab_as_elim] lemma ISigma1.pi1_succ_induction [V ⊧ₘ* 𝗜𝚺₁] +@[elab_as_elim] lemma ISigma1.pi1_succ_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚷₁-Predicate P) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := InductionOnHierarchy.succ_induction 𝚷 1 hP zero succ -@[elab_as_elim] lemma ISigma0.order_induction [V ⊧ₘ* 𝗜𝚺₀] +@[elab_as_elim] lemma ISigma0.order_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] {P : V → Prop} (hP : 𝚺₀-Predicate P) (ind : ∀ x, (∀ y < x, P y) → P x) : ∀ x, P x := InductionOnHierarchy.order_induction 𝚺 0 hP ind -@[elab_as_elim] lemma ISigma1.sigma1_order_induction [V ⊧ₘ* 𝗜𝚺₁] +@[elab_as_elim] lemma ISigma1.sigma1_order_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚺₁-Predicate P) (ind : ∀ x, (∀ y < x, P y) → P x) : ∀ x, P x := InductionOnHierarchy.order_induction 𝚺 1 hP ind -@[elab_as_elim] lemma ISigma1.pi1_order_induction [V ⊧ₘ* 𝗜𝚺₁] +@[elab_as_elim] lemma ISigma1.pi1_order_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚷₁-Predicate P) (ind : ∀ x, (∀ y < x, P y) → P x) : ∀ x, P x := InductionOnHierarchy.order_induction 𝚷 1 hP ind -lemma ISigma0.least_number [V ⊧ₘ* 𝗜𝚺₀] {P : V → Prop} (hP : 𝚺₀-Predicate P) +lemma ISigma0.least_number [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] {P : V → Prop} (hP : 𝚺₀-Predicate P) {x} (h : P x) : ∃ y, P y ∧ ∀ z < y, ¬P z := InductionOnHierarchy.least_number 𝚺 0 hP h -@[elab_as_elim] lemma ISigma1.succ_induction [V ⊧ₘ* 𝗜𝚺₁] (Γ) +@[elab_as_elim] lemma ISigma1.succ_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] (Γ) {P : V → Prop} (hP : Γ-[1]-Predicate P) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := InductionOnHierarchy.succ_induction_sigma Γ 1 hP zero succ -@[elab_as_elim] lemma ISigma1.order_induction [V ⊧ₘ* 𝗜𝚺₁] (Γ) +@[elab_as_elim] lemma ISigma1.order_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] (Γ) {P : V → Prop} (hP : Γ-[1]-Predicate P) (ind : ∀ x, (∀ y < x, P y) → P x) : ∀ x, P x := InductionOnHierarchy.order_induction_sigma Γ 1 hP ind -instance [V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻] : V ⊧ₘ* 𝗣𝗔⁻ := - have : V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻 := inferInstance +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻] : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻 := inferInstance models_of_subtheory this -instance [V ⊧ₘ* 𝗜𝚺₀] : V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻 := - have : V ⊧ₘ* 𝗜𝚺₀ := inferInstance +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] : V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻 := + have : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ := inferInstance models_of_subtheory this -instance [V ⊧ₘ* 𝗜𝚺₁] : V ⊧ₘ* 𝗜𝚺₀ := inferInstance +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ := inferInstance -abbrev mod_ISigma_of_le {n₁ n₂} (h : n₁ ≤ n₂) [V ⊧ₘ* 𝗜𝚺 n₂] : V ⊧ₘ* 𝗜𝚺 n₁ := +abbrev mod_ISigma_of_le {n₁ n₂} (h : n₁ ≤ n₂) [V↓[ℒₒᵣ] ⊧* 𝗜𝚺 n₂] : V↓[ℒₒᵣ] ⊧* 𝗜𝚺 n₁ := models_of_ss inferInstance (ISigma_subset_mono h) end models -lemma models_succInd (φ : Semiformula ℒₒᵣ ℕ 1) : ℕ ⊧ₘ (succInd φ).univCl := by +lemma models_succInd (φ : Semiformula ℒₒᵣ ℕ 1) : ℕ↓[ℒₒᵣ] ⊧ (succInd φ).univCl := by suffices ∀ f : ℕ → ℕ, - Semiformula.Evalm ℕ ![0] f φ → - (∀ x, Semiformula.Evalm ℕ ![x] f φ → Semiformula.Evalm ℕ ![x + 1] f φ) → - ∀ x, Semiformula.Evalm ℕ ![x] f φ by + φ.Eval ![0] f → (∀ x, φ.Eval ![x] f → φ.Eval ![x + 1] f) → ∀ x, φ.Eval ![x] f by simpa [Semiformula.eval_univCl, succInd, models_iff, Matrix.constant_eq_singleton, Semiformula.eval_substs] intro e hzero hsucc x; induction' x with x ih · exact hzero · exact hsucc x ih -instance models_ISigma (Γ k) : ℕ ⊧ₘ* 𝗜𝗡𝗗 Γ k := by - simp only [ModelsTheory.add_iff, PeanoMinus.instModelsTheoryNat, InductionScheme, - Semantics.ModelsSet.setOf_iff, forall_exists_index, and_imp, true_and] - rintro _ φ _ rfl; simp [models_succInd] +instance models_ISigma (Γ k) : ℕ↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ k := by + have : ∀ φ, ℕ↓[ℒₒᵣ] ⊧ (succInd φ).univCl := models_succInd + simp [InductionScheme] + grind -instance models_ISigmaZero : ℕ ⊧ₘ* 𝗜𝚺₀ := inferInstance +instance models_ISigmaZero : ℕ↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ := inferInstance -instance models_ISigmaOne : ℕ ⊧ₘ* 𝗜𝚺₁ := inferInstance +instance models_ISigmaOne : ℕ↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := inferInstance -instance models_Peano : ℕ ⊧ₘ* 𝗣𝗔 := by - simp only [Peano, InductionScheme, ModelsTheory.add_iff, PeanoMinus.instModelsTheoryNat, - Semantics.ModelsSet.setOf_iff, forall_exists_index, and_imp, true_and] - rintro _ φ _ rfl; simp [models_succInd] +instance models_Peano : ℕ↓[ℒₒᵣ] ⊧* 𝗣𝗔 := by + have : ∀ φ, ℕ↓[ℒₒᵣ] ⊧ (succInd φ).univCl := models_succInd + simp [Peano, InductionScheme] + grind instance : Entailment.Consistent (𝗜𝗡𝗗 Γ k) := (𝗜𝗡𝗗 Γ k).consistent_of_sound (Eq ⊥) rfl diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean index 01dacaf26..7a8652c1d 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean @@ -11,7 +11,7 @@ namespace LO.FirstOrder.Arithmetic.Bootstrapping open Classical FirstOrder -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean index 579824621..5049d95c4 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean @@ -11,7 +11,7 @@ namespace LO.FirstOrder.Arithmetic.Bootstrapping open FirstOrder -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D3.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D3.lean index 11bbb240a..237c9731c 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D3.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D3.lean @@ -13,7 +13,7 @@ open Classical open LO.Entailment LO.Entailment.FiniteContext -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] local prefix:max "#'" => Semiterm.bvar (V := V) (L := ℒₒᵣ) diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/EquationalTheory.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/EquationalTheory.lean index b758d23d9..cbde2e0d8 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/EquationalTheory.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/EquationalTheory.lean @@ -12,7 +12,7 @@ namespace LO.FirstOrder.Arithmetic.Bootstrapping open Classical Entailment -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] namespace Arithmetic diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/PeanoMinus.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/PeanoMinus.lean index 183c24e48..0eeed96e2 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/PeanoMinus.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/PeanoMinus.lean @@ -9,7 +9,7 @@ public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.Equation namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗣𝗔⁻] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] lemma lt_add_self_add_one (a b : V) : a < b + a + 1 := lt_succ_iff_le.mpr <| le_add_self @@ -22,7 +22,7 @@ namespace LO.FirstOrder.Arithmetic.Bootstrapping.Arithmetic open Classical LO.Entailment -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] local prefix:max "#'" => Semiterm.bvar (V := V) (L := ℒₒᵣ) diff --git a/Foundation/FirstOrder/Bootstrapping/FixedPoint.lean b/Foundation/FirstOrder/Bootstrapping/FixedPoint.lean index 4d3b469b5..c9c2b8a9e 100644 --- a/Foundation/FirstOrder/Bootstrapping/FixedPoint.lean +++ b/Foundation/FirstOrder/Bootstrapping/FixedPoint.lean @@ -7,7 +7,7 @@ open Classical namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] namespace Bootstrapping.Arithmetic @@ -121,7 +121,7 @@ theorem diagonal (θ : Semisentence ℒₒᵣ 1) : T ⊢ fixedpoint θ 🡘 θ/[⌜fixedpoint θ⌝] := haveI : 𝗘𝗤 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance provable_of_models _ _ fun (V : Type) _ _ ↦ by - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance suffices V ⊧/![] (fixedpoint θ) ↔ V ⊧/![⌜fixedpoint θ⌝] θ by simpa [models_iff, Matrix.constant_eq_singleton] let t : V := ⌜diag θ⌝ @@ -149,7 +149,7 @@ theorem multidiagonal (θ : Fin k → Semisentence ℒₒᵣ k) : T ⊢ multifixedpoint θ i 🡘 (Rew.subst fun j ↦ ⌜multifixedpoint θ j⌝) ▹ (θ i) := haveI : 𝗘𝗤 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance provable_of_models _ _ fun (V : Type) _ _ ↦ by - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance suffices V ⊧/![] (multifixedpoint θ i) ↔ V ⊧/(fun i ↦ ⌜multifixedpoint θ i⌝) (θ i) by simpa [models_iff] let t : Fin k → V := fun i ↦ ⌜multidiag (θ i)⌝ have ht : ∀ i, substNumerals (t i) t = ⌜multifixedpoint θ i⌝ := by @@ -199,7 +199,7 @@ theorem parameterized_diagonal (θ : Semisentence ℒₒᵣ (k + 1)) : T ⊢ ∀⁰* (parameterizedFixedpoint θ 🡘 “!θ !!(⌜parameterizedFixedpoint θ⌝) ⋯”) := haveI : 𝗘𝗤 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance provable_of_models _ _ fun (V : Type) _ _ ↦ by - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance suffices ∀ params : Fin k → V, V ⊧/params (parameterizedFixedpoint θ) ↔ V ⊧/(⌜parameterizedFixedpoint θ⌝ :> params) θ by diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Basic.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Basic.lean index 4e0600f6a..507cae5b9 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Basic.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Basic.lean @@ -6,7 +6,7 @@ public import Foundation.FirstOrder.Arithmetic.Induction @[expose] public section namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean index a7da578e6..b18af704a 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean @@ -41,7 +41,7 @@ end LO namespace LO -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Functions.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Functions.lean index 63b36d166..727dd6d79 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Functions.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Functions.lean @@ -6,7 +6,7 @@ public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Functions @[expose] public section namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Iteration.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Iteration.lean index 8affae9b0..b7a093ef1 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Iteration.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Iteration.lean @@ -21,7 +21,7 @@ end LO.FirstOrder.Semiformula namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Typed.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Typed.lean index 71044de8b..0d073f57f 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Typed.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Typed.lean @@ -10,7 +10,7 @@ public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Iteration namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Language.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Language.lean index 8282ecdd8..c6094df14 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Language.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Language.lean @@ -62,7 +62,7 @@ instance _root_.LO.FirstOrder.Language.IsRel.definable : 𝚺₀-Relation (L.IsR section -variable [V ⊧ₘ* 𝗣𝗔⁻] +variable [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] instance gödelQuoteFunc (k) : GödelQuote (L.Func k) V := ⟨fun f ↦ ↑(Encodable.encode f)⟩ @@ -147,7 +147,7 @@ instance : (ℒₒᵣ).LORDefinable where namespace Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] def zeroIndex : ℕ := Encodable.encode (Language.Zero.zero : (ℒₒᵣ : FirstOrder.Language).Func 0) diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean index bc2bb6646..d2c1e4142 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean @@ -7,7 +7,7 @@ namespace LO open FirstOrder Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean index ac5f43a1c..42051c1c5 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean @@ -8,7 +8,7 @@ namespace LO.FirstOrder open Arithmetic Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.DecidableEq] [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean index 282a61687..028636a64 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean @@ -11,7 +11,7 @@ namespace LO open FirstOrder Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] @@ -117,7 +117,7 @@ def _root_.LO.FirstOrder.Theory.internalize (T : Theory L) [T.Δ₁] : InternalT variable {V} -omit [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] in +omit [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] in @[simp] lemma internalize_theory (T : Theory L) [T.Δ₁] : (T.internalize V).theory = T := rfl structure TDerivation (T : InternalTheory V L) (Γ : Sequent V L) where diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Basic.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Basic.lean index 149e2c004..6160de92b 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Basic.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Basic.lean @@ -5,7 +5,7 @@ public import Foundation.FirstOrder.Bootstrapping.Syntax.Language @[expose] public section namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Coding.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Coding.lean index 77318e6f8..6b2230890 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Coding.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Coding.lean @@ -8,7 +8,7 @@ open Encodable LO FirstOrder Arithmetic PeanoMinus Bootstrapping namespace LO.FirstOrder.Semiterm -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Functions.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Functions.lean index b5fae8971..f7577a520 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Functions.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Functions.lean @@ -5,7 +5,7 @@ public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Basic @[expose] public section namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] section diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Typed.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Typed.lean index 705019aa9..8f7d429e2 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Typed.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Typed.lean @@ -11,7 +11,7 @@ public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Functions namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] noncomputable def matrixToVec (v : Fin k → V) : V := Matrix.foldr (fun t w ↦ t ∷ w) 0 v diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean index cf0fef538..ab6cbf1e3 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean @@ -5,7 +5,7 @@ public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Coding @[expose] public section namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Incompleteness/Consistency.lean b/Foundation/FirstOrder/Incompleteness/Consistency.lean index 8573a3925..0663c189d 100644 --- a/Foundation/FirstOrder/Incompleteness/Consistency.lean +++ b/Foundation/FirstOrder/Incompleteness/Consistency.lean @@ -11,7 +11,7 @@ open Classical namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] section WitnessComparisons diff --git a/Foundation/FirstOrder/Incompleteness/Jeroslow.lean b/Foundation/FirstOrder/Incompleteness/Jeroslow.lean index 4d4f450d3..1352983c7 100644 --- a/Foundation/FirstOrder/Incompleteness/Jeroslow.lean +++ b/Foundation/FirstOrder/Incompleteness/Jeroslow.lean @@ -33,7 +33,7 @@ section variable [L.Encodable] [L.LORDefinable] {T : Theory L} [T.Δ₁] -def Refutable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] (T : Theory L) [T.Δ₁] (φ : V) : Prop +def Refutable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] (T : Theory L) [T.Δ₁] (φ : V) : Prop := T.Provable (neg L φ) noncomputable def refutable (T : Theory L) [T.Δ₁] : 𝚺₁.Semisentence 1 @@ -41,7 +41,7 @@ noncomputable def refutable (T : Theory L) [T.Δ₁] : 𝚺₁.Semisentence 1 section -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] lemma Refutable.quote_iff {σ : Sentence L} : T.Refutable (⌜σ⌝ : V) ↔ T.Provable (⌜∼σ⌝ : V) := by simp [Theory.Refutable, Sentence.quote_def, Semiformula.quote_def] diff --git a/Foundation/FirstOrder/Incompleteness/RestrictedProvability.lean b/Foundation/FirstOrder/Incompleteness/RestrictedProvability.lean index 04a052e0a..548d86626 100644 --- a/Foundation/FirstOrder/Incompleteness/RestrictedProvability.lean +++ b/Foundation/FirstOrder/Incompleteness/RestrictedProvability.lean @@ -16,7 +16,7 @@ open PeanoMinus ISigma0 ISigma1 Bootstrapping Derivation namespace Theory -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] variable {T U : Theory L} [T.Δ₁] [U.Δ₁] @@ -43,7 +43,7 @@ end Theory namespace Arithmetic -variable {V : Type} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {T U : ArithmeticTheory} [T.Δ₁] -- [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] variable {e : ℕ} diff --git a/Foundation/FirstOrder/Incompleteness/RosserProvability.lean b/Foundation/FirstOrder/Incompleteness/RosserProvability.lean index 2024802d4..5a8587fab 100644 --- a/Foundation/FirstOrder/Incompleteness/RosserProvability.lean +++ b/Foundation/FirstOrder/Incompleteness/RosserProvability.lean @@ -9,7 +9,7 @@ public import Foundation.FirstOrder.Incompleteness.WitnessComparison namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Incompleteness/WitnessComparison.lean b/Foundation/FirstOrder/Incompleteness/WitnessComparison.lean index 1266e6145..da96679b4 100644 --- a/Foundation/FirstOrder/Incompleteness/WitnessComparison.lean +++ b/Foundation/FirstOrder/Incompleteness/WitnessComparison.lean @@ -9,7 +9,7 @@ public import Foundation.FirstOrder.Incompleteness.StandardProvability namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] section WitnessComparisons diff --git a/Foundation/FirstOrder/Incompleteness/Yablo.lean b/Foundation/FirstOrder/Incompleteness/Yablo.lean index 0a180ff85..e7aeffc40 100644 --- a/Foundation/FirstOrder/Incompleteness/Yablo.lean +++ b/Foundation/FirstOrder/Incompleteness/Yablo.lean @@ -23,7 +23,7 @@ end LO.FirstOrder.Arithmetic namespace LO.FirstOrder.Arithmetic.Bootstrapping.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] lemma substNumeral_app_quote_nat_model (σ : Semisentence ℒₒᵣ 1) (n : ℕ) : substNumeral ⌜σ⌝ (n : V) = ⌜(σ/[.numeral n] : Sentence ℒₒᵣ)⌝ := by @@ -47,7 +47,7 @@ open FirstOrder Arithmetic Bootstrapping Bootstrapping.Arithmetic namespace Theory -variable {V} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] {T U : ArithmeticTheory} [T.Δ₁] +variable {V} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {T U : ArithmeticTheory} [T.Δ₁] def YabloSystem (T : ArithmeticTheory) [T.Δ₁] (φ n : V) : Prop := ∀ m, n < m → ¬T.Provable (substNumeral φ m) @@ -74,7 +74,7 @@ open Theory -- Lemmata section -variable {V : Type} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {U : ArithmeticTheory} [𝗜𝚺₁ ⪯ U] lemma yablo_diagonal : U ⊢ ∀⁰ (T.yablo 🡘 (T.yabloSystem)/[⌜T.yablo⌝, #0]) := parameterized_diagonal₁ _ @@ -92,7 +92,7 @@ lemma iff_yablo_provable (n : ℕ) : U ⊢ T.yabloPred n ↔ U ⊢ “∀ m, ↑ constructor <;> . intro h; cl_prover [h, this]; apply provable_of_models.{0}; intro V _ _; - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; haveI : V ⊧/![ORingStructure.numeral n] (T.yablo) ↔ T.YabloSystem ⌜T.yablo⌝ (ORingStructure.numeral n) := yablo_diagonal_modeled _; simpa [models_iff, Matrix.constant_eq_singleton, Matrix.comp_vecCons'] using this; @@ -101,14 +101,14 @@ lemma iff_neg_yablo_provable (n : ℕ) : U ⊢ ∼(T.yabloPred n) ↔ U ⊢ “ constructor <;> . intro h; cl_prover [h, this]; apply provable_of_models.{0}; intro V _ _; - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; haveI : ¬V ⊧/![ORingStructure.numeral n] (T.yablo) ↔ ∃ m, ORingStructure.numeral n < m ∧ Provable T (substNumeral ⌜T.yablo⌝ m) := yablo_diagonal_neg_modeled _; simpa [models_iff, Matrix.constant_eq_singleton, Matrix.comp_vecCons'] using this; lemma provable_greater_yablo {n m : ℕ} (hnm : n < m) : U ⊢ T.yabloPred n 🡒 T.yabloPred m := by apply provable_of_models.{0}; intro V _ _; - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; suffices (∀ m, ORingStructure.numeral n < m → ¬Provable T (substNumeral ⌜yablo T⌝ m)) → (∀ k, ORingStructure.numeral m < k → ¬Provable T (substNumeral ⌜yablo T⌝ k)) @@ -132,7 +132,7 @@ theorem yablo_unprovable [Entailment.Consistent T] : T ⊬ (T.yabloPred n) := by have H₂ : T ⊢ ∼T.provabilityPred (T.yabloPred (n + 1)) := by apply provable_of_models.{0}; intro V _ _; - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance; + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance; suffices ¬T.Provable (substNumeral ⌜T.yablo⌝ (n + 1 : V)) by simpa [provabilityPred, models_iff, ←substNumeral_app_quote_nat_model]; have : ∀ (x : V), ORingStructure.numeral n < x → ¬T.Provable (substNumeral ⌜T.yablo⌝ x) := by diff --git a/Foundation/ProvabilityLogic/SolovaySentences.lean b/Foundation/ProvabilityLogic/SolovaySentences.lean index 25a1c8734..1cb40a91f 100644 --- a/Foundation/ProvabilityLogic/SolovaySentences.lean +++ b/Foundation/ProvabilityLogic/SolovaySentences.lean @@ -142,7 +142,7 @@ variable {F : Kripke.Frame} [Fintype F] [F.IsIrreflexive] [F.IsTransitive] [F.Is section model -variable (T) {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable (T) {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] def NegativeSuccessor (φ ψ : V) : Prop := T.ProvabilityComparisonLE (neg ℒₒᵣ φ) (neg ℒₒᵣ ψ) @@ -254,7 +254,7 @@ section model variable (T) -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] open Modal ProvabilityLogic Kripke From d415b8d708c106779c20f0edb9277ea8012d123e Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 13 Jun 2026 00:43:20 +0900 Subject: [PATCH 07/14] add --- .../Bootstrapping/Syntax/Formula/Basic.lean | 4 +- .../Bootstrapping/Syntax/Formula/Coding.lean | 12 +- .../Bootstrapping/Syntax/Language.lean | 8 +- .../Bootstrapping/Syntax/Proof/Basic.lean | 304 ++++++++---------- .../Bootstrapping/Syntax/Term/Basic.lean | 11 +- .../Bootstrapping/Syntax/Theory.lean | 31 +- 6 files changed, 166 insertions(+), 204 deletions(-) diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Basic.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Basic.lean index 507cae5b9..359769ba7 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Basic.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Basic.lean @@ -759,8 +759,8 @@ variable (c β) lemma graph_defined : 𝚺₁-Relation₃ c.Graph L via β.graph L := .mk fun v ↦ by simp [Blueprint.graph, (c.construction L).fixpoint_defined.iff, Matrix.empty_eq]; rfl -@[simp] lemma eval_graphDef (v) : - Semiformula.Evalbm V v (β.graph L).val ↔ c.Graph L (v 0) (v 1) (v 2) := (graph_defined β c).iff +@[simp] lemma eval_graphDef (v : Fin 3 → V) : + (β.graph L).val.Evalb v ↔ c.Graph L (v 0) (v 1) (v 2) := (graph_defined β c).iff instance graph_definable : 𝚺-[0 + 1]-Relation₃ c.Graph L := c.graph_defined.to_definable diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean index b18af704a..0d381160b 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean @@ -92,8 +92,8 @@ noncomputable instance : LCWQIsoGödelQuote (Semiproposition L) (Bootstrapping.S @[simp] lemma typed_quote_shift (φ : Semiproposition L n) : (⌜Rewriting.shift φ⌝ : Bootstrapping.Semiformula V L n) = Bootstrapping.Semiformula.shift ⌜φ⌝ := by induction φ using Semiformula.rec' - case hrel => simp [rew_rel, *]; rfl - case hnrel => simp [rew_nrel, *]; rfl + case hrel => simp [*]; rfl + case hnrel => simp [*]; rfl case hverum => simp case hfalsum => simp case hand => simp [*] @@ -104,8 +104,8 @@ noncomputable instance : LCWQIsoGödelQuote (Semiproposition L) (Bootstrapping.S @[simp] lemma typed_quote_substs {n m} (w : Fin n → SyntacticSemiterm L m) (φ : Semiproposition L n) : (⌜φ ⇜ w⌝ : Bootstrapping.Semiformula V L m) = Bootstrapping.Semiformula.subst (fun i ↦ ⌜w i⌝) ⌜φ⌝ := by induction φ using Semiformula.rec' generalizing m - case hrel => simp [rew_rel, *]; rfl - case hnrel => simp [rew_nrel, *]; rfl + case hrel => simp [*]; rfl + case hnrel => simp [*]; rfl case hverum => simp case hfalsum => simp case hand => simp [*] @@ -298,8 +298,8 @@ lemma quote_eq_encode (σ : Semisentence L n) : (⌜σ⌝ : V) = ↑(encode σ) lemma coe_quote_eq_quote (σ : Semisentence L n) : (↑(⌜σ⌝ : ℕ) : V) = ⌜σ⌝ := by simp [quote_eq_encode] -@[simp] lemma val_quote {ξ n e ε} (σ : Semisentence L n) : - Semiterm.valm V e ε (⌜σ⌝ : Semiterm ℒₒᵣ ξ m) = ⌜σ⌝ := by +@[simp] lemma val_quote {bv : Fin m → V} {fv : ξ → V} (σ : Semisentence L n) : + (⌜σ⌝ : Semiterm ℒₒᵣ ξ m).val bv fv = ⌜σ⌝ := by simp [gödelNumber'_def, quote_eq_encode, numeral_eq_natCast] @[simp] lemma coe_quote {ξ n} (σ : Semisentence L n) : ↑(⌜σ⌝ : ℕ) = (⌜σ⌝ : Semiterm ℒₒᵣ ξ m) := by diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Language.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Language.lean index c6094df14..d338cdfa2 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Language.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Language.lean @@ -40,11 +40,11 @@ lemma isFunc_def (k f : V) : L.IsFunc k f ↔ V ⊧/![k, f] L.isFunc.val := by r lemma isRel_def (k R : V) : L.IsRel k R ↔ V ⊧/![k, R] L.isRel.val := by rfl -@[simp] lemma eval_func (v) : - Semiformula.Evalbm V v L.isFunc.val ↔ L.IsFunc (v 0) (v 1) := by simp [Language.IsFunc, ← Matrix.fun_eq_vec_two] +@[simp] lemma eval_func (v : Fin 2 → V) : + L.isFunc.val.Evalb v ↔ L.IsFunc (v 0) (v 1) := by simp [Language.IsFunc, ← Matrix.fun_eq_vec_two] -@[simp] lemma eval_rel_iff (v) : - Semiformula.Evalbm V v L.isRel.val ↔ L.IsRel (v 0) (v 1) := by simp [Language.IsRel, ← Matrix.fun_eq_vec_two] +@[simp] lemma eval_rel_iff (v : Fin 2 → V) : + L.isRel.val.Evalb v ↔ L.IsRel (v 0) (v 1) := by simp [Language.IsRel, ← Matrix.fun_eq_vec_two] instance _root_.LO.FirstOrder.Language.IsFunc.defined : 𝚺₀-Relation (L.IsFunc (V := V)) via L.isFunc := .mk fun v ↦ by simp diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean index d2c1e4142..e199c7def 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean @@ -131,7 +131,13 @@ end end setShift -noncomputable def axL (s p : V) : V := ⟪s, 0, p⟫ + 1 +noncomputable def identity (s p : V) : V := ⟪s, 0, p⟫ + 1 + +noncomputable def cutRule (s p d₁ d₂ : V) : V := ⟪s, 8, p, d₁, d₂⟫ + 1 + +noncomputable def contraction (s d : V) : V := ⟪s, 6, d⟫ + 1 + +noncomputable def shiftRule (s d : V) : V := ⟪s, 7, d⟫ + 1 noncomputable def verumIntro (s : V) : V := ⟪s, 1, 0⟫ + 1 @@ -143,20 +149,12 @@ noncomputable def allIntro (s p d : V) : V := ⟪s, 4, p, d⟫ + 1 noncomputable def exsIntro (s p t d : V) : V := ⟪s, 5, p, t, d⟫ + 1 -noncomputable def wkRule (s d : V) : V := ⟪s, 6, d⟫ + 1 - -noncomputable def shiftRule (s d : V) : V := ⟪s, 7, d⟫ + 1 - -noncomputable def cutRule (s p d₁ d₂ : V) : V := ⟪s, 8, p, d₁, d₂⟫ + 1 - -noncomputable def axm (s p : V) : V := ⟪s, 9, p⟫ + 1 - section -def axLGraph : 𝚺₀.Semisentence 3 := +def identityGraph : 𝚺₀.Semisentence 3 := .mkSigma “y s p. ∃ y' < y, !pair₃Def y' s 0 p ∧ y = y' + 1” -instance axL.defined : 𝚺₀-Function₂[V] axL via axLGraph := .mk fun v ↦ by simp_all [axLGraph, axL] +instance identity.defined : 𝚺₀-Function₂[V] identity via identityGraph := .mk fun v ↦ by simp_all [identityGraph, identity] def verumIntroGraph : 𝚺₀.Semisentence 2 := .mkSigma “y s. ∃ y' < y, !pair₃Def y' s 1 0 ∧ y = y' + 1” @@ -183,10 +181,10 @@ def exsIntroGraph : 𝚺₀.Semisentence 5 := instance exsIntro.defined : 𝚺₀-Function₄ (exsIntro : V → V → V → V → V) via exsIntroGraph := .mk fun v ↦ by simp_all [exsIntroGraph, numeral_eq_natCast, exsIntro] -def wkRuleGraph : 𝚺₀.Semisentence 3 := +def contractionGraph : 𝚺₀.Semisentence 3 := .mkSigma “y s d. ∃ y' < y, !pair₃Def y' s 6 d ∧ y = y' + 1” -instance wkRule.defined : 𝚺₀-Function₂ (wkRule : V → V → V) via wkRuleGraph := .mk fun v ↦ by simp_all [wkRuleGraph, numeral_eq_natCast, wkRule] +instance contraction.defined : 𝚺₀-Function₂ (contraction : V → V → V) via contractionGraph := .mk fun v ↦ by simp_all [contractionGraph, numeral_eq_natCast, contraction] def shiftRuleGraph : 𝚺₀.Semisentence 3 := .mkSigma “y s d. ∃ y' < y, !pair₃Def y' s 7 d ∧ y = y' + 1” @@ -198,13 +196,8 @@ def cutRuleGraph : 𝚺₀.Semisentence 5 := instance cutRule_defined : 𝚺₀-Function₄ (cutRule : V → V → V → V → V) via cutRuleGraph := .mk fun v ↦ by simp_all [cutRuleGraph, numeral_eq_natCast, cutRule] -def axmGraph : 𝚺₀.Semisentence 3 := - .mkSigma “y s p. ∃ y' < y, !pair₃Def y' s 9 p ∧ y = y' + 1” - -instance axm_defined : 𝚺₀-Function₂ (axm : V → V → V) via axmGraph := .mk fun v ↦ by simp_all [axmGraph, numeral_eq_natCast, axm] - -@[simp] lemma seq_lt_axL (s p : V) : s < axL s p := le_iff_lt_succ.mp <| le_pair_left _ _ -@[simp] lemma arity_lt_axL (s p : V) : p < axL s p := +@[simp] lemma seq_lt_identity (s p : V) : s < identity s p := le_iff_lt_succ.mp <| le_pair_left _ _ +@[simp] lemma arity_lt_identity (s p : V) : p < identity s p := le_iff_lt_succ.mp <| le_trans (by simp) <| le_pair_right _ _ @[simp] lemma seq_lt_verumIntro (s : V) : s < verumIntro s := le_iff_lt_succ.mp <| le_pair_left _ _ @@ -241,8 +234,8 @@ instance axm_defined : 𝚺₀-Function₂ (axm : V → V → V) via axmGraph := @[simp] lemma d_lt_exsIntro (s p t d : V) : d < exsIntro s p t d := le_iff_lt_succ.mp <| le_trans (le_trans (le_trans (le_pair_right _ _) <| le_pair_right _ _) <| le_pair_right _ _) <| le_pair_right _ _ -@[simp] lemma seq_lt_wkRule (s d : V) : s < wkRule s d := le_iff_lt_succ.mp <| le_pair_left _ _ -@[simp] lemma d_lt_wkRule (s d : V) : d < wkRule s d := le_iff_lt_succ.mp <| le_trans (le_pair_right _ _) <| le_pair_right _ _ +@[simp] lemma seq_lt_contraction (s d : V) : s < contraction s d := le_iff_lt_succ.mp <| le_pair_left _ _ +@[simp] lemma d_lt_contraction (s d : V) : d < contraction s d := le_iff_lt_succ.mp <| le_trans (le_pair_right _ _) <| le_pair_right _ _ @[simp] lemma seq_lt_shiftRule (s d : V) : s < shiftRule s d := le_iff_lt_succ.mp <| le_pair_left _ _ @[simp] lemma d_lt_shiftRule (s d : V) : d < shiftRule s d := le_iff_lt_succ.mp <| le_trans (le_pair_right _ _) <| le_pair_right _ _ @@ -255,45 +248,40 @@ instance axm_defined : 𝚺₀-Function₂ (axm : V → V → V) via axmGraph := @[simp] lemma d₂_lt_cutRule (s p d₁ d₂ : V) : d₂ < cutRule s p d₁ d₂ := le_iff_lt_succ.mp <| le_trans (le_trans (le_trans (le_pair_right _ _) <| le_pair_right _ _) <| le_pair_right _ _) <| le_pair_right _ _ -@[simp] lemma seq_lt_axm (s p : V) : s < axm s p := le_iff_lt_succ.mp <| le_pair_left _ _ -@[simp] lemma p_lt_axm (s p : V) : p < axm s p := le_iff_lt_succ.mp <| le_trans (le_pair_right _ _) <| le_pair_right _ _ - -@[simp] lemma fstIdx_axL (s p : V) : fstIdx (axL s p) = s := by simp [fstIdx, axL] +@[simp] lemma fstIdx_identity (s p : V) : fstIdx (identity s p) = s := by simp [fstIdx, identity] @[simp] lemma fstIdx_verumIntro (s : V) : fstIdx (verumIntro s) = s := by simp [fstIdx, verumIntro] @[simp] lemma fstIdx_andIntro (s p q dp dq : V) : fstIdx (andIntro s p q dp dq) = s := by simp [fstIdx, andIntro] @[simp] lemma fstIdx_orIntro (s p q dpq : V) : fstIdx (orIntro s p q dpq) = s := by simp [fstIdx, orIntro] @[simp] lemma fstIdx_allIntro (s p d : V) : fstIdx (allIntro s p d) = s := by simp [fstIdx, allIntro] @[simp] lemma fstIdx_exsIntro (s p t d : V) : fstIdx (exsIntro s p t d) = s := by simp [fstIdx, exsIntro] -@[simp] lemma fstIdx_wkRule (s d : V) : fstIdx (wkRule s d) = s := by simp [fstIdx, wkRule] +@[simp] lemma fstIdx_contraction (s d : V) : fstIdx (contraction s d) = s := by simp [fstIdx, contraction] @[simp] lemma fstIdx_shiftRule (s d : V) : fstIdx (shiftRule s d) = s := by simp [fstIdx, shiftRule] @[simp] lemma fstIdx_cutRule (s p d₁ d₂ : V) : fstIdx (cutRule s p d₁ d₂) = s := by simp [fstIdx, cutRule] -@[simp] lemma fstIdx_axm (s p : V) : fstIdx (axm s p) = s := by simp [fstIdx, axm] end -namespace Derivation +namespace IDerivation noncomputable abbrev conseq (x : V) : V := π₁ x -variable (T) +variable (L) def Phi (C : Set V) (d : V) : Prop := IsFormulaSet L (fstIdx d) ∧ - ( (∃ s p, d = axL s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ + ( (∃ s p, d = identity s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ (∃ s, d = verumIntro s ∧ ^⊤ ∈ s) ∨ (∃ s p q dp dq, d = andIntro s p q dp dq ∧ p ^⋏ q ∈ s ∧ (fstIdx dp = insert p s ∧ dp ∈ C) ∧ (fstIdx dq = insert q s ∧ dq ∈ C)) ∨ (∃ s p q dpq, d = orIntro s p q dpq ∧ p ^⋎ q ∈ s ∧ fstIdx dpq = insert p (insert q s) ∧ dpq ∈ C) ∨ (∃ s p dp, d = allIntro s p dp ∧ ^∀ p ∈ s ∧ fstIdx dp = insert (free L p) (setShift L s) ∧ dp ∈ C) ∨ (∃ s p t dp, d = exsIntro s p t dp ∧ ^∃ p ∈ s ∧ IsTerm L t ∧ fstIdx dp = insert (substs1 L t p) s ∧ dp ∈ C) ∨ - (∃ s d', d = wkRule s d' ∧ fstIdx d' ⊆ s ∧ d' ∈ C) ∨ + (∃ s d', d = contraction s d' ∧ fstIdx d' ⊆ s ∧ d' ∈ C) ∨ (∃ s d', d = shiftRule s d' ∧ s = setShift L (fstIdx d') ∧ d' ∈ C) ∨ - (∃ s p d₁ d₂, d = cutRule s p d₁ d₂ ∧ (fstIdx d₁ = insert p s ∧ d₁ ∈ C) ∧ (fstIdx d₂ = insert (neg L p) s ∧ d₂ ∈ C)) ∨ - (∃ s p, d = axm s p ∧ p ∈ s ∧ p ∈ T.Δ₁Class) ) + (∃ s p d₁ d₂, d = cutRule s p d₁ d₂ ∧ (fstIdx d₁ = insert p s ∧ d₁ ∈ C) ∧ (fstIdx d₂ = insert (neg L p) s ∧ d₂ ∈ C))) private lemma phi_iff (C d : V) : - Phi T {x | x ∈ C} d ↔ + Phi L {x | x ∈ C} d ↔ IsFormulaSet L (fstIdx d) ∧ - ( (∃ s < d, ∃ p < d, d = axL s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ + ( (∃ s < d, ∃ p < d, d = identity s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ (∃ s < d, d = verumIntro s ∧ ^⊤ ∈ s) ∨ (∃ s < d, ∃ p < d, ∃ q < d, ∃ dp < d, ∃ dq < d, d = andIntro s p q dp dq ∧ p ^⋏ q ∈ s ∧ (fstIdx dp = insert p s ∧ dp ∈ C) ∧ (fstIdx dq = insert q s ∧ dq ∈ C)) ∨ @@ -304,18 +292,16 @@ private lemma phi_iff (C d : V) : (∃ s < d, ∃ p < d, ∃ t < d, ∃ dp < d, d = exsIntro s p t dp ∧ ^∃ p ∈ s ∧ IsTerm L t ∧ fstIdx dp = insert (substs1 L t p) s ∧ dp ∈ C) ∨ (∃ s < d, ∃ d' < d, - d = wkRule s d' ∧ fstIdx d' ⊆ s ∧ d' ∈ C) ∨ + d = contraction s d' ∧ fstIdx d' ⊆ s ∧ d' ∈ C) ∨ (∃ s < d, ∃ d' < d, d = shiftRule s d' ∧ s = setShift L (fstIdx d') ∧ d' ∈ C) ∨ (∃ s < d, ∃ p < d, ∃ d₁ < d, ∃ d₂ < d, - d = cutRule s p d₁ d₂ ∧ (fstIdx d₁ = insert p s ∧ d₁ ∈ C) ∧ (fstIdx d₂ = insert (neg L p) s ∧ d₂ ∈ C)) ∨ - (∃ s < d, ∃ p < d, - d = axm s p ∧ p ∈ s ∧ p ∈ T.Δ₁Class) ) := by + d = cutRule s p d₁ d₂ ∧ (fstIdx d₁ = insert p s ∧ d₁ ∈ C) ∧ (fstIdx d₂ = insert (neg L p) s ∧ d₂ ∈ C))) := by constructor · rintro ⟨hs, H⟩ refine ⟨hs, ?_⟩ rcases H with (⟨s, p, rfl, h⟩ | ⟨s, rfl, h⟩ | ⟨s, p, q, dp, dq, rfl, h⟩ | ⟨s, p, q, dpq, rfl, h⟩ | - ⟨s, p, dp, rfl, h⟩ | ⟨s, p, t, dp, rfl, h⟩ | ⟨s, d', rfl, h⟩ | ⟨s, d', rfl, h⟩ | ⟨s, p, d₁, d₂, rfl, h⟩ | ⟨s, p, rfl, h⟩) + ⟨s, p, dp, rfl, h⟩ | ⟨s, p, t, dp, rfl, h⟩ | ⟨s, d', rfl, h⟩ | ⟨s, d', rfl, h⟩ | ⟨s, p, d₁, d₂, rfl, h⟩) · left; exact ⟨s, by simp, p, by simp, rfl, h⟩ · right; left; exact ⟨s, by simp, rfl, h⟩ · right; right; left; exact ⟨s, by simp, p, by simp, q, by simp, dp, by simp, dq, by simp, rfl, h⟩ @@ -324,13 +310,12 @@ private lemma phi_iff (C d : V) : · right; right; right; right; right; left; exact ⟨s, by simp, p, by simp, t, by simp, dp, by simp, rfl, h⟩ · right; right; right; right; right; right; left; exact ⟨s, by simp, d', by simp, rfl, h⟩ · right; right; right; right; right; right; right; left; exact ⟨s, by simp, d', by simp, rfl, h⟩ - · right; right; right; right; right; right; right; right; left; exact ⟨s, by simp, p, by simp, d₁, by simp, d₂, by simp, rfl, h⟩ - · right; right; right; right; right; right; right; right; right; exact ⟨s, by simp, p, by simp, rfl, h⟩ + · right; right; right; right; right; right; right; right; exact ⟨s, by simp, p, by simp, d₁, by simp, d₂, by simp, rfl, h⟩ · rintro ⟨hs, H⟩ refine ⟨hs, ?_⟩ rcases H with (⟨s, _, p, _, rfl, h⟩ | ⟨s, _, rfl, h⟩ | ⟨s, _, p, _, q, _, dp, _, dq, _, rfl, h⟩ | ⟨s, _, p, _, q, _, dpq, _, rfl, h⟩ | ⟨s, _, p, _, dp, _, rfl, h⟩ | ⟨s, _, p, _, t, _, dp, _, rfl, h⟩ | ⟨s, _, d', _, rfl, h⟩ | - ⟨s, _, d', _, rfl, h⟩ | ⟨s, _, p, _, d₁, _, d₂, _, rfl, h⟩ | ⟨s, _, p, _, h⟩) + ⟨s, _, d', _, rfl, h⟩ | ⟨s, _, p, _, d₁, _, d₂, _, rfl, h⟩) · left; exact ⟨s, p, rfl, h⟩ · right; left; exact ⟨s, rfl, h⟩ · right; right; left; exact ⟨s, p, q, dp, dq, rfl, h⟩ @@ -339,13 +324,12 @@ private lemma phi_iff (C d : V) : · right; right; right; right; right; left; exact ⟨s, p, t, dp, rfl, h⟩ · right; right; right; right; right; right; left; exact ⟨s, d', rfl, h⟩ · right; right; right; right; right; right; right; left; exact ⟨s, d', rfl, h⟩ - · right; right; right; right; right; right; right; right; left; exact ⟨s, p, d₁, d₂, rfl, h⟩ - · right; right; right; right; right; right; right; right; right; exact ⟨s, p, h⟩ + · right; right; right; right; right; right; right; right; exact ⟨s, p, d₁, d₂, rfl, h⟩ noncomputable def blueprint : Fixpoint.Blueprint 0 := ⟨.mkDelta (.mkSigma “d C. (∃ fst, !fstIdxDef fst d ∧ !(isFormulaSet L).sigma fst) ∧ - ( (∃ s < d, ∃ p < d, !axLGraph d s p ∧ p ∈ s ∧ ∃ np, !(negGraph L) np p ∧ np ∈ s) ∨ + ( (∃ s < d, ∃ p < d, !identityGraph d s p ∧ p ∈ s ∧ ∃ np, !(negGraph L) np p ∧ np ∈ s) ∨ (∃ s < d, !verumIntroGraph d s ∧ ∃ vrm, !qqVerumDef vrm ∧ vrm ∈ s) ∨ (∃ s < d, ∃ p < d, ∃ q < d, ∃ dp < d, ∃ dq < d, !andIntroGraph d s p q dp dq ∧ (∃ and, !qqAndDef and p q ∧ and ∈ s) ∧ @@ -362,19 +346,17 @@ noncomputable def blueprint : Fixpoint.Blueprint 0 := ⟨.mkDelta !exsIntroGraph d s p t dp ∧ (∃ ex, !qqExsDef ex p ∧ ex ∈ s) ∧ !(isSemiterm L).sigma 0 t ∧ ∃ c, !fstIdxDef c dp ∧ ∃ pt, !(substs1Graph L) pt t p ∧ !insertDef c pt s ∧ dp ∈ C) ∨ (∃ s < d, ∃ d' < d, - !wkRuleGraph d s d' ∧ ∃ c, !fstIdxDef c d' ∧ !bitSubsetDef c s ∧ d' ∈ C) ∨ + !contractionGraph d s d' ∧ ∃ c, !fstIdxDef c d' ∧ !bitSubsetDef c s ∧ d' ∈ C) ∨ (∃ s < d, ∃ d' < d, !shiftRuleGraph d s d' ∧ ∃ c, !fstIdxDef c d' ∧ !(setShiftGraph L) s c ∧ d' ∈ C) ∨ (∃ s < d, ∃ p < d, ∃ d₁ < d, ∃ d₂ < d, !cutRuleGraph d s p d₁ d₂ ∧ (∃ c, !fstIdxDef c d₁ ∧ !insertDef c p s ∧ d₁ ∈ C) ∧ - (∃ c, !fstIdxDef c d₂ ∧ ∃ np, !(negGraph L) np p ∧ !insertDef c np s ∧ d₂ ∈ C)) ∨ - (∃ s < d, ∃ p < d, - !axmGraph d s p ∧ p ∈ s ∧ !T.Δ₁ch.sigma p) )” + (∃ c, !fstIdxDef c d₂ ∧ ∃ np, !(negGraph L) np p ∧ !insertDef c np s ∧ d₂ ∈ C)))” ) (.mkPi “d C. (∀ fst, !fstIdxDef fst d → !(isFormulaSet L).pi fst) ∧ - ( (∃ s < d, ∃ p < d, !axLGraph d s p ∧ p ∈ s ∧ ∀ np, !(negGraph L) np p → np ∈ s) ∨ + ( (∃ s < d, ∃ p < d, !identityGraph d s p ∧ p ∈ s ∧ ∀ np, !(negGraph L) np p → np ∈ s) ∨ (∃ s < d, !verumIntroGraph d s ∧ ∀ vrm, !qqVerumDef vrm → vrm ∈ s) ∨ (∃ s < d, ∃ p < d, ∃ q < d, ∃ dp < d, ∃ dq < d, !andIntroGraph d s p q dp dq ∧ (∀ and, !qqAndDef and p q → and ∈ s) ∧ @@ -392,31 +374,29 @@ noncomputable def blueprint : Fixpoint.Blueprint 0 := ⟨.mkDelta !(isSemiterm L).pi 0 t ∧ ∀ c, !fstIdxDef c dp → ∀ pt, !(substs1Graph L) pt t p → !insertDef c pt s ∧ dp ∈ C) ∨ (∃ s < d, ∃ d' < d, - !wkRuleGraph d s d' ∧ ∀ c, !fstIdxDef c d' → !bitSubsetDef c s ∧ d' ∈ C) ∨ + !contractionGraph d s d' ∧ ∀ c, !fstIdxDef c d' → !bitSubsetDef c s ∧ d' ∈ C) ∨ (∃ s < d, ∃ d' < d, !shiftRuleGraph d s d' ∧ ∀ c, !fstIdxDef c d' → ∀ ss, !(setShiftGraph L) ss c → s = ss ∧ d' ∈ C) ∨ (∃ s < d, ∃ p < d, ∃ d₁ < d, ∃ d₂ < d, !cutRuleGraph d s p d₁ d₂ ∧ (∀ c, !fstIdxDef c d₁ → !insertDef c p s ∧ d₁ ∈ C) ∧ - (∀ c, !fstIdxDef c d₂ → ∀ np, !(negGraph L) np p → !insertDef c np s ∧ d₂ ∈ C)) ∨ - (∃ s < d, ∃ p < d, - !axmGraph d s p ∧ p ∈ s ∧ !T.Δ₁ch.pi p) )” + (∀ c, !fstIdxDef c d₂ → ∀ np, !(negGraph L) np p → !insertDef c np s ∧ d₂ ∈ C)))” )⟩ -lemma Phi_definable : 𝚫₁.Defined (fun v : Fin 2 → V ↦ Phi T {x | x ∈ v 1} (v 0)) (blueprint T).core := .mk <| by +lemma Phi_definable : 𝚫₁.Defined (fun v : Fin 2 → V ↦ Phi L {x | x ∈ v 1} (v 0)) (blueprint L).core := .mk <| by constructor · intro v; simp [blueprint] · intro v; simp [phi_iff, blueprint] -def construction : Fixpoint.Construction V (blueprint T) where - Φ := fun _ ↦ Phi T +def construction : Fixpoint.Construction V (blueprint L) where + Φ := fun _ ↦ Phi L defined := Phi_definable _ monotone := by rintro C C' hC _ d ⟨hs, H⟩ refine ⟨hs, ?_⟩ rcases H with (h | h | ⟨s, p, q, dp, dq, rfl, hpq, ⟨hp, hpC⟩, ⟨hq, hqC⟩⟩ | ⟨s, p, q, dpq, rfl, hpq, h, hdC⟩ | ⟨s, p, dp, rfl, hp, h, hdC⟩ | ⟨s, p, t, dp, rfl, hp, ht, h, hdC⟩ | - ⟨s, d', rfl, ss, hdC⟩ | ⟨s, d', rfl, ss, hdC⟩ | ⟨s, p, d₁, d₂, rfl, ⟨h₁, hd₁C⟩, ⟨h₂, hd₂C⟩⟩ | ⟨s, p, h⟩) + ⟨s, d', rfl, ss, hdC⟩ | ⟨s, d', rfl, ss, hdC⟩ | ⟨s, p, d₁, d₂, rfl, ⟨h₁, hd₁C⟩, ⟨h₂, hd₂C⟩⟩) · left; exact h · right; left; exact h · right; right; left; exact ⟨s, p, q, dp, dq, rfl, hpq, ⟨hp, hC hpC⟩, ⟨hq, hC hqC⟩⟩ @@ -425,16 +405,15 @@ def construction : Fixpoint.Construction V (blueprint T) where · right; right; right; right; right; left; exact ⟨s, p, t, dp, rfl, hp, ht, h, hC hdC⟩ · right; right; right; right; right; right; left; exact ⟨s, d', rfl, ss, hC hdC⟩ · right; right; right; right; right; right; right; left; exact ⟨s, d', rfl, ss, hC hdC⟩ - · right; right; right; right; right; right; right; right; left; exact ⟨s, p, d₁, d₂, rfl, ⟨h₁, hC hd₁C⟩, ⟨h₂, hC hd₂C⟩⟩ - · right; right; right; right; right; right; right; right; right; exact ⟨s, p, h⟩ + · right; right; right; right; right; right; right; right; exact ⟨s, p, d₁, d₂, rfl, ⟨h₁, hC hd₁C⟩, ⟨h₂, hC hd₂C⟩⟩ -instance : (construction T).StrongFinite V where +instance : (construction L).StrongFinite V where strong_finite := by rintro C _ d ⟨hs, H⟩ refine ⟨hs, ?_⟩ rcases H with (h | h | ⟨s, p, q, dp, dq, rfl, hpq, ⟨hp, hpC⟩, ⟨hq, hqC⟩⟩ | ⟨s, p, q, dpq, rfl, hpq, h, hdC⟩ | ⟨s, p, dp, rfl, hp, h, hdC⟩ | ⟨s, p, t, dp, rfl, hp, ht, h, hdC⟩ | - ⟨s, d', rfl, ss, hdC⟩ | ⟨s, d', rfl, ss, hdC⟩ | ⟨s, p, d₁, d₂, rfl, ⟨h₁, hd₁C⟩, ⟨h₂, hd₂C⟩⟩ | ⟨s, p, h⟩) + ⟨s, d', rfl, ss, hdC⟩ | ⟨s, d', rfl, ss, hdC⟩ | ⟨s, p, d₁, d₂, rfl, ⟨h₁, hd₁C⟩, ⟨h₂, hd₂C⟩⟩) · left; exact h · right; left; exact h · right; right; left; exact ⟨s, p, q, dp, dq, rfl, hpq, ⟨hp, hpC, by simp⟩, ⟨hq, hqC, by simp⟩⟩ @@ -443,75 +422,84 @@ instance : (construction T).StrongFinite V where · right; right; right; right; right; left; exact ⟨s, p, t, dp, rfl, hp, ht, h, hdC, by simp⟩ · right; right; right; right; right; right; left; exact ⟨s, d', rfl, ss, hdC, by simp⟩ · right; right; right; right; right; right; right; left; exact ⟨s, d', rfl, ss, hdC, by simp⟩ - · right; right; right; right; right; right; right; right; left; exact ⟨s, p, d₁, d₂, rfl, ⟨h₁, hd₁C, by simp⟩, ⟨h₂, hd₂C, by simp⟩⟩ - · right; right; right; right; right; right; right; right; right; exact ⟨s, p, h⟩ - -end Derivation + · right; right; right; right; right; right; right; right; exact ⟨s, p, d₁, d₂, rfl, ⟨h₁, hd₁C, by simp⟩, ⟨h₂, hd₂C, by simp⟩⟩ -end FirstOrder.Arithmetic.Bootstrapping +end IDerivation -namespace FirstOrder.Theory +/- ## Internal `\mathbf{LK}` -/ -open PeanoMinus ISigma0 ISigma1 Bootstrapping Derivation +open PeanoMinus ISigma0 ISigma1 Bootstrapping IDerivation -variable (T) +variable (L) -def Derivation : V → Prop := (construction T).Fixpoint ![] +/-- Internal derivation -/ +def IDerivation : V → Prop := (construction L).Fixpoint ![] -def DerivationOf (d s : V) : Prop := fstIdx d = s ∧ T.Derivation d +/- Internal derivation of sequent `s` -/ +def IDerivationOf (d s : V) : Prop := fstIdx d = s ∧ IDerivation L d -def Derivable (s : V) : Prop := ∃ d, T.DerivationOf d s +/-- Internal derivability -/ +def IDerivable (s : V) : Prop := ∃ d, IDerivationOf L d s -def Proof (d φ : V) : Prop := T.DerivationOf d {φ} +/-- Internal proof -/ +@[deprecated IProof] +def IProof (d φ : V) : Prop := IDerivationOf L d {φ} -def Provable (φ : V) : Prop := ∃ d, T.Proof d φ +/-- Internal provability -/ +@[deprecated IProvable] +def IProvable (φ : V) : Prop := ∃ d, IProof L d φ -noncomputable def derivation : 𝚫₁.Semisentence 1 := (blueprint T).fixpointDefΔ₁ +noncomputable def iderivation : 𝚫₁.Semisentence 1 := (blueprint L).fixpointDefΔ₁ -noncomputable def derivationOf : 𝚫₁.Semisentence 2 := .mkDelta - (.mkSigma “d s. !fstIdxDef s d ∧ !T.derivation.sigma d”) - (.mkPi “d s. !fstIdxDef s d ∧ !T.derivation.pi d”) +noncomputable def iderivationOf : 𝚫₁.Semisentence 2 := .mkDelta + (.mkSigma “d s. !fstIdxDef s d ∧ !(iderivation L).sigma d”) + (.mkPi “d s. !fstIdxDef s d ∧ !(iderivation L).pi d”) -noncomputable def derivable : 𝚺₁.Semisentence 1 := .mkSigma - “Γ. ∃ d, !T.derivationOf.sigma d Γ” +noncomputable def iderivable : 𝚺₁.Semisentence 1 := .mkSigma + “Γ. ∃ d, !(iderivationOf L).sigma d Γ” -noncomputable def proof : 𝚫₁.Semisentence 2 := .mkDelta - (.mkSigma “d φ. ∃ s, !insertDef s φ 0 ∧ !T.derivationOf.sigma d s”) - (.mkPi “d φ. ∀ s, !insertDef s φ 0 → !T.derivationOf.pi d s”) +@[deprecated iproof] +noncomputable def iproof : 𝚫₁.Semisentence 2 := .mkDelta + (.mkSigma “d φ. ∃ s, !insertDef s φ 0 ∧ !(iderivationOf L).sigma d s”) + (.mkPi “d φ. ∀ s, !insertDef s φ 0 → !(iderivationOf L).pi d s”) -noncomputable def provable : 𝚺₁.Semisentence 1 := .mkSigma - “φ. ∃ d, !T.proof.sigma d φ” +noncomputable def iprovable : 𝚺₁.Semisentence 1 := .mkSigma + “φ. ∃ d, !(iproof L).sigma d φ” -noncomputable abbrev provabilityPred (σ : Sentence L) : Sentence ℒₒᵣ := T.provable.val/[⌜σ⌝] +@[deprecated iprovabilityPred] +noncomputable abbrev iprovabilityPred (σ : Sentence L) : Sentence ℒₒᵣ := (iprovable L).val/[⌜σ⌝] -noncomputable def provabilityPred' (σ : Sentence L) : 𝚺₁.Sentence := .mkSigma - “!T.provable !!(⌜σ⌝)” +@[deprecated iprovabilityPred'] +noncomputable def iprovabilityPred' (σ : Sentence L) : 𝚺₁.Sentence := .mkSigma + “!(iprovable L) !!(⌜σ⌝)” -@[simp] lemma provabilityPred'_val (σ : Sentence L) : (T.provabilityPred' σ).val = T.provabilityPred σ := by rfl +@[simp] lemma iprovabilityPred'_val (σ : Sentence L) : (iprovabilityPred' L σ).val = iprovabilityPred L σ := by rfl -variable {T} +variable {L} section -instance Derivation.defined : 𝚫₁-Predicate[V] T.Derivation via T.derivation := (construction T).fixpoint_definedΔ₁ +instance IDerivation.defined : 𝚫₁-Predicate[V] (IDerivation L) via iderivation L := (construction L).fixpoint_definedΔ₁ -instance Derivation.definable : 𝚫₁-Predicate[V] T.Derivation := Derivation.defined.to_definable +instance IDerivation.definable : 𝚫₁-Predicate[V] (IDerivation L) := IDerivation.defined.to_definable -instance Derivation.definable' : Γ-[m + 1]-Predicate[V] T.Derivation := Derivation.definable.of_deltaOne +instance IDerivation.definable' : Γ-[m + 1]-Predicate[V] (IDerivation L) := IDerivation.definable.of_deltaOne -instance DerivationOf.defined : 𝚫₁-Relation[V] T.DerivationOf via T.derivationOf := .mk - ⟨by intro v; simp [Theory.derivationOf], by intro v; simp [Theory.derivationOf, eq_comm (b := fstIdx (v 0))]; rfl⟩ +instance IDerivationOf.defined : 𝚫₁-Relation[V] (IDerivationOf L) via iderivationOf L := .mk + ⟨by intro v; simp [iderivationOf], by intro v; simp [iderivationOf, eq_comm (b := fstIdx (v 0))]; rfl⟩ -instance DerivationOf.definable : 𝚫₁-Relation[V] T.DerivationOf := DerivationOf.defined.to_definable +instance IDerivationOf.definable : 𝚫₁-Relation[V] IDerivationOf L := IDerivationOf.defined.to_definable -instance DerivationOf.definable' : Γ-[m + 1]-Relation[V] T.DerivationOf := DerivationOf.definable.of_deltaOne +instance IDerivationOf.definable' : Γ-[m + 1]-Relation[V] IDerivationOf L := IDerivationOf.definable.of_deltaOne -instance Derivable.defined : 𝚺₁-Predicate[V] T.Derivable via T.derivable := .mk fun v ↦ by simp [Theory.derivable, Theory.Derivable] +instance IDerivable.defined : 𝚺₁-Predicate[V] (IDerivable L) via iderivable L := .mk fun v ↦ by simp [IDerivable, iderivable] -instance Derivable.definable : 𝚺₁-Predicate[V] T.Derivable := Derivable.defined.to_definable +instance IDerivable.definable : 𝚺₁-Predicate[V] (IDerivable L) := IDerivable.defined.to_definable /-- instance for definability tactic-/ -instance Derivable.definable' : 𝚺-[0 + 1]-Predicate[V] T.Derivable := Derivable.definable +instance IDerivable.definable' : 𝚺-[0 + 1]-Predicate[V] (IDerivable L) := IDerivable.definable + +/- instance Proof.defined : 𝚫₁-Relation[V] T.Proof via T.proof := .mk ⟨by intro v; simp [Theory.proof], by intro v; simp [Theory.Proof, Theory.proof, singleton_eq_insert, emptyset_def]⟩ @@ -527,54 +515,54 @@ instance Provable.definable : 𝚺₁-Predicate[V] T.Provable := Provable.define /-- instance for definability tactic-/ instance Provable.definable' : 𝚺-[0 + 1]-Predicate[V] T.Provable := Provable.definable +-/ + end -namespace Derivation +namespace IDerivation lemma case_iff {d : V} : - T.Derivation d ↔ + IDerivation L d ↔ IsFormulaSet L (fstIdx d) ∧ - ( (∃ s p, d = Bootstrapping.axL s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ + ( (∃ s p, d = Bootstrapping.identity s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ (∃ s, d = verumIntro s ∧ ^⊤ ∈ s) ∨ - (∃ s p q dp dq, d = andIntro s p q dp dq ∧ p ^⋏ q ∈ s ∧ T.DerivationOf dp (insert p s) ∧ T.DerivationOf dq (insert q s)) ∨ - (∃ s p q dpq, d = orIntro s p q dpq ∧ p ^⋎ q ∈ s ∧ T.DerivationOf dpq (insert p (insert q s))) ∨ - (∃ s p dp, d = allIntro s p dp ∧ ^∀ p ∈ s ∧ T.DerivationOf dp (insert (free L p) (setShift L s))) ∨ - (∃ s p t dp, d = exsIntro s p t dp ∧ ^∃ p ∈ s ∧ IsTerm L t ∧ T.DerivationOf dp (insert (substs1 L t p) s)) ∨ - (∃ s d', d = wkRule s d' ∧ fstIdx d' ⊆ s ∧ T.Derivation d') ∨ - (∃ s d', d = shiftRule s d' ∧ s = setShift L (fstIdx d') ∧ T.Derivation d') ∨ - (∃ s p d₁ d₂, d = cutRule s p d₁ d₂ ∧ T.DerivationOf d₁ (insert p s) ∧ T.DerivationOf d₂ (insert (neg L p) s)) ∨ - (∃ s p, d = axm s p ∧ p ∈ s ∧ p ∈ T.Δ₁Class) ) := - (construction T).case + (∃ s p q dp dq, d = andIntro s p q dp dq ∧ p ^⋏ q ∈ s ∧ IDerivationOf L dp (insert p s) ∧ IDerivationOf L dq (insert q s)) ∨ + (∃ s p q dpq, d = orIntro s p q dpq ∧ p ^⋎ q ∈ s ∧ IDerivationOf L dpq (insert p (insert q s))) ∨ + (∃ s p dp, d = allIntro s p dp ∧ ^∀ p ∈ s ∧ IDerivationOf L dp (insert (free L p) (setShift L s))) ∨ + (∃ s p t dp, d = exsIntro s p t dp ∧ ^∃ p ∈ s ∧ IsTerm L t ∧ IDerivationOf L dp (insert (substs1 L t p) s)) ∨ + (∃ s d', d = contraction s d' ∧ fstIdx d' ⊆ s ∧ IDerivation L d') ∨ + (∃ s d', d = shiftRule s d' ∧ s = setShift L (fstIdx d') ∧ IDerivation L d') ∨ + (∃ s p d₁ d₂, d = cutRule s p d₁ d₂ ∧ IDerivationOf L d₁ (insert p s) ∧ IDerivationOf L d₂ (insert (neg L p) s)) ) := + (construction L).case alias ⟨case, _root_.LO.FirstOrder.Theory.Derivation.mk⟩ := case_iff lemma induction1 (Γ) {P : V → Prop} (hP : Γ-[1]-Predicate P) - {d} (hd : T.Derivation d) - (hAxL : ∀ s, IsFormulaSet L s → ∀ p ∈ s, neg L p ∈ s → P (axL s p)) + {d} (hd : IDerivation L d) + (hAxL : ∀ s, IsFormulaSet L s → ∀ p ∈ s, neg L p ∈ s → P (identity s p)) (hVerumIntro : ∀ s, IsFormulaSet L s → ^⊤ ∈ s → P (verumIntro s)) - (hAnd : ∀ s, IsFormulaSet L s → ∀ p q dp dq, p ^⋏ q ∈ s → T.DerivationOf dp (insert p s) → T.DerivationOf dq (insert q s) → + (hAnd : ∀ s, IsFormulaSet L s → ∀ p q dp dq, p ^⋏ q ∈ s → IDerivationOf L dp (insert p s) → IDerivationOf L dq (insert q s) → P dp → P dq → P (andIntro s p q dp dq)) - (hOr : ∀ s, IsFormulaSet L s → ∀ p q d, p ^⋎ q ∈ s → T.DerivationOf d (insert p (insert q s)) → + (hOr : ∀ s, IsFormulaSet L s → ∀ p q d, p ^⋎ q ∈ s → IDerivationOf L d (insert p (insert q s)) → P d → P (orIntro s p q d)) - (hAll : ∀ s, IsFormulaSet L s → ∀ p d, ^∀ p ∈ s → T.DerivationOf d (insert (free L p) (setShift L s)) → + (hAll : ∀ s, IsFormulaSet L s → ∀ p d, ^∀ p ∈ s → IDerivationOf L d (insert (free L p) (setShift L s)) → P d → P (allIntro s p d)) - (hExs : ∀ s, IsFormulaSet L s → ∀ p t d, ^∃ p ∈ s → IsTerm L t → T.DerivationOf d (insert (substs1 L t p) s) → + (hExs : ∀ s, IsFormulaSet L s → ∀ p t d, ^∃ p ∈ s → IsTerm L t → IDerivationOf L d (insert (substs1 L t p) s) → P d → P (exsIntro s p t d)) - (hWk : ∀ s, IsFormulaSet L s → ∀ d, fstIdx d ⊆ s → T.Derivation d → - P d → P (wkRule s d)) - (hShift : ∀ s, IsFormulaSet L s → ∀ d, s = setShift L (fstIdx d) → T.Derivation d → + (hWk : ∀ s, IsFormulaSet L s → ∀ d, fstIdx d ⊆ s → IDerivation L d → + P d → P (contraction s d)) + (hShift : ∀ s, IsFormulaSet L s → ∀ d, s = setShift L (fstIdx d) → IDerivation L d → P d → P (shiftRule s d)) - (hCut : ∀ s, IsFormulaSet L s → ∀ p d₁ d₂, T.DerivationOf d₁ (insert p s) → T.DerivationOf d₂ (insert (neg L p) s) → - P d₁ → P d₂ → P (cutRule s p d₁ d₂)) - (hRoot : ∀ s, IsFormulaSet L s → ∀ p, p ∈ s → p ∈ T.Δ₁Class → P (axm s p)) : P d := - (construction T).induction (v := ![]) hP (by + (hCut : ∀ s, IsFormulaSet L s → ∀ p d₁ d₂, IDerivationOf L d₁ (insert p s) → IDerivationOf L d₂ (insert (neg L p) s) → + P d₁ → P d₂ → P (cutRule s p d₁ d₂)) : P d := + (construction L).induction (v := ![]) hP (by intro C ih d hd rcases hd with ⟨hds, (⟨s, p, rfl, hps, hnps⟩ | ⟨s, rfl, hs⟩ | ⟨s, p, q, dp, dq, rfl, hpq, h₁, h₂⟩ | ⟨s, p, q, d, rfl, hpq, h⟩ | ⟨s, p, d, rfl, hp, h, hC⟩ | ⟨s, p, t, d, rfl, hp, ht, h, hC⟩ | ⟨s, d, rfl, h, hC⟩ | ⟨s, d, rfl, h, hC⟩ | - ⟨s, p, d₁, d₂, rfl, ⟨h₁, hC₁⟩, ⟨h₂, hC₂⟩⟩ | ⟨s, p, rfl, hs, hT⟩)⟩ + ⟨s, p, d₁, d₂, rfl, ⟨h₁, hC₁⟩, ⟨h₂, hC₂⟩⟩)⟩ · exact hAxL s (by simpa using hds) p hps hnps · exact hVerumIntro s (by simpa using hds) hs · exact hAnd s (by simpa using hds) p q dp dq hpq ⟨h₁.1, (ih dp h₁.2).1⟩ ⟨h₂.1, (ih dq h₂.2).1⟩ (ih dp h₁.2).2 (ih dq h₂.2).2 @@ -583,80 +571,72 @@ lemma induction1 (Γ) {P : V → Prop} (hP : Γ-[1]-Predicate P) · exact hExs s (by simpa using hds) p t d hp ht ⟨h, (ih d hC).1⟩ (ih d hC).2 · exact hWk s (by simpa using hds) d h (ih d hC).1 (ih d hC).2 · exact hShift s (by simpa using hds) d h (ih d hC).1 (ih d hC).2 - · exact hCut s (by simpa using hds) p d₁ d₂ ⟨h₁, (ih d₁ hC₁).1⟩ ⟨h₂, (ih d₂ hC₂).1⟩ (ih d₁ hC₁).2 (ih d₂ hC₂).2 - · exact hRoot s (by simpa using hds) p hs hT) d hd + · exact hCut s (by simpa using hds) p d₁ d₂ ⟨h₁, (ih d₁ hC₁).1⟩ ⟨h₂, (ih d₂ hC₂).1⟩ (ih d₁ hC₁).2 (ih d₂ hC₂).2) + d hd -lemma isFormulaSet {d : V} (h : T.Derivation d) : IsFormulaSet L (fstIdx d) := (h : T.Derivation d).case.1 +lemma isFormulaSet {d : V} (h : IDerivation L d) : IsFormulaSet L (fstIdx d) := (h : IDerivation L d).case.1 -lemma _root_.LO.FirstOrder.Theory.DerivationOf.isFormulaSet {d s : V} (h : T.DerivationOf d s) : IsFormulaSet L s := by +lemma _root_.LO.FirstOrder.Arithmetic.Bootstrapping.IDerivationOf.isFormulaSet {d s : V} (h : IDerivationOf L d s) : IsFormulaSet L s := by simpa [h.1] using h.2.case.1 -lemma axL {s p : V} (hs : IsFormulaSet L s) (h : p ∈ s) (hn : neg L p ∈ s) : T.Derivation (axL s p) := +lemma identity {s p : V} (hs : IsFormulaSet L s) (h : p ∈ s) (hn : neg L p ∈ s) : IDerivation L (identity s p) := Theory.Derivation.mk ⟨by simpa using hs, Or.inl ⟨s, p, rfl, h, hn⟩⟩ lemma verumIntro {s : V} (hs : IsFormulaSet L s) (h : ^⊤ ∈ s) : - T.Derivation (verumIntro s) := + IDerivation L (verumIntro s) := Theory.Derivation.mk ⟨by simpa using hs, Or.inr <| Or.inl ⟨s, rfl, h⟩⟩ lemma andIntro {s p q dp dq : V} (h : p ^⋏ q ∈ s) - (hdp : T.DerivationOf dp (insert p s)) (hdq : T.DerivationOf dq (insert q s)) : - T.Derivation (andIntro s p q dp dq) := + (hdp : IDerivationOf L dp (insert p s)) (hdq : IDerivationOf L dq (insert q s)) : + IDerivation L (andIntro s p q dp dq) := Theory.Derivation.mk ⟨by simp only [fstIdx_andIntro]; intro r hr; exact hdp.isFormulaSet r (by simp [hr]), Or.inr <| Or.inr <| Or.inl ⟨s, p, q, dp, dq, rfl, h, hdp, hdq⟩⟩ lemma orIntro {s p q dpq : V} (h : p ^⋎ q ∈ s) - (hdpq : T.DerivationOf dpq (insert p (insert q s))) : - T.Derivation (orIntro s p q dpq) := + (hdpq : IDerivationOf L dpq (insert p (insert q s))) : + IDerivation L (orIntro s p q dpq) := Theory.Derivation.mk ⟨by simp only [fstIdx_orIntro]; intro r hr; exact hdpq.isFormulaSet r (by simp [hr]), Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, q, dpq, rfl, h, hdpq⟩⟩ lemma allIntro {s p dp : V} (h : ^∀ p ∈ s) - (hdp : T.DerivationOf dp (insert (free L p) (setShift L s))) : - T.Derivation (allIntro s p dp) := + (hdp : IDerivationOf L dp (insert (free L p) (setShift L s))) : + IDerivation L (allIntro s p dp) := Theory.Derivation.mk ⟨by simp only [fstIdx_allIntro]; intro q hq; simpa using hdp.isFormulaSet (shift L q) (by simp [shift_mem_setShift hq]), Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, dp, rfl, h, hdp⟩⟩ lemma exsIntro {s p t dp : V} (h : ^∃ p ∈ s) (ht : IsTerm L t) - (hdp : T.DerivationOf dp (insert (substs1 L t p) s)) : - T.Derivation (exsIntro s p t dp) := + (hdp : IDerivationOf L dp (insert (substs1 L t p) s)) : + IDerivation L (exsIntro s p t dp) := Theory.Derivation.mk ⟨by simp only [fstIdx_exsIntro]; intro q hq; exact hdp.isFormulaSet q (by simp [hq]), Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, t, dp, rfl, h, ht, hdp⟩⟩ -lemma wkRule {s s' d : V} (hs : IsFormulaSet L s) - (h : s' ⊆ s) (hd : T.DerivationOf d s') : T.Derivation (wkRule s d) := +lemma contraction {s s' d : V} (hs : IsFormulaSet L s) + (h : s' ⊆ s) (hd : IDerivationOf L d s') : IDerivation L (contraction s d) := Theory.Derivation.mk ⟨by simpa using hs, Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, d, rfl, by simp [hd.1, h], hd.2⟩⟩ lemma shiftRule {s d : V} - (hd : T.DerivationOf d s) : T.Derivation (shiftRule (setShift L s) d) := + (hd : IDerivationOf L d s) : IDerivation L (shiftRule (setShift L s) d) := Theory.Derivation.mk ⟨by simp [hd.isFormulaSet], Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨setShift L s, d, rfl, by simp [hd.1], hd.2⟩⟩ lemma cutRule {s p d₁ d₂ : V} - (hd₁ : T.DerivationOf d₁ (insert p s)) - (hd₂ : T.DerivationOf d₂ (insert (neg L p) s)) : - T.Derivation (cutRule s p d₁ d₂) := + (hd₁ : IDerivationOf L d₁ (insert p s)) + (hd₂ : IDerivationOf L d₂ (insert (neg L p) s)) : + IDerivation L (cutRule s p d₁ d₂) := Theory.Derivation.mk ⟨by simp only [fstIdx_cutRule]; intro q hq; exact hd₁.isFormulaSet q (by simp [hq]), - Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, d₁, d₂, rfl, hd₁, hd₂⟩⟩ - -lemma axm {s p : V} (hs : IsFormulaSet L s) (hp : p ∈ s) (hT : p ∈ T.Δ₁Class) : - T.Derivation (axm s p) := - Theory.Derivation.mk - ⟨by simpa using hs, - Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr ⟨s, p, rfl, hp, hT⟩⟩ - -variable {U : Theory L} [U.Δ₁] + Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr ⟨s, p, d₁, d₂, rfl, hd₁, hd₂⟩⟩ lemma of_ss (h : T.Δ₁Class (V := V) ⊆ U.Δ₁Class) {d : V} : T.Derivation d → U.Derivation d := by intro hd apply Theory.Derivation.induction1 𝚺 ?_ hd - · intro s hs p hp hn; apply Derivation.axL hs hp hn + · intro s hs p hp hn; apply Derivation.identity hs hp hn · intro s hs hv; apply Derivation.verumIntro hs hv · intro s _ p q dp dq hpq hdp hdq ihp ihq apply Derivation.andIntro hpq ⟨hdp.1, ihp⟩ ⟨hdq.1, ihq⟩ @@ -667,7 +647,7 @@ lemma of_ss (h : T.Δ₁Class (V := V) ⊆ U.Δ₁Class) {d : V} : T.Derivation · intro s _ p t d hp ht hd ih apply Derivation.exsIntro hp ht ⟨hd.1, ih⟩ · intro s hs d h _ ih - apply Derivation.wkRule hs h ⟨rfl, ih⟩ + apply Derivation.contraction hs h ⟨rfl, ih⟩ · rintro s hs d rfl _ ih apply Derivation.shiftRule ⟨rfl, ih⟩ · intro s _ p d₁ d₂ h₁ h₂ ih₁ ih₂ @@ -684,7 +664,7 @@ lemma isFormulaSet {s : V} (h : T.Derivable s) : IsFormulaSet L s := by rcases h with ⟨d, hd⟩; exact hd.isFormulaSet lemma em {s : V} (hs : IsFormulaSet L s) (p) (h : p ∈ s) (hn : neg L p ∈ s) : - T.Derivable s := ⟨axL s p, by simp, Derivation.axL hs h hn⟩ + T.Derivable s := ⟨identity s p, by simp, Derivation.identity hs h hn⟩ lemma verum {s : V} (hs : IsFormulaSet L s) (h : ^⊤ ∈ s) : T.Derivable s := ⟨verumIntro s, by simp, Derivation.verumIntro hs h⟩ @@ -712,7 +692,7 @@ lemma ex_m {s p t : V} (h : ^∃ p ∈ s) (ht : IsTerm L t) (hp : T.Derivable (i lemma wk {s s' : V} (hs : IsFormulaSet L s) (h : s' ⊆ s) (hd : T.Derivable s') : T.Derivable s := by rcases hd with ⟨d, hd⟩ - exact ⟨wkRule s d, by simp, Derivation.wkRule hs h hd⟩ + exact ⟨contraction s d, by simp, Derivation.contraction hs h hd⟩ lemma shift {s : V} (hd : T.Derivable s) : T.Derivable (setShift L s) := by diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Basic.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Basic.lean index 6160de92b..5b4b929e0 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Basic.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Basic.lean @@ -408,8 +408,8 @@ variable (c) lemma graph_defined : 𝚺₁.Defined (fun v ↦ c.Graph L (v ·.succ.succ) (v 0) (v 1)) (β.graph L) := .mk fun v ↦ by simp [Blueprint.graph, (c.construction L).fixpoint_defined.iff, Graph] -@[simp] lemma eval_graphDef (v) : - Semiformula.Evalbm V v (β.graph L).val ↔ c.Graph L (v ·.succ.succ) (v 0) (v 1) := (graph_defined c).iff +@[simp] lemma eval_graphDef (v : Fin (arity + 2) → V) : + (β.graph L).val.Evalb v ↔ c.Graph L (v ·.succ.succ) (v 0) (v 1) := (graph_defined c).iff instance graph_definable : 𝚺₁.Definable fun v ↦ c.Graph L (v ·.succ.succ) (v 0) (v 1) := (graph_defined c).to_definable @@ -587,8 +587,8 @@ lemma result_defined : 𝚺₁.DefinedFunction (fun v ↦ c.result L (v ·.succ) simp [Blueprint.result, HierarchySymbol.Semiformula.val_sigma, IsUTerm.defined.proper.iff', c.eval_graphDef, result, Classical.choose!_eq_iff_right] -@[simp] lemma result_graphDef (v) : - Semiformula.Evalbm V v (β.result L).val ↔ v 0 = c.result L (v ·.succ.succ) (v 1) := (result_defined c).iff +@[simp] lemma result_graphDef (v : Fin (arity + 2) → V) : + (β.result L).val.Evalb v ↔ v 0 = c.result L (v ·.succ.succ) (v 1) := (result_defined c).iff private lemma resultVec_graph {w' k w} : w' = c.resultVec L param k w ↔ @@ -602,8 +602,7 @@ lemma resultVec_defined : 𝚺₁.DefinedFunction (fun v ↦ c.resultVec L (v · c.eval_graphDef] using c.resultVec_graph lemma eval_resultVec (v : Fin (arity + 3) → V) : - Semiformula.Evalbm V v (β.resultVec L).val ↔ - v 0 = c.resultVec L (v ·.succ.succ.succ) (v 1) (v 2) := c.resultVec_defined.iff + (β.resultVec L).val.Evalb v ↔ v 0 = c.resultVec L (v ·.succ.succ.succ) (v 1) (v 2) := c.resultVec_defined.iff end diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean index ab6cbf1e3..4975c8bc5 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean @@ -25,10 +25,10 @@ instance Δ₁Class.defined : 𝚫₁-Predicate[V] (· ∈ T.Δ₁Class) via T. constructor · intro v have : V ⊧/![v 0] (Theory.Δ₁.ch T).sigma.val ↔ V ⊧/![v 0] (Theory.Δ₁.ch T).pi.val := by - have := (consequence_iff (T := 𝗜𝚺₁)).mp (sound! <| FirstOrder.Theory.Δ₁.isDelta1 (T := T)) V inferInstance + have := (consequence_iff (T := 𝗜𝚺₁)).mp (Theory.Proof.sound <| FirstOrder.Theory.Δ₁.isDelta1 (T := T)) V inferInstance simp [models_iff] at this ⊢ simpa [Matrix.constant_eq_singleton] using this ![v 0] - rwa [show v = ![v 0] from Matrix.fun_eq_vec_one] + rwa [Matrix.fun_eq_vec_one v] · intro v; simp [←Matrix.fun_eq_vec_one, Theory.Δ₁Class] instance Δ₁Class.definable : 𝚫₁-Predicate[V] (· ∈ T.Δ₁Class) := Δ₁Class.defined.to_definable @@ -63,11 +63,11 @@ namespace Δ₁ open Arithmetic.HierarchySymbol.Semiformula LO.FirstOrder.Theory -instance add (dT : T.Δ₁) (dU : U.Δ₁) : (T + U).Δ₁ where +instance add (dT : T.Δ₁) (dU : U.Δ₁) : (T ∪ U).Δ₁ where ch := T.Δ₁ch ⋎ U.Δ₁ch mem_iff {φ} := by simp only [Nat.succ_eq_add_one, Nat.reduceAdd, val_or, LogicalConnective.HomClass.map_or, - FirstOrder.Arithmetic.Bootstrapping.Δ₁Class.mem_iff'_s, LogicalConnective.Prop.or_eq, add_def, Set.mem_union] + FirstOrder.Arithmetic.Bootstrapping.Δ₁Class.mem_iff'_s, LogicalConnective.Prop.or_eq, Set.mem_union] grind isDelta1 := ProvablyProperOn.ofProperOn.{0} _ fun V _ _ ↦ ProperOn.or (by simp) (by simp) @@ -76,23 +76,6 @@ abbrev ofEq (dT : T.Δ₁) (h : T = U) : U.Δ₁ where mem_iff := by rcases h; exact dT.mem_iff isDelta1 := by rcases h; exact dT.isDelta1 -/- -def add_subset_left (dT : T.Δ₁) (dU : U.Δ₁) : - haveI := dT.add dU - T.codeIn V ⊆ (T + U).codeIn V := by - intro p hp - apply FirstOrder.Semiformula.curve_mem_left - simpa [val_sigma] using hp - -def add_subset_right (dT : T.Δ₁) (dU : U.Δ₁) : - haveI := dT.add dU - U.codeIn V ⊆ (T + U).codeIn V := by - intro p hp - apply FirstOrder.Semiformula.curve_mem_right - simpa [val_sigma] using hp --/ - - instance empty : Theory.Δ₁ (∅ : Theory L) where ch := ⊥ mem_iff {ψ} := by simp @@ -110,15 +93,15 @@ abbrev singleton (φ : Sentence L) : Theory.Δ₁ {φ} where abbrev ofList (l : List (Sentence L)) : Δ₁ {φ | φ ∈ l} := match l with | [] => empty.ofEq (by ext; simp) - | φ :: l => ((singleton φ).add (ofList l)).ofEq (by ext; simp [Theory.add_def]) + | φ :: l => ((singleton φ).add (ofList l)).ofEq (by ext; simp) noncomputable abbrev ofFinite (T : Theory L) (h : Set.Finite T) : T.Δ₁ := (ofList h.toFinset.toList).ofEq (by ext; simp) -instance [T.Δ₁] [U.Δ₁] : (T + U).Δ₁ := add inferInstance inferInstance +instance [T.Δ₁] [U.Δ₁] : (T ∪ U).Δ₁ := add inferInstance inferInstance instance (φ : Sentence L) : Theory.Δ₁ {φ} := singleton φ -instance insert [d : T.Δ₁] : (insert φ T).Δ₁ := (d.add (singleton φ)).ofEq (by ext; simp [Theory.add_def]) +instance insert [d : T.Δ₁] : (insert φ T).Δ₁ := (d.add (singleton φ)).ofEq (by ext; simp) end Δ₁ From fc5731755bd54f1258fa448d09186a8851ae2e79 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 18 Jun 2026 08:03:11 +0900 Subject: [PATCH 08/14] hfsImage --- .../FirstOrder/Arithmetic/HFS/Basic.lean | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean b/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean index 015f8a9fe..6969340d0 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean @@ -579,6 +579,60 @@ theorem sigma₁_replacement₂ {f : V → V → V} (hf : 𝚺₁-Function₂ f) · rintro ⟨x₁, h₁, x₂, h₂, rfl⟩; exact ⟨⟪x₁, x₂⟫, by simp [h₁, h₂]⟩)).mp (sigma₁_replacement this (s₁ ×ʰᶠ s₂)) +/-! ### Image of HFS -/ + +noncomputable def hfsImage (f : V → V) [𝚺₁-Function₁ f] (s : V) : V := Classical.choose! (sigma₁_replacement (f := f) inferInstance s) + + +variable {L} + +section hfsImage + +variable {f : V → V} [𝚺₁-Function₁ f] + +lemma mem_hfsImage_iff {s y : V} : y ∈ hfsImage f s ↔ ∃ x ∈ s, y = f x := + Classical.choose!_spec (sigma₁_replacement (f := f) inferInstance s) y + +lemma app_mem_hfsImage {p s : V} (h : p ∈ s) : f p ∈ hfsImage f s := + mem_hfsImage_iff.mpr ⟨p, h, rfl⟩ + +@[simp] lemma mem_hfsImage_union {s t : V} : hfsImage f (s ∪ t) = hfsImage f s ∪ hfsImage f t := mem_ext <| by + simp only [mem_hfsImage_iff, mem_cup_iff]; grind + +@[simp] lemma mem_hfsImage_insert {x s : V} : hfsImage f (insert x s) = insert (f x) (hfsImage f s) := mem_ext <| by + simp [mem_hfsImage_iff] + +@[simp] lemma hfsImage_empty : hfsImage f (∅ : V) = ∅ := mem_ext <| by simp [mem_hfsImage_iff] + +section + +private lemma hfsImage_graph (t s : V) : + t = hfsImage f s ↔ (∀ y ∈ t, ∃ x ∈ s, y = f x) ∧ (∀ x ∈ s, f x ∈ t) := by + constructor + · rintro rfl + constructor + · intro y hy; exact mem_hfsImage_iff.mp hy + · intro x hx; exact mem_hfsImage_iff.mpr ⟨x, hx, rfl⟩ + · rintro ⟨h₁, h₂⟩ + apply mem_ext; intro y; constructor + · intro hy; exact mem_hfsImage_iff.mpr (h₁ y hy) + · intro hy + rcases mem_hfsImage_iff.mp hy with ⟨x, hx, rfl⟩ + exact h₂ x hx + +noncomputable def hfsImage.graph (f : V → V) (δ : 𝚺₁.Semisentence 2) [𝚺₁-Function₁ f via δ] : 𝚺₁.Semisentence 2 := .mkSigma + “t s. (∀ y ∈' t, ∃ x ∈' s, !δ y x) ∧ (∀ x ∈' s, ∃ y, !δ y x ∧ y ∈ t)” + +instance hfsImage.defined (f : V → V) {δ : 𝚺₁.Semisentence 2} [𝚺₁-Function₁ f] (h : 𝚺₁-Function₁ f via δ) : + 𝚺₁-Function₁[V] (hfsImage f) via (hfsImage.graph f δ) := .mk fun v ↦ by simp [hfsImage.graph, hfsImage_graph] + +instance hfsImage.definable (f : V → V) {δ : 𝚺₁.Semisentence 2} [𝚺₁-Function₁ f] (h : 𝚺₁-Function₁ f via δ) : + 𝚺₁-Function₁[V] hfsImage f := (hfsImage.defined f h).to_definable + +end + +end hfsImage + section fstIdx noncomputable def fstIdx (p : V) : V := π₁ (p - 1) From b5aa49791a2df95892e9814ca3c6ed4fa1993916 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 18 Jun 2026 09:52:45 +0900 Subject: [PATCH 09/14] fix --- .../Arithmetic/Definability/Definable.lean | 32 ++ .../FirstOrder/Arithmetic/HFS/Basic.lean | 10 +- .../Bootstrapping/Syntax/Proof/Basic.lean | 394 +++++++++--------- 3 files changed, 236 insertions(+), 200 deletions(-) diff --git a/Foundation/FirstOrder/Arithmetic/Definability/Definable.lean b/Foundation/FirstOrder/Arithmetic/Definability/Definable.lean index dc91ab5f4..e8a2edab0 100644 --- a/Foundation/FirstOrder/Arithmetic/Definability/Definable.lean +++ b/Foundation/FirstOrder/Arithmetic/Definability/Definable.lean @@ -874,4 +874,36 @@ attribute [aesop 11 (rule_sets := [Definability]) safe] Definable.all Definable.exs +/-! ### Auxiliary lemmata for aesop -/ + +section + +variable (P : (Fin k → V) → Prop) (f : (Fin k → V) → V) + +instance [𝚺₁.Definable P] : 𝚺-[0+1].Definable P := inferInstance + +instance [𝚷₁.Definable P] : 𝚷-[0+1].Definable P := inferInstance + +instance [𝚫₁.Definable P] : 𝚫-[0+1].Definable P := inferInstance + +instance [𝚺₁.DefinableFunction f] : 𝚺-[0+1].DefinableFunction f := inferInstance + +instance [𝚷₁.DefinableFunction f] : 𝚷-[0+1].DefinableFunction f := inferInstance + +instance [𝚫₁.DefinableFunction f] : 𝚫-[0+1].DefinableFunction f := inferInstance + +instance [𝚺-[2].Definable P] : 𝚺-[0+1+1].Definable P := inferInstance + +instance [𝚷-[2].Definable P] : 𝚷-[0+1+1].Definable P := inferInstance + +instance [𝚫-[2].Definable P] : 𝚫-[0+1+1].Definable P := inferInstance + +instance [𝚺-[2].DefinableFunction f] : 𝚺-[0+1+1].DefinableFunction f := inferInstance + +instance [𝚷-[2].DefinableFunction f] : 𝚷-[0+1+1].DefinableFunction f := inferInstance + +instance [𝚫-[2].DefinableFunction f] : 𝚫-[0+1+1].DefinableFunction f := inferInstance + +end + end LO.FirstOrder.Arithmetic.HierarchySymbol diff --git a/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean b/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean index 6969340d0..5bcc700b3 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean @@ -620,14 +620,14 @@ private lemma hfsImage_graph (t s : V) : rcases mem_hfsImage_iff.mp hy with ⟨x, hx, rfl⟩ exact h₂ x hx -noncomputable def hfsImage.graph (f : V → V) (δ : 𝚺₁.Semisentence 2) [𝚺₁-Function₁ f via δ] : 𝚺₁.Semisentence 2 := .mkSigma +noncomputable def hfsImage.graph (δ : 𝚺₁.Semisentence 2) : 𝚺₁.Semisentence 2 := .mkSigma “t s. (∀ y ∈' t, ∃ x ∈' s, !δ y x) ∧ (∀ x ∈' s, ∃ y, !δ y x ∧ y ∈ t)” -instance hfsImage.defined (f : V → V) {δ : 𝚺₁.Semisentence 2} [𝚺₁-Function₁ f] (h : 𝚺₁-Function₁ f via δ) : - 𝚺₁-Function₁[V] (hfsImage f) via (hfsImage.graph f δ) := .mk fun v ↦ by simp [hfsImage.graph, hfsImage_graph] +abbrev hfsImage.defined (f : V → V) [𝚺₁-Function₁ f] (δ : 𝚺₁.Semisentence 2) [𝚺₁-Function₁ f via δ] : + 𝚺₁-Function₁[V] (hfsImage f) via (hfsImage.graph δ) := .mk fun v ↦ by simp [hfsImage.graph, hfsImage_graph] -instance hfsImage.definable (f : V → V) {δ : 𝚺₁.Semisentence 2} [𝚺₁-Function₁ f] (h : 𝚺₁-Function₁ f via δ) : - 𝚺₁-Function₁[V] hfsImage f := (hfsImage.defined f h).to_definable +abbrev hfsImage.definable (f : V → V) [𝚺₁-Function₁ f] (δ : 𝚺₁.Semisentence 2) [𝚺₁-Function₁ f via δ] : + 𝚺₁-Function₁[V] hfsImage f := (hfsImage.defined f δ).to_definable end diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean index e199c7def..4a7464335 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean @@ -2,6 +2,8 @@ module public import Foundation.FirstOrder.Bootstrapping.Syntax.Theory +/-! # Internal $\mathbf{LK}$ -/ + @[expose] public section namespace LO @@ -11,10 +13,10 @@ variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] -variable {T U : Theory L} [T.Δ₁] [U.Δ₁] - namespace FirstOrder.Arithmetic.Bootstrapping +/-! ## Sequent -/ + variable (L) def IsFormulaSet (s : V) : Prop := ∀ p ∈ s, IsFormula L p @@ -64,72 +66,78 @@ alias ⟨insert, _⟩ := insert_iff end IsFormulaSet +/-! ### setShift: shift over a sequent -/ + variable (L) -lemma setShift_existsUnique (s : V) : - ∃! t : V, ∀ y, y ∈ t ↔ ∃ x ∈ s, y = shift L x := - sigma₁_replacement (by definability) s +noncomputable def setShift : V → V := hfsImage (shift L) -noncomputable def setShift (s : V) : V := Classical.choose! (setShift_existsUnique L s) +noncomputable def setShiftGraph : 𝚺₁.Semisentence 2 := hfsImage.graph (shiftGraph L) -noncomputable def setShiftGraph : 𝚺₁.Semisentence 2 := .mkSigma - “t s. (∀ y ∈' t, ∃ x ∈' s, !(shiftGraph L) y x) ∧ (∀ x ∈' s, ∃ y, !(shiftGraph L) y x ∧ y ∈ t)” +instance setShift.defined : 𝚺₁-Function₁[V] setShift L via setShiftGraph L := hfsImage.defined _ (shiftGraph L) -variable {L} +instance setShift.definable : 𝚺₁-Function₁[V] setShift L := hfsImage.definable _ (shiftGraph L) +variable {L} section setShift -lemma mem_setShift_iff {s y : V} : y ∈ setShift L s ↔ ∃ x ∈ s, y = shift L x := - Classical.choose!_spec (setShift_existsUnique L s) y +lemma mem_setShift_iff {s y : V} : y ∈ setShift L s ↔ ∃ x ∈ s, y = shift L x := mem_hfsImage_iff + +@[simp] lemma mem_setShift_union {s t : V} : setShift L (s ∪ t) = setShift L s ∪ setShift L t := mem_hfsImage_union + +@[simp] lemma mem_setShift_insert {x s : V} : setShift L (insert x s) = insert (shift L x) (setShift L s) := mem_hfsImage_insert + +@[simp] lemma setShift_empty : setShift L (∅ : V) = ∅ := hfsImage_empty lemma IsFormulaSet.setShift {s : V} (h : IsFormulaSet L s) : IsFormulaSet L (setShift L s) := by simp only [IsFormulaSet, mem_setShift_iff, forall_exists_index, and_imp] rintro _ p hp rfl; exact (h p hp).shift -lemma shift_mem_setShift {p s : V} (h : p ∈ s) : shift L p ∈ setShift L s := - mem_setShift_iff.mpr ⟨p, h, rfl⟩ +lemma shift_mem_setShift {p s : V} (h : p ∈ s) : shift L p ∈ setShift L s := app_mem_hfsImage h @[simp] lemma IsFormulaSet.setShift_iff {s : V} : IsFormulaSet L (Bootstrapping.setShift L s) ↔ IsFormulaSet L s := ⟨by intro h p hp; simpa using h (shift L p) (shift_mem_setShift hp), IsFormulaSet.setShift⟩ -@[simp] lemma mem_setShift_union {s t : V} : setShift L (s ∪ t) = setShift L s ∪ setShift L t := mem_ext <| by - simp only [mem_setShift_iff, mem_cup_iff]; intro x - constructor - · rintro ⟨z, (hz | hz), rfl⟩ - · left; exact ⟨z, hz, rfl⟩ - · right; exact ⟨z, hz, rfl⟩ - · rintro (⟨z, hz, rfl⟩ | ⟨z, hz, rfl⟩) - · exact ⟨z, Or.inl hz, rfl⟩ - · exact ⟨z, Or.inr hz, rfl⟩ +end setShift -@[simp] lemma mem_setShift_insert {x s : V} : setShift L (insert x s) = insert (shift L x) (setShift L s) := mem_ext <| by - simp [mem_setShift_iff] +/-! ### setNeg: negation over a sequent -/ -@[simp] lemma setShift_empty : setShift L (∅ : V) = ∅ := mem_ext <| by simp [mem_setShift_iff] -section +variable (L) -private lemma setShift_graph (t s : V) : - t = setShift L s ↔ (∀ y ∈ t, ∃ x ∈ s, y = shift L x) ∧ (∀ x ∈ s, shift L x ∈ t) := by - constructor - · rintro rfl - constructor - · intro y hy; exact mem_setShift_iff.mp hy - · intro x hx; exact mem_setShift_iff.mpr ⟨x, hx, rfl⟩ - · rintro ⟨h₁, h₂⟩ - apply mem_ext; intro y; constructor - · intro hy; exact mem_setShift_iff.mpr (h₁ y hy) - · intro hy - rcases mem_setShift_iff.mp hy with ⟨x, hx, rfl⟩ - exact h₂ x hx +noncomputable def setNeg : V → V := hfsImage (neg L) -instance setShift.defined : 𝚺₁-Function₁[V] setShift L via setShiftGraph L := .mk fun v ↦ by simp [setShiftGraph, setShift_graph] +noncomputable def setNegGraph : 𝚺₁.Semisentence 2 := hfsImage.graph (negGraph L) -instance setShift.definable : 𝚺₁-Function₁[V] setShift L := setShift.defined.to_definable +instance setNeg.defined : 𝚺₁-Function₁[V] setNeg L via setNegGraph L := hfsImage.defined _ (negGraph L) -end +instance setNeg.definable : 𝚺₁-Function₁[V] setNeg L := hfsImage.definable _ (negGraph L) -end setShift +variable {L} + +section setNeg + +lemma mem_setNeg_iff {s y : V} : y ∈ setNeg L s ↔ ∃ x ∈ s, y = neg L x := mem_hfsImage_iff + +@[simp] lemma mem_setNeg_union {s t : V} : setNeg L (s ∪ t) = setNeg L s ∪ setNeg L t := mem_hfsImage_union + +@[simp] lemma mem_setNeg_insert {x s : V} : setNeg L (insert x s) = insert (neg L x) (setNeg L s) := mem_hfsImage_insert + +@[simp] lemma setNeg_empty : setNeg L (∅ : V) = ∅ := hfsImage_empty + +lemma IsFormulaSet.setNeg {s : V} (h : IsFormulaSet L s) : IsFormulaSet L (setNeg L s) := by + simp only [IsFormulaSet, mem_setNeg_iff, forall_exists_index, and_imp] + rintro _ p hp rfl; exact (h p hp).neg + +lemma neg_mem_setNeg {p s : V} (h : p ∈ s) : neg L p ∈ setNeg L s := app_mem_hfsImage h + +@[simp] lemma IsFormulaSet.setNeg_iff {s : V} : + IsFormulaSet L (Bootstrapping.setNeg L s) ↔ IsFormulaSet L s := + ⟨by intro h p hp; simpa using h (neg L p) (neg_mem_setNeg hp), IsFormulaSet.setNeg⟩ + +end setNeg + +/-- ### Coding of rules -/ noncomputable def identity (s p : V) : V := ⟪s, 0, p⟫ + 1 @@ -260,7 +268,11 @@ instance cutRule_defined : 𝚺₀-Function₄ (cutRule : V → V → V → V end -namespace IDerivation +/-! ## Internal derivation -/ + +namespace IsDerivation + +/-! ### Preparation -/ noncomputable abbrev conseq (x : V) : V := π₁ x @@ -424,44 +436,44 @@ instance : (construction L).StrongFinite V where · right; right; right; right; right; right; right; left; exact ⟨s, d', rfl, ss, hdC, by simp⟩ · right; right; right; right; right; right; right; right; exact ⟨s, p, d₁, d₂, rfl, ⟨h₁, hd₁C, by simp⟩, ⟨h₂, hd₂C, by simp⟩⟩ -end IDerivation +end IsDerivation -/- ## Internal `\mathbf{LK}` -/ +/- ### Main definitions -/ -open PeanoMinus ISigma0 ISigma1 Bootstrapping IDerivation +open PeanoMinus ISigma0 ISigma1 Bootstrapping IsDerivation variable (L) /-- Internal derivation -/ -def IDerivation : V → Prop := (construction L).Fixpoint ![] +def IsDerivation : V → Prop := (construction L).Fixpoint ![] /- Internal derivation of sequent `s` -/ -def IDerivationOf (d s : V) : Prop := fstIdx d = s ∧ IDerivation L d +def IsDerivationOf (d s : V) : Prop := fstIdx d = s ∧ IsDerivation L d /-- Internal derivability -/ -def IDerivable (s : V) : Prop := ∃ d, IDerivationOf L d s +def Derivable (s : V) : Prop := ∃ d, IsDerivationOf L d s /-- Internal proof -/ @[deprecated IProof] -def IProof (d φ : V) : Prop := IDerivationOf L d {φ} +def IProof (d φ : V) : Prop := IsDerivationOf L d {φ} /-- Internal provability -/ @[deprecated IProvable] def IProvable (φ : V) : Prop := ∃ d, IProof L d φ -noncomputable def iderivation : 𝚫₁.Semisentence 1 := (blueprint L).fixpointDefΔ₁ +noncomputable def derivation : 𝚫₁.Semisentence 1 := (blueprint L).fixpointDefΔ₁ -noncomputable def iderivationOf : 𝚫₁.Semisentence 2 := .mkDelta - (.mkSigma “d s. !fstIdxDef s d ∧ !(iderivation L).sigma d”) - (.mkPi “d s. !fstIdxDef s d ∧ !(iderivation L).pi d”) +noncomputable def derivationOf : 𝚫₁.Semisentence 2 := .mkDelta + (.mkSigma “d s. !fstIdxDef s d ∧ !(derivation L).sigma d”) + (.mkPi “d s. !fstIdxDef s d ∧ !(derivation L).pi d”) -noncomputable def iderivable : 𝚺₁.Semisentence 1 := .mkSigma - “Γ. ∃ d, !(iderivationOf L).sigma d Γ” +noncomputable def derivable : 𝚺₁.Semisentence 1 := .mkSigma + “Γ. ∃ d, !(derivationOf L).sigma d Γ” @[deprecated iproof] noncomputable def iproof : 𝚫₁.Semisentence 2 := .mkDelta - (.mkSigma “d φ. ∃ s, !insertDef s φ 0 ∧ !(iderivationOf L).sigma d s”) - (.mkPi “d φ. ∀ s, !insertDef s φ 0 → !(iderivationOf L).pi d s”) + (.mkSigma “d φ. ∃ s, !insertDef s φ 0 ∧ !(derivationOf L).sigma d s”) + (.mkPi “d φ. ∀ s, !insertDef s φ 0 → !(derivationOf L).pi d s”) noncomputable def iprovable : 𝚺₁.Semisentence 1 := .mkSigma “φ. ∃ d, !(iproof L).sigma d φ” @@ -479,25 +491,25 @@ variable {L} section -instance IDerivation.defined : 𝚫₁-Predicate[V] (IDerivation L) via iderivation L := (construction L).fixpoint_definedΔ₁ +instance IsDerivation.defined : 𝚫₁-Predicate[V] (IsDerivation L) via derivation L := (construction L).fixpoint_definedΔ₁ -instance IDerivation.definable : 𝚫₁-Predicate[V] (IDerivation L) := IDerivation.defined.to_definable +instance IsDerivation.definable : 𝚫₁-Predicate[V] (IsDerivation L) := IsDerivation.defined.to_definable -instance IDerivation.definable' : Γ-[m + 1]-Predicate[V] (IDerivation L) := IDerivation.definable.of_deltaOne +instance IsDerivation.definable' : Γ-[m + 1]-Predicate[V] (IsDerivation L) := IsDerivation.definable.of_deltaOne -instance IDerivationOf.defined : 𝚫₁-Relation[V] (IDerivationOf L) via iderivationOf L := .mk - ⟨by intro v; simp [iderivationOf], by intro v; simp [iderivationOf, eq_comm (b := fstIdx (v 0))]; rfl⟩ +instance IsDerivationOf.defined : 𝚫₁-Relation[V] (IsDerivationOf L) via derivationOf L := .mk + ⟨by intro v; simp [derivationOf], by intro v; simp [derivationOf, eq_comm (b := fstIdx (v 0))]; rfl⟩ -instance IDerivationOf.definable : 𝚫₁-Relation[V] IDerivationOf L := IDerivationOf.defined.to_definable +instance IsDerivationOf.definable : 𝚫₁-Relation[V] IsDerivationOf L := IsDerivationOf.defined.to_definable -instance IDerivationOf.definable' : Γ-[m + 1]-Relation[V] IDerivationOf L := IDerivationOf.definable.of_deltaOne +instance IsDerivationOf.definable' : Γ-[m + 1]-Relation[V] IsDerivationOf L := IsDerivationOf.definable.of_deltaOne -instance IDerivable.defined : 𝚺₁-Predicate[V] (IDerivable L) via iderivable L := .mk fun v ↦ by simp [IDerivable, iderivable] +instance Derivable.defined : 𝚺₁-Predicate[V] (Derivable L) via derivable L := .mk fun v ↦ by simp [Derivable, derivable] -instance IDerivable.definable : 𝚺₁-Predicate[V] (IDerivable L) := IDerivable.defined.to_definable +instance Derivable.definable : 𝚺₁-Predicate[V] (Derivable L) := Derivable.defined.to_definable /-- instance for definability tactic-/ -instance IDerivable.definable' : 𝚺-[0 + 1]-Predicate[V] (IDerivable L) := IDerivable.definable +instance Derivable.definable' : 𝚺-[0 + 1]-Predicate[V] (Derivable L) := Derivable.definable /- @@ -519,41 +531,43 @@ instance Provable.definable' : 𝚺-[0 + 1]-Predicate[V] T.Provable := Provable. end -namespace IDerivation +/-! ### Induction and recursion of derivation -/ + +namespace IsDerivation lemma case_iff {d : V} : - IDerivation L d ↔ + IsDerivation L d ↔ IsFormulaSet L (fstIdx d) ∧ ( (∃ s p, d = Bootstrapping.identity s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ (∃ s, d = verumIntro s ∧ ^⊤ ∈ s) ∨ - (∃ s p q dp dq, d = andIntro s p q dp dq ∧ p ^⋏ q ∈ s ∧ IDerivationOf L dp (insert p s) ∧ IDerivationOf L dq (insert q s)) ∨ - (∃ s p q dpq, d = orIntro s p q dpq ∧ p ^⋎ q ∈ s ∧ IDerivationOf L dpq (insert p (insert q s))) ∨ - (∃ s p dp, d = allIntro s p dp ∧ ^∀ p ∈ s ∧ IDerivationOf L dp (insert (free L p) (setShift L s))) ∨ - (∃ s p t dp, d = exsIntro s p t dp ∧ ^∃ p ∈ s ∧ IsTerm L t ∧ IDerivationOf L dp (insert (substs1 L t p) s)) ∨ - (∃ s d', d = contraction s d' ∧ fstIdx d' ⊆ s ∧ IDerivation L d') ∨ - (∃ s d', d = shiftRule s d' ∧ s = setShift L (fstIdx d') ∧ IDerivation L d') ∨ - (∃ s p d₁ d₂, d = cutRule s p d₁ d₂ ∧ IDerivationOf L d₁ (insert p s) ∧ IDerivationOf L d₂ (insert (neg L p) s)) ) := + (∃ s p q dp dq, d = andIntro s p q dp dq ∧ p ^⋏ q ∈ s ∧ IsDerivationOf L dp (insert p s) ∧ IsDerivationOf L dq (insert q s)) ∨ + (∃ s p q dpq, d = orIntro s p q dpq ∧ p ^⋎ q ∈ s ∧ IsDerivationOf L dpq (insert p (insert q s))) ∨ + (∃ s p dp, d = allIntro s p dp ∧ ^∀ p ∈ s ∧ IsDerivationOf L dp (insert (free L p) (setShift L s))) ∨ + (∃ s p t dp, d = exsIntro s p t dp ∧ ^∃ p ∈ s ∧ IsTerm L t ∧ IsDerivationOf L dp (insert (substs1 L t p) s)) ∨ + (∃ s d', d = contraction s d' ∧ fstIdx d' ⊆ s ∧ IsDerivation L d') ∨ + (∃ s d', d = shiftRule s d' ∧ s = setShift L (fstIdx d') ∧ IsDerivation L d') ∨ + (∃ s p d₁ d₂, d = cutRule s p d₁ d₂ ∧ IsDerivationOf L d₁ (insert p s) ∧ IsDerivationOf L d₂ (insert (neg L p) s)) ) := (construction L).case -alias ⟨case, _root_.LO.FirstOrder.Theory.Derivation.mk⟩ := case_iff +alias ⟨case, _root_.LO.FirstOrder.Theory.IsDerivation.mk⟩ := case_iff lemma induction1 (Γ) {P : V → Prop} (hP : Γ-[1]-Predicate P) - {d} (hd : IDerivation L d) + {d} (hd : IsDerivation L d) (hAxL : ∀ s, IsFormulaSet L s → ∀ p ∈ s, neg L p ∈ s → P (identity s p)) (hVerumIntro : ∀ s, IsFormulaSet L s → ^⊤ ∈ s → P (verumIntro s)) - (hAnd : ∀ s, IsFormulaSet L s → ∀ p q dp dq, p ^⋏ q ∈ s → IDerivationOf L dp (insert p s) → IDerivationOf L dq (insert q s) → + (hAnd : ∀ s, IsFormulaSet L s → ∀ p q dp dq, p ^⋏ q ∈ s → IsDerivationOf L dp (insert p s) → IsDerivationOf L dq (insert q s) → P dp → P dq → P (andIntro s p q dp dq)) - (hOr : ∀ s, IsFormulaSet L s → ∀ p q d, p ^⋎ q ∈ s → IDerivationOf L d (insert p (insert q s)) → + (hOr : ∀ s, IsFormulaSet L s → ∀ p q d, p ^⋎ q ∈ s → IsDerivationOf L d (insert p (insert q s)) → P d → P (orIntro s p q d)) - (hAll : ∀ s, IsFormulaSet L s → ∀ p d, ^∀ p ∈ s → IDerivationOf L d (insert (free L p) (setShift L s)) → + (hAll : ∀ s, IsFormulaSet L s → ∀ p d, ^∀ p ∈ s → IsDerivationOf L d (insert (free L p) (setShift L s)) → P d → P (allIntro s p d)) - (hExs : ∀ s, IsFormulaSet L s → ∀ p t d, ^∃ p ∈ s → IsTerm L t → IDerivationOf L d (insert (substs1 L t p) s) → + (hExs : ∀ s, IsFormulaSet L s → ∀ p t d, ^∃ p ∈ s → IsTerm L t → IsDerivationOf L d (insert (substs1 L t p) s) → P d → P (exsIntro s p t d)) - (hWk : ∀ s, IsFormulaSet L s → ∀ d, fstIdx d ⊆ s → IDerivation L d → + (hWk : ∀ s, IsFormulaSet L s → ∀ d, fstIdx d ⊆ s → IsDerivation L d → P d → P (contraction s d)) - (hShift : ∀ s, IsFormulaSet L s → ∀ d, s = setShift L (fstIdx d) → IDerivation L d → + (hShift : ∀ s, IsFormulaSet L s → ∀ d, s = setShift L (fstIdx d) → IsDerivation L d → P d → P (shiftRule s d)) - (hCut : ∀ s, IsFormulaSet L s → ∀ p d₁ d₂, IDerivationOf L d₁ (insert p s) → IDerivationOf L d₂ (insert (neg L p) s) → + (hCut : ∀ s, IsFormulaSet L s → ∀ p d₁ d₂, IsDerivationOf L d₁ (insert p s) → IsDerivationOf L d₂ (insert (neg L p) s) → P d₁ → P d₂ → P (cutRule s p d₁ d₂)) : P d := (construction L).induction (v := ![]) hP (by intro C ih d hd @@ -574,180 +588,150 @@ lemma induction1 (Γ) {P : V → Prop} (hP : Γ-[1]-Predicate P) · exact hCut s (by simpa using hds) p d₁ d₂ ⟨h₁, (ih d₁ hC₁).1⟩ ⟨h₂, (ih d₂ hC₂).1⟩ (ih d₁ hC₁).2 (ih d₂ hC₂).2) d hd -lemma isFormulaSet {d : V} (h : IDerivation L d) : IsFormulaSet L (fstIdx d) := (h : IDerivation L d).case.1 +lemma isFormulaSet {d : V} (h : IsDerivation L d) : IsFormulaSet L (fstIdx d) := (h : IsDerivation L d).case.1 -lemma _root_.LO.FirstOrder.Arithmetic.Bootstrapping.IDerivationOf.isFormulaSet {d s : V} (h : IDerivationOf L d s) : IsFormulaSet L s := by +lemma _root_.LO.FirstOrder.Arithmetic.Bootstrapping.IsDerivationOf.isFormulaSet {d s : V} (h : IsDerivationOf L d s) : IsFormulaSet L s := by simpa [h.1] using h.2.case.1 -lemma identity {s p : V} (hs : IsFormulaSet L s) (h : p ∈ s) (hn : neg L p ∈ s) : IDerivation L (identity s p) := - Theory.Derivation.mk ⟨by simpa using hs, Or.inl ⟨s, p, rfl, h, hn⟩⟩ +lemma identity {s p : V} (hs : IsFormulaSet L s) (h : p ∈ s) (hn : neg L p ∈ s) : IsDerivation L (identity s p) := + Theory.IsDerivation.mk ⟨by simpa using hs, Or.inl ⟨s, p, rfl, h, hn⟩⟩ lemma verumIntro {s : V} (hs : IsFormulaSet L s) (h : ^⊤ ∈ s) : - IDerivation L (verumIntro s) := - Theory.Derivation.mk ⟨by simpa using hs, Or.inr <| Or.inl ⟨s, rfl, h⟩⟩ + IsDerivation L (verumIntro s) := + Theory.IsDerivation.mk ⟨by simpa using hs, Or.inr <| Or.inl ⟨s, rfl, h⟩⟩ lemma andIntro {s p q dp dq : V} (h : p ^⋏ q ∈ s) - (hdp : IDerivationOf L dp (insert p s)) (hdq : IDerivationOf L dq (insert q s)) : - IDerivation L (andIntro s p q dp dq) := - Theory.Derivation.mk ⟨by simp only [fstIdx_andIntro]; intro r hr; exact hdp.isFormulaSet r (by simp [hr]), + (hdp : IsDerivationOf L dp (insert p s)) (hdq : IsDerivationOf L dq (insert q s)) : + IsDerivation L (andIntro s p q dp dq) := + Theory.IsDerivation.mk ⟨by simp only [fstIdx_andIntro]; intro r hr; exact hdp.isFormulaSet r (by simp [hr]), Or.inr <| Or.inr <| Or.inl ⟨s, p, q, dp, dq, rfl, h, hdp, hdq⟩⟩ lemma orIntro {s p q dpq : V} (h : p ^⋎ q ∈ s) - (hdpq : IDerivationOf L dpq (insert p (insert q s))) : - IDerivation L (orIntro s p q dpq) := - Theory.Derivation.mk ⟨by simp only [fstIdx_orIntro]; intro r hr; exact hdpq.isFormulaSet r (by simp [hr]), + (hdpq : IsDerivationOf L dpq (insert p (insert q s))) : + IsDerivation L (orIntro s p q dpq) := + Theory.IsDerivation.mk ⟨by simp only [fstIdx_orIntro]; intro r hr; exact hdpq.isFormulaSet r (by simp [hr]), Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, q, dpq, rfl, h, hdpq⟩⟩ lemma allIntro {s p dp : V} (h : ^∀ p ∈ s) - (hdp : IDerivationOf L dp (insert (free L p) (setShift L s))) : - IDerivation L (allIntro s p dp) := - Theory.Derivation.mk + (hdp : IsDerivationOf L dp (insert (free L p) (setShift L s))) : + IsDerivation L (allIntro s p dp) := + Theory.IsDerivation.mk ⟨by simp only [fstIdx_allIntro]; intro q hq; simpa using hdp.isFormulaSet (shift L q) (by simp [shift_mem_setShift hq]), Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, dp, rfl, h, hdp⟩⟩ lemma exsIntro {s p t dp : V} (h : ^∃ p ∈ s) (ht : IsTerm L t) - (hdp : IDerivationOf L dp (insert (substs1 L t p) s)) : - IDerivation L (exsIntro s p t dp) := - Theory.Derivation.mk + (hdp : IsDerivationOf L dp (insert (substs1 L t p) s)) : + IsDerivation L (exsIntro s p t dp) := + Theory.IsDerivation.mk ⟨by simp only [fstIdx_exsIntro]; intro q hq; exact hdp.isFormulaSet q (by simp [hq]), Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, t, dp, rfl, h, ht, hdp⟩⟩ lemma contraction {s s' d : V} (hs : IsFormulaSet L s) - (h : s' ⊆ s) (hd : IDerivationOf L d s') : IDerivation L (contraction s d) := - Theory.Derivation.mk + (h : s' ⊆ s) (hd : IsDerivationOf L d s') : IsDerivation L (contraction s d) := + Theory.IsDerivation.mk ⟨by simpa using hs, Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, d, rfl, by simp [hd.1, h], hd.2⟩⟩ lemma shiftRule {s d : V} - (hd : IDerivationOf L d s) : IDerivation L (shiftRule (setShift L s) d) := - Theory.Derivation.mk + (hd : IsDerivationOf L d s) : IsDerivation L (shiftRule (setShift L s) d) := + Theory.IsDerivation.mk ⟨by simp [hd.isFormulaSet], Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨setShift L s, d, rfl, by simp [hd.1], hd.2⟩⟩ lemma cutRule {s p d₁ d₂ : V} - (hd₁ : IDerivationOf L d₁ (insert p s)) - (hd₂ : IDerivationOf L d₂ (insert (neg L p) s)) : - IDerivation L (cutRule s p d₁ d₂) := - Theory.Derivation.mk + (hd₁ : IsDerivationOf L d₁ (insert p s)) + (hd₂ : IsDerivationOf L d₂ (insert (neg L p) s)) : + IsDerivation L (cutRule s p d₁ d₂) := + Theory.IsDerivation.mk ⟨by simp only [fstIdx_cutRule]; intro q hq; exact hd₁.isFormulaSet q (by simp [hq]), Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr ⟨s, p, d₁, d₂, rfl, hd₁, hd₂⟩⟩ -lemma of_ss (h : T.Δ₁Class (V := V) ⊆ U.Δ₁Class) {d : V} : T.Derivation d → U.Derivation d := by - intro hd - apply Theory.Derivation.induction1 𝚺 ?_ hd - · intro s hs p hp hn; apply Derivation.identity hs hp hn - · intro s hs hv; apply Derivation.verumIntro hs hv - · intro s _ p q dp dq hpq hdp hdq ihp ihq - apply Derivation.andIntro hpq ⟨hdp.1, ihp⟩ ⟨hdq.1, ihq⟩ - · intro s _ p q d hpq hd ih - apply Derivation.orIntro hpq ⟨hd.1, ih⟩ - · intro s _ p d hp hd ih - apply Derivation.allIntro hp ⟨hd.1, ih⟩ - · intro s _ p t d hp ht hd ih - apply Derivation.exsIntro hp ht ⟨hd.1, ih⟩ - · intro s hs d h _ ih - apply Derivation.contraction hs h ⟨rfl, ih⟩ - · rintro s hs d rfl _ ih - apply Derivation.shiftRule ⟨rfl, ih⟩ - · intro s _ p d₁ d₂ h₁ h₂ ih₁ ih₂ - apply Derivation.cutRule ⟨h₁.1, ih₁⟩ ⟨h₂.1, ih₂⟩ - · intro s hs p hps hpT - apply Derivation.axm hs hps (h hpT) - · definability - -end Derivation +end IsDerivation namespace Derivable -lemma isFormulaSet {s : V} (h : T.Derivable s) : IsFormulaSet L s := by +lemma isFormulaSet {s : V} (h : Derivable L s) : IsFormulaSet L s := by rcases h with ⟨d, hd⟩; exact hd.isFormulaSet lemma em {s : V} (hs : IsFormulaSet L s) (p) (h : p ∈ s) (hn : neg L p ∈ s) : - T.Derivable s := ⟨identity s p, by simp, Derivation.identity hs h hn⟩ + Derivable L s := ⟨identity s p, by simp, IsDerivation.identity hs h hn⟩ lemma verum {s : V} (hs : IsFormulaSet L s) (h : ^⊤ ∈ s) : - T.Derivable s := ⟨verumIntro s, by simp, Derivation.verumIntro hs h⟩ + Derivable L s := ⟨verumIntro s, by simp, IsDerivation.verumIntro hs h⟩ -lemma and_m {s p q : V} (h : p ^⋏ q ∈ s) (hp : T.Derivable (insert p s)) (hq : T.Derivable (insert q s)) : - T.Derivable s := by +lemma and_m {s p q : V} (h : p ^⋏ q ∈ s) (hp : Derivable L (insert p s)) (hq : Derivable L (insert q s)) : + Derivable L s := by rcases hp with ⟨dp, hdp⟩; rcases hq with ⟨dq, hdq⟩ - exact ⟨andIntro s p q dp dq, by simp, Derivation.andIntro h hdp hdq⟩ + exact ⟨andIntro s p q dp dq, by simp, IsDerivation.andIntro h hdp hdq⟩ -lemma or_m {s p q : V} (h : p ^⋎ q ∈ s) (hpq : T.Derivable (insert p (insert q s))) : - T.Derivable s := by +lemma or_m {s p q : V} (h : p ^⋎ q ∈ s) (hpq : Derivable L (insert p (insert q s))) : + Derivable L s := by rcases hpq with ⟨dpq, hdpq⟩ - exact ⟨orIntro s p q dpq, by simp, Derivation.orIntro h hdpq⟩ + exact ⟨orIntro s p q dpq, by simp, IsDerivation.orIntro h hdpq⟩ -lemma all_m {s p : V} (h : ^∀ p ∈ s) (hp : T.Derivable (insert (free L p) (setShift L s))) : - T.Derivable s := by +lemma all_m {s p : V} (h : ^∀ p ∈ s) (hp : Derivable L (insert (free L p) (setShift L s))) : + Derivable L s := by rcases hp with ⟨dp, hdp⟩ - exact ⟨allIntro s p dp, by simp, Derivation.allIntro h hdp⟩ + exact ⟨allIntro s p dp, by simp, IsDerivation.allIntro h hdp⟩ -lemma ex_m {s p t : V} (h : ^∃ p ∈ s) (ht : IsTerm L t) (hp : T.Derivable (insert (substs1 L t p) s)) : - T.Derivable s := by +lemma ex_m {s p t : V} (h : ^∃ p ∈ s) (ht : IsTerm L t) (hp : Derivable L (insert (substs1 L t p) s)) : + Derivable L s := by rcases hp with ⟨dp, hdp⟩ - exact ⟨exsIntro s p t dp, by simp, Derivation.exsIntro h ht hdp⟩ + exact ⟨exsIntro s p t dp, by simp, IsDerivation.exsIntro h ht hdp⟩ -lemma wk {s s' : V} (hs : IsFormulaSet L s) (h : s' ⊆ s) (hd : T.Derivable s') : - T.Derivable s := by +lemma wk {s s' : V} (hs : IsFormulaSet L s) (h : s' ⊆ s) (hd : Derivable L s') : + Derivable L s := by rcases hd with ⟨d, hd⟩ - exact ⟨contraction s d, by simp, Derivation.contraction hs h hd⟩ + exact ⟨contraction s d, by simp, IsDerivation.contraction hs h hd⟩ -lemma shift {s : V} (hd : T.Derivable s) : - T.Derivable (setShift L s) := by +lemma shift {s : V} (hd : Derivable L s) : + Derivable L (setShift L s) := by rcases hd with ⟨d, hd⟩ - exact ⟨shiftRule (setShift L s) d, by simp, Derivation.shiftRule hd⟩ + exact ⟨shiftRule (setShift L s) d, by simp, IsDerivation.shiftRule hd⟩ -lemma ofSetEq {s s' : V} (h : ∀ x, x ∈ s' ↔ x ∈ s) (hd : T.Derivable s') : - T.Derivable s := by +lemma ofSetEq {s s' : V} (h : ∀ x, x ∈ s' ↔ x ∈ s) (hd : Derivable L s') : + Derivable L s := by have : s' = s := mem_ext h rcases this; exact hd -lemma exchange {s p q : V} (h : T.Derivable (insert p <| insert q s)) : - T.Derivable (insert q <| insert p s) := h.ofSetEq (fun x ↦ by simp; tauto) +lemma exchange {s p q : V} (h : Derivable L (insert p <| insert q s)) : + Derivable L (insert q <| insert p s) := h.ofSetEq (fun x ↦ by simp; tauto) -lemma cut {s : V} (p) (hd₁ : T.Derivable (insert p s)) (hd₂ : T.Derivable (insert (neg L p) s)) : - T.Derivable s := by +lemma cut {s : V} (p) (hd₁ : Derivable L (insert p s)) (hd₂ : Derivable L (insert (neg L p) s)) : + Derivable L s := by rcases hd₁ with ⟨d₁, hd₁⟩; rcases hd₂ with ⟨d₂, hd₂⟩ - exact ⟨cutRule s p d₁ d₂, by simp, Derivation.cutRule hd₁ hd₂⟩ + exact ⟨cutRule s p d₁ d₂, by simp, IsDerivation.cutRule hd₁ hd₂⟩ -lemma by_axm {s : V} (hs : IsFormulaSet L s) (p) (hp : p ∈ s) (hT : p ∈ T.Δ₁Class) : - T.Derivable s := by - exact ⟨Bootstrapping.axm s p, by simp, Derivation.axm hs hp hT⟩ - -lemma of_ss (h : T.Δ₁Class (V := V) ⊆ U.Δ₁Class) {s : V} : T.Derivable s → U.Derivable s := by - rintro ⟨d, hd⟩; exact ⟨d, hd.1, hd.2.of_ss h⟩ - -lemma and {s p q : V} (hp : T.Derivable (insert p s)) (hq : T.Derivable (insert q s)) : - T.Derivable (insert (p ^⋏ q) s) := +lemma and {s p q : V} (hp : Derivable L (insert p s)) (hq : Derivable L (insert q s)) : + Derivable L (insert (p ^⋏ q) s) := and_m (p := p) (q := q) (by simp) (wk (by simp [hp.isFormulaSet.insert, hq.isFormulaSet.insert]) (insert_subset_insert_of_subset _ <| by simp) hp) (wk (by simp [hp.isFormulaSet.insert, hq.isFormulaSet.insert]) (insert_subset_insert_of_subset _ <| by simp) hq) -lemma or {s p q : V} (hpq : T.Derivable (insert p (insert q s))) : - T.Derivable (insert (p ^⋎ q) s) := +lemma or {s p q : V} (hpq : Derivable L (insert p (insert q s))) : + Derivable L (insert (p ^⋎ q) s) := or_m (p := p) (q := q) (by simp) (wk (by simp [hpq.isFormulaSet.insert, hpq.isFormulaSet.insert.2.insert]) (insert_subset_insert_of_subset _ <| insert_subset_insert_of_subset _ <| by simp) hpq) /-- Crucial inducion for formalized $\Sigma_1$-completeness. -/ lemma conj (ps : V) {s : V} (hs : IsFormulaSet L s) - (ds : ∀ i < len ps, T.Derivable (insert ps.[i] s)) : T.Derivable (insert (^⋀ ps) s) := by - have : ∀ k ≤ len ps, T.Derivable (insert (^⋀ (takeLast ps k)) s) := by + (ds : ∀ i < len ps, Derivable L (insert ps.[i] s)) : Derivable L (insert (^⋀ ps) s) := by + have : ∀ k ≤ len ps, Derivable L (insert (^⋀ (takeLast ps k)) s) := by intro k hk induction k using ISigma1.sigma1_succ_induction · definability case zero => simpa using verum (by simp [hs]) (by simp) case succ k ih => - have ih : T.Derivable (insert (^⋀ takeLast ps k) s) := ih (le_trans le_self_add hk) - have : T.Derivable (insert ps.[len ps - (k + 1)] s) := ds (len ps - (k + 1)) ((tsub_lt_iff_left hk).mpr (by simp)) + have ih : Derivable L (insert (^⋀ takeLast ps k) s) := ih (le_trans le_self_add hk) + have : Derivable L (insert ps.[len ps - (k + 1)] s) := ds (len ps - (k + 1)) ((tsub_lt_iff_left hk).mpr (by simp)) simpa [takeLast_succ_of_lt (succ_le_iff_lt.mp hk)] using this.and ih simpa using this (len ps) (by rfl) -lemma disjDistr (ps s : V) (d : T.Derivable (vecToSet ps ∪ s)) : T.Derivable (insert (^⋁ ps) s) := by +lemma disjDistr (ps s : V) (d : Derivable L (vecToSet ps ∪ s)) : Derivable L (insert (^⋁ ps) s) := by have : ∀ k ≤ len ps, ∀ s' ≤ vecToSet ps, s' ⊆ vecToSet ps → - (∀ i < len ps - k, ps.[i] ∈ s') → T.Derivable (insert (^⋁ takeLast ps k) (s' ∪ s)) := by + (∀ i < len ps - k, ps.[i] ∈ s') → Derivable L (insert (^⋁ takeLast ps k) (s' ∪ s)) := by intro k hk induction k using ISigma1.sigma1_succ_induction · apply HierarchySymbol.Definable.imp (by definability) @@ -776,7 +760,7 @@ lemma disjDistr (ps s : V) (d : T.Derivable (vecToSet ps ∪ s)) : T.Derivable ( rintro (rfl | h) · exact mem_vecToSet_iff.mpr ⟨_, by simp [tsub_lt_iff_left hk], rfl⟩ · exact ss h - have : T.Derivable (insert (^⋁ takeLast ps k) (s'' ∪ s)) := by + have : Derivable L (insert (^⋁ takeLast ps k) (s'' ∪ s)) := by refine ih (le_trans (by simp) hk) s'' (le_of_subset hs'') hs'' ?_ intro i hi have : i ≤ len ps - (k + 1) := by @@ -788,7 +772,7 @@ lemma disjDistr (ps s : V) (d : T.Derivable (vecToSet ps ∪ s)) : T.Derivable ( simpa using this (len ps) (by rfl) ∅ (by simp [emptyset_def]) (by simp) (by simp) lemma disj (ps s : V) {i} (hps : ∀ i < len ps, IsFormula L ps.[i]) - (hi : i < len ps) (d : T.Derivable (insert ps.[i] s)) : T.Derivable (insert (^⋁ ps) s) := + (hi : i < len ps) (d : Derivable L (insert ps.[i] s)) : Derivable L (insert (^⋁ ps) s) := disjDistr ps s <| wk (by suffices IsFormulaSet L (vecToSet ps) by simpa [by simpa using d.isFormulaSet] intro x hx; rcases mem_vecToSet_iff.mp hx with ⟨i, hi, rfl⟩; exact hps i hi) @@ -798,32 +782,52 @@ lemma disj (ps s : V) {i} (hps : ∀ i < len ps, IsFormula L ps.[i]) · left; exact mem_vecToSet_iff.mpr ⟨i, hi, rfl⟩ · right; exact hx) d -lemma all {p s : V} (hp : IsSemiformula L 1 p) (dp : T.Derivable (insert (free L p) (setShift L s))) : T.Derivable (insert (^∀ p) s) := +lemma all {p s : V} (hp : IsSemiformula L 1 p) (dp : Derivable L (insert (free L p) (setShift L s))) : Derivable L (insert (^∀ p) s) := all_m (p := p) (by simp) (wk (by simp [hp, by simpa using dp.isFormulaSet]) (by intro x; simp; tauto) dp) lemma exs {p t s : V} (hp : IsSemiformula L 1 p) (ht : IsTerm L t) - (dp : T.Derivable (insert (substs1 L t p) s)) : T.Derivable (insert (^∃ p) s) := + (dp : Derivable L (insert (substs1 L t p) s)) : Derivable L (insert (^∃ p) s) := ex_m (p := p) (by simp) ht <| wk (by simp [hp, by simpa using dp.isFormulaSet]) (by intro x; simp; tauto) dp end Derivable -lemma internal_provable_iff_internal_derivable {φ : V} : T.Provable φ ↔ T.Derivable (insert φ ∅ : V) := by - constructor - · rintro ⟨b, hb⟩ - exact ⟨b, by simpa using hb⟩ - · rintro ⟨b, hb⟩ - exact ⟨b, by simpa using hb⟩ +/-! ## Proof with axiom -/ + +variable (T : Theory L) [T.Δ₁] + +def IsProof (d φ : V) : Prop := ∃ s, (∀ x ∈ s, neg L x ∈ T.Δ₁Class) ∧ IsDerivationOf L d (insert φ s) + +def Provable (φ : V) : Prop := ∃ d, IsProof T d φ -alias ⟨Provable.toDerivable, Derivable.toProvable⟩ := internal_provable_iff_internal_derivable +variable {T} + +lemma provable_iff_derivable {φ : V} : Provable T φ ↔ ∃ s : V, (∀ x ∈ s, neg L x ∈ T.Δ₁Class) ∧ Derivable L (insert φ s) := by + simp [Provable, IsProof, Derivable]; grind + +alias ⟨Provable.toDerivable, Derivable.toProvable⟩ := provable_iff_derivable namespace Provable + + + + +lemma conj (ps : V) + (ds : ∀ i < len ps, Provable T ps.[i]) : Provable T (^⋀ ps) := + Derivable.toProvable <| by { + have : ∀ i ∈ under (len ps), ∃ s : V, (∀ x ∈ s, neg L x ∈ T.Δ₁Class) ∧ Derivable L (insert ps.[i] s) := by simpa [provable_iff_derivable] using ds + have := sigmaOne_skolem (by definability) this + + + + } + lemma conj (ps : V) - (ds : ∀ i < len ps, T.Provable ps.[i]) : T.Provable (^⋀ ps) := + (ds : ∀ i < len ps, Provable T ps.[i]) : Provable T (^⋀ ps) := Derivable.toProvable <| Derivable.conj _ (by simp) fun i hi ↦ (ds i hi).toDerivable lemma disj (ps : V) {i} (hps : ∀ i < len ps, IsFormula L ps.[i]) - (hi : i < len ps) (d : T.Provable ps.[i]) : T.Provable (^⋁ ps) := + (hi : i < len ps) (d : Provable T ps.[i]) : Provable T (^⋁ ps) := Derivable.toProvable <| Derivable.disj _ _ hps hi d.toDerivable end Provable From 27590f2e198d02f0c6d82ab1dddbf77a257703a5 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Mon, 22 Jun 2026 22:21:42 +0900 Subject: [PATCH 10/14] isProof --- .../Bootstrapping/Syntax/Proof/Basic.lean | 56 ++++++++++++------- 1 file changed, 37 insertions(+), 19 deletions(-) diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean index 4a7464335..4269879bc 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean @@ -268,7 +268,7 @@ instance cutRule_defined : 𝚺₀-Function₄ (cutRule : V → V → V → V end -/-! ## Internal derivation -/ +/-! ## Internal isDerivation -/ namespace IsDerivation @@ -444,10 +444,10 @@ open PeanoMinus ISigma0 ISigma1 Bootstrapping IsDerivation variable (L) -/-- Internal derivation -/ +/-- Internal isDerivation -/ def IsDerivation : V → Prop := (construction L).Fixpoint ![] -/- Internal derivation of sequent `s` -/ +/- Internal isDerivation of sequent `s` -/ def IsDerivationOf (d s : V) : Prop := fstIdx d = s ∧ IsDerivation L d /-- Internal derivability -/ @@ -461,19 +461,19 @@ def IProof (d φ : V) : Prop := IsDerivationOf L d {φ} @[deprecated IProvable] def IProvable (φ : V) : Prop := ∃ d, IProof L d φ -noncomputable def derivation : 𝚫₁.Semisentence 1 := (blueprint L).fixpointDefΔ₁ +noncomputable def isDerivation : 𝚫₁.Semisentence 1 := (blueprint L).fixpointDefΔ₁ -noncomputable def derivationOf : 𝚫₁.Semisentence 2 := .mkDelta - (.mkSigma “d s. !fstIdxDef s d ∧ !(derivation L).sigma d”) - (.mkPi “d s. !fstIdxDef s d ∧ !(derivation L).pi d”) +noncomputable def isDerivationOf : 𝚫₁.Semisentence 2 := .mkDelta + (.mkSigma “d s. !fstIdxDef s d ∧ !(isDerivation L).sigma d”) + (.mkPi “d s. !fstIdxDef s d ∧ !(isDerivation L).pi d”) noncomputable def derivable : 𝚺₁.Semisentence 1 := .mkSigma - “Γ. ∃ d, !(derivationOf L).sigma d Γ” + “Γ. ∃ d, !(isDerivationOf L).sigma d Γ” @[deprecated iproof] noncomputable def iproof : 𝚫₁.Semisentence 2 := .mkDelta - (.mkSigma “d φ. ∃ s, !insertDef s φ 0 ∧ !(derivationOf L).sigma d s”) - (.mkPi “d φ. ∀ s, !insertDef s φ 0 → !(derivationOf L).pi d s”) + (.mkSigma “d φ. ∃ s, !insertDef s φ 0 ∧ !(isDerivationOf L).sigma d s”) + (.mkPi “d φ. ∀ s, !insertDef s φ 0 → !(isDerivationOf L).pi d s”) noncomputable def iprovable : 𝚺₁.Semisentence 1 := .mkSigma “φ. ∃ d, !(iproof L).sigma d φ” @@ -491,14 +491,14 @@ variable {L} section -instance IsDerivation.defined : 𝚫₁-Predicate[V] (IsDerivation L) via derivation L := (construction L).fixpoint_definedΔ₁ +instance IsDerivation.defined : 𝚫₁-Predicate[V] (IsDerivation L) via isDerivation L := (construction L).fixpoint_definedΔ₁ instance IsDerivation.definable : 𝚫₁-Predicate[V] (IsDerivation L) := IsDerivation.defined.to_definable instance IsDerivation.definable' : Γ-[m + 1]-Predicate[V] (IsDerivation L) := IsDerivation.definable.of_deltaOne -instance IsDerivationOf.defined : 𝚫₁-Relation[V] (IsDerivationOf L) via derivationOf L := .mk - ⟨by intro v; simp [derivationOf], by intro v; simp [derivationOf, eq_comm (b := fstIdx (v 0))]; rfl⟩ +instance IsDerivationOf.defined : 𝚫₁-Relation[V] (IsDerivationOf L) via isDerivationOf L := .mk + ⟨by intro v; simp [isDerivationOf], by intro v; simp [isDerivationOf, eq_comm (b := fstIdx (v 0))]; rfl⟩ instance IsDerivationOf.definable : 𝚫₁-Relation[V] IsDerivationOf L := IsDerivationOf.defined.to_definable @@ -531,7 +531,7 @@ instance Provable.definable' : 𝚺-[0 + 1]-Predicate[V] T.Provable := Provable. end -/-! ### Induction and recursion of derivation -/ +/-! ### Induction and recursion of isDerivation -/ namespace IsDerivation @@ -795,17 +795,33 @@ end Derivable variable (T : Theory L) [T.Δ₁] -def IsProof (d φ : V) : Prop := ∃ s, (∀ x ∈ s, neg L x ∈ T.Δ₁Class) ∧ IsDerivationOf L d (insert φ s) +def IsProof (d φ : V) : Prop := (∀ x ∈ pi₁ d, x ∈ T.Δ₁Class) ∧ IsDerivationOf L (pi₂ d) (insert φ (setNeg L (pi₁ d))) def Provable (φ : V) : Prop := ∃ d, IsProof T d φ variable {T} -lemma provable_iff_derivable {φ : V} : Provable T φ ↔ ∃ s : V, (∀ x ∈ s, neg L x ∈ T.Δ₁Class) ∧ Derivable L (insert φ s) := by - simp [Provable, IsProof, Derivable]; grind +lemma provable_iff_derivable {φ : V} : Provable T φ ↔ ∃ s : V, (∀ x ∈ s, x ∈ T.Δ₁Class) ∧ Derivable L (insert φ (setNeg L s)) := by + simp [Provable, IsProof, Derivable]; + sorry + alias ⟨Provable.toDerivable, Derivable.toProvable⟩ := provable_iff_derivable +noncomputable def isProof : 𝚫₁.Semisentence 2 := .mkDelta + (.mkSigma “p φ. ∃ s d, (∀ x ∈' s, !T.Δ₁ch.sigma x) ∧ ∃ ns, !(setNegGraph L) ns s ∧ ∃ ins, !insertDef ins φ ns ∧ !(isDerivationOf L).sigma d ins”) + “⊤” + +noncomputable def isProof : 𝚺₁.Semisentence 2 := .mkSigma + “d φ. ∃ s, (∀ x ∈' s, !T.Δ₁ch.sigma x) ∧ ∃ ns, !(setNegGraph L) ns s ∧ ∃ ins, !insertDef ins φ ns ∧ !(isDerivationOf L).sigma d ins” +/--/ +instance IsProof.defined : 𝚺₁-Relation[V] (IsProof T) via isDerivation L := (construction L).fixpoint_definedΔ₁ + +instance IsDerivation.definable : 𝚫₁-Predicate[V] (IsDerivation L) := IsDerivation.defined.to_definable + +instance IsDerivation.definable' : Γ-[m + 1]-Predicate[V] (IsDerivation L) := IsDerivation.definable.of_deltaOne + +/--/ namespace Provable @@ -815,8 +831,10 @@ namespace Provable lemma conj (ps : V) (ds : ∀ i < len ps, Provable T ps.[i]) : Provable T (^⋀ ps) := Derivable.toProvable <| by { - have : ∀ i ∈ under (len ps), ∃ s : V, (∀ x ∈ s, neg L x ∈ T.Δ₁Class) ∧ Derivable L (insert ps.[i] s) := by simpa [provable_iff_derivable] using ds - have := sigmaOne_skolem (by definability) this + have : ∀ i ∈ under (len ps), ∃ s : V, (∀ x ∈ s, x ∈ T.Δ₁Class) ∧ Derivable L (insert ps.[i] (setNeg L s)) := by simpa [provable_iff_derivable] using ds + let ⟨f, hf, fdom, H⟩ := sigmaOne_skolem (by definability) this + + From 60583d660b44a5d8cf0505701e2ff42086093c02 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Tue, 23 Jun 2026 00:58:00 +0900 Subject: [PATCH 11/14] proof --- .../FirstOrder/Arithmetic/HFS/Basic.lean | 5 + .../FirstOrder/Arithmetic/IOpen/Basic.lean | 10 +- Foundation/FirstOrder/Basic/Definability.lean | 13 +++ .../Bootstrapping/Syntax/Proof/Basic.lean | 110 +++++++++++++----- 4 files changed, 106 insertions(+), 32 deletions(-) diff --git a/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean b/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean index 5bcc700b3..a3a88aed9 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean @@ -596,6 +596,11 @@ lemma mem_hfsImage_iff {s y : V} : y ∈ hfsImage f s ↔ ∃ x ∈ s, y = f x : lemma app_mem_hfsImage {p s : V} (h : p ∈ s) : f p ∈ hfsImage f s := mem_hfsImage_iff.mpr ⟨p, h, rfl⟩ +lemma hfsImage_subset_of_subset {s t : V} (h : s ⊆ t) : hfsImage f s ⊆ hfsImage f t := by + intro y hy + rcases mem_hfsImage_iff.mp hy with ⟨x, hx, rfl⟩ + exact app_mem_hfsImage (h hx) + @[simp] lemma mem_hfsImage_union {s t : V} : hfsImage f (s ∪ t) = hfsImage f s ∪ hfsImage f t := mem_ext <| by simp only [mem_hfsImage_iff, mem_cup_iff]; grind diff --git a/Foundation/FirstOrder/Arithmetic/IOpen/Basic.lean b/Foundation/FirstOrder/Arithmetic/IOpen/Basic.lean index 23c266fc8..fe38dfe74 100644 --- a/Foundation/FirstOrder/Arithmetic/IOpen/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/IOpen/Basic.lean @@ -551,7 +551,7 @@ prefix: 80 "π₁" => pi₁ prefix: 80 "π₂" => pi₂ -@[simp] lemma pair_unpair (a : V) : ⟪π₁ a, π₂ a⟫ = a := by +@[simp, grind =] lemma pair_unpair (a : V) : ⟪π₁ a, π₂ a⟫ = a := by simp only [pi₁, unpair, pi₂] split_ifs with h · simp [pair, h] @@ -563,7 +563,7 @@ prefix: 80 "π₂" => pi₂ _ = √a * √a + (a - √a * √a) := by simp [add_tsub_self_of_le this] _ = a := add_tsub_self_of_le (by simp) -@[simp] lemma unpair_pair (a b : V) : unpair ⟪a, b⟫ = (a, b) := by +@[simp, grind =] lemma unpair_pair (a b : V) : unpair ⟪a, b⟫ = (a, b) := by simp only [pair]; split_ifs with h · have : √(b * b + a) = b := sqrt_eq_of_le_of_le (by simp) (by simpa using le_trans (le_of_lt h) (by simp)) simp [unpair, this, show ¬b ≤ a from by simpa using h] @@ -571,9 +571,9 @@ prefix: 80 "π₂" => pi₂ sqrt_eq_of_le_of_le (by simp) (by simp [two_mul, show b ≤ a from by simpa using h]) simp [unpair, this, add_assoc] -@[simp] lemma pi₁_pair (a b : V) : π₁ ⟪a, b⟫ = a := by simp [pi₁] +@[simp, grind =] lemma pi₁_pair (a b : V) : π₁ ⟪a, b⟫ = a := by simp [pi₁] -@[simp] lemma pi₂_pair (a b : V) : π₂ ⟪a, b⟫ = b := by simp [pi₂] +@[simp, grind =] lemma pi₂_pair (a b : V) : π₂ ⟪a, b⟫ = b := by simp [pi₂] noncomputable def pairEquiv : V × V ≃ V := ⟨Function.uncurry pair, unpair, fun ⟨a, b⟩ => unpair_pair a b, pair_unpair⟩ @@ -670,7 +670,7 @@ lemma pair_lt_pair {a₁ a₂ b₁ b₂ : V} (ha : a₁ < a₂) (hb : b₁ < b · simp [←add_assoc, add_right_comm _ a]; simp [add_right_comm _ (b * b)] · simp [←add_assoc, add_right_comm _ b]; simp [add_right_comm _ a]; simp [add_assoc] -@[simp] lemma pair_ext_iff {a₁ a₂ b₁ b₂ : V} : ⟪a₁, b₁⟫ = ⟪a₂, b₂⟫ ↔ a₁ = a₂ ∧ b₁ = b₂ := +@[simp, grind =>] lemma pair_ext_iff {a₁ a₂ b₁ b₂ : V} : ⟪a₁, b₁⟫ = ⟪a₂, b₂⟫ ↔ a₁ = a₂ ∧ b₁ = b₂ := ⟨fun e ↦ ⟨by simpa using congr_arg (π₁ ·) e, by simpa using congr_arg (π₂ ·) e⟩, by rintro ⟨rfl, rfl⟩; simp⟩ section diff --git a/Foundation/FirstOrder/Basic/Definability.lean b/Foundation/FirstOrder/Basic/Definability.lean index b422d7b66..59778fb58 100644 --- a/Foundation/FirstOrder/Basic/Definability.lean +++ b/Foundation/FirstOrder/Basic/Definability.lean @@ -175,6 +175,19 @@ notation L "-function₄[" N "] " f => DefinableFunction₄ (M := N) L f end Language +namespace IsDefinedBy + +lemma of_vec_one {R : (Fin 1 → M) → Prop} {φ : Semisentence L 1} (h : ∀ x, Semiformula.Evalb ![x] φ ↔ R ![x]) : IsDefinedBy R φ := by + intro v; simpa [←Matrix.fun_eq_vec_one] using h (v 0) + +lemma of_vec_two {R : (Fin 2 → M) → Prop} {φ : Semisentence L 2} (h : ∀ x y, Semiformula.Evalb ![x, y] φ ↔ R ![x, y]) : IsDefinedBy R φ := by + intro v; simpa [←Matrix.fun_eq_vec_two] using h (v 0) (v 1) + +lemma of_vec_three {R : (Fin 3 → M) → Prop} {φ : Semisentence L 3} (h : ∀ x y z, Semiformula.Evalb ![x, y, z] φ ↔ R ![x, y, z]) : IsDefinedBy R φ := by + intro v; simpa [←Matrix.fun_eq_vec_three] using h (v 0) (v 1) (v 2) + +end IsDefinedBy + namespace Defined lemma to_definable {R : (Fin k → M) → Prop} {φ : Semisentence L k} (hR : Defined R φ) : L.Definable R := diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean index 4269879bc..54c3f74fc 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean @@ -131,6 +131,9 @@ lemma IsFormulaSet.setNeg {s : V} (h : IsFormulaSet L s) : IsFormulaSet L (setNe lemma neg_mem_setNeg {p s : V} (h : p ∈ s) : neg L p ∈ setNeg L s := app_mem_hfsImage h +lemma setNeg_subset_of_subset {s t : V} (h : s ⊆ t) : setNeg L s ⊆ setNeg L t := + hfsImage_subset_of_subset h + @[simp] lemma IsFormulaSet.setNeg_iff {s : V} : IsFormulaSet L (Bootstrapping.setNeg L s) ↔ IsFormulaSet L s := ⟨by intro h p hp; simpa using h (neg L p) (neg_mem_setNeg hp), IsFormulaSet.setNeg⟩ @@ -802,52 +805,105 @@ def Provable (φ : V) : Prop := ∃ d, IsProof T d φ variable {T} lemma provable_iff_derivable {φ : V} : Provable T φ ↔ ∃ s : V, (∀ x ∈ s, x ∈ T.Δ₁Class) ∧ Derivable L (insert φ (setNeg L s)) := by - simp [Provable, IsProof, Derivable]; - sorry + constructor + · rintro ⟨d, hT, hd⟩ + exact ⟨pi₁ d, hT, pi₂ d, hd⟩ + · rintro ⟨s, hT, d, hd⟩ + exact ⟨⟪s, d⟫, by simpa [IsProof] using And.intro hT hd⟩ alias ⟨Provable.toDerivable, Derivable.toProvable⟩ := provable_iff_derivable -noncomputable def isProof : 𝚫₁.Semisentence 2 := .mkDelta - (.mkSigma “p φ. ∃ s d, (∀ x ∈' s, !T.Δ₁ch.sigma x) ∧ ∃ ns, !(setNegGraph L) ns s ∧ ∃ ins, !insertDef ins φ ns ∧ !(isDerivationOf L).sigma d ins”) - “⊤” +variable (T) -noncomputable def isProof : 𝚺₁.Semisentence 2 := .mkSigma - “d φ. ∃ s, (∀ x ∈' s, !T.Δ₁ch.sigma x) ∧ ∃ ns, !(setNegGraph L) ns s ∧ ∃ ins, !insertDef ins φ ns ∧ !(isDerivationOf L).sigma d ins” -/--/ -instance IsProof.defined : 𝚺₁-Relation[V] (IsProof T) via isDerivation L := (construction L).fixpoint_definedΔ₁ +noncomputable def isProof : 𝚫₁.Semisentence 2 := .mkDelta + (.mkSigma “p φ. + ∃ s d, !pairDef p s d ∧ (∀ x ∈' s, !T.Δ₁ch.sigma x) ∧ + ∃ ns, !(setNegGraph L) ns s ∧ + ∃ ins, !insertDef ins φ ns ∧ !(isDerivationOf L).sigma d ins”) + (.mkPi “p φ. + ∀ s d, !pairDef p s d → (∀ x ∈' s, !T.Δ₁ch.pi x) ∧ + ∀ ns, !(setNegGraph L) ns s → + ∀ ins, !insertDef ins φ ns → !(isDerivationOf L).pi d ins”) + +set_option linter.flexible false in instance IsProof.defined : 𝚫₁-Relation[V] (IsProof T) via isProof T := ⟨fun x ↦ by + simp [isProof]; + constructor + · intro ⟨x, y, e, h⟩ x y e2 + simp [e] at e2 + rcases e2 with ⟨rfl, rfl⟩ + simpa + · intro h + refine ⟨pi₁ (x 0), pi₂ (x 0), by simp, ?_⟩ + grind, + .of_vec_two fun x y ↦ by + simp [isProof] + constructor + · rintro ⟨x, y, rfl, h⟩ + simpa [IsProof] + · rintro h + refine ⟨pi₁ x, pi₂ x, by simp, by simpa [IsProof]⟩⟩ -instance IsDerivation.definable : 𝚫₁-Predicate[V] (IsDerivation L) := IsDerivation.defined.to_definable +instance IsProof.definable : 𝚫₁-Relation[V] (IsProof T) := (IsProof.defined T).to_definable -instance IsDerivation.definable' : Γ-[m + 1]-Predicate[V] (IsDerivation L) := IsDerivation.definable.of_deltaOne +instance IsProof.definable' : Γ-[m + 1]-Relation[V] (IsProof T) := (IsProof.definable T).of_deltaOne -/--/ -namespace Provable +noncomputable def provable : 𝚺₁.Semisentence 1 := .mkSigma “φ. ∃ d, !(isProof T).sigma d φ” +instance Provable.defined : 𝚺₁-Predicate[V] (Provable T) via provable T := .mk fun v ↦ by simp [provable, Provable] +instance Provable.definable : 𝚺₁-Predicate[V] (Provable T) := (Provable.defined T).to_definable +instance Provable.definable' : 𝚺-[0 + 1]-Predicate[V] (Provable T) := Provable.definable T +namespace Provable -lemma conj (ps : V) - (ds : ∀ i < len ps, Provable T ps.[i]) : Provable T (^⋀ ps) := - Derivable.toProvable <| by { - have : ∀ i ∈ under (len ps), ∃ s : V, (∀ x ∈ s, x ∈ T.Δ₁Class) ∧ Derivable L (insert ps.[i] (setNeg L s)) := by simpa [provable_iff_derivable] using ds +lemma exists_common_axiom_set {ps : V} (ds : ∀ i < len ps, Provable T ps.[i]) : + ∃ s : V, (∀ x ∈ s, x ∈ T.Δ₁Class) ∧ IsFormulaSet L (setNeg L s) ∧ + ∀ i < len ps, Derivable L (insert ps.[i] (setNeg L s)) := by + have : ∀ i ∈ under (len ps), ∃ s : V, (∀ x ∈ s, x ∈ T.Δ₁Class) ∧ Derivable L (insert ps.[i] (setNeg L s)) := by + simpa [provable_iff_derivable] using ds let ⟨f, hf, fdom, H⟩ := sigmaOne_skolem (by definability) this - - - - - - } + let s := ⋃ʰᶠ range f + have hs : IsFormulaSet L (setNeg L s) := by + intro φ hφ + rcases mem_setNeg_iff.mp hφ with ⟨p, hp, rfl⟩ + have : ∃ s_i, (∃ i, ⟪i, s_i⟫ ∈ f) ∧ p ∈ s_i := by simpa [s, mem_range_iff] using hp + rcases this with ⟨s_i, ⟨i, hi⟩, hp⟩ + exact (H i s_i hi).2.isFormulaSet (neg L p) (by simp [neg_mem_setNeg hp]) + refine ⟨s, ?_, hs, ?_⟩ + · intro φ hφ + have : ∃ s_i, (∃ i, ⟪i, s_i⟫ ∈ f) ∧ φ ∈ s_i := by simpa [s, mem_range_iff] using hφ + rcases this with ⟨s_i, ⟨i, hi⟩, hφ⟩ + exact (H i s_i hi).1 φ hφ + · intro i hi + have hidom : i ∈ domain f := by simpa [fdom] using hi + rcases mem_domain_iff.mp hidom with ⟨s_i, hi⟩ + refine Derivable.wk ?_ ?_ (H i s_i hi).2 + · intro φ hφ + simp only [mem_bitInsert_iff] at hφ + rcases hφ with rfl | hφ + · exact (H i s_i hi).2.isFormulaSet ps.[i] (by simp) + · exact hs φ hφ + · intro φ + simp only [mem_bitInsert_iff] + rintro (rfl | hφ) + · simp + · right + exact setNeg_subset_of_subset (by intro p hp; exact mem_sUnion_iff.mpr ⟨s_i, mem_range_iff.mpr ⟨i, hi⟩, hp⟩) hφ lemma conj (ps : V) - (ds : ∀ i < len ps, Provable T ps.[i]) : Provable T (^⋀ ps) := - Derivable.toProvable <| Derivable.conj _ (by simp) fun i hi ↦ (ds i hi).toDerivable + (ds : ∀ i < len ps, Provable T ps.[i]) : Provable T (^⋀ ps) := by + rcases exists_common_axiom_set (T := T) (ps := ps) ds with ⟨s, hT, hs, hds⟩ + exact Derivable.toProvable ⟨s, hT, Derivable.conj ps hs hds⟩ lemma disj (ps : V) {i} (hps : ∀ i < len ps, IsFormula L ps.[i]) (hi : i < len ps) (d : Provable T ps.[i]) : Provable T (^⋁ ps) := - Derivable.toProvable <| Derivable.disj _ _ hps hi d.toDerivable + let ⟨s, hT, d⟩ := d.toDerivable + Derivable.toProvable ⟨s, hT, Derivable.disj _ _ hps hi d⟩ end Provable -end LO.FirstOrder.Theory +end FirstOrder.Arithmetic.Bootstrapping + +end LO From d5b2038677fea5679942e848977f8ce46a34689f Mon Sep 17 00:00:00 2001 From: palalansouki Date: Tue, 23 Jun 2026 02:16:52 +0900 Subject: [PATCH 12/14] bump --- Foundation/FirstOrder/Basic/Calculus2Alt.lean | 210 ++++++++++++++++++ .../Bootstrapping/Syntax/Proof/Typed.lean | 131 ++++++----- 2 files changed, 290 insertions(+), 51 deletions(-) create mode 100644 Foundation/FirstOrder/Basic/Calculus2Alt.lean diff --git a/Foundation/FirstOrder/Basic/Calculus2Alt.lean b/Foundation/FirstOrder/Basic/Calculus2Alt.lean new file mode 100644 index 000000000..0d8239c08 --- /dev/null +++ b/Foundation/FirstOrder/Basic/Calculus2Alt.lean @@ -0,0 +1,210 @@ +module +public import Foundation.FirstOrder.Basic.Calculus +@[expose] public section + +/-! # Alternative definition of proof -/ + +namespace LO.FirstOrder + +variable {L : Language} [L.DecidableEq] + +section derivation2 + +inductive Derivation2 (T : Theory L) : Finset (Proposition L) → Type _ +| closed (Γ) (φ : Proposition L) : φ ∈ Γ → ∼φ ∈ Γ → Derivation2 T Γ +| axm {Γ} (φ : Sentence L) : φ ∈ T → (φ : Proposition L) ∈ Γ → Derivation2 T Γ +| verum {Γ} : ⊤ ∈ Γ → Derivation2 T Γ +| and {Γ} {φ ψ : Proposition L} : φ ⋏ ψ ∈ Γ → Derivation2 T (insert φ Γ) → Derivation2 T (insert ψ Γ) → Derivation2 T Γ +| or {Γ} {φ ψ : Proposition L} : φ ⋎ ψ ∈ Γ → Derivation2 T (insert φ (insert ψ Γ)) → Derivation2 T Γ +| all {Γ} {φ : Semiproposition L 1} : ∀⁰ φ ∈ Γ → Derivation2 T (insert (Rewriting.free φ) (Γ.image Rewriting.shift)) → Derivation2 T Γ +| exs {Γ} {φ : Semiproposition L 1} : ∃⁰ φ ∈ Γ → (t : SyntacticTerm L) → Derivation2 T (insert (φ/[t]) Γ) → Derivation2 T Γ +| wk {Δ Γ} : Derivation2 T Δ → Δ ⊆ Γ → Derivation2 T Γ +| shift {Γ} : Derivation2 T Γ → Derivation2 T (Γ.image Rewriting.shift) +| cut {Γ φ} : Derivation2 T (insert φ Γ) → Derivation2 T (insert (∼φ) Γ) → Derivation2 T Γ + +scoped infix:45 " ⟹₂" => Derivation2 + +abbrev Derivable2 (T : Theory L) (Γ : Finset (Proposition L)) := Nonempty (T ⟹₂ Γ) + +scoped infix:45 " ⟹₂! " => Derivable2 + +abbrev Derivable2SingleConseq (T : Theory L) (φ : Proposition L) : Prop := T ⟹₂! {φ} + +scoped infix: 45 " ⊢!₂! " => Derivable2SingleConseq + +variable {T : Theory L} + +omit [L.DecidableEq] in +@[simp] lemma Sequent.embed_append (A B : List (Sentence L)) : + Sequent.embed (A ++ B) = Sequent.embed A ++ Sequent.embed B := by + simp [Sequent.embed] + +lemma shifts_toFinset_eq_image_shift (Γ : Sequent L) : + (Rewriting.shifts Γ).toFinset = Γ.toFinset.image Rewriting.shift := by ext φ; simp [Rewriting.shifts] + +set_option linter.flexible false in +def Derivation.toDerivation2 (T) {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → T ⟹₂ Γ.toFinset + | Derivation.identity R v => Derivation2.closed _ (Semiformula.rel R v) (by simp) (by simp) + | Derivation.verum => Derivation2.verum (by simp) + | Derivation.and (Γ := Γ) (φ := φ) (ψ := ψ) dp dq => + Derivation2.and (φ := φ) (ψ := ψ) (by simp) + (Derivation2.wk (Derivation.toDerivation2 T dp) (by simp)) + (Derivation2.wk (Derivation.toDerivation2 T dq) (by simp)) + | Derivation.or (Γ := Γ) (φ := φ) (ψ := ψ) dpq => + Derivation2.or (φ := φ) (ψ := ψ) (by simp) + (Derivation2.wk (Derivation.toDerivation2 T dpq) + (by simp)) + | Derivation.all (Γ := Γ) (φ := φ) dp => + Derivation2.all (φ := φ) (by simp) + (Derivation2.wk (Derivation.toDerivation2 T dp) + (by + intro x hx + simp [shifts_toFinset_eq_image_shift] at hx ⊢ + grind)) + | Derivation.exs (Γ := Γ) (φ := φ) (t := t) dp => + Derivation2.exs (φ := φ) (by simp) t + (Derivation2.wk (Derivation.toDerivation2 T dp) (by simp)) + | Derivation.contraction d h => + Derivation2.wk (Derivation.toDerivation2 T d) (List.toFinset_mono h) + | Derivation.cut (Γ := Γ) (Δ := Δ) (φ := φ) d₁ d₂ => + Derivation2.cut (φ := φ) + (Derivation2.wk (Derivation.toDerivation2 T d₁) (by intro x hx; simp at hx ⊢; grind)) + (Derivation2.wk (Derivation.toDerivation2 T d₂) (by intro x hx; simp at hx ⊢; grind)) + +namespace Derivation2 + +noncomputable def cast {Γ Δ : Finset (Proposition L)} (d : T ⟹₂ Γ) (h : Γ = Δ := by simp) : T ⟹₂ Δ := by + rcases h; exact d + +noncomputable def contra {Γ Δ : Finset (Proposition L)} (d : T ⟹₂ Δ) (h : Δ ⊆ Γ := by simp) : T ⟹₂ Γ := + d.wk h + +omit [L.DecidableEq] in +lemma mem_theory_append {A B : List (Sentence L)} (hA : ∀ ψ ∈ A, ψ ∈ T) (hB : ∀ ψ ∈ B, ψ ∈ T) : + ∀ ψ ∈ A ++ B, ψ ∈ T := by + intro ψ hψ + rcases List.mem_append.mp hψ with hψ | hψ + · exact hA ψ hψ + · exact hB ψ hψ + +@[reducible] noncomputable def cutMany : (A : List (Sentence L)) → (∀ ψ ∈ A, ψ ∈ T) → + T ⟹₂! (insert (φ : Proposition L) (∼Sequent.embed A).toFinset) → T ⟹₂! {φ} + | [], _, d => d + | ψ :: A, hA, ⟨d⟩ => + have ax : T ⟹₂ insert (ψ : Proposition L) (insert φ (∼Sequent.embed A).toFinset) := + Derivation2.axm ψ (hA ψ (by simp)) (by simp) + have dn : T ⟹₂ insert (∼(ψ : Proposition L)) (insert φ (∼Sequent.embed A).toFinset) := by + refine Derivation2.cast d ?_ + ext x; simp [List.toFinset_cons]; grind + have c : T ⟹₂ insert φ (∼Sequent.embed A).toFinset := by + refine Derivation2.cast (Derivation2.cut ax dn) ?_ + ext x; simp + cutMany A (by intro θ hθ; exact hA θ (by simp [hθ])) ⟨c⟩ + +set_option linter.flexible false in +noncomputable def toProof : {Γ : Finset (Proposition L)} → T ⟹₂ Γ → + ∃ A : List (Sentence L), (∀ ψ ∈ A, ψ ∈ T) ∧ Nonempty (⊢ᴸᴷ¹ Γ.toList ++ ∼Sequent.embed A) + | Γ, closed _ φ hp hn => + ⟨[], by simp, ⟨(Derivation.eta φ).contra (by intro x hx; simp at hx ⊢; grind)⟩⟩ + | Γ, axm φ hT hΓ => + ⟨[φ], by simp [hT], ⟨(Derivation.eta (φ : Proposition L)).contra (by intro x hx; simp at hx ⊢; grind)⟩⟩ + | Γ, verum h => + ⟨[], by simp, ⟨Derivation.verum.contra (by intro x hx; simp at hx ⊢; grind)⟩⟩ + | Γ, and (φ := φ) (ψ := ψ) h dφ dψ => by + rcases toProof dφ with ⟨A, hA, ⟨bφ⟩⟩ + rcases toProof dψ with ⟨B, hB, ⟨bψ⟩⟩ + refine ⟨A ++ B, mem_theory_append hA hB, ⟨?_⟩⟩ + have bφ' : ⊢ᴸᴷ¹ φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := + bφ.contra (by intro x hx; simp at hx ⊢; grind) + have bψ' : ⊢ᴸᴷ¹ ψ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := + bψ.contra (by intro x hx; simp at hx ⊢; grind) + exact (Derivation.and bφ' bψ').contra (by intro x hx; simp at hx ⊢; grind) + | Γ, or (φ := φ) (ψ := ψ) h d => by + rcases toProof d with ⟨A, hA, ⟨b⟩⟩ + refine ⟨A, hA, ⟨?_⟩⟩ + have b' : ⊢ᴸᴷ¹ φ :: ψ :: Γ.toList ++ ∼Sequent.embed A := + b.contra (by intro x hx; simp at hx ⊢; grind) + exact (Derivation.or b').contra (by intro x hx; simp at hx ⊢; grind) + | Γ, all (φ := φ) h d => by + rcases toProof d with ⟨A, hA, ⟨b⟩⟩ + refine ⟨A, hA, ⟨?_⟩⟩ + have b' : ⊢ᴸᴷ¹ Rewriting.free φ :: (Γ.toList ++ ∼Sequent.embed A)⁺ := + b.contra (by + intro x hx + suffices x = Rewriting.free φ ∨ (∃ a ∈ Γ, Rewriting.shift a = x) ∨ + ∃ a ∈ Sequent.embed A, Rewriting.shift a = ∼x by + simpa [Rewriting.shifts] using this + have hx' : (x = Rewriting.free φ ∨ ∃ a ∈ Γ, Rewriting.shift a = x) ∨ + ∼x ∈ Sequent.embed A := by + simpa [Rewriting.shifts] using hx + rcases hx' with (rfl | hx) | hx + · exact Or.inl rfl + · exact Or.inr <| Or.inl hx + · rw [Sequent.embed] at hx + rcases List.mem_map.mp hx with ⟨θ, hθ, hθx⟩ + exact Or.inr <| Or.inr ⟨Rewriting.emb θ, + by rw [Sequent.embed]; exact List.mem_map.mpr ⟨θ, hθ, rfl⟩, + by rw [←hθx]; simp⟩) + exact (Derivation.all b').contra (by intro x hx; simp at hx ⊢; grind) + | Γ, exs (φ := φ) h t d => by + rcases toProof d with ⟨A, hA, ⟨b⟩⟩ + refine ⟨A, hA, ⟨?_⟩⟩ + have b' : ⊢ᴸᴷ¹ φ/[t] :: Γ.toList ++ ∼Sequent.embed A := + b.contra (by intro x hx; simp at hx ⊢; grind) + exact (Derivation.exs (t := t) b').contra (by intro x hx; simp at hx ⊢; grind) + | Γ, wk d h => by + rcases toProof d with ⟨A, hA, ⟨b⟩⟩ + refine ⟨A, hA, ⟨b.contra ?_⟩⟩ + intro x hx + simp at hx ⊢ + grind + | _, shift (Γ := Γ) d => by + rcases toProof d with ⟨A, hA, ⟨b⟩⟩ + refine ⟨A, hA, ⟨?_⟩⟩ + exact b.shift.contra (by + intro x hx + suffices (∃ a ∈ Γ, Rewriting.shift a = x) ∨ ∼x ∈ Sequent.embed A by + simpa [Rewriting.shifts] using this + have hx' : (∃ a ∈ Γ, Rewriting.shift a = x) ∨ + ∃ a ∈ Sequent.embed A, Rewriting.shift a = ∼x := by + simpa [Rewriting.shifts] using hx + rcases hx' with hx | ⟨a, ha, hax⟩ + · exact Or.inl hx + · right + rw [Sequent.embed] at ha + rcases List.mem_map.mp ha with ⟨θ, hθ, rfl⟩ + rw [←hax] + rw [Sequent.embed] + exact List.mem_map.mpr ⟨θ, hθ, by simp⟩) + | Γ, cut (φ := φ) d dn => by + rcases toProof d with ⟨A, hA, ⟨b⟩⟩ + rcases toProof dn with ⟨B, hB, ⟨bn⟩⟩ + refine ⟨A ++ B, mem_theory_append hA hB, ⟨?_⟩⟩ + have b' : ⊢ᴸᴷ¹ φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := + b.contra (by intro x hx; simp at hx ⊢; grind) + have bn' : ⊢ᴸᴷ¹ ∼φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := + bn.contra (by intro x hx; simp at hx ⊢; grind) + exact (Derivation.cut + b' bn').contra (by intro x hx; simp at hx ⊢; grind) + +end Derivation2 + +set_option linter.flexible false in +lemma provable_iff_derivable2 {φ : Sentence L} : T ⊢ φ ↔ T ⊢!₂! (φ : Proposition L) := by + constructor + · rintro ⟨A, hA, d⟩ + exact Derivation2.cutMany A hA ⟨Derivation2.cast (Derivation.toDerivation2 T d) (by ext x; simp [Sequent.embed])⟩ + · rintro ⟨d⟩ + rcases d.toProof with ⟨A, hA, ⟨b⟩⟩ + exact ⟨A, hA, b.contra (by + intro x hx + simp at hx ⊢ + rcases hx with rfl | hx + · exact Or.inl rfl + · right + rw [Sequent.embed] at hx + exact List.mem_map.mp hx)⟩ + +end derivation2 + +end LO.FirstOrder diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean index 028636a64..d56f721b6 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean @@ -120,15 +120,21 @@ variable {V} omit [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] in @[simp] lemma internalize_theory (T : Theory L) [T.Δ₁] : (T.internalize V).theory = T := rfl -structure TDerivation (T : InternalTheory V L) (Γ : Sequent V L) where +structure TIsDerivation (Γ : Sequent V L) where val : V - derivationOf : T.theory.DerivationOf val Γ.val + derivationOf : IsDerivationOf L val Γ.val -attribute [simp] TDerivation.derivationOf +attribute [simp] TIsDerivation.derivationOf + +abbrev TDerivation (_T : InternalTheory V L) (Γ : Sequent V L) := TIsDerivation Γ scoped infix:45 " ⊢!ᵈᵉʳ " => TDerivation -def TProof (T : InternalTheory V L) (φ : Formula V L) := T ⊢!ᵈᵉʳ insert φ ∅ +structure TIsProof (T : InternalTheory V L) (φ : Formula V L) where + val : V + proof : IsProof T.theory val φ.val + +def TProof (T : InternalTheory V L) (φ : Formula V L) := TIsProof T φ instance : Entailment (InternalTheory V L) (Formula V L) := ⟨TProof⟩ @@ -136,39 +142,48 @@ instance : HasSubset (InternalTheory V L) := ⟨fun T U ↦ T.theory.Δ₁Class variable {T U : InternalTheory V L} -noncomputable def _root_.LO.FirstOrder.Theory.Derivable.toTDerivation (Γ : Sequent V L) (h : T.theory.Derivable Γ.val) : T ⊢!ᵈᵉʳ Γ := by - choose a ha using h; choose d hd using ha.2 - exact ⟨a, ha.1, d, hd⟩ +noncomputable def Derivable.toTDerivation (Γ : Sequent V L) (h : Derivable L Γ.val) : T ⊢!ᵈᵉʳ Γ := by + exact ⟨Classical.choose h, Classical.choose_spec h⟩ -lemma TDerivation.toDerivable {Γ : (Sequent V L)} (d : T ⊢!ᵈᵉʳ Γ) : T.theory.Derivable Γ.val := +lemma TDerivation.toDerivable {Γ : (Sequent V L)} (d : T ⊢!ᵈᵉʳ Γ) : Derivable L Γ.val := ⟨d.val, d.derivationOf⟩ +lemma TIsProof.toProvable {σ : Formula V L} (d : TIsProof T σ) : Provable T.theory σ.val := + ⟨d.val, d.proof⟩ + +noncomputable def Provable.toTIsProof {σ : Formula V L} (h : Provable T.theory σ.val) : TIsProof T σ := by + exact ⟨Classical.choose h, Classical.choose_spec h⟩ + lemma TProvable.iff_provable {σ : Formula V L} : - T ⊢ σ ↔ T.theory.Provable σ.val := by + T ⊢ σ ↔ Provable T.theory σ.val := by constructor · intro b - simpa [←singleton_eq_insert] using TDerivation.toDerivable b.get + exact b.get.toProvable · intro h - exact ⟨Theory.Derivable.toTDerivation _ <| by simpa [←singleton_eq_insert] using h⟩ + exact ⟨Provable.toTIsProof h⟩ -alias ⟨toProvable, _root_.LO.FirstOrder.Theory.Provable.toTProvable⟩ := TProvable.iff_provable +alias ⟨toProvable, Provable.toTProvable⟩ := TProvable.iff_provable -def proof_to_tDerivation {σ : Formula V L} : T ⊢! σ → T ⊢!ᵈᵉʳ insert σ ∅ := fun x ↦ x +noncomputable def proof_to_tDerivation {σ : Formula V L} (d : T ⊢!ᵈᵉʳ insert σ ∅) : T ⊢!ᵈᵉʳ insert σ ∅ := d lemma tprovable_iff_provable {T : Theory L} [T.Δ₁] {σ : Formula V L} : - T.internalize V ⊢ σ ↔ T.Provable σ.val := TProvable.iff_provable + T.internalize V ⊢ σ ↔ Provable T σ.val := TProvable.iff_provable lemma tprovable_tquote_iff_provable_quote {T : Theory L} [T.Δ₁] {φ : Proposition L} : - T.internalize V ⊢ ⌜φ⌝ ↔ T.Provable (⌜φ⌝ : V) := TProvable.iff_provable + T.internalize V ⊢ ⌜φ⌝ ↔ Provable T (⌜φ⌝ : V) := TProvable.iff_provable lemma tprovable_tquote_iff_provable_quote_sentence {T : Theory L} [T.Δ₁] {σ : Sentence L} : - T.internalize V ⊢ ⌜σ⌝ ↔ T.Provable (⌜σ⌝ : V) := TProvable.iff_provable + T.internalize V ⊢ ⌜σ⌝ ↔ Provable T (⌜σ⌝ : V) := TProvable.iff_provable -def TDerivation.toTProof {φ} (d : T ⊢!ᵈᵉʳ insert φ ∅) : T ⊢! φ := d +noncomputable def TDerivation.toTProof {φ} (d : T ⊢!ᵈᵉʳ insert φ ∅) : T ⊢! φ := + ⟨⟪∅, d.val⟫, by + constructor + · intro x hx; simpa using hx + · simpa [IsProof] using d.derivationOf⟩ def TDerivation.of_eq (d : T ⊢!ᵈᵉʳ Γ) (e : Γ = Δ) : T ⊢!ᵈᵉʳ Δ := by rcases e; exact d -def TProof.toTDerivation {φ} (d : T ⊢! φ) : T ⊢!ᵈᵉʳ insert φ ∅ := d +lemma TProof.toProvable {φ} (d : T ⊢! φ) : Provable T.theory φ.val := TIsProof.toProvable d namespace TDerivation @@ -180,83 +195,75 @@ protected noncomputable def cast {Γ Δ : Bootstrapping.Sequent V L} (e : Γ = @[simp] lemma cast_val {Γ Δ : Bootstrapping.Sequent V L} (e : Γ = Δ) (d : T ⊢!ᵈᵉʳ Γ) : (TDerivation.cast e d).val = d.val := by rcases e; simp [TDerivation.cast] -noncomputable def byAxm (φ) (h : φ ∈' T.theory) (hΓ : φ ∈ Γ) : T ⊢!ᵈᵉʳ Γ := - ⟨Bootstrapping.axm Γ.val φ.val, by simp, Theory.Derivation.axm (by simp) (by simpa) h⟩ - -@[simp] lemma byAxm_val (φ) (h : φ ∈' T.theory) (hΓ : φ ∈ Γ) : - (byAxm φ h hΓ).val = Bootstrapping.axm Γ.val φ.val := rfl - noncomputable def em (φ) (h : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : T ⊢!ᵈᵉʳ Γ := - ⟨axL Γ.val φ.val, by simp, Theory.Derivation.axL (by simp) h hn⟩ + ⟨identity Γ.val φ.val, by simp, IsDerivation.identity (by simp) h hn⟩ @[simp] lemma em_val (φ) (h : φ ∈ Γ) (hn : ∼φ ∈ Γ) : - (em φ h hn : T ⊢!ᵈᵉʳ Γ).val = Bootstrapping.axL Γ.val φ.val := rfl + (em φ h hn : T ⊢!ᵈᵉʳ Γ).val = Bootstrapping.identity Γ.val φ.val := rfl noncomputable def verum (h : ⊤ ∈ Γ := by simp) : T ⊢!ᵈᵉʳ Γ := - ⟨verumIntro Γ.val, by simp, Theory.Derivation.verumIntro (by simp) h⟩ + ⟨verumIntro Γ.val, by simp, IsDerivation.verumIntro (by simp) h⟩ @[simp] lemma verum_val (h : ⊤ ∈ Γ) : (verum h : T ⊢!ᵈᵉʳ Γ).val = Bootstrapping.verumIntro Γ.val := rfl noncomputable def and' (H : φ ⋏ ψ ∈ Γ) (dp : T ⊢!ᵈᵉʳ insert φ Γ) (dq : T ⊢!ᵈᵉʳ insert ψ Γ) : T ⊢!ᵈᵉʳ Γ := ⟨andIntro Γ.val φ.val ψ.val dp.val dq.val, by simp, - Theory.Derivation.andIntro (by simpa) (by simpa using dp.derivationOf) (by simpa using dq.derivationOf)⟩ + IsDerivation.andIntro (by simpa) (by simpa using dp.derivationOf) (by simpa using dq.derivationOf)⟩ @[simp] lemma and'_val (H : φ ⋏ ψ ∈ Γ) (dp : T ⊢!ᵈᵉʳ insert φ Γ) (dq : T ⊢!ᵈᵉʳ insert ψ Γ) : (and' H dp dq : T ⊢!ᵈᵉʳ Γ).val = andIntro Γ.val φ.val ψ.val dp.val dq.val := rfl noncomputable def or' (H : φ ⋎ ψ ∈ Γ) (dpq : T ⊢!ᵈᵉʳ insert φ (insert ψ Γ)) : T ⊢!ᵈᵉʳ Γ := - ⟨orIntro Γ.val φ.val ψ.val dpq.val, by simp, Theory.Derivation.orIntro (by simpa) (by simpa using dpq.derivationOf)⟩ + ⟨orIntro Γ.val φ.val ψ.val dpq.val, by simp, IsDerivation.orIntro (by simpa) (by simpa using dpq.derivationOf)⟩ @[simp] lemma or'_val (H : φ ⋎ ψ ∈ Γ) (dpq : T ⊢!ᵈᵉʳ insert φ (insert ψ Γ)) : (or' H dpq : T ⊢!ᵈᵉʳ Γ).val = orIntro Γ.val φ.val ψ.val dpq.val := rfl noncomputable def all' {φ : Semiformula V L 1} (H : ∀⁰ φ ∈ Γ) (dp : T ⊢!ᵈᵉʳ insert φ.free Γ.shift) : T ⊢!ᵈᵉʳ Γ := - ⟨allIntro Γ.val φ.val dp.val, by simp, Theory.Derivation.allIntro (by simpa) (by simpa using dp.derivationOf)⟩ + ⟨allIntro Γ.val φ.val dp.val, by simp, IsDerivation.allIntro (by simpa) (by simpa using dp.derivationOf)⟩ @[simp] lemma all'_val {φ : Semiformula V L 1} (H : ∀⁰ φ ∈ Γ) (dp : T ⊢!ᵈᵉʳ insert φ.free Γ.shift) : (all' H dp : T ⊢!ᵈᵉʳ Γ).val = allIntro Γ.val φ.val dp.val := rfl noncomputable def exs' {φ : Semiformula V L 1} (H : ∃⁰ φ ∈ Γ) (t : Term V L) (dp : T ⊢!ᵈᵉʳ insert (φ.subst ![t]) Γ) : T ⊢!ᵈᵉʳ Γ := - ⟨exsIntro Γ.val φ.val t.val dp.val, by simp, Theory.Derivation.exsIntro (by simpa) (by simp) (by simpa using dp.derivationOf)⟩ + ⟨exsIntro Γ.val φ.val t.val dp.val, by simp, IsDerivation.exsIntro (by simpa) (by simp) (by simpa using dp.derivationOf)⟩ @[simp] lemma exs'_val {φ : Semiformula V L 1} (H : ∃⁰ φ ∈ Γ) (t : Term V L) (dp : T ⊢!ᵈᵉʳ insert (φ.subst ![t]) Γ) : (exs' H t dp : T ⊢!ᵈᵉʳ Γ).val = exsIntro Γ.val φ.val t.val dp.val := rfl noncomputable def wk (d : T ⊢!ᵈᵉʳ Δ) (h : Δ ⊆ Γ) : T ⊢!ᵈᵉʳ Γ := - ⟨wkRule Γ.val d.val, by simp, Theory.Derivation.wkRule (s' := Δ.val) (by simp) (by simpa) (by simp)⟩ + ⟨contraction Γ.val d.val, by simp, IsDerivation.contraction (by simp) h d.derivationOf⟩ -@[simp] lemma wk_val (d : T ⊢!ᵈᵉʳ Δ) (h : Δ ⊆ Γ) : (wk d h).val = wkRule Γ.val d.val := rfl +@[simp] lemma wk_val (d : T ⊢!ᵈᵉʳ Δ) (h : Δ ⊆ Γ) : (wk d h).val = contraction Γ.val d.val := rfl noncomputable def shift (d : T ⊢!ᵈᵉʳ Γ) : T ⊢!ᵈᵉʳ Γ.shift := - ⟨shiftRule Γ.shift.val d.val, by simp, Theory.Derivation.shiftRule (by simp)⟩ + ⟨shiftRule Γ.shift.val d.val, by simp [Sequent.shift], IsDerivation.shiftRule (by simpa using d.derivationOf)⟩ @[simp] lemma shift_val (d : T ⊢!ᵈᵉʳ Γ) : (shift d).val = shiftRule Γ.shift.val d.val := rfl noncomputable def cut (d₁ : T ⊢!ᵈᵉʳ insert φ Γ) (d₂ : T ⊢!ᵈᵉʳ insert (∼φ) Γ) : T ⊢!ᵈᵉʳ Γ := - ⟨cutRule Γ.val φ.val d₁.val d₂.val, by simp, Theory.Derivation.cutRule (by simpa using d₁.derivationOf) (by simpa using d₂.derivationOf)⟩ + ⟨cutRule Γ.val φ.val d₁.val d₂.val, by simp, IsDerivation.cutRule (by simpa using d₁.derivationOf) (by simpa using d₂.derivationOf)⟩ @[simp] lemma cut_val (d₁ : T ⊢!ᵈᵉʳ insert φ Γ) (d₂ : T ⊢!ᵈᵉʳ insert (∼φ) Γ) : (cut d₁ d₂).val = cutRule Γ.val φ.val d₁.val d₂.val := rfl noncomputable def and (dp : T ⊢!ᵈᵉʳ insert φ Γ) (dq : T ⊢!ᵈᵉʳ insert ψ Γ) : T ⊢!ᵈᵉʳ insert (φ ⋏ ψ) Γ := - Theory.Derivable.toTDerivation _ - <| by simpa using Theory.Derivable.and (by simpa using dp.toDerivable) (by simpa using dq.toDerivable) + Derivable.toTDerivation _ + <| by simpa using Derivable.and (by simpa using dp.toDerivable) (by simpa using dq.toDerivable) noncomputable def or (dpq : T ⊢!ᵈᵉʳ insert φ (insert ψ Γ)) : T ⊢!ᵈᵉʳ insert (φ ⋎ ψ) Γ := - Theory.Derivable.toTDerivation _ <| by simpa using Theory.Derivable.or (by simpa using dpq.toDerivable) + Derivable.toTDerivation _ <| by simpa using Derivable.or (by simpa using dpq.toDerivable) noncomputable def all {φ : Semiformula V L 1} (dp : T ⊢!ᵈᵉʳ insert φ.free Γ.shift) : T ⊢!ᵈᵉʳ insert (∀⁰ φ) Γ := - Theory.Derivable.toTDerivation _ <| by - simpa using Theory.Derivable.all (by simp) (by simpa using dp.toDerivable) + Derivable.toTDerivation _ <| by + simpa using Derivable.all (by simp) (by simpa using dp.toDerivable) noncomputable def exs {φ : Semiformula V L 1} (t : Term V L) (dp : T ⊢!ᵈᵉʳ insert (φ.subst ![t]) Γ) : T ⊢!ᵈᵉʳ insert (∃⁰ φ) Γ := - Theory.Derivable.toTDerivation _ <| by - simpa using Theory.Derivable.exs (by simp) t.isSemiterm (by simpa using dp.toDerivable) + Derivable.toTDerivation _ <| by + simpa using Derivable.exs (by simp) t.isSemiterm (by simpa using dp.toDerivable) -def ofSubset (h : T ⊆ U) (d : T ⊢!ᵈᵉʳ Γ) : U ⊢!ᵈᵉʳ Γ where - val := d.val - derivationOf := ⟨d.derivationOf.1, d.derivationOf.2.of_ss h⟩ +def ofSubset (h : T ⊆ U) (d : T ⊢!ᵈᵉʳ Γ) : U ⊢!ᵈᵉʳ Γ := d noncomputable def cut' (d₁ : T ⊢!ᵈᵉʳ insert φ Γ) (d₂ : T ⊢!ᵈᵉʳ insert (∼φ) Δ) : T ⊢!ᵈᵉʳ Γ ∪ Δ := cut (φ := φ) (d₁.wk (by intro x; simp; tauto)) (d₂.wk (by intro x; simp; tauto)) @@ -303,9 +310,20 @@ variable {T U : InternalTheory V L} {φ ψ : Formula V L} /-- Condition D2 -/ noncomputable def modusPonens (d : T ⊢! φ 🡒 ψ) (b : T ⊢! φ) : T ⊢! ψ := TDerivation.modusPonens d b -noncomputable def byAxm {φ : Formula V L} (h : φ ∈' T.theory) : T ⊢! φ := TDerivation.byAxm φ h (by simp) +noncomputable def byAxm {φ : Formula V L} (h : φ ∈' T.theory) : T ⊢! φ := by + refine Provable.toTIsProof (T := T) (Derivable.toProvable (T := T.theory) ?_) + refine ⟨{φ.val}, ?_, ?_⟩ + · intro x hx + simpa using hx ▸ h + · apply Derivable.em + · simp + · simp + · simp [neg_mem_setNeg] -noncomputable def ofSubset (h : T ⊆ U) {φ : Formula V L} : T ⊢! φ → U ⊢! φ := TDerivation.ofSubset h +noncomputable def ofSubset (h : T ⊆ U) {φ : Formula V L} (d : T ⊢! φ) : U ⊢! φ := + ⟨d.val, by + rcases d.proof with ⟨hT, hd⟩ + exact ⟨fun x hx ↦ h (hT x hx), hd⟩⟩ lemma of_subset (h : T ⊆ U) {φ : Formula V L} : T ⊢ φ → U ⊢ φ := by rintro ⟨b⟩; exact ⟨ofSubset h b⟩ @@ -314,7 +332,8 @@ noncomputable instance : Entailment.ModusPonens T := ⟨modusPonens⟩ noncomputable instance : Entailment.NegationEquiv T where negEquiv {φ} := by - suffices T ⊢! (φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ) by + apply TDerivation.toTProof + suffices T ⊢!ᵈᵉʳ insert ((φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ)) ∅ by simpa [Axioms.NegEquiv, LO.LogicalConnective.iff, Semiformula.imp_def] apply TDerivation.and · apply TDerivation.or @@ -329,12 +348,14 @@ noncomputable instance : Entailment.NegationEquiv T where noncomputable instance : Entailment.Minimal T where verum := TDerivation.toTProof <| TDerivation.verum implyK {φ ψ} := by + apply TDerivation.toTProof simp only [Axioms.ImplyK, Semiformula.imp_def] apply TDerivation.or apply TDerivation.rotate₁ apply TDerivation.or exact TDerivation.em φ implyS {φ ψ r} := by + apply TDerivation.toTProof simp only [Axioms.ImplyS, Semiformula.imp_def, DeMorgan.or, DeMorgan.neg] apply TDerivation.or apply TDerivation.rotate₁ @@ -351,16 +372,19 @@ noncomputable instance : Entailment.Minimal T where · exact TDerivation.em ψ · exact TDerivation.em r and₁ {φ ψ} := by + apply TDerivation.toTProof simp only [Axioms.AndElim₁, Semiformula.imp_def, DeMorgan.and] apply TDerivation.or apply TDerivation.or exact TDerivation.em φ and₂ {φ ψ} := by + apply TDerivation.toTProof simp only [Axioms.AndElim₂, Semiformula.imp_def, DeMorgan.and] apply TDerivation.or apply TDerivation.or exact TDerivation.em ψ and₃ {φ ψ} := by + apply TDerivation.toTProof simp only [Axioms.AndInst, Semiformula.imp_def] apply TDerivation.or apply TDerivation.rotate₁ @@ -370,20 +394,23 @@ noncomputable instance : Entailment.Minimal T where · exact TDerivation.em φ · exact TDerivation.em ψ or₁ {φ ψ} := by + apply TDerivation.toTProof simp only [Axioms.OrInst₁, Semiformula.imp_def] apply TDerivation.or apply TDerivation.rotate₁ apply TDerivation.or exact TDerivation.em φ or₂ {φ ψ} := by - suffices T ⊢! ∼ψ ⋎ φ ⋎ ψ by + apply TDerivation.toTProof + suffices T ⊢!ᵈᵉʳ insert (∼ψ ⋎ φ ⋎ ψ) ∅ by simpa [Axioms.OrInst₂, Semiformula.imp_def] apply TDerivation.or apply TDerivation.rotate₁ apply TDerivation.or exact TDerivation.em ψ or₃ {φ ψ r} := by - suffices T ⊢! φ ⋏ ∼r ⋎ ψ ⋏ ∼r ⋎ ∼φ ⋏ ∼ψ ⋎ r by + apply TDerivation.toTProof + suffices T ⊢!ᵈᵉʳ insert (φ ⋏ ∼r ⋎ ψ ⋏ ∼r ⋎ ∼φ ⋏ ∼ψ ⋎ r) ∅ by simpa [Axioms.OrElim, Semiformula.imp_def] apply TDerivation.or apply TDerivation.rotate₁ @@ -401,7 +428,9 @@ noncomputable instance : Entailment.Minimal T where · exact TDerivation.em r noncomputable instance : Entailment.Cl T where - dne {φ} := by simpa [Axioms.DNE, Semiformula.imp_def] using TDerivation.or (TDerivation.em φ) + dne {φ} := by + apply TDerivation.toTProof + simpa [Axioms.DNE, Semiformula.imp_def] using TDerivation.or (TDerivation.em φ) noncomputable def exsIntro (φ : Semiformula V L 1) (t : Term V L) (b : T ⊢! φ.subst ![t]) : T ⊢! (∃⁰ φ) := TDerivation.exs t b From 53ccbe4919db096f4bdc64cf4a31993a9a266c72 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 25 Jun 2026 01:45:49 +0900 Subject: [PATCH 13/14] refactor --- Foundation/FirstOrder/Basic/Calculus.lean | 4 + Foundation/FirstOrder/Basic/Calculus2Alt.lean | 117 +++++------------- 2 files changed, 38 insertions(+), 83 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index c1c2962f0..6b3a94406 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -39,6 +39,10 @@ def embed (Γ : List (Sentence L)) : Sequent L := List.map Rewriting.emb Γ @[simp] lemma embed_cons {φ : Sentence L} {Γ : List (Sentence L)} : embed (φ :: Γ) = (↑φ :: embed Γ) := rfl +@[simp] lemma embed_append (Γ Δ : List (Sentence L)) : + embed (Γ ++ Δ) = embed Γ ++ embed Δ := by + simp [embed] + @[simp] lemma embed_shift (Γ : List (Sentence L)) : (embed Γ)⁺ = embed Γ := by simp [embed, Rewriting.shifts] diff --git a/Foundation/FirstOrder/Basic/Calculus2Alt.lean b/Foundation/FirstOrder/Basic/Calculus2Alt.lean index 0d8239c08..1443f0e7b 100644 --- a/Foundation/FirstOrder/Basic/Calculus2Alt.lean +++ b/Foundation/FirstOrder/Basic/Calculus2Alt.lean @@ -34,15 +34,9 @@ scoped infix: 45 " ⊢!₂! " => Derivable2SingleConseq variable {T : Theory L} -omit [L.DecidableEq] in -@[simp] lemma Sequent.embed_append (A B : List (Sentence L)) : - Sequent.embed (A ++ B) = Sequent.embed A ++ Sequent.embed B := by - simp [Sequent.embed] - lemma shifts_toFinset_eq_image_shift (Γ : Sequent L) : (Rewriting.shifts Γ).toFinset = Γ.toFinset.image Rewriting.shift := by ext φ; simp [Rewriting.shifts] -set_option linter.flexible false in def Derivation.toDerivation2 (T) {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → T ⟹₂ Γ.toFinset | Derivation.identity R v => Derivation2.closed _ (Semiformula.rel R v) (by simp) (by simp) | Derivation.verum => Derivation2.verum (by simp) @@ -57,10 +51,7 @@ def Derivation.toDerivation2 (T) {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → T ⟹₂ | Derivation.all (Γ := Γ) (φ := φ) dp => Derivation2.all (φ := φ) (by simp) (Derivation2.wk (Derivation.toDerivation2 T dp) - (by - intro x hx - simp [shifts_toFinset_eq_image_shift] at hx ⊢ - grind)) + (by simp [shifts_toFinset_eq_image_shift])) | Derivation.exs (Γ := Γ) (φ := φ) (t := t) dp => Derivation2.exs (φ := φ) (by simp) t (Derivation2.wk (Derivation.toDerivation2 T dp) (by simp)) @@ -68,24 +59,25 @@ def Derivation.toDerivation2 (T) {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → T ⟹₂ Derivation2.wk (Derivation.toDerivation2 T d) (List.toFinset_mono h) | Derivation.cut (Γ := Γ) (Δ := Δ) (φ := φ) d₁ d₂ => Derivation2.cut (φ := φ) - (Derivation2.wk (Derivation.toDerivation2 T d₁) (by intro x hx; simp at hx ⊢; grind)) - (Derivation2.wk (Derivation.toDerivation2 T d₂) (by intro x hx; simp at hx ⊢; grind)) + (Derivation2.wk (Derivation.toDerivation2 T d₁) (List.subset_def.mpr <| by simp_all)) + (Derivation2.wk (Derivation.toDerivation2 T d₂) (List.subset_def.mpr <| by simp_all)) namespace Derivation2 noncomputable def cast {Γ Δ : Finset (Proposition L)} (d : T ⟹₂ Γ) (h : Γ = Δ := by simp) : T ⟹₂ Δ := by rcases h; exact d -noncomputable def contra {Γ Δ : Finset (Proposition L)} (d : T ⟹₂ Δ) (h : Δ ⊆ Γ := by simp) : T ⟹₂ Γ := - d.wk h +omit [L.DecidableEq] in +private lemma exists_shift_mem_embed_of_mem {A : List (Sentence L)} {φ : Proposition L} + (h : φ ∈ Sequent.embed A) : ∃ ψ ∈ Sequent.embed A, Rewriting.shift ψ = φ := by + simp [Sequent.embed] at h ⊢ + grind omit [L.DecidableEq] in -lemma mem_theory_append {A B : List (Sentence L)} (hA : ∀ ψ ∈ A, ψ ∈ T) (hB : ∀ ψ ∈ B, ψ ∈ T) : - ∀ ψ ∈ A ++ B, ψ ∈ T := by - intro ψ hψ - rcases List.mem_append.mp hψ with hψ | hψ - · exact hA ψ hψ - · exact hB ψ hψ +private lemma mem_embed_of_exists_shift_mem {A : List (Sentence L)} {φ : Proposition L} + (h : ∃ ψ ∈ Sequent.embed A, Rewriting.shift ψ = φ) : φ ∈ Sequent.embed A := by + simp [Sequent.embed] at h ⊢ + grind @[reducible] noncomputable def cutMany : (A : List (Sentence L)) → (∀ ψ ∈ A, ψ ∈ T) → T ⟹₂! (insert (φ : Proposition L) (∼Sequent.embed A).toFinset) → T ⟹₂! {φ} @@ -99,111 +91,70 @@ lemma mem_theory_append {A B : List (Sentence L)} (hA : ∀ ψ ∈ A, ψ ∈ T) have c : T ⟹₂ insert φ (∼Sequent.embed A).toFinset := by refine Derivation2.cast (Derivation2.cut ax dn) ?_ ext x; simp - cutMany A (by intro θ hθ; exact hA θ (by simp [hθ])) ⟨c⟩ + cutMany A (by simp_all) ⟨c⟩ -set_option linter.flexible false in noncomputable def toProof : {Γ : Finset (Proposition L)} → T ⟹₂ Γ → ∃ A : List (Sentence L), (∀ ψ ∈ A, ψ ∈ T) ∧ Nonempty (⊢ᴸᴷ¹ Γ.toList ++ ∼Sequent.embed A) | Γ, closed _ φ hp hn => - ⟨[], by simp, ⟨(Derivation.eta φ).contra (by intro x hx; simp at hx ⊢; grind)⟩⟩ + ⟨[], by simp, ⟨(Derivation.eta φ).contra <| List.subset_def.mpr (by simp_all)⟩⟩ | Γ, axm φ hT hΓ => - ⟨[φ], by simp [hT], ⟨(Derivation.eta (φ : Proposition L)).contra (by intro x hx; simp at hx ⊢; grind)⟩⟩ + ⟨[φ], by simp [hT], ⟨(Derivation.eta (φ : Proposition L)).contra <| List.subset_def.mpr (by simp_all)⟩⟩ | Γ, verum h => - ⟨[], by simp, ⟨Derivation.verum.contra (by intro x hx; simp at hx ⊢; grind)⟩⟩ + ⟨[], by simp, ⟨Derivation.verum.contra <| List.subset_def.mpr (by simp_all)⟩⟩ | Γ, and (φ := φ) (ψ := ψ) h dφ dψ => by rcases toProof dφ with ⟨A, hA, ⟨bφ⟩⟩ rcases toProof dψ with ⟨B, hB, ⟨bψ⟩⟩ - refine ⟨A ++ B, mem_theory_append hA hB, ⟨?_⟩⟩ + refine ⟨A ++ B, by simp; grind, ⟨?_⟩⟩ have bφ' : ⊢ᴸᴷ¹ φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := - bφ.contra (by intro x hx; simp at hx ⊢; grind) + bφ.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) have bψ' : ⊢ᴸᴷ¹ ψ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := - bψ.contra (by intro x hx; simp at hx ⊢; grind) - exact (Derivation.and bφ' bψ').contra (by intro x hx; simp at hx ⊢; grind) + bψ.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) + exact (Derivation.and bφ' bψ').contra <| List.subset_def.mpr (by simp_all) | Γ, or (φ := φ) (ψ := ψ) h d => by rcases toProof d with ⟨A, hA, ⟨b⟩⟩ refine ⟨A, hA, ⟨?_⟩⟩ have b' : ⊢ᴸᴷ¹ φ :: ψ :: Γ.toList ++ ∼Sequent.embed A := - b.contra (by intro x hx; simp at hx ⊢; grind) - exact (Derivation.or b').contra (by intro x hx; simp at hx ⊢; grind) + b.contra <| List.subset_def.mpr (by simp_all; grind) + exact (Derivation.or b').contra <| List.subset_def.mpr (by simp_all) | Γ, all (φ := φ) h d => by rcases toProof d with ⟨A, hA, ⟨b⟩⟩ refine ⟨A, hA, ⟨?_⟩⟩ have b' : ⊢ᴸᴷ¹ Rewriting.free φ :: (Γ.toList ++ ∼Sequent.embed A)⁺ := - b.contra (by - intro x hx - suffices x = Rewriting.free φ ∨ (∃ a ∈ Γ, Rewriting.shift a = x) ∨ - ∃ a ∈ Sequent.embed A, Rewriting.shift a = ∼x by - simpa [Rewriting.shifts] using this - have hx' : (x = Rewriting.free φ ∨ ∃ a ∈ Γ, Rewriting.shift a = x) ∨ - ∼x ∈ Sequent.embed A := by - simpa [Rewriting.shifts] using hx - rcases hx' with (rfl | hx) | hx - · exact Or.inl rfl - · exact Or.inr <| Or.inl hx - · rw [Sequent.embed] at hx - rcases List.mem_map.mp hx with ⟨θ, hθ, hθx⟩ - exact Or.inr <| Or.inr ⟨Rewriting.emb θ, - by rw [Sequent.embed]; exact List.mem_map.mpr ⟨θ, hθ, rfl⟩, - by rw [←hθx]; simp⟩) - exact (Derivation.all b').contra (by intro x hx; simp at hx ⊢; grind) + b.contra <| List.subset_def.mpr (by simp_all [Rewriting.shifts]; grind [exists_shift_mem_embed_of_mem]) + exact (Derivation.all b').contra <| List.subset_def.mpr (by simp_all) | Γ, exs (φ := φ) h t d => by rcases toProof d with ⟨A, hA, ⟨b⟩⟩ refine ⟨A, hA, ⟨?_⟩⟩ have b' : ⊢ᴸᴷ¹ φ/[t] :: Γ.toList ++ ∼Sequent.embed A := - b.contra (by intro x hx; simp at hx ⊢; grind) - exact (Derivation.exs (t := t) b').contra (by intro x hx; simp at hx ⊢; grind) + b.contra <| List.subset_def.mpr (by simp_all; grind) + exact (Derivation.exs (t := t) b').contra <| List.subset_def.mpr (by simp_all) | Γ, wk d h => by rcases toProof d with ⟨A, hA, ⟨b⟩⟩ - refine ⟨A, hA, ⟨b.contra ?_⟩⟩ - intro x hx - simp at hx ⊢ - grind + refine ⟨A, hA, ⟨b.contra <| List.subset_def.mpr (by simp_all; grind)⟩⟩ | _, shift (Γ := Γ) d => by rcases toProof d with ⟨A, hA, ⟨b⟩⟩ refine ⟨A, hA, ⟨?_⟩⟩ - exact b.shift.contra (by - intro x hx - suffices (∃ a ∈ Γ, Rewriting.shift a = x) ∨ ∼x ∈ Sequent.embed A by - simpa [Rewriting.shifts] using this - have hx' : (∃ a ∈ Γ, Rewriting.shift a = x) ∨ - ∃ a ∈ Sequent.embed A, Rewriting.shift a = ∼x := by - simpa [Rewriting.shifts] using hx - rcases hx' with hx | ⟨a, ha, hax⟩ - · exact Or.inl hx - · right - rw [Sequent.embed] at ha - rcases List.mem_map.mp ha with ⟨θ, hθ, rfl⟩ - rw [←hax] - rw [Sequent.embed] - exact List.mem_map.mpr ⟨θ, hθ, by simp⟩) + exact b.shift.contra <| List.subset_def.mpr (by simp_all [Rewriting.shifts]; grind [mem_embed_of_exists_shift_mem]) | Γ, cut (φ := φ) d dn => by rcases toProof d with ⟨A, hA, ⟨b⟩⟩ rcases toProof dn with ⟨B, hB, ⟨bn⟩⟩ - refine ⟨A ++ B, mem_theory_append hA hB, ⟨?_⟩⟩ + refine ⟨A ++ B, by simp; grind, ⟨?_⟩⟩ have b' : ⊢ᴸᴷ¹ φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := - b.contra (by intro x hx; simp at hx ⊢; grind) + b.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) have bn' : ⊢ᴸᴷ¹ ∼φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := - bn.contra (by intro x hx; simp at hx ⊢; grind) + bn.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) exact (Derivation.cut - b' bn').contra (by intro x hx; simp at hx ⊢; grind) + b' bn').contra <| List.subset_def.mpr (by simp_all; grind) end Derivation2 -set_option linter.flexible false in lemma provable_iff_derivable2 {φ : Sentence L} : T ⊢ φ ↔ T ⊢!₂! (φ : Proposition L) := by constructor · rintro ⟨A, hA, d⟩ - exact Derivation2.cutMany A hA ⟨Derivation2.cast (Derivation.toDerivation2 T d) (by ext x; simp [Sequent.embed])⟩ + exact Derivation2.cutMany A hA ⟨Derivation2.cast (Derivation.toDerivation2 T d) (by simp [Sequent.embed])⟩ · rintro ⟨d⟩ rcases d.toProof with ⟨A, hA, ⟨b⟩⟩ - exact ⟨A, hA, b.contra (by - intro x hx - simp at hx ⊢ - rcases hx with rfl | hx - · exact Or.inl rfl - · right - rw [Sequent.embed] at hx - exact List.mem_map.mp hx)⟩ + exact ⟨A, hA, b.contra <| List.subset_def.mpr (by simp [Sequent.embed])⟩ end derivation2 From aa6009a2c0312f7f743c4ff71a35a3050960aa47 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 25 Jun 2026 04:01:54 +0900 Subject: [PATCH 14/14] fix --- Foundation.lean | 10 +- Foundation/FirstOrder/Basic/Calculus.lean | 12 + Foundation/FirstOrder/Basic/Calculus2.lean | 268 ++++--- Foundation/FirstOrder/Basic/Calculus2Alt.lean | 161 ----- .../DerivabilityCondition/D1.lean | 10 +- .../DerivabilityCondition/D2.lean | 8 +- .../DerivabilityCondition/D3.lean | 58 +- .../EquationalTheory.lean | 29 +- .../DerivabilityCondition/PeanoMinus.lean | 58 +- .../FirstOrder/Bootstrapping/FixedPoint.lean | 30 +- .../Bootstrapping/Syntax/Proof/Basic.lean | 660 ++++++++---------- .../Bootstrapping/Syntax/Proof/Coding.lean | 73 +- .../Bootstrapping/Syntax/Proof/Typed.lean | 131 ++-- .../Incompleteness/Consistency.lean | 14 +- .../FirstOrder/Incompleteness/First.lean | 12 +- .../FirstOrder/Incompleteness/Halting.lean | 4 +- .../FirstOrder/Incompleteness/Jeroslow.lean | 10 +- .../Incompleteness/L\303\266b.lean" | 6 +- .../ProvabilityAbstraction/Basic.lean | 9 +- .../ProvabilityAbstraction/Refutability.lean | 2 +- .../Incompleteness/RestrictedProvability.lean | 12 +- .../Incompleteness/RosserProvability.lean | 26 +- .../Incompleteness/StandardProvability.lean | 20 +- .../FirstOrder/Incompleteness/Tarski.lean | 2 +- .../Incompleteness/WitnessComparison.lean | 24 +- .../FirstOrder/Incompleteness/Yablo.lean | 53 +- 26 files changed, 757 insertions(+), 945 deletions(-) delete mode 100644 Foundation/FirstOrder/Basic/Calculus2Alt.lean diff --git a/Foundation.lean b/Foundation.lean index 88e505493..66d0922e2 100644 --- a/Foundation.lean +++ b/Foundation.lean @@ -53,7 +53,6 @@ public import Foundation.FirstOrder.Basic.Semantics.Semantics public import Foundation.FirstOrder.Basic.Soundness public import Foundation.FirstOrder.Basic.Syntax.Formula public import Foundation.FirstOrder.Basic.Syntax.Rew -public import Foundation.FirstOrder.Basic.Syntax.Schema -- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D1 -- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D2 -- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D3 @@ -75,8 +74,9 @@ public import Foundation.FirstOrder.Basic.Syntax.Schema -- public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Functions -- public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Typed -- public import Foundation.FirstOrder.Bootstrapping.Syntax.Theory -public import Foundation.FirstOrder.Completeness.BooleanValuedModel public import Foundation.FirstOrder.Completeness.CanonicalModel +public import Foundation.FirstOrder.Completeness.CountableSublanguage +public import Foundation.FirstOrder.Completeness.CounterModel -- public import Foundation.FirstOrder.Hauptsatz -- public import Foundation.FirstOrder.Incompleteness.Consistency -- public import Foundation.FirstOrder.Incompleteness.Dense @@ -116,7 +116,7 @@ public import Foundation.FirstOrder.Polarity -- public import Foundation.FirstOrder.SetTheory.TransitiveModel -- public import Foundation.FirstOrder.SetTheory.Universe -- public import Foundation.FirstOrder.SetTheory.Z -public import Foundation.FirstOrder.Skolemization.Hull +-- public import Foundation.FirstOrder.Skolemization.Hull public import Foundation.FirstOrder.Ultraproduct public import Foundation.Init public import Foundation.InterpretabilityLogic.Axioms @@ -375,7 +375,7 @@ public import Foundation.Modal.VanBentham.StandardTranslation public import Foundation.Propositional.Boolean.Basic public import Foundation.Propositional.Boolean.Hilbert public import Foundation.Propositional.Boolean.NNFormula -public import Foundation.Propositional.Boolean.Tait +-- public import Foundation.Propositional.Boolean.Tait public import Foundation.Propositional.Boolean.ZeroSubst public import Foundation.Propositional.ConsistentTableau public import Foundation.Propositional.Dialectica.Basic @@ -458,7 +458,7 @@ public import Foundation.Propositional.Neighborhood.NB.Basic public import Foundation.Propositional.Neighborhood.NB.Hilbert.Basic public import Foundation.Propositional.Neighborhood.NB.Hilbert.WF public import Foundation.Propositional.Slash -public import Foundation.Propositional.Tait.Calculus +-- public import Foundation.Propositional.Tait.Calculus public import Foundation.Propositional.Translation -- public import Foundation.ProvabilityLogic.Arithmetic -- public import Foundation.ProvabilityLogic.Classification.LetterlessTrace diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index 6b3a94406..de15f1eee 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -359,6 +359,18 @@ lemma of_LK_provable {T : Theory L} {φ : Sentence L} : 𝐋𝐊¹ ⊢ (φ : Pro have : pullback 𝐋𝐊¹[L] (Rewriting.emb : Sentence L → Proposition L) ⊢ φ := h OneSidedLK.ContextualEntailment.of_principal_provable this +lemma specialize {T : Theory L} (φ : Semisentence L 1) (t : ClosedTerm L) : + T ⊢ ∀⁰ φ 🡒 Semiformula.subst φ ![t] := by + apply of_LK_provable + refine ⟨?_⟩ + let φt : Sentence L := Semiformula.subst φ ![t] + have d : ⊢ᴸᴷ¹ [∼(φt : Proposition L), φt] := (Derivation.eta (φt : Proposition L)).rotate.cast (by simp) + have d₀ : ⊢ᴸᴷ¹ [(∼(φ : Semiproposition L 1))/[Rew.emb t], (φt : Proposition L)] := by + simpa [φt, Semiformula.coe_subst_eq_subst_coe₁] using d + have d' : ⊢ᴸᴷ¹ [∃⁰ ∼(φ : Semiproposition L 1), (φt : Proposition L)] := + Derivation.exs (φ := ∼(φ : Semiproposition L 1)) (Γ := [(φt : Proposition L)]) (t := Rew.emb t) d₀ + exact d'.or.cast (by simp [Semiformula.imp_eq, φt]) + open Classical in noncomputable instance : Entailment.Deduction (Theory L) := OneSidedLK.ContextualEntailment.deduction (pullback 𝐋𝐊¹[L] (Rewriting.emb : Sentence L → Proposition L)) diff --git a/Foundation/FirstOrder/Basic/Calculus2.lean b/Foundation/FirstOrder/Basic/Calculus2.lean index c29e317ff..190a11278 100644 --- a/Foundation/FirstOrder/Basic/Calculus2.lean +++ b/Foundation/FirstOrder/Basic/Calculus2.lean @@ -6,141 +6,179 @@ public import Foundation.FirstOrder.Basic.Calculus namespace LO.FirstOrder -variable {L : Language} +variable {L : Language} [L.DecidableEq] -variable (L) - -abbrev Sequent2 := Finset (Proposition L) - -variable {L} - -namespace Sequent2 - -def emb (Γ : Finset (Sentence L)) : Sequent2 L := Γ.map ⟨Rewriting.emb, Rewriting.emb_injective⟩ - -@[simp] lemma emb_empty : emb (∅ : Finset (Sentence L)) = ∅ := by simp [emb] - -@[simp] lemma emb_insert [L.DecidableEq] (φ : Sentence L) (Γ : Finset (Sentence L)) : - emb (insert φ Γ) = insert ↑φ (emb Γ) := by simp [emb] - -@[simp] lemma emb_neg (Γ : Finset (Sentence L)) : emb (∼Γ) = ∼(emb Γ) := by - ext φ - suffices (∃ a, ∼a ∈ Γ ∧ Rewriting.emb a = φ) ↔ ∃ a ∈ Γ, Rewriting.emb a = ∼φ by - simpa [emb] - constructor - · grind - · rintro ⟨x, hx, eq⟩ - refine ⟨∼x, by simpa using hx, by simp [eq]⟩ - -def shifts (Γ : Sequent2 L) : Sequent2 L := Γ.map ⟨Rewriting.shift, LawfulSyntacticRewriting.shift_injective⟩ +section derivation2 -@[simp] lemma shifts_empty : shifts (∅ : Sequent2 L) = ∅ := by simp [shifts] +inductive Derivation2 (T : Theory L) : Finset (Proposition L) → Type _ +| closed (Γ) (φ : Proposition L) : φ ∈ Γ → ∼φ ∈ Γ → Derivation2 T Γ +| axm {Γ} (φ : Sentence L) : φ ∈ T → (φ : Proposition L) ∈ Γ → Derivation2 T Γ +| verum {Γ} : ⊤ ∈ Γ → Derivation2 T Γ +| and {Γ} {φ ψ : Proposition L} : φ ⋏ ψ ∈ Γ → Derivation2 T (insert φ Γ) → Derivation2 T (insert ψ Γ) → Derivation2 T Γ +| or {Γ} {φ ψ : Proposition L} : φ ⋎ ψ ∈ Γ → Derivation2 T (insert φ (insert ψ Γ)) → Derivation2 T Γ +| all {Γ} {φ : Semiproposition L 1} : ∀⁰ φ ∈ Γ → Derivation2 T (insert (Rewriting.free φ) (Γ.image Rewriting.shift)) → Derivation2 T Γ +| exs {Γ} {φ : Semiproposition L 1} : ∃⁰ φ ∈ Γ → (t : SyntacticTerm L) → Derivation2 T (insert (φ/[t]) Γ) → Derivation2 T Γ +| wk {Δ Γ} : Derivation2 T Δ → Δ ⊆ Γ → Derivation2 T Γ +| shift {Γ} : Derivation2 T Γ → Derivation2 T (Γ.image Rewriting.shift) +| cut {Γ φ} : Derivation2 T (insert φ Γ) → Derivation2 T (insert (∼φ) Γ) → Derivation2 T Γ -@[simp] lemma shifts_insert [L.DecidableEq] (φ : Proposition L) (Γ : Finset (Proposition L)) : - shifts (insert φ Γ) = insert (Rewriting.shift φ) (shifts Γ) := by simp [shifts] +scoped infix:45 " ⟹₂" => Derivation2 -@[simp] lemma shifts_toFinset_eq_shifts [L.DecidableEq] (Γ : Sequent L) : - (Γ⁺).toFinset = shifts Γ.toFinset := by ext φ; simp [shifts, Rewriting.shifts] +abbrev Derivable2 (T : Theory L) (Γ : Finset (Proposition L)) := Nonempty (T ⟹₂ Γ) -@[simp] lemma neg_toFinset [L.DecidableEq] (Γ : Sequent L) : - (∼Γ).toFinset = ∼Γ.toFinset := by ext φ; simp +scoped infix:45 " ⟹₂! " => Derivable2 -@[simp] lemma map_emb_toFinset_eq [L.DecidableEq] {Γ : List (Sentence L)} : - (Γ.map Rewriting.emb).toFinset = emb Γ.toFinset := by ext; simp [emb] +abbrev _root_.LO.FirstOrder.Theory.Proof2 (T : Theory L) (φ : Proposition L) := T ⟹₂ {φ} -end Sequent2 +scoped infix: 45 " ⊢!₂! " => Theory.Proof2 -variable [L.DecidableEq] +variable {T : Theory L} -section derivation2 +lemma shifts_toFinset_eq_image_shift (Γ : Sequent L) : + (Rewriting.shifts Γ).toFinset = Γ.toFinset.image Rewriting.shift := by ext φ; simp [Rewriting.shifts] -inductive Derivation2 : Finset (Proposition L) → Type _ -| identity (φ) : Derivation2 {φ, ∼φ} -| cut : Derivation2 (insert φ Γ) → Derivation2 (insert (∼φ) Δ) → Derivation2 (Γ ∪ Δ) -| contraction : Derivation2 Δ → Δ ⊆ Γ → Derivation2 Γ -| verum : Derivation2 {⊤} -| or : Derivation2 (insert φ (insert ψ Γ)) → Derivation2 (insert (φ ⋎ ψ) Γ) -| and : Derivation2 (insert φ Γ) → Derivation2 (insert ψ Γ) → Derivation2 (insert (φ ⋏ ψ) Γ) -| all : Derivation2 (insert (Rewriting.free φ) (Sequent2.shifts Γ)) → Derivation2 (insert (∀⁰ φ) Γ) -| exs : Derivation2 (insert (φ/[t]) Γ) → Derivation2 (insert (∃⁰ φ) Γ) - -structure Theory.Proof2 (T : Theory L) (σ : Sentence L) where - axioms : Finset (Sentence L) - axioms_mem : ∀ ψ ∈ axioms, ψ ∈ T - derivation : Derivation2 (Sequent2.emb (insert σ (∼axioms))) +def Derivation.toDerivation2 (T) {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → T ⟹₂ Γ.toFinset + | Derivation.identity R v => Derivation2.closed _ (Semiformula.rel R v) (by simp) (by simp) + | Derivation.verum => Derivation2.verum (by simp) + | Derivation.and (Γ := Γ) (φ := φ) (ψ := ψ) dp dq => + Derivation2.and (φ := φ) (ψ := ψ) (by simp) + (Derivation2.wk (Derivation.toDerivation2 T dp) (by simp)) + (Derivation2.wk (Derivation.toDerivation2 T dq) (by simp)) + | Derivation.or (Γ := Γ) (φ := φ) (ψ := ψ) dpq => + Derivation2.or (φ := φ) (ψ := ψ) (by simp) + (Derivation2.wk (Derivation.toDerivation2 T dpq) + (by simp)) + | Derivation.all (Γ := Γ) (φ := φ) dp => + Derivation2.all (φ := φ) (by simp) + (Derivation2.wk (Derivation.toDerivation2 T dp) + (by simp [shifts_toFinset_eq_image_shift])) + | Derivation.exs (Γ := Γ) (φ := φ) (t := t) dp => + Derivation2.exs (φ := φ) (by simp) t + (Derivation2.wk (Derivation.toDerivation2 T dp) (by simp)) + | Derivation.contraction d h => + Derivation2.wk (Derivation.toDerivation2 T d) (List.toFinset_mono h) + | Derivation.cut (Γ := Γ) (Δ := Δ) (φ := φ) d₁ d₂ => + Derivation2.cut (φ := φ) + (Derivation2.wk (Derivation.toDerivation2 T d₁) (List.subset_def.mpr <| by simp_all)) + (Derivation2.wk (Derivation.toDerivation2 T d₂) (List.subset_def.mpr <| by simp_all)) namespace Derivation2 -def cast {Γ Δ : Sequent2 L} (d : Derivation2 Γ) (h : Γ = Δ := by simp) : Derivation2 Δ := by subst h; exact d - -def contra {Γ Δ : Sequent2 L} (d : Derivation2 Δ) (h : Δ ⊆ Γ := by simp) : Derivation2 Γ := d.contraction h +structure ProofData (T : Theory L) (Γ : Finset (Proposition L)) where + axioms : List (Sentence L) + axioms_mem : ∀ ψ ∈ axioms, ψ ∈ T + derivation : ⊢ᴸᴷ¹ Γ.toList ++ ∼Sequent.embed axioms + +noncomputable def cast {Γ Δ : Finset (Proposition L)} (d : T ⟹₂ Γ) (h : Γ = Δ := by simp) : T ⟹₂ Δ := by + rcases h; exact d + +omit [L.DecidableEq] in +private lemma exists_shift_mem_embed_of_mem {A : List (Sentence L)} {φ : Proposition L} + (h : φ ∈ Sequent.embed A) : ∃ ψ ∈ Sequent.embed A, Rewriting.shift ψ = φ := by + simp [Sequent.embed] at h ⊢ + grind + +omit [L.DecidableEq] in +private lemma mem_embed_of_exists_shift_mem {A : List (Sentence L)} {φ : Proposition L} + (h : ∃ ψ ∈ Sequent.embed A, Rewriting.shift ψ = φ) : φ ∈ Sequent.embed A := by + simp [Sequent.embed] at h ⊢ + grind + +@[reducible] noncomputable def cutManyProof : (A : List (Sentence L)) → (∀ ψ ∈ A, ψ ∈ T) → + T ⟹₂ (insert (φ : Proposition L) (∼Sequent.embed A).toFinset) → T ⟹₂ {φ} + | [], _, d => d + | ψ :: A, hA, d => + have ax : T ⟹₂ insert (ψ : Proposition L) (insert φ (∼Sequent.embed A).toFinset) := + Derivation2.axm ψ (hA ψ (by simp)) (by simp) + have dn : T ⟹₂ insert (∼(ψ : Proposition L)) (insert φ (∼Sequent.embed A).toFinset) := by + refine Derivation2.cast d ?_ + ext x; simp [List.toFinset_cons]; grind + have c : T ⟹₂ insert φ (∼Sequent.embed A).toFinset := by + refine Derivation2.cast (Derivation2.cut ax dn) ?_ + ext x; simp + cutManyProof A (by simp_all) c + +@[reducible] noncomputable def cutMany (A : List (Sentence L)) (hA : ∀ ψ ∈ A, ψ ∈ T) + (d : T ⟹₂! (insert (φ : Proposition L) (∼Sequent.embed A).toFinset)) : T ⟹₂! {φ} := + d.elim fun d ↦ ⟨cutManyProof A hA d⟩ + +noncomputable def toProofData : {Γ : Finset (Proposition L)} → T ⟹₂ Γ → + ProofData T Γ + | Γ, closed _ φ hp hn => + ⟨[], by simp, (Derivation.eta φ).contra <| List.subset_def.mpr (by simp_all)⟩ + | Γ, axm φ hT hΓ => + ⟨[φ], by simp [hT], (Derivation.eta (φ : Proposition L)).contra <| List.subset_def.mpr (by simp_all)⟩ + | Γ, verum h => + ⟨[], by simp, Derivation.verum.contra <| List.subset_def.mpr (by simp_all)⟩ + | Γ, and (φ := φ) (ψ := ψ) h dφ dψ => by + rcases toProofData dφ with ⟨A, hA, bφ⟩ + rcases toProofData dψ with ⟨B, hB, bψ⟩ + refine ⟨A ++ B, by simp; grind, ?_⟩ + have bφ' : ⊢ᴸᴷ¹ φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := + bφ.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) + have bψ' : ⊢ᴸᴷ¹ ψ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := + bψ.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) + exact (Derivation.and bφ' bψ').contra <| List.subset_def.mpr (by simp_all) + | Γ, or (φ := φ) (ψ := ψ) h d => by + rcases toProofData d with ⟨A, hA, b⟩ + refine ⟨A, hA, ?_⟩ + have b' : ⊢ᴸᴷ¹ φ :: ψ :: Γ.toList ++ ∼Sequent.embed A := + b.contra <| List.subset_def.mpr (by simp_all; grind) + exact (Derivation.or b').contra <| List.subset_def.mpr (by simp_all) + | Γ, all (φ := φ) h d => by + rcases toProofData d with ⟨A, hA, b⟩ + refine ⟨A, hA, ?_⟩ + have b' : ⊢ᴸᴷ¹ Rewriting.free φ :: (Γ.toList ++ ∼Sequent.embed A)⁺ := + b.contra <| List.subset_def.mpr (by simp_all [Rewriting.shifts]; grind [exists_shift_mem_embed_of_mem]) + exact (Derivation.all b').contra <| List.subset_def.mpr (by simp_all) + | Γ, exs (φ := φ) h t d => by + rcases toProofData d with ⟨A, hA, b⟩ + refine ⟨A, hA, ?_⟩ + have b' : ⊢ᴸᴷ¹ φ/[t] :: Γ.toList ++ ∼Sequent.embed A := + b.contra <| List.subset_def.mpr (by simp_all; grind) + exact (Derivation.exs (t := t) b').contra <| List.subset_def.mpr (by simp_all) + | Γ, wk d h => by + rcases toProofData d with ⟨A, hA, b⟩ + refine ⟨A, hA, b.contra <| List.subset_def.mpr (by simp_all; grind)⟩ + | _, shift (Γ := Γ) d => by + rcases toProofData d with ⟨A, hA, b⟩ + refine ⟨A, hA, ?_⟩ + exact b.shift.contra <| List.subset_def.mpr (by simp_all [Rewriting.shifts]; grind [mem_embed_of_exists_shift_mem]) + | Γ, cut (φ := φ) d dn => by + rcases toProofData d with ⟨A, hA, b⟩ + rcases toProofData dn with ⟨B, hB, bn⟩ + refine ⟨A ++ B, by simp; grind, ?_⟩ + have b' : ⊢ᴸᴷ¹ φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := + b.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) + have bn' : ⊢ᴸᴷ¹ ∼φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := + bn.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) + exact (Derivation.cut + b' bn').contra <| List.subset_def.mpr (by simp_all; grind) + +noncomputable def toProof (d : T ⟹₂ Γ) : + ∃ A : List (Sentence L), (∀ ψ ∈ A, ψ ∈ T) ∧ Nonempty (⊢ᴸᴷ¹ Γ.toList ++ ∼Sequent.embed A) := by + rcases toProofData d with ⟨A, hA, b⟩ + exact ⟨A, hA, ⟨b⟩⟩ end Derivation2 -variable {T : Theory L} +namespace Theory -lemma shifts_toFinset_eq_image_shift (Γ : Sequent L) : - (Rewriting.shifts Γ).toFinset = Γ.toFinset.image Rewriting.shift := by ext φ; simp [Rewriting.shifts] +noncomputable def Proof.toProof2 {φ : Sentence L} (b : T ⊢! φ) : T ⊢!₂! (φ : Proposition L) := + Derivation2.cutManyProof b.axioms b.axioms_mem <| + Derivation2.cast (Derivation.toDerivation2 T b.derivation) (by ext x; simp [List.toFinset_cons, Sequent.embed]) -def Derivation.toDerivation2 {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → Derivation2 Γ.toFinset - | .identity R v => (Derivation2.identity (.rel R v)).cast - | .cut (Γ := Γ) (Δ := Δ) (φ := φ) d₁ d₂ => - let b₁ : Derivation2 (insert φ Γ.toFinset) := d₁.toDerivation2.cast - let b₂ : Derivation2 (insert (∼φ) Δ.toFinset) := d₂.toDerivation2.cast - (b₁.cut b₂).cast - | .contraction d h => d.toDerivation2.contra (List.toFinset_mono h) - | .verum => Derivation2.verum.cast - | .and (Γ := Γ) (φ := φ) (ψ := ψ) d₁ d₂ => - let b₁ : Derivation2 (insert φ Γ.toFinset) := d₁.toDerivation2.cast - let b₂ : Derivation2 (insert ψ Γ.toFinset) := d₂.toDerivation2.cast - (b₁.and b₂).cast - | .or (Γ := Γ) (φ := φ) (ψ := ψ) d => - let b : Derivation2 (insert φ (insert ψ Γ.toFinset)) := d.toDerivation2.cast - b.or.cast - | .all (Γ := Γ) (φ := φ) dp => - let b : Derivation2 (insert (Rewriting.free φ) (Sequent2.shifts Γ.toFinset)) := dp.toDerivation2.cast - b.all.cast - | .exs (Γ := Γ) (φ := φ) (t := t) d => - let b : Derivation2 (insert (φ/[t]) Γ.toFinset) := d.toDerivation2.cast - b.exs.cast - -noncomputable def Derivation2.toDerivation {Γ : Sequent2 L} : Derivation2 Γ → ⊢ᴸᴷ¹ Γ.toList -| .identity φ => (Derivation.eta φ).contra -| .cut (Γ := Γ) (Δ := Δ) (φ := φ) d₁ d₂ => - let b₁ : ⊢ᴸᴷ¹ φ :: Γ.toList := d₁.toDerivation.contra (by intro _; simp) - let b₂ : ⊢ᴸᴷ¹ (∼φ) :: Δ.toList := d₂.toDerivation.contra (by intro _; simp) - (b₁.cut b₂).contra (by intro _; simp) -| .contraction d h => d.toDerivation.contra (by intro _; simp; grind) -| .verum => Derivation.verum.contra -| .and (Γ := Γ) (φ := φ) (ψ := ψ) d₁ d₂ => - let b₁ : ⊢ᴸᴷ¹ φ :: Γ.toList := d₁.toDerivation.contra (by intro _; simp) - let b₂ : ⊢ᴸᴷ¹ ψ :: Γ.toList := d₂.toDerivation.contra (by intro _; simp) - (b₁.and b₂).contra (by intro _; simp) -| .or (Γ := Γ) (φ := φ) (ψ := ψ) d => - let b : ⊢ᴸᴷ¹ φ :: ψ :: Γ.toList := d.toDerivation.contra (by intro _; simp) - b.or.contra (by intro _; simp) -| .all (Γ := Γ) (φ := φ) d => - let b : ⊢ᴸᴷ¹ (Rewriting.free φ) :: Γ.toList⁺ := - d.toDerivation.contra (by intro _; simp [Rewriting.shifts, Sequent2.shifts]) - b.all.contra (by intro _; simp) -| .exs (Γ := Γ) (φ := φ) (t := t) d => - let b : ⊢ᴸᴷ¹ (φ/[t]) :: Γ.toList := d.toDerivation.contra (by intro _; simp) - b.exs.contra (by intro _; simp) - -lemma derivable_iff_derivable2 {Γ : Sequent L} : - Nonempty (⊢ᴸᴷ¹ Γ) ↔ Nonempty (Derivation2 Γ.toFinset) := by - constructor - · rintro ⟨d⟩; exact ⟨by simpa using d.toDerivation2⟩ - · rintro ⟨d⟩; exact ⟨d.toDerivation.contra (by intro _; simp)⟩ +noncomputable def Proof2.toProof {φ : Sentence L} (d : T ⊢!₂! (φ : Proposition L)) : T ⊢! φ := by + rcases Derivation2.toProofData d with ⟨A, hA, b⟩ + exact ⟨A, hA, b.contra <| List.subset_def.mpr (by simp [Sequent.embed])⟩ + +end Theory -lemma provable_iff_provable2 {φ} : T ⊢ φ ↔ Nonempty (T.Proof2 φ) := by +lemma provable_iff_derivable2 {φ : Sentence L} : T ⊢ φ ↔ Nonempty (T ⊢!₂! (φ : Proposition L)) := by constructor - · rintro ⟨d⟩ - exact ⟨⟨d.axioms.toFinset, by simpa using d.axioms_mem, - d.derivation.toDerivation2.contra (by simp)⟩⟩ - · rintro ⟨d⟩ - exact ⟨d.axioms.toList, by simpa using d.axioms_mem, - d.derivation.toDerivation.contra (by intro _; simp [Sequent2.emb]; grind)⟩ + · exact fun h ↦ ⟨h.get.toProof2⟩ + · rintro ⟨h⟩ + exact ⟨h.toProof⟩ end derivation2 diff --git a/Foundation/FirstOrder/Basic/Calculus2Alt.lean b/Foundation/FirstOrder/Basic/Calculus2Alt.lean deleted file mode 100644 index 1443f0e7b..000000000 --- a/Foundation/FirstOrder/Basic/Calculus2Alt.lean +++ /dev/null @@ -1,161 +0,0 @@ -module -public import Foundation.FirstOrder.Basic.Calculus -@[expose] public section - -/-! # Alternative definition of proof -/ - -namespace LO.FirstOrder - -variable {L : Language} [L.DecidableEq] - -section derivation2 - -inductive Derivation2 (T : Theory L) : Finset (Proposition L) → Type _ -| closed (Γ) (φ : Proposition L) : φ ∈ Γ → ∼φ ∈ Γ → Derivation2 T Γ -| axm {Γ} (φ : Sentence L) : φ ∈ T → (φ : Proposition L) ∈ Γ → Derivation2 T Γ -| verum {Γ} : ⊤ ∈ Γ → Derivation2 T Γ -| and {Γ} {φ ψ : Proposition L} : φ ⋏ ψ ∈ Γ → Derivation2 T (insert φ Γ) → Derivation2 T (insert ψ Γ) → Derivation2 T Γ -| or {Γ} {φ ψ : Proposition L} : φ ⋎ ψ ∈ Γ → Derivation2 T (insert φ (insert ψ Γ)) → Derivation2 T Γ -| all {Γ} {φ : Semiproposition L 1} : ∀⁰ φ ∈ Γ → Derivation2 T (insert (Rewriting.free φ) (Γ.image Rewriting.shift)) → Derivation2 T Γ -| exs {Γ} {φ : Semiproposition L 1} : ∃⁰ φ ∈ Γ → (t : SyntacticTerm L) → Derivation2 T (insert (φ/[t]) Γ) → Derivation2 T Γ -| wk {Δ Γ} : Derivation2 T Δ → Δ ⊆ Γ → Derivation2 T Γ -| shift {Γ} : Derivation2 T Γ → Derivation2 T (Γ.image Rewriting.shift) -| cut {Γ φ} : Derivation2 T (insert φ Γ) → Derivation2 T (insert (∼φ) Γ) → Derivation2 T Γ - -scoped infix:45 " ⟹₂" => Derivation2 - -abbrev Derivable2 (T : Theory L) (Γ : Finset (Proposition L)) := Nonempty (T ⟹₂ Γ) - -scoped infix:45 " ⟹₂! " => Derivable2 - -abbrev Derivable2SingleConseq (T : Theory L) (φ : Proposition L) : Prop := T ⟹₂! {φ} - -scoped infix: 45 " ⊢!₂! " => Derivable2SingleConseq - -variable {T : Theory L} - -lemma shifts_toFinset_eq_image_shift (Γ : Sequent L) : - (Rewriting.shifts Γ).toFinset = Γ.toFinset.image Rewriting.shift := by ext φ; simp [Rewriting.shifts] - -def Derivation.toDerivation2 (T) {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → T ⟹₂ Γ.toFinset - | Derivation.identity R v => Derivation2.closed _ (Semiformula.rel R v) (by simp) (by simp) - | Derivation.verum => Derivation2.verum (by simp) - | Derivation.and (Γ := Γ) (φ := φ) (ψ := ψ) dp dq => - Derivation2.and (φ := φ) (ψ := ψ) (by simp) - (Derivation2.wk (Derivation.toDerivation2 T dp) (by simp)) - (Derivation2.wk (Derivation.toDerivation2 T dq) (by simp)) - | Derivation.or (Γ := Γ) (φ := φ) (ψ := ψ) dpq => - Derivation2.or (φ := φ) (ψ := ψ) (by simp) - (Derivation2.wk (Derivation.toDerivation2 T dpq) - (by simp)) - | Derivation.all (Γ := Γ) (φ := φ) dp => - Derivation2.all (φ := φ) (by simp) - (Derivation2.wk (Derivation.toDerivation2 T dp) - (by simp [shifts_toFinset_eq_image_shift])) - | Derivation.exs (Γ := Γ) (φ := φ) (t := t) dp => - Derivation2.exs (φ := φ) (by simp) t - (Derivation2.wk (Derivation.toDerivation2 T dp) (by simp)) - | Derivation.contraction d h => - Derivation2.wk (Derivation.toDerivation2 T d) (List.toFinset_mono h) - | Derivation.cut (Γ := Γ) (Δ := Δ) (φ := φ) d₁ d₂ => - Derivation2.cut (φ := φ) - (Derivation2.wk (Derivation.toDerivation2 T d₁) (List.subset_def.mpr <| by simp_all)) - (Derivation2.wk (Derivation.toDerivation2 T d₂) (List.subset_def.mpr <| by simp_all)) - -namespace Derivation2 - -noncomputable def cast {Γ Δ : Finset (Proposition L)} (d : T ⟹₂ Γ) (h : Γ = Δ := by simp) : T ⟹₂ Δ := by - rcases h; exact d - -omit [L.DecidableEq] in -private lemma exists_shift_mem_embed_of_mem {A : List (Sentence L)} {φ : Proposition L} - (h : φ ∈ Sequent.embed A) : ∃ ψ ∈ Sequent.embed A, Rewriting.shift ψ = φ := by - simp [Sequent.embed] at h ⊢ - grind - -omit [L.DecidableEq] in -private lemma mem_embed_of_exists_shift_mem {A : List (Sentence L)} {φ : Proposition L} - (h : ∃ ψ ∈ Sequent.embed A, Rewriting.shift ψ = φ) : φ ∈ Sequent.embed A := by - simp [Sequent.embed] at h ⊢ - grind - -@[reducible] noncomputable def cutMany : (A : List (Sentence L)) → (∀ ψ ∈ A, ψ ∈ T) → - T ⟹₂! (insert (φ : Proposition L) (∼Sequent.embed A).toFinset) → T ⟹₂! {φ} - | [], _, d => d - | ψ :: A, hA, ⟨d⟩ => - have ax : T ⟹₂ insert (ψ : Proposition L) (insert φ (∼Sequent.embed A).toFinset) := - Derivation2.axm ψ (hA ψ (by simp)) (by simp) - have dn : T ⟹₂ insert (∼(ψ : Proposition L)) (insert φ (∼Sequent.embed A).toFinset) := by - refine Derivation2.cast d ?_ - ext x; simp [List.toFinset_cons]; grind - have c : T ⟹₂ insert φ (∼Sequent.embed A).toFinset := by - refine Derivation2.cast (Derivation2.cut ax dn) ?_ - ext x; simp - cutMany A (by simp_all) ⟨c⟩ - -noncomputable def toProof : {Γ : Finset (Proposition L)} → T ⟹₂ Γ → - ∃ A : List (Sentence L), (∀ ψ ∈ A, ψ ∈ T) ∧ Nonempty (⊢ᴸᴷ¹ Γ.toList ++ ∼Sequent.embed A) - | Γ, closed _ φ hp hn => - ⟨[], by simp, ⟨(Derivation.eta φ).contra <| List.subset_def.mpr (by simp_all)⟩⟩ - | Γ, axm φ hT hΓ => - ⟨[φ], by simp [hT], ⟨(Derivation.eta (φ : Proposition L)).contra <| List.subset_def.mpr (by simp_all)⟩⟩ - | Γ, verum h => - ⟨[], by simp, ⟨Derivation.verum.contra <| List.subset_def.mpr (by simp_all)⟩⟩ - | Γ, and (φ := φ) (ψ := ψ) h dφ dψ => by - rcases toProof dφ with ⟨A, hA, ⟨bφ⟩⟩ - rcases toProof dψ with ⟨B, hB, ⟨bψ⟩⟩ - refine ⟨A ++ B, by simp; grind, ⟨?_⟩⟩ - have bφ' : ⊢ᴸᴷ¹ φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := - bφ.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) - have bψ' : ⊢ᴸᴷ¹ ψ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := - bψ.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) - exact (Derivation.and bφ' bψ').contra <| List.subset_def.mpr (by simp_all) - | Γ, or (φ := φ) (ψ := ψ) h d => by - rcases toProof d with ⟨A, hA, ⟨b⟩⟩ - refine ⟨A, hA, ⟨?_⟩⟩ - have b' : ⊢ᴸᴷ¹ φ :: ψ :: Γ.toList ++ ∼Sequent.embed A := - b.contra <| List.subset_def.mpr (by simp_all; grind) - exact (Derivation.or b').contra <| List.subset_def.mpr (by simp_all) - | Γ, all (φ := φ) h d => by - rcases toProof d with ⟨A, hA, ⟨b⟩⟩ - refine ⟨A, hA, ⟨?_⟩⟩ - have b' : ⊢ᴸᴷ¹ Rewriting.free φ :: (Γ.toList ++ ∼Sequent.embed A)⁺ := - b.contra <| List.subset_def.mpr (by simp_all [Rewriting.shifts]; grind [exists_shift_mem_embed_of_mem]) - exact (Derivation.all b').contra <| List.subset_def.mpr (by simp_all) - | Γ, exs (φ := φ) h t d => by - rcases toProof d with ⟨A, hA, ⟨b⟩⟩ - refine ⟨A, hA, ⟨?_⟩⟩ - have b' : ⊢ᴸᴷ¹ φ/[t] :: Γ.toList ++ ∼Sequent.embed A := - b.contra <| List.subset_def.mpr (by simp_all; grind) - exact (Derivation.exs (t := t) b').contra <| List.subset_def.mpr (by simp_all) - | Γ, wk d h => by - rcases toProof d with ⟨A, hA, ⟨b⟩⟩ - refine ⟨A, hA, ⟨b.contra <| List.subset_def.mpr (by simp_all; grind)⟩⟩ - | _, shift (Γ := Γ) d => by - rcases toProof d with ⟨A, hA, ⟨b⟩⟩ - refine ⟨A, hA, ⟨?_⟩⟩ - exact b.shift.contra <| List.subset_def.mpr (by simp_all [Rewriting.shifts]; grind [mem_embed_of_exists_shift_mem]) - | Γ, cut (φ := φ) d dn => by - rcases toProof d with ⟨A, hA, ⟨b⟩⟩ - rcases toProof dn with ⟨B, hB, ⟨bn⟩⟩ - refine ⟨A ++ B, by simp; grind, ⟨?_⟩⟩ - have b' : ⊢ᴸᴷ¹ φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := - b.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) - have bn' : ⊢ᴸᴷ¹ ∼φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := - bn.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) - exact (Derivation.cut - b' bn').contra <| List.subset_def.mpr (by simp_all; grind) - -end Derivation2 - -lemma provable_iff_derivable2 {φ : Sentence L} : T ⊢ φ ↔ T ⊢!₂! (φ : Proposition L) := by - constructor - · rintro ⟨A, hA, d⟩ - exact Derivation2.cutMany A hA ⟨Derivation2.cast (Derivation.toDerivation2 T d) (by simp [Sequent.embed])⟩ - · rintro ⟨d⟩ - rcases d.toProof with ⟨A, hA, ⟨b⟩⟩ - exact ⟨A, hA, b.contra <| List.subset_def.mpr (by simp [Sequent.embed])⟩ - -end derivation2 - -end LO.FirstOrder diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean index 7a8652c1d..7dffa59ae 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean @@ -17,21 +17,21 @@ variable {L : Language} [L.Encodable] [L.LORDefinable] variable {T : Theory L} [T.Δ₁] -lemma derivable_quote {Γ : Finset (Proposition L)} (d : T ⟹₂ Γ) : T.Derivable (⌜Γ⌝ : V) := +lemma derivable_quote {Γ : Finset (Proposition L)} (d : T ⟹₂ Γ) : Derivable T (⌜Γ⌝ : V) := ⟨⌜d⌝, by simpa [Semiformula.quote_def] using (⌜d⌝ : Theory.internalize V T ⊢!ᵈᵉʳ ⌜Γ⌝).derivationOf⟩ /-- Hilbert–Bernays provability condition D1 -/ -theorem internalize_provability {φ} : T ⊢ φ → T.Provable (⌜φ⌝ : V) := fun h ↦ by +theorem internalize_provability {φ} : T ⊢ φ → Provable T (⌜φ⌝ : V) := fun h ↦ by simpa using derivable_quote (V := V) (provable_iff_derivable2.mp h).some theorem internal_provable_of_outer_provable {φ} : T ⊢ φ → T.internalize V ⊢ ⌜φ⌝ := fun h ↦ by simpa [TProvable.iff_provable] using internalize_provability (V := V) h -@[simp] lemma _root_.LO.FirstOrder.Theory.Provable.complete {φ : Sentence L} : +@[simp] lemma Provable.complete {φ : Sentence L} : T.internalize ℕ ⊢ ⌜φ⌝ ↔ T ⊢ φ := - ⟨by simpa [TProvable.iff_provable] using Theory.Provable.sound, internal_provable_of_outer_provable⟩ + ⟨by simpa [TProvable.iff_provable] using Provable.sound, internal_provable_of_outer_provable⟩ @[simp] lemma provable_iff_provable {T : Theory L} [T.Δ₁] {φ : Sentence L} : - T.Provable (⌜φ⌝ : ℕ) ↔ T ⊢ φ := by simpa [TProvable.iff_provable] using Theory.Provable.complete + Provable T (⌜φ⌝ : ℕ) ↔ T ⊢ φ := by simpa [TProvable.iff_provable] using Provable.complete end LO.FirstOrder.Arithmetic.Bootstrapping diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean index 5049d95c4..65ade2ae9 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean @@ -18,15 +18,15 @@ variable {L : Language} [L.Encodable] [L.LORDefinable] variable (T : Theory L) [T.Δ₁] /-- Hilbert–Bernays provability condition D2 -/ -theorem modus_ponens {φ ψ : Proposition L} (hφψ : T.Provable (⌜φ 🡒 ψ⌝ : V)) (hφ : T.Provable (⌜φ⌝ : V)) : - T.Provable (⌜ψ⌝ : V) := by +theorem modus_ponens {φ ψ : Proposition L} (hφψ : Provable T (⌜φ 🡒 ψ⌝ : V)) (hφ : Provable T (⌜φ⌝ : V)) : + Provable T (⌜ψ⌝ : V) := by apply (tprovable_tquote_iff_provable_quote (L := L)).mp have hφψ : Theory.internalize V T ⊢ ⌜φ⌝ 🡒 ⌜ψ⌝ := by simpa using (tprovable_tquote_iff_provable_quote (L := L)).mpr hφψ have hφ : Theory.internalize V T ⊢ ⌜φ⌝ := (tprovable_tquote_iff_provable_quote (L := L)).mpr hφ exact hφψ ⨀ hφ -theorem modus_ponens_sentence {σ τ : Sentence L} (hστ : T.Provable (⌜σ 🡒 τ⌝ : V)) (hσ : T.Provable (⌜σ⌝ : V)) : - T.Provable (⌜τ⌝ : V) := by +theorem modus_ponens_sentence {σ τ : Sentence L} (hστ : Provable T (⌜σ 🡒 τ⌝ : V)) (hσ : Provable T (⌜σ⌝ : V)) : + Provable T (⌜τ⌝ : V) := by apply (tprovable_tquote_iff_provable_quote (L := L)).mp have hστ : Theory.internalize V T ⊢ ⌜σ⌝ 🡒 ⌜τ⌝ := by simpa using (tprovable_tquote_iff_provable_quote (L := L)).mpr hστ have hσ : Theory.internalize V T ⊢ ⌜σ⌝ := (tprovable_tquote_iff_provable_quote (L := L)).mpr hσ diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D3.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D3.lean index 237c9731c..32b915c37 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D3.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D3.lean @@ -39,7 +39,7 @@ noncomputable abbrev toNumVec (w : Fin n → V) : SemitermVec V ℒₒᵣ n k := variable (T) theorem term_complete {n : ℕ} (t : FirstOrder.ClosedSemiterm ℒₒᵣ n) (w : Fin n → V) : - T.internalize V ⊢ (toNumVec w ⤕ ⌜t⌝) ≐ 𝕹 (t.valbm V w) := + T.internalize V ⊢ (toNumVec w ⤕ ⌜t⌝) ≐ 𝕹 (t.valb w) := match t with | #z => by simp | &x => Empty.elim x @@ -47,21 +47,21 @@ theorem term_complete {n : ℕ} (t : FirstOrder.ClosedSemiterm ℒₒᵣ n) (w : | .func Language.One.one v => by simp | .func Language.Add.add v => by suffices - T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) + (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹 ((v 0).valbm V w + (v 1).valbm V w) by + T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) + (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹 ((v 0).valb w + (v 1).valb w) by simpa [Rew.func, Semiterm.val_func] - have ih : T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) + (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹((v 0).valbm V w) + 𝕹((v 1).valbm V w) := + have ih : T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) + (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹((v 0).valb w) + 𝕹((v 1).valb w) := subst_add_eq_add T _ _ _ _ ⨀ term_complete (v 0) w ⨀ term_complete (v 1) w - have : T.internalize V ⊢ 𝕹((v 0).valbm V w) + 𝕹((v 1).valbm V w) ≐ 𝕹((v 0).valbm V w + (v 1).valbm V w) := numeral_add T _ _ + have : T.internalize V ⊢ 𝕹((v 0).valb w) + 𝕹((v 1).valb w) ≐ 𝕹((v 0).valb w + (v 1).valb w) := numeral_add T _ _ exact eq_trans ih this | .func Language.Mul.mul v => by suffices - T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) * (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹((v 0).valbm V w * (v 1).valbm V w) by + T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) * (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹((v 0).valb w * (v 1).valb w) by simpa [Rew.func, Semiterm.val_func] have ih : - T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) * (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹((v 0).valbm V w) * 𝕹((v 1).valbm V w) := + T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) * (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹((v 0).valb w) * 𝕹((v 1).valb w) := subst_mul_eq_mul T _ _ _ _ ⨀ term_complete (v 0) w ⨀ term_complete (v 1) w have : - T.internalize V ⊢ 𝕹((v 0).valbm V w) * 𝕹((v 1).valbm V w) ≐ 𝕹((v 0).valbm V w * (v 1).valbm V w) := numeral_mul T _ _ + T.internalize V ⊢ 𝕹((v 0).valb w) * 𝕹((v 1).valb w) ≐ 𝕹((v 0).valb w * (v 1).valb w) := numeral_mul T _ _ exact eq_trans ih this open FirstOrder.Arithmetic @@ -76,37 +76,37 @@ theorem bold_sigma_one_complete {n} {φ : Semisentence ℒₒᵣ n} (hp : Hierar intro n t₁ t₂ w h suffices T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ (toNumVec w ⤕ ⌜t₂⌝) by simpa [Sentence.typed_quote_def] - have : t₁.valbm V w = t₂.valbm V w := by simpa using h - have h₀ : T.internalize V ⊢ 𝕹(t₁.valbm V w) ≐ 𝕹(t₂.valbm V w) := by simp [this] - have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valbm V w) := term_complete T t₁ w - have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valbm V w) := term_complete T t₂ w + have : t₁.valb w = t₂.valb w := by simpa using h + have h₀ : T.internalize V ⊢ 𝕹(t₁.valb w) ≐ 𝕹(t₂.valb w) := by simp [this] + have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valb w) := term_complete T t₁ w + have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valb w) := term_complete T t₂ w exact eq_trans (eq_trans h₁ h₀) (eq_comm h₂) case hNEQ => intro n t₁ t₂ w h suffices T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≉ (toNumVec w ⤕ ⌜t₂⌝) by simpa [Sentence.typed_quote_def] - have : t₁.valbm V w ≠ t₂.valbm V w := by simpa using h - have h₀ : T.internalize V ⊢ 𝕹(t₁.valbm V w) ≉ 𝕹(t₂.valbm V w) := by simpa using numeral_ne T this - have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valbm V w) := term_complete T t₁ w - have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valbm V w) := term_complete T t₂ w + have : t₁.valb w ≠ t₂.valb w := by simpa using h + have h₀ : T.internalize V ⊢ 𝕹(t₁.valb w) ≉ 𝕹(t₂.valb w) := by simpa using numeral_ne T this + have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valb w) := term_complete T t₁ w + have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valb w) := term_complete T t₂ w exact subst_ne T _ _ _ _ ⨀ eq_comm h₁ ⨀ eq_comm h₂ ⨀ h₀ case hLT => intro n t₁ t₂ w h suffices T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) <' (toNumVec w ⤕ ⌜t₂⌝) by simpa [Sentence.typed_quote_def] - have : t₁.valbm V w < t₂.valbm V w := by simpa using h - have h₀ : T.internalize V ⊢ 𝕹(t₁.valbm V w) <' 𝕹(t₂.valbm V w) := by simpa using numeral_lt T this - have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valbm V w) := term_complete T t₁ w - have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valbm V w) := term_complete T t₂ w + have : t₁.valb w < t₂.valb w := by simpa using h + have h₀ : T.internalize V ⊢ 𝕹(t₁.valb w) <' 𝕹(t₂.valb w) := by simpa using numeral_lt T this + have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valb w) := term_complete T t₁ w + have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valb w) := term_complete T t₂ w exact subst_lt T _ _ _ _ ⨀ eq_comm h₁ ⨀ eq_comm h₂ ⨀ h₀ case hNLT => intro n t₁ t₂ w h suffices T.internalize V ⊢ ((toNumVec w ⤕ ⌜t₁⌝) ≮' (toNumVec w ⤕ ⌜t₂⌝)) by simpa [Sentence.typed_quote_def] - have : t₁.valbm V w ≥ t₂.valbm V w := by simpa using h - have h₀ : T.internalize V ⊢ 𝕹(t₁.valbm V w) ≮' 𝕹(t₂.valbm V w) := by simpa using numeral_nlt T this - have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valbm V w) := term_complete T t₁ w - have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valbm V w) := term_complete T t₂ w + have : t₁.valb w ≥ t₂.valb w := by simpa using h + have h₀ : T.internalize V ⊢ 𝕹(t₁.valb w) ≮' 𝕹(t₂.valb w) := by simpa using numeral_nlt T this + have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valb w) := term_complete T t₁ w + have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valb w) := term_complete T t₂ w exact subst_nlt T _ _ _ _ ⨀ eq_comm h₁ ⨀ eq_comm h₂ ⨀ h₀ case hAnd => intro n φ ψ _ _ ihφ ihψ w h @@ -121,11 +121,11 @@ theorem bold_sigma_one_complete {n} {φ : Semisentence ℒₒᵣ n} (hp : Hierar · apply A!_intro_right (ihψ h) case hBall => intro n t φ _ ih w h - have h : ∀ i < t.valbm V w, V ⊧/(i :> w) φ := by + have h : ∀ i < t.valb w, V ⊧/(i :> w) φ := by simpa using h suffices T.internalize V ⊢ ((toNumVec w).q ⤔ ⌜φ⌝).ball (toNumVec w ⤕ ⌜t⌝) by simpa [Semiterm.empty_typed_quote_def, ←Rew.emb_bShift_term, Semiformula.ball, ball, Semiformula.imp_def] - have : T.internalize V ⊢ ((toNumVec w).q ⤔ ⌜φ⌝).ball 𝕹(t.valbm V w) := by + have : T.internalize V ⊢ ((toNumVec w).q ⤔ ⌜φ⌝).ball 𝕹(t.valb w) := by apply ball_intro intro i hi suffices T.internalize V ⊢ (toNumVec (i :> w) ⤔ ⌜φ⌝) by @@ -143,7 +143,7 @@ theorem bold_sigma_one_complete {n} {φ : Semisentence ℒₒᵣ n} (hp : Hierar exact ih hφ theorem sigma_one_provable_of_models {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : - V ⊧ₘ σ → T.internalize V ⊢ ⌜σ⌝ := by + V↓[ℒₒᵣ] ⊧ σ → T.internalize V ⊢ ⌜σ⌝ := by intro h have : T.internalize V ⊢ (toNumVec ![] ⤔ ⌜σ⌝) := bold_sigma_one_complete T hσ (by simpa [models_iff] using h) @@ -151,12 +151,12 @@ theorem sigma_one_provable_of_models {σ : Sentence ℒₒᵣ} (hσ : Hierarchy /-- Hilbert–Bernays provability condition D3 -/ theorem sigma_one_complete {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : - V ⊧ₘ σ → T.Provable (⌜σ⌝ : V) := fun h ↦ by + V↓[ℒₒᵣ] ⊧ σ → Provable T (⌜σ⌝ : V) := fun h ↦ by simpa [tprovable_iff_provable] using Bootstrapping.Arithmetic.sigma_one_provable_of_models T hσ h theorem provable_internalize {σ : Sentence ℒₒᵣ} : - T.Provable (⌜σ⌝ : V) → T.Provable (⌜T.provabilityPred σ⌝ : V) := by - simpa [models_iff] using sigma_one_complete (V := V) (σ := T.provabilityPred σ) T (by simp) + Provable T (⌜σ⌝ : V) → Provable T (⌜provabilityPred T σ⌝ : V) := by + simpa [models_iff] using sigma_one_complete (V := V) (T := T) (σ := provabilityPred T σ) (by simp) end LO.FirstOrder.Arithmetic.Bootstrapping.Arithmetic diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/EquationalTheory.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/EquationalTheory.lean index cbde2e0d8..07f5d0b1a 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/EquationalTheory.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/EquationalTheory.lean @@ -1,6 +1,7 @@ module public import Foundation.Meta.ClProver +public import Foundation.FirstOrder.Arithmetic.Basic.Model public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D1 @[expose] public section @@ -24,31 +25,31 @@ local postfix:max "⇞" => Semiterm.shift local postfix:max "⤉" => Semiformula.shift -variable (T : ArithmeticTheory) [Theory.Δ₁ T] [𝗘𝗤 ⪯ T] +variable (T : ArithmeticTheory) [Theory.Δ₁ T] [𝗘𝗤 _ ⪯ T] open Entailment Entailment.FiniteContext Semiformula @[simp] lemma eq_refl (t : Term V ℒₒᵣ) : T.internalize V ⊢ t ≐ t := by - have : T ⊢ “∀ x, x = x” := provable_of_models.{0} _ _ fun _ _ _ ↦ by simp [models_iff] + have : T ⊢ “∀ x, x = x” := complete.{0} T _ fun (M : Type) _ _ ↦ by simp [models_iff] have : T.internalize V ⊢ ∀⁰ (#'0 ≐ #'0) := by simpa using internal_provable_of_outer_provable this simpa using TProof.specialize! this t @[simp] lemma eq_symm (t u : Term V ℒₒᵣ) : T.internalize V ⊢ (t ≐ u) 🡒 (u ≐ t) := by - have : T ⊢ “∀ x y, x = y → y = x” := provable_of_models.{0} _ _ fun _ _ _ ↦ by simp [models_iff] + have : T ⊢ “∀ x y, x = y → y = x” := complete.{0} T _ fun (M : Type) _ _ ↦ by simp [models_iff] have : T.internalize V ⊢ ∀⁰ ∀⁰ ((#'1 ≐ #'0) 🡒 (#'0 ≐ #'1)) := by simpa using internal_provable_of_outer_provable this simpa using TProof.specialize₂! this u t @[simp] lemma ne_symm (t u : Term V ℒₒᵣ) : T.internalize V ⊢ (t ≉ u) 🡒 (u ≉ t) := by - have : T ⊢ “∀ x y, x ≠ y → y ≠ x” := provable_of_models.{0} _ _ fun _ _ _ ↦ by + have : T ⊢ “∀ x y, x ≠ y → y ≠ x” := complete.{0} T _ fun (M : Type) _ _ ↦ by simp [models_iff, ne_comm] have : T.internalize V ⊢ ∀⁰ ∀⁰ ((#'1 ≉ #'0) 🡒 (#'0 ≉ #'1)) := by simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize₂! this u t @[simp] lemma eq_uniform_trans (t₁ t₂ t₃ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (t₂ ≐ t₃) 🡒 (t₁ ≐ t₃) := by - have : T ⊢ “∀ x y z, x = y → y = z → x = z” := provable_of_models.{0} _ _ fun _ _ _ ↦ by simp [models_iff] + have : T ⊢ “∀ x y z, x = y → y = z → x = z” := complete.{0} T _ fun (M : Type) _ _ ↦ by simp [models_iff] have : T.internalize V ⊢ ∀⁰ ∀⁰ ∀⁰ ((#'2 ≐ #'1) 🡒 (#'1 ≐ #'0) 🡒 (#'2 ≐ #'0)) := by simpa using internal_provable_of_outer_provable this simpa using TProof.specialize₃! this t₃ t₂ t₁ @@ -70,36 +71,36 @@ section replace open LO.Entailment lemma subst_eq (t₁ t₂ u₁ u₂ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (u₁ ≐ u₂) 🡒 (t₁ ≐ u₁) 🡒 (t₂ ≐ u₂) := by - have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ = y₁ → x₂ = y₂” := provable_of_models.{0} _ _ fun _ _ _ ↦ by simp [models_iff] + have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ = y₁ → x₂ = y₂” := complete.{0} T _ fun (M : Type) _ _ ↦ by simp [models_iff] have := by simpa using internal_provable_of_outer_provable this (V := V) simpa using TProof.specialize₄! this u₂ u₁ t₂ t₁ lemma subst_lt (t₁ t₂ u₁ u₂ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (u₁ ≐ u₂) 🡒 (t₁ <' u₁) 🡒 (t₂ <' u₂) := by - have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ < y₁ → x₂ < y₂” := provable_of_models.{0} _ _ fun _ _ _ ↦ by + have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ < y₁ → x₂ < y₂” := complete.{0} T _ fun (M : Type) _ _ ↦ by simpa [models_iff] using fun a b c e h ↦ e ▸ h have := by simpa using internal_provable_of_outer_provable this (V := V) simpa using TProof.specialize₄! this u₂ u₁ t₂ t₁ lemma subst_ne (t₁ t₂ u₁ u₂ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (u₁ ≐ u₂) 🡒 (t₁ ≉ u₁) 🡒 (t₂ ≉ u₂) := by - have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ ≠ y₁ → x₂ ≠ y₂” := provable_of_models.{0} _ _ fun _ _ _ ↦ by + have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ ≠ y₁ → x₂ ≠ y₂” := complete.{0} T _ fun (M : Type) _ _ ↦ by simpa [models_iff] using fun a b c e h ↦ e ▸ h have := by simpa using internal_provable_of_outer_provable this (V := V) simpa using TProof.specialize₄! this u₂ u₁ t₂ t₁ lemma subst_nlt (t₁ t₂ u₁ u₂ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (u₁ ≐ u₂) 🡒 (t₁ ≮' u₁) 🡒 (t₂ ≮' u₂) := by - have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ ≮ y₁ → x₂ ≮ y₂” := provable_of_models.{0} _ _ fun _ _ _ ↦ by + have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ ≮ y₁ → x₂ ≮ y₂” := complete.{0} T _ fun (M : Type) _ _ ↦ by simpa [models_iff] using fun a b c e h ↦ e ▸ h have := by simpa using internal_provable_of_outer_provable this (V := V) simpa using TProof.specialize₄! this u₂ u₁ t₂ t₁ lemma subst_add_eq_add (t₁ t₂ u₁ u₂ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (u₁ ≐ u₂) 🡒 (t₁ + u₁ ≐ t₂ + u₂) := by - have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ + y₁ = x₂ + y₂” := provable_of_models.{0} _ _ fun _ _ _ ↦ by + have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ + y₁ = x₂ + y₂” := complete.{0} T _ fun (M : Type) _ _ ↦ by simpa [models_iff] using fun a b c e ↦ by simp [e] have := by simpa using internal_provable_of_outer_provable this (V := V) simpa using TProof.specialize₄! this u₂ u₁ t₂ t₁ lemma subst_mul_eq_mul (t₁ t₂ u₁ u₂ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (u₁ ≐ u₂) 🡒 (t₁ * u₁ ≐ t₂ * u₂) := by - have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ * y₁ = x₂ * y₂” := provable_of_models.{0} _ _ fun _ _ _ ↦ by + have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ * y₁ = x₂ * y₂” := complete.{0} T _ fun (M : Type) _ _ ↦ by simpa [models_iff] using fun a b c e ↦ by simp [e] have := by simpa using internal_provable_of_outer_provable this (V := V) simpa using TProof.specialize₄! this u₂ u₁ t₂ t₁ @@ -112,7 +113,7 @@ lemma vec2_eq {v : V} (h : len v = 2) : ?[v.[0], v.[1]] = v := lemma term_replace_aux (t : V) : IsSemiterm ℒₒᵣ 1 t → - T.Provable (^∀ ^∀ imp ℒₒᵣ (^#1 ^= ^#0) (termSubst ℒₒᵣ (^#1 ∷ 0) t ^= termSubst ℒₒᵣ (^#0 ∷ 0) t)) := by + Provable T (^∀ ^∀ imp ℒₒᵣ (^#1 ^= ^#0) (termSubst ℒₒᵣ (^#1 ∷ 0) t ^= termSubst ℒₒᵣ (^#0 ∷ 0) t)) := by apply IsSemiterm.sigma1_induction · definability case hfunc => @@ -199,7 +200,7 @@ lemma term_replace_aux (t : V) : suffices T.internalize V ⊢ ∀⁰ ∀⁰ ((#'1 ≐ #'0) 🡒 (#'1 ≐ #'0)) by have := (tprovable_iff_provable (T := T)).mp this simpa [-substs_equals, val_all] using this - have : T ⊢ “∀ x y, (x = y → x = y)” := provable_of_models.{0} _ _ fun _ _ _ ↦ by simp [models_iff] + have : T ⊢ “∀ x y, (x = y → x = y)” := complete.{0} T _ fun (M : Type) _ _ ↦ by simp [models_iff] simpa using internal_provable_of_outer_provable this (V := V) case hfvar => intro x @@ -326,7 +327,7 @@ lemma replace_nlt (t u : Semiterm V ℒₒᵣ 1) : lemma replace_aux (φ : V) : IsSemiformula ℒₒᵣ 1 φ → - T.Provable (^∀ ^∀ imp ℒₒᵣ (^#1 ^= ^#0) (imp ℒₒᵣ (subst ℒₒᵣ (^#1 ∷ 0) φ) (subst ℒₒᵣ (^#0 ∷ 0) φ))) := by + Provable T (^∀ ^∀ imp ℒₒᵣ (^#1 ^= ^#0) (imp ℒₒᵣ (subst ℒₒᵣ (^#1 ∷ 0) φ) (subst ℒₒᵣ (^#0 ∷ 0) φ))) := by apply IsFormula.sigma1_structural_induction₂_ss · definability case hand => diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/PeanoMinus.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/PeanoMinus.lean index 0eeed96e2..555388f6d 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/PeanoMinus.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/PeanoMinus.lean @@ -36,15 +36,15 @@ variable (T : ArithmeticTheory) [Theory.Δ₁ T] [𝗣𝗔⁻ ⪯ T] open Entailment Entailment.FiniteContext Semiformula -instance : 𝗘𝗤 ⪯ T := +instance : 𝗘𝗤 _ ⪯ T := have : 𝗣𝗔⁻ ⪯ T := inferInstance WeakerThan.trans inferInstance this lemma term_add_assoc (t₁ t₂ t₃ : Term V ℒₒᵣ) : T.internalize V ⊢ t₁ + (t₂ + t₃) ≐ (t₁ + t₂) + t₃ := by have : T ⊢ “∀ x y z, x + (y + z) = (x + y) + z” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff, add_assoc] have : T.internalize V ⊢ ∀⁰ ∀⁰ ∀⁰ (#'2 + (#'1 + #'0) ≐ #'2 + #'1 + #'0) := by simpa using internal_provable_of_outer_provable (V := V) this @@ -58,8 +58,8 @@ lemma numeral_add (n m : V) : case zero => have : T.internalize V ⊢ ∀⁰ ((#'0 + 𝕹 0) ≐ #'0) := by have : T ⊢ “∀ x, x + 0 = x” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] have := internal_provable_of_outer_provable (V := V) this simpa using this @@ -68,8 +68,8 @@ lemma numeral_add (n m : V) : rcases eq_zero_or_pos n with (rfl | pos) · have : T.internalize V ⊢ (𝕹 0 + 𝕹 1) ≐ 𝕹 1 := by have : T ⊢ “0 + 1 = 1” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] simpa using internal_provable_of_outer_provable (V := V) this simpa using this @@ -79,7 +79,7 @@ lemma numeral_add (n m : V) : T.internalize V ⊢ 𝕹 n + (𝕹 (m + 1) + 𝕹 1) ≐ 𝕹 (n + m + 1) + 𝕹 1 by simpa [←one_add_one_eq_two, ←add_assoc] have e1 : T.internalize V ⊢ 𝕹 n + (𝕹 (m + 1) + 𝕹 1) ≐ (𝕹 n + 𝕹 (m + 1)) + 𝕹 1 := term_add_assoc T _ _ _ have e2 : T.internalize V ⊢ (𝕹 n + 𝕹 (m + 1)) + 𝕹 1 ≐ 𝕹 (n + (m + 1)) + 𝕹 1 := - subst_add_eq_add T _ _ _ _ ⨀! ih ⨀! (eq_refl T (𝕹 1)) + subst_add_eq_add T _ _ _ _ ⨀ ih ⨀ (eq_refl T (𝕹 1)) simpa [add_assoc] using eq_trans e1 e2 lemma numeral_mul (n m : V) : @@ -90,8 +90,8 @@ lemma numeral_mul (n m : V) : case zero => have : T.internalize V ⊢ ∀⁰ ((#'0 * 𝕹 0) ≐ 𝕹 0) := by have : T ⊢ “∀ x, x * 0 = 0” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] have := internal_provable_of_outer_provable (V := V) this simpa using this @@ -99,8 +99,8 @@ lemma numeral_mul (n m : V) : case one => have : T.internalize V ⊢ ∀⁰ ((#'0 * 𝕹 1) ≐ #'0) := by have : T ⊢ “∀ x, x * 1 = x” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] have := internal_provable_of_outer_provable (V := V) this simpa using this @@ -111,13 +111,13 @@ lemma numeral_mul (n m : V) : simpa [←one_add_one_eq_two, ←add_assoc, mul_add] have e1 : T.internalize V ⊢ 𝕹 n * (𝕹(m + 1) + 𝕹 1) ≐ 𝕹 n * 𝕹(m + 1) + 𝕹 n := by have : T ⊢ “∀ x y, x * (y + 1) = x * y + x” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff, mul_add] have := by simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize₂! this 𝕹(m + 1) (𝕹 n) have e2 : T.internalize V ⊢ 𝕹 n * 𝕹(m + 1) + 𝕹 n ≐ 𝕹 (n * (m + 1)) + 𝕹 n := - subst_add_eq_add T _ _ _ _ ⨀! ih ⨀! (eq_refl T (𝕹 n)) + subst_add_eq_add T _ _ _ _ ⨀ ih ⨀ (eq_refl T (𝕹 n)) have e3 : T.internalize V ⊢ 𝕹 (n * (m + 1)) + 𝕹 n ≐ 𝕹 (n * (m + 1) + n) := numeral_add T _ _ exact eq_trans (eq_trans e1 e2) e3 @@ -133,8 +133,8 @@ lemma numeral_lt {n m : V} : suffices T.internalize V ⊢ 𝕹 n <' 𝕹 (d + n + 1) by simpa [hm] have l₁ : T.internalize V ⊢ 𝕹 n <' 𝕹 d + 𝕹 n + 𝕹 1 := by have : T ⊢ “∀ x y, x < y + x + 1” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff, Arithmetic.lt_add_self_add_one] have := by simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize₂! this (𝕹 d) (𝕹 n) @@ -154,8 +154,8 @@ lemma numeral_ne {n m : V} : have l₁ : T.internalize V ⊢ 𝕹 n <' 𝕹 m := numeral_lt T hnm have l₂ : T.internalize V ⊢ (𝕹 n <' 𝕹 m) 🡒 (𝕹 n ≉ 𝕹 m) := by have : T ⊢ “∀ x y, x < y → x ≠ y” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simpa [models_iff] using fun _ _ ↦ ne_of_lt have := by simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize₂! this (𝕹 m) (𝕹 n) @@ -165,16 +165,16 @@ lemma numeral_nlt {n m : V} : n ≥ m → T.internalize V ⊢ 𝕹 n ≮' 𝕹 m := fun h ↦ by rcases eq_or_lt_of_le h with (rfl | lt) · have : T ⊢ “∀ x, x ≮ x” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] have := by simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize! this (𝕹 m) · have l₁ : T.internalize V ⊢ 𝕹 m <' 𝕹 n := numeral_lt T lt have l₂ : T.internalize V ⊢ (𝕹 m <' 𝕹 n) 🡒 (𝕹 n ≮' 𝕹 m) := by have : T ⊢ “∀ x y, x < y → y ≮ x” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simpa [models_iff] using fun _ _ ↦ le_of_lt have := by simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize₂! this (𝕹 n) (𝕹 m) @@ -192,8 +192,8 @@ lemma lt_iff_substItrDisj (t : Term V ℒₒᵣ) (m : V) : suffices T.internalize V ⊢ (t <' 𝕹 0) 🡘 ⊥ by simpa have : T.internalize V ⊢ ∀⁰ ((#'0 <' 𝕹 0) 🡘 ⊥) := by have : T ⊢ “∀ x, x < 0 ↔ ⊥” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize! this t @@ -201,8 +201,8 @@ lemma lt_iff_substItrDisj (t : Term V ℒₒᵣ) (m : V) : suffices T.internalize V ⊢ (t <' 𝕹 1) 🡘 (t ≐ 𝕹 0) ⋎ ⊥ by simpa have : T.internalize V ⊢ ∀⁰ ((#'0 <' 𝕹 1) 🡘 (#'0 ≐ 𝕹 0) ⋎ ⊥) := by have : T ⊢ “∀ x, x < 1 ↔ x = 0 ∨ ⊥” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize! this t @@ -214,8 +214,8 @@ lemma lt_iff_substItrDisj (t : Term V ℒₒᵣ) (m : V) : have : T.internalize V ⊢ (t <' 𝕹(m + 1) + 𝕹 1) 🡘 (t ≐ 𝕹(m + 1)) ⋎ (t <' 𝕹(m + 1)) := by have : T.internalize V ⊢ ∀⁰ ∀⁰ ((#'0 <' #'1 + 𝕹 1) 🡘 (#'0 ≐ #'1) ⋎ (#'0 <' #'1)) := by have : T ⊢ “∀ m x, x < m + 1 ↔ x = m ∨ x < m” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff, Arithmetic.lt_succ_iff_eq_or_succ] simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize₂! this t 𝕹(m + 1) diff --git a/Foundation/FirstOrder/Bootstrapping/FixedPoint.lean b/Foundation/FirstOrder/Bootstrapping/FixedPoint.lean index c9c2b8a9e..44781c7c1 100644 --- a/Foundation/FirstOrder/Bootstrapping/FixedPoint.lean +++ b/Foundation/FirstOrder/Bootstrapping/FixedPoint.lean @@ -1,5 +1,6 @@ module +public import Foundation.FirstOrder.Arithmetic.Basic.Model public import Foundation.FirstOrder.Bootstrapping.Syntax @[expose] public section @@ -119,8 +120,8 @@ noncomputable def fixedpoint (θ : Semisentence ℒₒᵣ 1) : Sentence ℒₒ theorem diagonal (θ : Semisentence ℒₒᵣ 1) : T ⊢ fixedpoint θ 🡘 θ/[⌜fixedpoint θ⌝] := - haveI : 𝗘𝗤 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance - provable_of_models _ _ fun (V : Type) _ _ ↦ by + haveI : 𝗘𝗤 _ ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance + complete.{0} T _ fun (V : Type) _ _ ↦ by haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance suffices V ⊧/![] (fixedpoint θ) ↔ V ⊧/![⌜fixedpoint θ⌝] θ by simpa [models_iff, Matrix.constant_eq_singleton] @@ -129,8 +130,8 @@ theorem diagonal (θ : Semisentence ℒₒᵣ 1) : simp [t, fixedpoint, substNumeral_app_quote] calc V ⊧/![] (fixedpoint θ) - _ ↔ V ⊧/![t] (diag θ) := by simp [fixedpoint, Matrix.constant_eq_singleton, t] - _ ↔ V ⊧/![substNumeral t t] θ := by simp [diag, Matrix.constant_eq_singleton] + _ ↔ V ⊧/![t] (diag θ) := by simp [fixedpoint, t] + _ ↔ V ⊧/![substNumeral t t] θ := by simp [diag] _ ↔ V ⊧/![⌜fixedpoint θ⌝] θ := by simp [ht] end Diagonalization @@ -147,17 +148,18 @@ noncomputable def multifixedpoint (θ : Fin k → Semisentence ℒₒᵣ k) (i : theorem multidiagonal (θ : Fin k → Semisentence ℒₒᵣ k) : T ⊢ multifixedpoint θ i 🡘 (Rew.subst fun j ↦ ⌜multifixedpoint θ j⌝) ▹ (θ i) := - haveI : 𝗘𝗤 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance - provable_of_models _ _ fun (V : Type) _ _ ↦ by + haveI : 𝗘𝗤 _ ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance + complete.{0} T _ fun (V : Type) _ _ ↦ by haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance - suffices V ⊧/![] (multifixedpoint θ i) ↔ V ⊧/(fun i ↦ ⌜multifixedpoint θ i⌝) (θ i) by simpa [models_iff] + suffices V ⊧/![] (multifixedpoint θ i) ↔ V ⊧/(fun i ↦ ⌜multifixedpoint θ i⌝) (θ i) by + simpa [models_iff, Function.comp_def, Matrix.empty_eq] let t : Fin k → V := fun i ↦ ⌜multidiag (θ i)⌝ have ht : ∀ i, substNumerals (t i) t = ⌜multifixedpoint θ i⌝ := by intro i; simp [t, multifixedpoint, substNumerals_app_quote_quote] calc V ⊧/![] (multifixedpoint θ i) - ↔ V ⊧/t (multidiag (θ i)) := by simp [t, multifixedpoint] - _ ↔ V ⊧/(fun i ↦ substNumerals (t i) t) (θ i) := by simp [multidiag, ← funext_iff] + ↔ V ⊧/t (multidiag (θ i)) := by simp [t, multifixedpoint, Function.comp_def] + _ ↔ V ⊧/(fun i ↦ substNumerals (t i) t) (θ i) := by simp [multidiag, ← funext_iff, Function.comp_def] _ ↔ V ⊧/(fun i ↦ ⌜multifixedpoint θ i⌝) (θ i) := by simp [ht] noncomputable def exclusiveMultifixedpoint (θ : Fin k → Semisentence ℒₒᵣ k) (i : Fin k) : Sentence ℒₒᵣ := @@ -197,21 +199,21 @@ noncomputable def parameterizedFixedpoint (θ : Semisentence ℒₒᵣ (k + 1)) theorem parameterized_diagonal (θ : Semisentence ℒₒᵣ (k + 1)) : T ⊢ ∀⁰* (parameterizedFixedpoint θ 🡘 “!θ !!(⌜parameterizedFixedpoint θ⌝) ⋯”) := - haveI : 𝗘𝗤 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance - provable_of_models _ _ fun (V : Type) _ _ ↦ by + haveI : 𝗘𝗤 _ ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance + complete.{0} T _ fun (V : Type) _ _ ↦ by haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance suffices ∀ params : Fin k → V, V ⊧/params (parameterizedFixedpoint θ) ↔ V ⊧/(⌜parameterizedFixedpoint θ⌝ :> params) θ by - simpa [models_iff, Matrix.comp_vecCons', BinderNotation.finSuccItr] + simpa [models_iff, Matrix.comp_vecCons', BinderNotation.finSuccItr, Function.comp_def, Matrix.empty_eq] intro params let t : V := ⌜parameterizedDiag θ⌝ have ht : substNumeralParams k t t = ⌜parameterizedFixedpoint θ⌝ := by simp [t, substNumeralParams_app_quote, parameterizedFixedpoint] calc V ⊧/params (parameterizedFixedpoint θ) - ↔ V ⊧/(t :> params) (parameterizedDiag θ) := by simp [parameterizedFixedpoint, Matrix.comp_vecCons', t] - _ ↔ V ⊧/(substNumeralParams k t t :> params) θ := by simp [parameterizedDiag, Matrix.comp_vecCons', BinderNotation.finSuccItr] + ↔ V ⊧/(t :> params) (parameterizedDiag θ) := by simp [parameterizedFixedpoint, Matrix.comp_vecCons', t, Function.comp_def] + _ ↔ V ⊧/(substNumeralParams k t t :> params) θ := by simp [parameterizedDiag, Matrix.comp_vecCons', BinderNotation.finSuccItr, Function.comp_def] _ ↔ V ⊧/(⌜parameterizedFixedpoint θ⌝ :> params) θ := by simp [ht] theorem parameterized_diagonal₁ (θ : Semisentence ℒₒᵣ 2) : diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean index 54c3f74fc..9ccbad744 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean @@ -2,8 +2,6 @@ module public import Foundation.FirstOrder.Bootstrapping.Syntax.Theory -/-! # Internal $\mathbf{LK}$ -/ - @[expose] public section namespace LO @@ -13,9 +11,9 @@ variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] -namespace FirstOrder.Arithmetic.Bootstrapping +variable {T U : Theory L} [T.Δ₁] [U.Δ₁] -/-! ## Sequent -/ +namespace FirstOrder.Arithmetic.Bootstrapping variable (L) @@ -66,89 +64,74 @@ alias ⟨insert, _⟩ := insert_iff end IsFormulaSet -/-! ### setShift: shift over a sequent -/ - variable (L) -noncomputable def setShift : V → V := hfsImage (shift L) - -noncomputable def setShiftGraph : 𝚺₁.Semisentence 2 := hfsImage.graph (shiftGraph L) +lemma setShift_existsUnique (s : V) : + ∃! t : V, ∀ y, y ∈ t ↔ ∃ x ∈ s, y = shift L x := + sigma₁_replacement (by definability) s -instance setShift.defined : 𝚺₁-Function₁[V] setShift L via setShiftGraph L := hfsImage.defined _ (shiftGraph L) +noncomputable def setShift (s : V) : V := Classical.choose! (setShift_existsUnique L s) -instance setShift.definable : 𝚺₁-Function₁[V] setShift L := hfsImage.definable _ (shiftGraph L) +noncomputable def setShiftGraph : 𝚺₁.Semisentence 2 := .mkSigma + “t s. (∀ y ∈' t, ∃ x ∈' s, !(shiftGraph L) y x) ∧ (∀ x ∈' s, ∃ y, !(shiftGraph L) y x ∧ y ∈ t)” variable {L} -section setShift -lemma mem_setShift_iff {s y : V} : y ∈ setShift L s ↔ ∃ x ∈ s, y = shift L x := mem_hfsImage_iff - -@[simp] lemma mem_setShift_union {s t : V} : setShift L (s ∪ t) = setShift L s ∪ setShift L t := mem_hfsImage_union - -@[simp] lemma mem_setShift_insert {x s : V} : setShift L (insert x s) = insert (shift L x) (setShift L s) := mem_hfsImage_insert +section setShift -@[simp] lemma setShift_empty : setShift L (∅ : V) = ∅ := hfsImage_empty +lemma mem_setShift_iff {s y : V} : y ∈ setShift L s ↔ ∃ x ∈ s, y = shift L x := + Classical.choose!_spec (setShift_existsUnique L s) y lemma IsFormulaSet.setShift {s : V} (h : IsFormulaSet L s) : IsFormulaSet L (setShift L s) := by simp only [IsFormulaSet, mem_setShift_iff, forall_exists_index, and_imp] rintro _ p hp rfl; exact (h p hp).shift -lemma shift_mem_setShift {p s : V} (h : p ∈ s) : shift L p ∈ setShift L s := app_mem_hfsImage h +lemma shift_mem_setShift {p s : V} (h : p ∈ s) : shift L p ∈ setShift L s := + mem_setShift_iff.mpr ⟨p, h, rfl⟩ @[simp] lemma IsFormulaSet.setShift_iff {s : V} : IsFormulaSet L (Bootstrapping.setShift L s) ↔ IsFormulaSet L s := ⟨by intro h p hp; simpa using h (shift L p) (shift_mem_setShift hp), IsFormulaSet.setShift⟩ -end setShift - -/-! ### setNeg: negation over a sequent -/ - -variable (L) - -noncomputable def setNeg : V → V := hfsImage (neg L) - -noncomputable def setNegGraph : 𝚺₁.Semisentence 2 := hfsImage.graph (negGraph L) - -instance setNeg.defined : 𝚺₁-Function₁[V] setNeg L via setNegGraph L := hfsImage.defined _ (negGraph L) - -instance setNeg.definable : 𝚺₁-Function₁[V] setNeg L := hfsImage.definable _ (negGraph L) - -variable {L} - -section setNeg - -lemma mem_setNeg_iff {s y : V} : y ∈ setNeg L s ↔ ∃ x ∈ s, y = neg L x := mem_hfsImage_iff - -@[simp] lemma mem_setNeg_union {s t : V} : setNeg L (s ∪ t) = setNeg L s ∪ setNeg L t := mem_hfsImage_union - -@[simp] lemma mem_setNeg_insert {x s : V} : setNeg L (insert x s) = insert (neg L x) (setNeg L s) := mem_hfsImage_insert - -@[simp] lemma setNeg_empty : setNeg L (∅ : V) = ∅ := hfsImage_empty - -lemma IsFormulaSet.setNeg {s : V} (h : IsFormulaSet L s) : IsFormulaSet L (setNeg L s) := by - simp only [IsFormulaSet, mem_setNeg_iff, forall_exists_index, and_imp] - rintro _ p hp rfl; exact (h p hp).neg - -lemma neg_mem_setNeg {p s : V} (h : p ∈ s) : neg L p ∈ setNeg L s := app_mem_hfsImage h +@[simp] lemma mem_setShift_union {s t : V} : setShift L (s ∪ t) = setShift L s ∪ setShift L t := mem_ext <| by + simp only [mem_setShift_iff, mem_cup_iff]; intro x + constructor + · rintro ⟨z, (hz | hz), rfl⟩ + · left; exact ⟨z, hz, rfl⟩ + · right; exact ⟨z, hz, rfl⟩ + · rintro (⟨z, hz, rfl⟩ | ⟨z, hz, rfl⟩) + · exact ⟨z, Or.inl hz, rfl⟩ + · exact ⟨z, Or.inr hz, rfl⟩ -lemma setNeg_subset_of_subset {s t : V} (h : s ⊆ t) : setNeg L s ⊆ setNeg L t := - hfsImage_subset_of_subset h +@[simp] lemma mem_setShift_insert {x s : V} : setShift L (insert x s) = insert (shift L x) (setShift L s) := mem_ext <| by + simp [mem_setShift_iff] -@[simp] lemma IsFormulaSet.setNeg_iff {s : V} : - IsFormulaSet L (Bootstrapping.setNeg L s) ↔ IsFormulaSet L s := - ⟨by intro h p hp; simpa using h (neg L p) (neg_mem_setNeg hp), IsFormulaSet.setNeg⟩ +@[simp] lemma setShift_empty : setShift L (∅ : V) = ∅ := mem_ext <| by simp [mem_setShift_iff] +section -end setNeg +private lemma setShift_graph (t s : V) : + t = setShift L s ↔ (∀ y ∈ t, ∃ x ∈ s, y = shift L x) ∧ (∀ x ∈ s, shift L x ∈ t) := by + constructor + · rintro rfl + constructor + · intro y hy; exact mem_setShift_iff.mp hy + · intro x hx; exact mem_setShift_iff.mpr ⟨x, hx, rfl⟩ + · rintro ⟨h₁, h₂⟩ + apply mem_ext; intro y; constructor + · intro hy; exact mem_setShift_iff.mpr (h₁ y hy) + · intro hy + rcases mem_setShift_iff.mp hy with ⟨x, hx, rfl⟩ + exact h₂ x hx -/-- ### Coding of rules -/ +instance setShift.defined : 𝚺₁-Function₁[V] setShift L via setShiftGraph L := .mk fun v ↦ by simp [setShiftGraph, setShift_graph] -noncomputable def identity (s p : V) : V := ⟪s, 0, p⟫ + 1 +instance setShift.definable : 𝚺₁-Function₁[V] setShift L := setShift.defined.to_definable -noncomputable def cutRule (s p d₁ d₂ : V) : V := ⟪s, 8, p, d₁, d₂⟫ + 1 +end -noncomputable def contraction (s d : V) : V := ⟪s, 6, d⟫ + 1 +end setShift -noncomputable def shiftRule (s d : V) : V := ⟪s, 7, d⟫ + 1 +noncomputable def axL (s p : V) : V := ⟪s, 0, p⟫ + 1 noncomputable def verumIntro (s : V) : V := ⟪s, 1, 0⟫ + 1 @@ -160,12 +143,20 @@ noncomputable def allIntro (s p d : V) : V := ⟪s, 4, p, d⟫ + 1 noncomputable def exsIntro (s p t d : V) : V := ⟪s, 5, p, t, d⟫ + 1 +noncomputable def wkRule (s d : V) : V := ⟪s, 6, d⟫ + 1 + +noncomputable def shiftRule (s d : V) : V := ⟪s, 7, d⟫ + 1 + +noncomputable def cutRule (s p d₁ d₂ : V) : V := ⟪s, 8, p, d₁, d₂⟫ + 1 + +noncomputable def axm (s p : V) : V := ⟪s, 9, p⟫ + 1 + section -def identityGraph : 𝚺₀.Semisentence 3 := +def axLGraph : 𝚺₀.Semisentence 3 := .mkSigma “y s p. ∃ y' < y, !pair₃Def y' s 0 p ∧ y = y' + 1” -instance identity.defined : 𝚺₀-Function₂[V] identity via identityGraph := .mk fun v ↦ by simp_all [identityGraph, identity] +instance axL.defined : 𝚺₀-Function₂[V] axL via axLGraph := .mk fun v ↦ by simp_all [axLGraph, axL] def verumIntroGraph : 𝚺₀.Semisentence 2 := .mkSigma “y s. ∃ y' < y, !pair₃Def y' s 1 0 ∧ y = y' + 1” @@ -192,10 +183,10 @@ def exsIntroGraph : 𝚺₀.Semisentence 5 := instance exsIntro.defined : 𝚺₀-Function₄ (exsIntro : V → V → V → V → V) via exsIntroGraph := .mk fun v ↦ by simp_all [exsIntroGraph, numeral_eq_natCast, exsIntro] -def contractionGraph : 𝚺₀.Semisentence 3 := +def wkRuleGraph : 𝚺₀.Semisentence 3 := .mkSigma “y s d. ∃ y' < y, !pair₃Def y' s 6 d ∧ y = y' + 1” -instance contraction.defined : 𝚺₀-Function₂ (contraction : V → V → V) via contractionGraph := .mk fun v ↦ by simp_all [contractionGraph, numeral_eq_natCast, contraction] +instance wkRule.defined : 𝚺₀-Function₂ (wkRule : V → V → V) via wkRuleGraph := .mk fun v ↦ by simp_all [wkRuleGraph, numeral_eq_natCast, wkRule] def shiftRuleGraph : 𝚺₀.Semisentence 3 := .mkSigma “y s d. ∃ y' < y, !pair₃Def y' s 7 d ∧ y = y' + 1” @@ -207,8 +198,13 @@ def cutRuleGraph : 𝚺₀.Semisentence 5 := instance cutRule_defined : 𝚺₀-Function₄ (cutRule : V → V → V → V → V) via cutRuleGraph := .mk fun v ↦ by simp_all [cutRuleGraph, numeral_eq_natCast, cutRule] -@[simp] lemma seq_lt_identity (s p : V) : s < identity s p := le_iff_lt_succ.mp <| le_pair_left _ _ -@[simp] lemma arity_lt_identity (s p : V) : p < identity s p := +def axmGraph : 𝚺₀.Semisentence 3 := + .mkSigma “y s p. ∃ y' < y, !pair₃Def y' s 9 p ∧ y = y' + 1” + +instance axm_defined : 𝚺₀-Function₂ (axm : V → V → V) via axmGraph := .mk fun v ↦ by simp_all [axmGraph, numeral_eq_natCast, axm] + +@[simp] lemma seq_lt_axL (s p : V) : s < axL s p := le_iff_lt_succ.mp <| le_pair_left _ _ +@[simp] lemma arity_lt_axL (s p : V) : p < axL s p := le_iff_lt_succ.mp <| le_trans (by simp) <| le_pair_right _ _ @[simp] lemma seq_lt_verumIntro (s : V) : s < verumIntro s := le_iff_lt_succ.mp <| le_pair_left _ _ @@ -245,8 +241,8 @@ instance cutRule_defined : 𝚺₀-Function₄ (cutRule : V → V → V → V @[simp] lemma d_lt_exsIntro (s p t d : V) : d < exsIntro s p t d := le_iff_lt_succ.mp <| le_trans (le_trans (le_trans (le_pair_right _ _) <| le_pair_right _ _) <| le_pair_right _ _) <| le_pair_right _ _ -@[simp] lemma seq_lt_contraction (s d : V) : s < contraction s d := le_iff_lt_succ.mp <| le_pair_left _ _ -@[simp] lemma d_lt_contraction (s d : V) : d < contraction s d := le_iff_lt_succ.mp <| le_trans (le_pair_right _ _) <| le_pair_right _ _ +@[simp] lemma seq_lt_wkRule (s d : V) : s < wkRule s d := le_iff_lt_succ.mp <| le_pair_left _ _ +@[simp] lemma d_lt_wkRule (s d : V) : d < wkRule s d := le_iff_lt_succ.mp <| le_trans (le_pair_right _ _) <| le_pair_right _ _ @[simp] lemma seq_lt_shiftRule (s d : V) : s < shiftRule s d := le_iff_lt_succ.mp <| le_pair_left _ _ @[simp] lemma d_lt_shiftRule (s d : V) : d < shiftRule s d := le_iff_lt_succ.mp <| le_trans (le_pair_right _ _) <| le_pair_right _ _ @@ -259,44 +255,45 @@ instance cutRule_defined : 𝚺₀-Function₄ (cutRule : V → V → V → V @[simp] lemma d₂_lt_cutRule (s p d₁ d₂ : V) : d₂ < cutRule s p d₁ d₂ := le_iff_lt_succ.mp <| le_trans (le_trans (le_trans (le_pair_right _ _) <| le_pair_right _ _) <| le_pair_right _ _) <| le_pair_right _ _ -@[simp] lemma fstIdx_identity (s p : V) : fstIdx (identity s p) = s := by simp [fstIdx, identity] +@[simp] lemma seq_lt_axm (s p : V) : s < axm s p := le_iff_lt_succ.mp <| le_pair_left _ _ +@[simp] lemma p_lt_axm (s p : V) : p < axm s p := le_iff_lt_succ.mp <| le_trans (le_pair_right _ _) <| le_pair_right _ _ + +@[simp] lemma fstIdx_axL (s p : V) : fstIdx (axL s p) = s := by simp [fstIdx, axL] @[simp] lemma fstIdx_verumIntro (s : V) : fstIdx (verumIntro s) = s := by simp [fstIdx, verumIntro] @[simp] lemma fstIdx_andIntro (s p q dp dq : V) : fstIdx (andIntro s p q dp dq) = s := by simp [fstIdx, andIntro] @[simp] lemma fstIdx_orIntro (s p q dpq : V) : fstIdx (orIntro s p q dpq) = s := by simp [fstIdx, orIntro] @[simp] lemma fstIdx_allIntro (s p d : V) : fstIdx (allIntro s p d) = s := by simp [fstIdx, allIntro] @[simp] lemma fstIdx_exsIntro (s p t d : V) : fstIdx (exsIntro s p t d) = s := by simp [fstIdx, exsIntro] -@[simp] lemma fstIdx_contraction (s d : V) : fstIdx (contraction s d) = s := by simp [fstIdx, contraction] +@[simp] lemma fstIdx_wkRule (s d : V) : fstIdx (wkRule s d) = s := by simp [fstIdx, wkRule] @[simp] lemma fstIdx_shiftRule (s d : V) : fstIdx (shiftRule s d) = s := by simp [fstIdx, shiftRule] @[simp] lemma fstIdx_cutRule (s p d₁ d₂ : V) : fstIdx (cutRule s p d₁ d₂) = s := by simp [fstIdx, cutRule] +@[simp] lemma fstIdx_axm (s p : V) : fstIdx (axm s p) = s := by simp [fstIdx, axm] end -/-! ## Internal isDerivation -/ - -namespace IsDerivation - -/-! ### Preparation -/ +namespace Derivation noncomputable abbrev conseq (x : V) : V := π₁ x -variable (L) +variable (T) def Phi (C : Set V) (d : V) : Prop := IsFormulaSet L (fstIdx d) ∧ - ( (∃ s p, d = identity s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ + ( (∃ s p, d = axL s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ (∃ s, d = verumIntro s ∧ ^⊤ ∈ s) ∨ (∃ s p q dp dq, d = andIntro s p q dp dq ∧ p ^⋏ q ∈ s ∧ (fstIdx dp = insert p s ∧ dp ∈ C) ∧ (fstIdx dq = insert q s ∧ dq ∈ C)) ∨ (∃ s p q dpq, d = orIntro s p q dpq ∧ p ^⋎ q ∈ s ∧ fstIdx dpq = insert p (insert q s) ∧ dpq ∈ C) ∨ (∃ s p dp, d = allIntro s p dp ∧ ^∀ p ∈ s ∧ fstIdx dp = insert (free L p) (setShift L s) ∧ dp ∈ C) ∨ (∃ s p t dp, d = exsIntro s p t dp ∧ ^∃ p ∈ s ∧ IsTerm L t ∧ fstIdx dp = insert (substs1 L t p) s ∧ dp ∈ C) ∨ - (∃ s d', d = contraction s d' ∧ fstIdx d' ⊆ s ∧ d' ∈ C) ∨ + (∃ s d', d = wkRule s d' ∧ fstIdx d' ⊆ s ∧ d' ∈ C) ∨ (∃ s d', d = shiftRule s d' ∧ s = setShift L (fstIdx d') ∧ d' ∈ C) ∨ - (∃ s p d₁ d₂, d = cutRule s p d₁ d₂ ∧ (fstIdx d₁ = insert p s ∧ d₁ ∈ C) ∧ (fstIdx d₂ = insert (neg L p) s ∧ d₂ ∈ C))) + (∃ s p d₁ d₂, d = cutRule s p d₁ d₂ ∧ (fstIdx d₁ = insert p s ∧ d₁ ∈ C) ∧ (fstIdx d₂ = insert (neg L p) s ∧ d₂ ∈ C)) ∨ + (∃ s p, d = axm s p ∧ p ∈ s ∧ p ∈ T.Δ₁Class) ) private lemma phi_iff (C d : V) : - Phi L {x | x ∈ C} d ↔ + Phi T {x | x ∈ C} d ↔ IsFormulaSet L (fstIdx d) ∧ - ( (∃ s < d, ∃ p < d, d = identity s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ + ( (∃ s < d, ∃ p < d, d = axL s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ (∃ s < d, d = verumIntro s ∧ ^⊤ ∈ s) ∨ (∃ s < d, ∃ p < d, ∃ q < d, ∃ dp < d, ∃ dq < d, d = andIntro s p q dp dq ∧ p ^⋏ q ∈ s ∧ (fstIdx dp = insert p s ∧ dp ∈ C) ∧ (fstIdx dq = insert q s ∧ dq ∈ C)) ∨ @@ -307,16 +304,18 @@ private lemma phi_iff (C d : V) : (∃ s < d, ∃ p < d, ∃ t < d, ∃ dp < d, d = exsIntro s p t dp ∧ ^∃ p ∈ s ∧ IsTerm L t ∧ fstIdx dp = insert (substs1 L t p) s ∧ dp ∈ C) ∨ (∃ s < d, ∃ d' < d, - d = contraction s d' ∧ fstIdx d' ⊆ s ∧ d' ∈ C) ∨ + d = wkRule s d' ∧ fstIdx d' ⊆ s ∧ d' ∈ C) ∨ (∃ s < d, ∃ d' < d, d = shiftRule s d' ∧ s = setShift L (fstIdx d') ∧ d' ∈ C) ∨ (∃ s < d, ∃ p < d, ∃ d₁ < d, ∃ d₂ < d, - d = cutRule s p d₁ d₂ ∧ (fstIdx d₁ = insert p s ∧ d₁ ∈ C) ∧ (fstIdx d₂ = insert (neg L p) s ∧ d₂ ∈ C))) := by + d = cutRule s p d₁ d₂ ∧ (fstIdx d₁ = insert p s ∧ d₁ ∈ C) ∧ (fstIdx d₂ = insert (neg L p) s ∧ d₂ ∈ C)) ∨ + (∃ s < d, ∃ p < d, + d = axm s p ∧ p ∈ s ∧ p ∈ T.Δ₁Class) ) := by constructor · rintro ⟨hs, H⟩ refine ⟨hs, ?_⟩ rcases H with (⟨s, p, rfl, h⟩ | ⟨s, rfl, h⟩ | ⟨s, p, q, dp, dq, rfl, h⟩ | ⟨s, p, q, dpq, rfl, h⟩ | - ⟨s, p, dp, rfl, h⟩ | ⟨s, p, t, dp, rfl, h⟩ | ⟨s, d', rfl, h⟩ | ⟨s, d', rfl, h⟩ | ⟨s, p, d₁, d₂, rfl, h⟩) + ⟨s, p, dp, rfl, h⟩ | ⟨s, p, t, dp, rfl, h⟩ | ⟨s, d', rfl, h⟩ | ⟨s, d', rfl, h⟩ | ⟨s, p, d₁, d₂, rfl, h⟩ | ⟨s, p, rfl, h⟩) · left; exact ⟨s, by simp, p, by simp, rfl, h⟩ · right; left; exact ⟨s, by simp, rfl, h⟩ · right; right; left; exact ⟨s, by simp, p, by simp, q, by simp, dp, by simp, dq, by simp, rfl, h⟩ @@ -325,12 +324,13 @@ private lemma phi_iff (C d : V) : · right; right; right; right; right; left; exact ⟨s, by simp, p, by simp, t, by simp, dp, by simp, rfl, h⟩ · right; right; right; right; right; right; left; exact ⟨s, by simp, d', by simp, rfl, h⟩ · right; right; right; right; right; right; right; left; exact ⟨s, by simp, d', by simp, rfl, h⟩ - · right; right; right; right; right; right; right; right; exact ⟨s, by simp, p, by simp, d₁, by simp, d₂, by simp, rfl, h⟩ + · right; right; right; right; right; right; right; right; left; exact ⟨s, by simp, p, by simp, d₁, by simp, d₂, by simp, rfl, h⟩ + · right; right; right; right; right; right; right; right; right; exact ⟨s, by simp, p, by simp, rfl, h⟩ · rintro ⟨hs, H⟩ refine ⟨hs, ?_⟩ rcases H with (⟨s, _, p, _, rfl, h⟩ | ⟨s, _, rfl, h⟩ | ⟨s, _, p, _, q, _, dp, _, dq, _, rfl, h⟩ | ⟨s, _, p, _, q, _, dpq, _, rfl, h⟩ | ⟨s, _, p, _, dp, _, rfl, h⟩ | ⟨s, _, p, _, t, _, dp, _, rfl, h⟩ | ⟨s, _, d', _, rfl, h⟩ | - ⟨s, _, d', _, rfl, h⟩ | ⟨s, _, p, _, d₁, _, d₂, _, rfl, h⟩) + ⟨s, _, d', _, rfl, h⟩ | ⟨s, _, p, _, d₁, _, d₂, _, rfl, h⟩ | ⟨s, _, p, _, h⟩) · left; exact ⟨s, p, rfl, h⟩ · right; left; exact ⟨s, rfl, h⟩ · right; right; left; exact ⟨s, p, q, dp, dq, rfl, h⟩ @@ -339,12 +339,13 @@ private lemma phi_iff (C d : V) : · right; right; right; right; right; left; exact ⟨s, p, t, dp, rfl, h⟩ · right; right; right; right; right; right; left; exact ⟨s, d', rfl, h⟩ · right; right; right; right; right; right; right; left; exact ⟨s, d', rfl, h⟩ - · right; right; right; right; right; right; right; right; exact ⟨s, p, d₁, d₂, rfl, h⟩ + · right; right; right; right; right; right; right; right; left; exact ⟨s, p, d₁, d₂, rfl, h⟩ + · right; right; right; right; right; right; right; right; right; exact ⟨s, p, h⟩ noncomputable def blueprint : Fixpoint.Blueprint 0 := ⟨.mkDelta (.mkSigma “d C. (∃ fst, !fstIdxDef fst d ∧ !(isFormulaSet L).sigma fst) ∧ - ( (∃ s < d, ∃ p < d, !identityGraph d s p ∧ p ∈ s ∧ ∃ np, !(negGraph L) np p ∧ np ∈ s) ∨ + ( (∃ s < d, ∃ p < d, !axLGraph d s p ∧ p ∈ s ∧ ∃ np, !(negGraph L) np p ∧ np ∈ s) ∨ (∃ s < d, !verumIntroGraph d s ∧ ∃ vrm, !qqVerumDef vrm ∧ vrm ∈ s) ∨ (∃ s < d, ∃ p < d, ∃ q < d, ∃ dp < d, ∃ dq < d, !andIntroGraph d s p q dp dq ∧ (∃ and, !qqAndDef and p q ∧ and ∈ s) ∧ @@ -361,17 +362,19 @@ noncomputable def blueprint : Fixpoint.Blueprint 0 := ⟨.mkDelta !exsIntroGraph d s p t dp ∧ (∃ ex, !qqExsDef ex p ∧ ex ∈ s) ∧ !(isSemiterm L).sigma 0 t ∧ ∃ c, !fstIdxDef c dp ∧ ∃ pt, !(substs1Graph L) pt t p ∧ !insertDef c pt s ∧ dp ∈ C) ∨ (∃ s < d, ∃ d' < d, - !contractionGraph d s d' ∧ ∃ c, !fstIdxDef c d' ∧ !bitSubsetDef c s ∧ d' ∈ C) ∨ + !wkRuleGraph d s d' ∧ ∃ c, !fstIdxDef c d' ∧ !bitSubsetDef c s ∧ d' ∈ C) ∨ (∃ s < d, ∃ d' < d, !shiftRuleGraph d s d' ∧ ∃ c, !fstIdxDef c d' ∧ !(setShiftGraph L) s c ∧ d' ∈ C) ∨ (∃ s < d, ∃ p < d, ∃ d₁ < d, ∃ d₂ < d, !cutRuleGraph d s p d₁ d₂ ∧ (∃ c, !fstIdxDef c d₁ ∧ !insertDef c p s ∧ d₁ ∈ C) ∧ - (∃ c, !fstIdxDef c d₂ ∧ ∃ np, !(negGraph L) np p ∧ !insertDef c np s ∧ d₂ ∈ C)))” + (∃ c, !fstIdxDef c d₂ ∧ ∃ np, !(negGraph L) np p ∧ !insertDef c np s ∧ d₂ ∈ C)) ∨ + (∃ s < d, ∃ p < d, + !axmGraph d s p ∧ p ∈ s ∧ !T.Δ₁ch.sigma p) )” ) (.mkPi “d C. (∀ fst, !fstIdxDef fst d → !(isFormulaSet L).pi fst) ∧ - ( (∃ s < d, ∃ p < d, !identityGraph d s p ∧ p ∈ s ∧ ∀ np, !(negGraph L) np p → np ∈ s) ∨ + ( (∃ s < d, ∃ p < d, !axLGraph d s p ∧ p ∈ s ∧ ∀ np, !(negGraph L) np p → np ∈ s) ∨ (∃ s < d, !verumIntroGraph d s ∧ ∀ vrm, !qqVerumDef vrm → vrm ∈ s) ∨ (∃ s < d, ∃ p < d, ∃ q < d, ∃ dp < d, ∃ dq < d, !andIntroGraph d s p q dp dq ∧ (∀ and, !qqAndDef and p q → and ∈ s) ∧ @@ -389,29 +392,31 @@ noncomputable def blueprint : Fixpoint.Blueprint 0 := ⟨.mkDelta !(isSemiterm L).pi 0 t ∧ ∀ c, !fstIdxDef c dp → ∀ pt, !(substs1Graph L) pt t p → !insertDef c pt s ∧ dp ∈ C) ∨ (∃ s < d, ∃ d' < d, - !contractionGraph d s d' ∧ ∀ c, !fstIdxDef c d' → !bitSubsetDef c s ∧ d' ∈ C) ∨ + !wkRuleGraph d s d' ∧ ∀ c, !fstIdxDef c d' → !bitSubsetDef c s ∧ d' ∈ C) ∨ (∃ s < d, ∃ d' < d, !shiftRuleGraph d s d' ∧ ∀ c, !fstIdxDef c d' → ∀ ss, !(setShiftGraph L) ss c → s = ss ∧ d' ∈ C) ∨ (∃ s < d, ∃ p < d, ∃ d₁ < d, ∃ d₂ < d, !cutRuleGraph d s p d₁ d₂ ∧ (∀ c, !fstIdxDef c d₁ → !insertDef c p s ∧ d₁ ∈ C) ∧ - (∀ c, !fstIdxDef c d₂ → ∀ np, !(negGraph L) np p → !insertDef c np s ∧ d₂ ∈ C)))” + (∀ c, !fstIdxDef c d₂ → ∀ np, !(negGraph L) np p → !insertDef c np s ∧ d₂ ∈ C)) ∨ + (∃ s < d, ∃ p < d, + !axmGraph d s p ∧ p ∈ s ∧ !T.Δ₁ch.pi p) )” )⟩ -lemma Phi_definable : 𝚫₁.Defined (fun v : Fin 2 → V ↦ Phi L {x | x ∈ v 1} (v 0)) (blueprint L).core := .mk <| by +lemma Phi_definable : 𝚫₁.Defined (fun v : Fin 2 → V ↦ Phi T {x | x ∈ v 1} (v 0)) (blueprint T).core := .mk <| by constructor · intro v; simp [blueprint] · intro v; simp [phi_iff, blueprint] -def construction : Fixpoint.Construction V (blueprint L) where - Φ := fun _ ↦ Phi L +def construction : Fixpoint.Construction V (blueprint T) where + Φ := fun _ ↦ Phi T defined := Phi_definable _ monotone := by rintro C C' hC _ d ⟨hs, H⟩ refine ⟨hs, ?_⟩ rcases H with (h | h | ⟨s, p, q, dp, dq, rfl, hpq, ⟨hp, hpC⟩, ⟨hq, hqC⟩⟩ | ⟨s, p, q, dpq, rfl, hpq, h, hdC⟩ | ⟨s, p, dp, rfl, hp, h, hdC⟩ | ⟨s, p, t, dp, rfl, hp, ht, h, hdC⟩ | - ⟨s, d', rfl, ss, hdC⟩ | ⟨s, d', rfl, ss, hdC⟩ | ⟨s, p, d₁, d₂, rfl, ⟨h₁, hd₁C⟩, ⟨h₂, hd₂C⟩⟩) + ⟨s, d', rfl, ss, hdC⟩ | ⟨s, d', rfl, ss, hdC⟩ | ⟨s, p, d₁, d₂, rfl, ⟨h₁, hd₁C⟩, ⟨h₂, hd₂C⟩⟩ | ⟨s, p, h⟩) · left; exact h · right; left; exact h · right; right; left; exact ⟨s, p, q, dp, dq, rfl, hpq, ⟨hp, hC hpC⟩, ⟨hq, hC hqC⟩⟩ @@ -420,15 +425,16 @@ def construction : Fixpoint.Construction V (blueprint L) where · right; right; right; right; right; left; exact ⟨s, p, t, dp, rfl, hp, ht, h, hC hdC⟩ · right; right; right; right; right; right; left; exact ⟨s, d', rfl, ss, hC hdC⟩ · right; right; right; right; right; right; right; left; exact ⟨s, d', rfl, ss, hC hdC⟩ - · right; right; right; right; right; right; right; right; exact ⟨s, p, d₁, d₂, rfl, ⟨h₁, hC hd₁C⟩, ⟨h₂, hC hd₂C⟩⟩ + · right; right; right; right; right; right; right; right; left; exact ⟨s, p, d₁, d₂, rfl, ⟨h₁, hC hd₁C⟩, ⟨h₂, hC hd₂C⟩⟩ + · right; right; right; right; right; right; right; right; right; exact ⟨s, p, h⟩ -instance : (construction L).StrongFinite V where +instance : (construction T).StrongFinite V where strong_finite := by rintro C _ d ⟨hs, H⟩ refine ⟨hs, ?_⟩ rcases H with (h | h | ⟨s, p, q, dp, dq, rfl, hpq, ⟨hp, hpC⟩, ⟨hq, hqC⟩⟩ | ⟨s, p, q, dpq, rfl, hpq, h, hdC⟩ | ⟨s, p, dp, rfl, hp, h, hdC⟩ | ⟨s, p, t, dp, rfl, hp, ht, h, hdC⟩ | - ⟨s, d', rfl, ss, hdC⟩ | ⟨s, d', rfl, ss, hdC⟩ | ⟨s, p, d₁, d₂, rfl, ⟨h₁, hd₁C⟩, ⟨h₂, hd₂C⟩⟩) + ⟨s, d', rfl, ss, hdC⟩ | ⟨s, d', rfl, ss, hdC⟩ | ⟨s, p, d₁, d₂, rfl, ⟨h₁, hd₁C⟩, ⟨h₂, hd₂C⟩⟩ | ⟨s, p, h⟩) · left; exact h · right; left; exact h · right; right; left; exact ⟨s, p, q, dp, dq, rfl, hpq, ⟨hp, hpC, by simp⟩, ⟨hq, hqC, by simp⟩⟩ @@ -437,149 +443,138 @@ instance : (construction L).StrongFinite V where · right; right; right; right; right; left; exact ⟨s, p, t, dp, rfl, hp, ht, h, hdC, by simp⟩ · right; right; right; right; right; right; left; exact ⟨s, d', rfl, ss, hdC, by simp⟩ · right; right; right; right; right; right; right; left; exact ⟨s, d', rfl, ss, hdC, by simp⟩ - · right; right; right; right; right; right; right; right; exact ⟨s, p, d₁, d₂, rfl, ⟨h₁, hd₁C, by simp⟩, ⟨h₂, hd₂C, by simp⟩⟩ + · right; right; right; right; right; right; right; right; left; exact ⟨s, p, d₁, d₂, rfl, ⟨h₁, hd₁C, by simp⟩, ⟨h₂, hd₂C, by simp⟩⟩ + · right; right; right; right; right; right; right; right; right; exact ⟨s, p, h⟩ -end IsDerivation +end Derivation -/- ### Main definitions -/ +end FirstOrder.Arithmetic.Bootstrapping -open PeanoMinus ISigma0 ISigma1 Bootstrapping IsDerivation +namespace FirstOrder.Arithmetic.Bootstrapping -variable (L) +open PeanoMinus ISigma0 ISigma1 Derivation + +variable (T) -/-- Internal isDerivation -/ -def IsDerivation : V → Prop := (construction L).Fixpoint ![] +def Derivation : V → Prop := (construction T).Fixpoint ![] -/- Internal isDerivation of sequent `s` -/ -def IsDerivationOf (d s : V) : Prop := fstIdx d = s ∧ IsDerivation L d +def DerivationOf (d s : V) : Prop := fstIdx d = s ∧ Derivation T d -/-- Internal derivability -/ -def Derivable (s : V) : Prop := ∃ d, IsDerivationOf L d s +def Derivable (s : V) : Prop := ∃ d, DerivationOf T d s -/-- Internal proof -/ -@[deprecated IProof] -def IProof (d φ : V) : Prop := IsDerivationOf L d {φ} +def Proof (d φ : V) : Prop := DerivationOf T d {φ} -/-- Internal provability -/ -@[deprecated IProvable] -def IProvable (φ : V) : Prop := ∃ d, IProof L d φ +def Provable (φ : V) : Prop := ∃ d, Proof T d φ -noncomputable def isDerivation : 𝚫₁.Semisentence 1 := (blueprint L).fixpointDefΔ₁ +noncomputable def derivation : 𝚫₁.Semisentence 1 := (blueprint T).fixpointDefΔ₁ -noncomputable def isDerivationOf : 𝚫₁.Semisentence 2 := .mkDelta - (.mkSigma “d s. !fstIdxDef s d ∧ !(isDerivation L).sigma d”) - (.mkPi “d s. !fstIdxDef s d ∧ !(isDerivation L).pi d”) +noncomputable def derivationOf : 𝚫₁.Semisentence 2 := .mkDelta + (.mkSigma “d s. !fstIdxDef s d ∧ !(derivation T).sigma d”) + (.mkPi “d s. !fstIdxDef s d ∧ !(derivation T).pi d”) noncomputable def derivable : 𝚺₁.Semisentence 1 := .mkSigma - “Γ. ∃ d, !(isDerivationOf L).sigma d Γ” + “Γ. ∃ d, !(derivationOf T).sigma d Γ” -@[deprecated iproof] -noncomputable def iproof : 𝚫₁.Semisentence 2 := .mkDelta - (.mkSigma “d φ. ∃ s, !insertDef s φ 0 ∧ !(isDerivationOf L).sigma d s”) - (.mkPi “d φ. ∀ s, !insertDef s φ 0 → !(isDerivationOf L).pi d s”) +noncomputable def proof : 𝚫₁.Semisentence 2 := .mkDelta + (.mkSigma “d φ. ∃ s, !insertDef s φ 0 ∧ !(derivationOf T).sigma d s”) + (.mkPi “d φ. ∀ s, !insertDef s φ 0 → !(derivationOf T).pi d s”) -noncomputable def iprovable : 𝚺₁.Semisentence 1 := .mkSigma - “φ. ∃ d, !(iproof L).sigma d φ” +noncomputable def provable : 𝚺₁.Semisentence 1 := .mkSigma + “φ. ∃ d, !(proof T).sigma d φ” -@[deprecated iprovabilityPred] -noncomputable abbrev iprovabilityPred (σ : Sentence L) : Sentence ℒₒᵣ := (iprovable L).val/[⌜σ⌝] +noncomputable abbrev provabilityPred (σ : Sentence L) : Sentence ℒₒᵣ := (provable T).val/[⌜σ⌝] -@[deprecated iprovabilityPred'] -noncomputable def iprovabilityPred' (σ : Sentence L) : 𝚺₁.Sentence := .mkSigma - “!(iprovable L) !!(⌜σ⌝)” +noncomputable def provabilityPred' (σ : Sentence L) : 𝚺₁.Sentence := .mkSigma + “!(provable T) !!(⌜σ⌝)” -@[simp] lemma iprovabilityPred'_val (σ : Sentence L) : (iprovabilityPred' L σ).val = iprovabilityPred L σ := by rfl +@[simp] lemma provabilityPred'_val (σ : Sentence L) : (provabilityPred' T σ).val = provabilityPred T σ := by rfl -variable {L} +variable {T} section -instance IsDerivation.defined : 𝚫₁-Predicate[V] (IsDerivation L) via isDerivation L := (construction L).fixpoint_definedΔ₁ +instance Derivation.defined : 𝚫₁-Predicate[V] Derivation T via derivation T := (construction T).fixpoint_definedΔ₁ -instance IsDerivation.definable : 𝚫₁-Predicate[V] (IsDerivation L) := IsDerivation.defined.to_definable +instance Derivation.definable : 𝚫₁-Predicate[V] Derivation T := Derivation.defined.to_definable -instance IsDerivation.definable' : Γ-[m + 1]-Predicate[V] (IsDerivation L) := IsDerivation.definable.of_deltaOne +instance Derivation.definable' : Γ-[m + 1]-Predicate[V] Derivation T := Derivation.definable.of_deltaOne -instance IsDerivationOf.defined : 𝚫₁-Relation[V] (IsDerivationOf L) via isDerivationOf L := .mk - ⟨by intro v; simp [isDerivationOf], by intro v; simp [isDerivationOf, eq_comm (b := fstIdx (v 0))]; rfl⟩ +instance DerivationOf.defined : 𝚫₁-Relation[V] DerivationOf T via derivationOf T := .mk + ⟨by intro v; simp [derivationOf], by intro v; simp [derivationOf, eq_comm (b := fstIdx (v 0))]; rfl⟩ -instance IsDerivationOf.definable : 𝚫₁-Relation[V] IsDerivationOf L := IsDerivationOf.defined.to_definable +instance DerivationOf.definable : 𝚫₁-Relation[V] DerivationOf T := DerivationOf.defined.to_definable -instance IsDerivationOf.definable' : Γ-[m + 1]-Relation[V] IsDerivationOf L := IsDerivationOf.definable.of_deltaOne +instance DerivationOf.definable' : Γ-[m + 1]-Relation[V] DerivationOf T := DerivationOf.definable.of_deltaOne -instance Derivable.defined : 𝚺₁-Predicate[V] (Derivable L) via derivable L := .mk fun v ↦ by simp [Derivable, derivable] +instance Derivable.defined : 𝚺₁-Predicate[V] Derivable T via derivable T := .mk fun v ↦ by simp [derivable, Derivable] -instance Derivable.definable : 𝚺₁-Predicate[V] (Derivable L) := Derivable.defined.to_definable +instance Derivable.definable : 𝚺₁-Predicate[V] Derivable T := Derivable.defined.to_definable /-- instance for definability tactic-/ -instance Derivable.definable' : 𝚺-[0 + 1]-Predicate[V] (Derivable L) := Derivable.definable - -/- +instance Derivable.definable' : 𝚺-[0 + 1]-Predicate[V] Derivable T := Derivable.definable -instance Proof.defined : 𝚫₁-Relation[V] T.Proof via T.proof := .mk - ⟨by intro v; simp [Theory.proof], by intro v; simp [Theory.Proof, Theory.proof, singleton_eq_insert, emptyset_def]⟩ +instance Proof.defined : 𝚫₁-Relation[V] Proof T via proof T := .mk + ⟨by intro v; simp [proof], by intro v; simp [Proof, proof, singleton_eq_insert, emptyset_def]⟩ -instance Proof.definable : 𝚫₁-Relation[V] T.Proof := Proof.defined.to_definable +instance Proof.definable : 𝚫₁-Relation[V] Proof T := Proof.defined.to_definable -instance Proof.definable' : Γ-[m + 1]-Relation[V] T.Proof := Proof.definable.of_deltaOne +instance Proof.definable' : Γ-[m + 1]-Relation[V] Proof T := Proof.definable.of_deltaOne -instance Provable.defined : 𝚺₁-Predicate[V] T.Provable via T.provable := .mk fun v ↦ by simp [Theory.provable, Theory.Provable] +instance Provable.defined : 𝚺₁-Predicate[V] Provable T via provable T := .mk fun v ↦ by simp [provable, Provable] -instance Provable.definable : 𝚺₁-Predicate[V] T.Provable := Provable.defined.to_definable +instance Provable.definable : 𝚺₁-Predicate[V] Provable T := Provable.defined.to_definable /-- instance for definability tactic-/ -instance Provable.definable' : 𝚺-[0 + 1]-Predicate[V] T.Provable := Provable.definable - --/ +instance Provable.definable' : 𝚺-[0 + 1]-Predicate[V] Provable T := Provable.definable end -/-! ### Induction and recursion of isDerivation -/ - -namespace IsDerivation +namespace Derivation lemma case_iff {d : V} : - IsDerivation L d ↔ + Derivation T d ↔ IsFormulaSet L (fstIdx d) ∧ - ( (∃ s p, d = Bootstrapping.identity s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ + ( (∃ s p, d = Bootstrapping.axL s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ (∃ s, d = verumIntro s ∧ ^⊤ ∈ s) ∨ - (∃ s p q dp dq, d = andIntro s p q dp dq ∧ p ^⋏ q ∈ s ∧ IsDerivationOf L dp (insert p s) ∧ IsDerivationOf L dq (insert q s)) ∨ - (∃ s p q dpq, d = orIntro s p q dpq ∧ p ^⋎ q ∈ s ∧ IsDerivationOf L dpq (insert p (insert q s))) ∨ - (∃ s p dp, d = allIntro s p dp ∧ ^∀ p ∈ s ∧ IsDerivationOf L dp (insert (free L p) (setShift L s))) ∨ - (∃ s p t dp, d = exsIntro s p t dp ∧ ^∃ p ∈ s ∧ IsTerm L t ∧ IsDerivationOf L dp (insert (substs1 L t p) s)) ∨ - (∃ s d', d = contraction s d' ∧ fstIdx d' ⊆ s ∧ IsDerivation L d') ∨ - (∃ s d', d = shiftRule s d' ∧ s = setShift L (fstIdx d') ∧ IsDerivation L d') ∨ - (∃ s p d₁ d₂, d = cutRule s p d₁ d₂ ∧ IsDerivationOf L d₁ (insert p s) ∧ IsDerivationOf L d₂ (insert (neg L p) s)) ) := - (construction L).case - -alias ⟨case, _root_.LO.FirstOrder.Theory.IsDerivation.mk⟩ := case_iff + (∃ s p q dp dq, d = andIntro s p q dp dq ∧ p ^⋏ q ∈ s ∧ DerivationOf T dp (insert p s) ∧ DerivationOf T dq (insert q s)) ∨ + (∃ s p q dpq, d = orIntro s p q dpq ∧ p ^⋎ q ∈ s ∧ DerivationOf T dpq (insert p (insert q s))) ∨ + (∃ s p dp, d = allIntro s p dp ∧ ^∀ p ∈ s ∧ DerivationOf T dp (insert (free L p) (setShift L s))) ∨ + (∃ s p t dp, d = exsIntro s p t dp ∧ ^∃ p ∈ s ∧ IsTerm L t ∧ DerivationOf T dp (insert (substs1 L t p) s)) ∨ + (∃ s d', d = wkRule s d' ∧ fstIdx d' ⊆ s ∧ Derivation T d') ∨ + (∃ s d', d = shiftRule s d' ∧ s = setShift L (fstIdx d') ∧ Derivation T d') ∨ + (∃ s p d₁ d₂, d = cutRule s p d₁ d₂ ∧ DerivationOf T d₁ (insert p s) ∧ DerivationOf T d₂ (insert (neg L p) s)) ∨ + (∃ s p, d = axm s p ∧ p ∈ s ∧ p ∈ T.Δ₁Class) ) := + (construction T).case + +alias ⟨case, _root_.LO.FirstOrder.Arithmetic.Bootstrapping.Derivation.mk⟩ := case_iff lemma induction1 (Γ) {P : V → Prop} (hP : Γ-[1]-Predicate P) - {d} (hd : IsDerivation L d) - (hAxL : ∀ s, IsFormulaSet L s → ∀ p ∈ s, neg L p ∈ s → P (identity s p)) + {d} (hd : Derivation T d) + (hAxL : ∀ s, IsFormulaSet L s → ∀ p ∈ s, neg L p ∈ s → P (axL s p)) (hVerumIntro : ∀ s, IsFormulaSet L s → ^⊤ ∈ s → P (verumIntro s)) - (hAnd : ∀ s, IsFormulaSet L s → ∀ p q dp dq, p ^⋏ q ∈ s → IsDerivationOf L dp (insert p s) → IsDerivationOf L dq (insert q s) → + (hAnd : ∀ s, IsFormulaSet L s → ∀ p q dp dq, p ^⋏ q ∈ s → DerivationOf T dp (insert p s) → DerivationOf T dq (insert q s) → P dp → P dq → P (andIntro s p q dp dq)) - (hOr : ∀ s, IsFormulaSet L s → ∀ p q d, p ^⋎ q ∈ s → IsDerivationOf L d (insert p (insert q s)) → + (hOr : ∀ s, IsFormulaSet L s → ∀ p q d, p ^⋎ q ∈ s → DerivationOf T d (insert p (insert q s)) → P d → P (orIntro s p q d)) - (hAll : ∀ s, IsFormulaSet L s → ∀ p d, ^∀ p ∈ s → IsDerivationOf L d (insert (free L p) (setShift L s)) → + (hAll : ∀ s, IsFormulaSet L s → ∀ p d, ^∀ p ∈ s → DerivationOf T d (insert (free L p) (setShift L s)) → P d → P (allIntro s p d)) - (hExs : ∀ s, IsFormulaSet L s → ∀ p t d, ^∃ p ∈ s → IsTerm L t → IsDerivationOf L d (insert (substs1 L t p) s) → + (hExs : ∀ s, IsFormulaSet L s → ∀ p t d, ^∃ p ∈ s → IsTerm L t → DerivationOf T d (insert (substs1 L t p) s) → P d → P (exsIntro s p t d)) - (hWk : ∀ s, IsFormulaSet L s → ∀ d, fstIdx d ⊆ s → IsDerivation L d → - P d → P (contraction s d)) - (hShift : ∀ s, IsFormulaSet L s → ∀ d, s = setShift L (fstIdx d) → IsDerivation L d → + (hWk : ∀ s, IsFormulaSet L s → ∀ d, fstIdx d ⊆ s → Derivation T d → + P d → P (wkRule s d)) + (hShift : ∀ s, IsFormulaSet L s → ∀ d, s = setShift L (fstIdx d) → Derivation T d → P d → P (shiftRule s d)) - (hCut : ∀ s, IsFormulaSet L s → ∀ p d₁ d₂, IsDerivationOf L d₁ (insert p s) → IsDerivationOf L d₂ (insert (neg L p) s) → - P d₁ → P d₂ → P (cutRule s p d₁ d₂)) : P d := - (construction L).induction (v := ![]) hP (by + (hCut : ∀ s, IsFormulaSet L s → ∀ p d₁ d₂, DerivationOf T d₁ (insert p s) → DerivationOf T d₂ (insert (neg L p) s) → + P d₁ → P d₂ → P (cutRule s p d₁ d₂)) + (hRoot : ∀ s, IsFormulaSet L s → ∀ p, p ∈ s → p ∈ T.Δ₁Class → P (axm s p)) : P d := + (construction T).induction (v := ![]) hP (by intro C ih d hd rcases hd with ⟨hds, (⟨s, p, rfl, hps, hnps⟩ | ⟨s, rfl, hs⟩ | ⟨s, p, q, dp, dq, rfl, hpq, h₁, h₂⟩ | ⟨s, p, q, d, rfl, hpq, h⟩ | ⟨s, p, d, rfl, hp, h, hC⟩ | ⟨s, p, t, d, rfl, hp, ht, h, hC⟩ | ⟨s, d, rfl, h, hC⟩ | ⟨s, d, rfl, h, hC⟩ | - ⟨s, p, d₁, d₂, rfl, ⟨h₁, hC₁⟩, ⟨h₂, hC₂⟩⟩)⟩ + ⟨s, p, d₁, d₂, rfl, ⟨h₁, hC₁⟩, ⟨h₂, hC₂⟩⟩ | ⟨s, p, rfl, hs, hT⟩)⟩ · exact hAxL s (by simpa using hds) p hps hnps · exact hVerumIntro s (by simpa using hds) hs · exact hAnd s (by simpa using hds) p q dp dq hpq ⟨h₁.1, (ih dp h₁.2).1⟩ ⟨h₂.1, (ih dq h₂.2).1⟩ (ih dp h₁.2).2 (ih dq h₂.2).2 @@ -588,153 +583,191 @@ lemma induction1 (Γ) {P : V → Prop} (hP : Γ-[1]-Predicate P) · exact hExs s (by simpa using hds) p t d hp ht ⟨h, (ih d hC).1⟩ (ih d hC).2 · exact hWk s (by simpa using hds) d h (ih d hC).1 (ih d hC).2 · exact hShift s (by simpa using hds) d h (ih d hC).1 (ih d hC).2 - · exact hCut s (by simpa using hds) p d₁ d₂ ⟨h₁, (ih d₁ hC₁).1⟩ ⟨h₂, (ih d₂ hC₂).1⟩ (ih d₁ hC₁).2 (ih d₂ hC₂).2) - d hd + · exact hCut s (by simpa using hds) p d₁ d₂ ⟨h₁, (ih d₁ hC₁).1⟩ ⟨h₂, (ih d₂ hC₂).1⟩ (ih d₁ hC₁).2 (ih d₂ hC₂).2 + · exact hRoot s (by simpa using hds) p hs hT) d hd -lemma isFormulaSet {d : V} (h : IsDerivation L d) : IsFormulaSet L (fstIdx d) := (h : IsDerivation L d).case.1 +lemma isFormulaSet {d : V} (h : Derivation T d) : IsFormulaSet L (fstIdx d) := (h : Derivation T d).case.1 -lemma _root_.LO.FirstOrder.Arithmetic.Bootstrapping.IsDerivationOf.isFormulaSet {d s : V} (h : IsDerivationOf L d s) : IsFormulaSet L s := by +lemma _root_.LO.FirstOrder.Arithmetic.Bootstrapping.DerivationOf.isFormulaSet {d s : V} (h : DerivationOf T d s) : IsFormulaSet L s := by simpa [h.1] using h.2.case.1 -lemma identity {s p : V} (hs : IsFormulaSet L s) (h : p ∈ s) (hn : neg L p ∈ s) : IsDerivation L (identity s p) := - Theory.IsDerivation.mk ⟨by simpa using hs, Or.inl ⟨s, p, rfl, h, hn⟩⟩ +lemma axL {s p : V} (hs : IsFormulaSet L s) (h : p ∈ s) (hn : neg L p ∈ s) : Derivation T (axL s p) := + Bootstrapping.Derivation.mk ⟨by simpa using hs, Or.inl ⟨s, p, rfl, h, hn⟩⟩ lemma verumIntro {s : V} (hs : IsFormulaSet L s) (h : ^⊤ ∈ s) : - IsDerivation L (verumIntro s) := - Theory.IsDerivation.mk ⟨by simpa using hs, Or.inr <| Or.inl ⟨s, rfl, h⟩⟩ + Derivation T (verumIntro s) := + Bootstrapping.Derivation.mk ⟨by simpa using hs, Or.inr <| Or.inl ⟨s, rfl, h⟩⟩ lemma andIntro {s p q dp dq : V} (h : p ^⋏ q ∈ s) - (hdp : IsDerivationOf L dp (insert p s)) (hdq : IsDerivationOf L dq (insert q s)) : - IsDerivation L (andIntro s p q dp dq) := - Theory.IsDerivation.mk ⟨by simp only [fstIdx_andIntro]; intro r hr; exact hdp.isFormulaSet r (by simp [hr]), + (hdp : DerivationOf T dp (insert p s)) (hdq : DerivationOf T dq (insert q s)) : + Derivation T (andIntro s p q dp dq) := + Bootstrapping.Derivation.mk ⟨by simp only [fstIdx_andIntro]; intro r hr; exact hdp.isFormulaSet r (by simp [hr]), Or.inr <| Or.inr <| Or.inl ⟨s, p, q, dp, dq, rfl, h, hdp, hdq⟩⟩ lemma orIntro {s p q dpq : V} (h : p ^⋎ q ∈ s) - (hdpq : IsDerivationOf L dpq (insert p (insert q s))) : - IsDerivation L (orIntro s p q dpq) := - Theory.IsDerivation.mk ⟨by simp only [fstIdx_orIntro]; intro r hr; exact hdpq.isFormulaSet r (by simp [hr]), + (hdpq : DerivationOf T dpq (insert p (insert q s))) : + Derivation T (orIntro s p q dpq) := + Bootstrapping.Derivation.mk ⟨by simp only [fstIdx_orIntro]; intro r hr; exact hdpq.isFormulaSet r (by simp [hr]), Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, q, dpq, rfl, h, hdpq⟩⟩ lemma allIntro {s p dp : V} (h : ^∀ p ∈ s) - (hdp : IsDerivationOf L dp (insert (free L p) (setShift L s))) : - IsDerivation L (allIntro s p dp) := - Theory.IsDerivation.mk + (hdp : DerivationOf T dp (insert (free L p) (setShift L s))) : + Derivation T (allIntro s p dp) := + Bootstrapping.Derivation.mk ⟨by simp only [fstIdx_allIntro]; intro q hq; simpa using hdp.isFormulaSet (shift L q) (by simp [shift_mem_setShift hq]), Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, dp, rfl, h, hdp⟩⟩ lemma exsIntro {s p t dp : V} (h : ^∃ p ∈ s) (ht : IsTerm L t) - (hdp : IsDerivationOf L dp (insert (substs1 L t p) s)) : - IsDerivation L (exsIntro s p t dp) := - Theory.IsDerivation.mk + (hdp : DerivationOf T dp (insert (substs1 L t p) s)) : + Derivation T (exsIntro s p t dp) := + Bootstrapping.Derivation.mk ⟨by simp only [fstIdx_exsIntro]; intro q hq; exact hdp.isFormulaSet q (by simp [hq]), Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, t, dp, rfl, h, ht, hdp⟩⟩ -lemma contraction {s s' d : V} (hs : IsFormulaSet L s) - (h : s' ⊆ s) (hd : IsDerivationOf L d s') : IsDerivation L (contraction s d) := - Theory.IsDerivation.mk +lemma wkRule {s s' d : V} (hs : IsFormulaSet L s) + (h : s' ⊆ s) (hd : DerivationOf T d s') : Derivation T (wkRule s d) := + Bootstrapping.Derivation.mk ⟨by simpa using hs, Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, d, rfl, by simp [hd.1, h], hd.2⟩⟩ lemma shiftRule {s d : V} - (hd : IsDerivationOf L d s) : IsDerivation L (shiftRule (setShift L s) d) := - Theory.IsDerivation.mk + (hd : DerivationOf T d s) : Derivation T (shiftRule (setShift L s) d) := + Bootstrapping.Derivation.mk ⟨by simp [hd.isFormulaSet], Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨setShift L s, d, rfl, by simp [hd.1], hd.2⟩⟩ lemma cutRule {s p d₁ d₂ : V} - (hd₁ : IsDerivationOf L d₁ (insert p s)) - (hd₂ : IsDerivationOf L d₂ (insert (neg L p) s)) : - IsDerivation L (cutRule s p d₁ d₂) := - Theory.IsDerivation.mk + (hd₁ : DerivationOf T d₁ (insert p s)) + (hd₂ : DerivationOf T d₂ (insert (neg L p) s)) : + Derivation T (cutRule s p d₁ d₂) := + Bootstrapping.Derivation.mk ⟨by simp only [fstIdx_cutRule]; intro q hq; exact hd₁.isFormulaSet q (by simp [hq]), - Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr ⟨s, p, d₁, d₂, rfl, hd₁, hd₂⟩⟩ + Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, d₁, d₂, rfl, hd₁, hd₂⟩⟩ -end IsDerivation +lemma axm {s p : V} (hs : IsFormulaSet L s) (hp : p ∈ s) (hT : p ∈ T.Δ₁Class) : + Derivation T (axm s p) := + Bootstrapping.Derivation.mk + ⟨by simpa using hs, + Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr ⟨s, p, rfl, hp, hT⟩⟩ + +variable {U : Theory L} [U.Δ₁] + +lemma of_ss (h : T.Δ₁Class (V := V) ⊆ U.Δ₁Class) {d : V} : Derivation T d → Derivation U d := by + intro hd + apply Bootstrapping.Derivation.induction1 𝚺 ?_ hd + · intro s hs p hp hn; apply Derivation.axL hs hp hn + · intro s hs hv; apply Derivation.verumIntro hs hv + · intro s _ p q dp dq hpq hdp hdq ihp ihq + apply Derivation.andIntro hpq ⟨hdp.1, ihp⟩ ⟨hdq.1, ihq⟩ + · intro s _ p q d hpq hd ih + apply Derivation.orIntro hpq ⟨hd.1, ih⟩ + · intro s _ p d hp hd ih + apply Derivation.allIntro hp ⟨hd.1, ih⟩ + · intro s _ p t d hp ht hd ih + apply Derivation.exsIntro hp ht ⟨hd.1, ih⟩ + · intro s hs d h _ ih + apply Derivation.wkRule hs h ⟨rfl, ih⟩ + · rintro s hs d rfl _ ih + apply Derivation.shiftRule ⟨rfl, ih⟩ + · intro s _ p d₁ d₂ h₁ h₂ ih₁ ih₂ + apply Derivation.cutRule ⟨h₁.1, ih₁⟩ ⟨h₂.1, ih₂⟩ + · intro s hs p hps hpT + apply Derivation.axm hs hps (h hpT) + · definability + +end Derivation namespace Derivable -lemma isFormulaSet {s : V} (h : Derivable L s) : IsFormulaSet L s := by +lemma isFormulaSet {s : V} (h : Derivable T s) : IsFormulaSet L s := by rcases h with ⟨d, hd⟩; exact hd.isFormulaSet lemma em {s : V} (hs : IsFormulaSet L s) (p) (h : p ∈ s) (hn : neg L p ∈ s) : - Derivable L s := ⟨identity s p, by simp, IsDerivation.identity hs h hn⟩ + Derivable T s := ⟨axL s p, by simp, Derivation.axL hs h hn⟩ lemma verum {s : V} (hs : IsFormulaSet L s) (h : ^⊤ ∈ s) : - Derivable L s := ⟨verumIntro s, by simp, IsDerivation.verumIntro hs h⟩ + Derivable T s := ⟨verumIntro s, by simp, Derivation.verumIntro hs h⟩ -lemma and_m {s p q : V} (h : p ^⋏ q ∈ s) (hp : Derivable L (insert p s)) (hq : Derivable L (insert q s)) : - Derivable L s := by +lemma and_m {s p q : V} (h : p ^⋏ q ∈ s) (hp : Derivable T (insert p s)) (hq : Derivable T (insert q s)) : + Derivable T s := by rcases hp with ⟨dp, hdp⟩; rcases hq with ⟨dq, hdq⟩ - exact ⟨andIntro s p q dp dq, by simp, IsDerivation.andIntro h hdp hdq⟩ + exact ⟨andIntro s p q dp dq, by simp, Derivation.andIntro h hdp hdq⟩ -lemma or_m {s p q : V} (h : p ^⋎ q ∈ s) (hpq : Derivable L (insert p (insert q s))) : - Derivable L s := by +lemma or_m {s p q : V} (h : p ^⋎ q ∈ s) (hpq : Derivable T (insert p (insert q s))) : + Derivable T s := by rcases hpq with ⟨dpq, hdpq⟩ - exact ⟨orIntro s p q dpq, by simp, IsDerivation.orIntro h hdpq⟩ + exact ⟨orIntro s p q dpq, by simp, Derivation.orIntro h hdpq⟩ -lemma all_m {s p : V} (h : ^∀ p ∈ s) (hp : Derivable L (insert (free L p) (setShift L s))) : - Derivable L s := by +lemma all_m {s p : V} (h : ^∀ p ∈ s) (hp : Derivable T (insert (free L p) (setShift L s))) : + Derivable T s := by rcases hp with ⟨dp, hdp⟩ - exact ⟨allIntro s p dp, by simp, IsDerivation.allIntro h hdp⟩ + exact ⟨allIntro s p dp, by simp, Derivation.allIntro h hdp⟩ -lemma ex_m {s p t : V} (h : ^∃ p ∈ s) (ht : IsTerm L t) (hp : Derivable L (insert (substs1 L t p) s)) : - Derivable L s := by +lemma ex_m {s p t : V} (h : ^∃ p ∈ s) (ht : IsTerm L t) (hp : Derivable T (insert (substs1 L t p) s)) : + Derivable T s := by rcases hp with ⟨dp, hdp⟩ - exact ⟨exsIntro s p t dp, by simp, IsDerivation.exsIntro h ht hdp⟩ + exact ⟨exsIntro s p t dp, by simp, Derivation.exsIntro h ht hdp⟩ -lemma wk {s s' : V} (hs : IsFormulaSet L s) (h : s' ⊆ s) (hd : Derivable L s') : - Derivable L s := by +lemma wk {s s' : V} (hs : IsFormulaSet L s) (h : s' ⊆ s) (hd : Derivable T s') : + Derivable T s := by rcases hd with ⟨d, hd⟩ - exact ⟨contraction s d, by simp, IsDerivation.contraction hs h hd⟩ + exact ⟨wkRule s d, by simp, Derivation.wkRule hs h hd⟩ -lemma shift {s : V} (hd : Derivable L s) : - Derivable L (setShift L s) := by +lemma shift {s : V} (hd : Derivable T s) : + Derivable T (setShift L s) := by rcases hd with ⟨d, hd⟩ - exact ⟨shiftRule (setShift L s) d, by simp, IsDerivation.shiftRule hd⟩ + exact ⟨shiftRule (setShift L s) d, by simp, Derivation.shiftRule hd⟩ -lemma ofSetEq {s s' : V} (h : ∀ x, x ∈ s' ↔ x ∈ s) (hd : Derivable L s') : - Derivable L s := by +lemma ofSetEq {s s' : V} (h : ∀ x, x ∈ s' ↔ x ∈ s) (hd : Derivable T s') : + Derivable T s := by have : s' = s := mem_ext h rcases this; exact hd -lemma exchange {s p q : V} (h : Derivable L (insert p <| insert q s)) : - Derivable L (insert q <| insert p s) := h.ofSetEq (fun x ↦ by simp; tauto) +lemma exchange {s p q : V} (h : Derivable T (insert p <| insert q s)) : + Derivable T (insert q <| insert p s) := h.ofSetEq (fun x ↦ by simp; tauto) -lemma cut {s : V} (p) (hd₁ : Derivable L (insert p s)) (hd₂ : Derivable L (insert (neg L p) s)) : - Derivable L s := by +lemma cut {s : V} (p) (hd₁ : Derivable T (insert p s)) (hd₂ : Derivable T (insert (neg L p) s)) : + Derivable T s := by rcases hd₁ with ⟨d₁, hd₁⟩; rcases hd₂ with ⟨d₂, hd₂⟩ - exact ⟨cutRule s p d₁ d₂, by simp, IsDerivation.cutRule hd₁ hd₂⟩ + exact ⟨cutRule s p d₁ d₂, by simp, Derivation.cutRule hd₁ hd₂⟩ + +lemma by_axm {s : V} (hs : IsFormulaSet L s) (p) (hp : p ∈ s) (hT : p ∈ T.Δ₁Class) : + Derivable T s := by + exact ⟨Bootstrapping.axm s p, by simp, Derivation.axm hs hp hT⟩ -lemma and {s p q : V} (hp : Derivable L (insert p s)) (hq : Derivable L (insert q s)) : - Derivable L (insert (p ^⋏ q) s) := +lemma of_ss (h : T.Δ₁Class (V := V) ⊆ U.Δ₁Class) {s : V} : Derivable T s → Derivable U s := by + rintro ⟨d, hd⟩; exact ⟨d, hd.1, hd.2.of_ss h⟩ + +lemma and {s p q : V} (hp : Derivable T (insert p s)) (hq : Derivable T (insert q s)) : + Derivable T (insert (p ^⋏ q) s) := and_m (p := p) (q := q) (by simp) (wk (by simp [hp.isFormulaSet.insert, hq.isFormulaSet.insert]) (insert_subset_insert_of_subset _ <| by simp) hp) (wk (by simp [hp.isFormulaSet.insert, hq.isFormulaSet.insert]) (insert_subset_insert_of_subset _ <| by simp) hq) -lemma or {s p q : V} (hpq : Derivable L (insert p (insert q s))) : - Derivable L (insert (p ^⋎ q) s) := +lemma or {s p q : V} (hpq : Derivable T (insert p (insert q s))) : + Derivable T (insert (p ^⋎ q) s) := or_m (p := p) (q := q) (by simp) (wk (by simp [hpq.isFormulaSet.insert, hpq.isFormulaSet.insert.2.insert]) (insert_subset_insert_of_subset _ <| insert_subset_insert_of_subset _ <| by simp) hpq) /-- Crucial inducion for formalized $\Sigma_1$-completeness. -/ lemma conj (ps : V) {s : V} (hs : IsFormulaSet L s) - (ds : ∀ i < len ps, Derivable L (insert ps.[i] s)) : Derivable L (insert (^⋀ ps) s) := by - have : ∀ k ≤ len ps, Derivable L (insert (^⋀ (takeLast ps k)) s) := by + (ds : ∀ i < len ps, Derivable T (insert ps.[i] s)) : Derivable T (insert (^⋀ ps) s) := by + have : ∀ k ≤ len ps, Derivable T (insert (^⋀ (takeLast ps k)) s) := by intro k hk induction k using ISigma1.sigma1_succ_induction · definability case zero => simpa using verum (by simp [hs]) (by simp) case succ k ih => - have ih : Derivable L (insert (^⋀ takeLast ps k) s) := ih (le_trans le_self_add hk) - have : Derivable L (insert ps.[len ps - (k + 1)] s) := ds (len ps - (k + 1)) ((tsub_lt_iff_left hk).mpr (by simp)) + have ih : Derivable T (insert (^⋀ takeLast ps k) s) := ih (le_trans le_self_add hk) + have : Derivable T (insert ps.[len ps - (k + 1)] s) := ds (len ps - (k + 1)) ((tsub_lt_iff_left hk).mpr (by simp)) simpa [takeLast_succ_of_lt (succ_le_iff_lt.mp hk)] using this.and ih simpa using this (len ps) (by rfl) -lemma disjDistr (ps s : V) (d : Derivable L (vecToSet ps ∪ s)) : Derivable L (insert (^⋁ ps) s) := by +lemma disjDistr (ps s : V) (d : Derivable T (vecToSet ps ∪ s)) : Derivable T (insert (^⋁ ps) s) := by have : ∀ k ≤ len ps, ∀ s' ≤ vecToSet ps, s' ⊆ vecToSet ps → - (∀ i < len ps - k, ps.[i] ∈ s') → Derivable L (insert (^⋁ takeLast ps k) (s' ∪ s)) := by + (∀ i < len ps - k, ps.[i] ∈ s') → Derivable T (insert (^⋁ takeLast ps k) (s' ∪ s)) := by intro k hk induction k using ISigma1.sigma1_succ_induction · apply HierarchySymbol.Definable.imp (by definability) @@ -763,7 +796,7 @@ lemma disjDistr (ps s : V) (d : Derivable L (vecToSet ps ∪ s)) : Derivable L ( rintro (rfl | h) · exact mem_vecToSet_iff.mpr ⟨_, by simp [tsub_lt_iff_left hk], rfl⟩ · exact ss h - have : Derivable L (insert (^⋁ takeLast ps k) (s'' ∪ s)) := by + have : Derivable T (insert (^⋁ takeLast ps k) (s'' ∪ s)) := by refine ih (le_trans (by simp) hk) s'' (le_of_subset hs'') hs'' ?_ intro i hi have : i ≤ len ps - (k + 1) := by @@ -775,7 +808,7 @@ lemma disjDistr (ps s : V) (d : Derivable L (vecToSet ps ∪ s)) : Derivable L ( simpa using this (len ps) (by rfl) ∅ (by simp [emptyset_def]) (by simp) (by simp) lemma disj (ps s : V) {i} (hps : ∀ i < len ps, IsFormula L ps.[i]) - (hi : i < len ps) (d : Derivable L (insert ps.[i] s)) : Derivable L (insert (^⋁ ps) s) := + (hi : i < len ps) (d : Derivable T (insert ps.[i] s)) : Derivable T (insert (^⋁ ps) s) := disjDistr ps s <| wk (by suffices IsFormulaSet L (vecToSet ps) by simpa [by simpa using d.isFormulaSet] intro x hx; rcases mem_vecToSet_iff.mp hx with ⟨i, hi, rfl⟩; exact hps i hi) @@ -785,125 +818,34 @@ lemma disj (ps s : V) {i} (hps : ∀ i < len ps, IsFormula L ps.[i]) · left; exact mem_vecToSet_iff.mpr ⟨i, hi, rfl⟩ · right; exact hx) d -lemma all {p s : V} (hp : IsSemiformula L 1 p) (dp : Derivable L (insert (free L p) (setShift L s))) : Derivable L (insert (^∀ p) s) := +lemma all {p s : V} (hp : IsSemiformula L 1 p) (dp : Derivable T (insert (free L p) (setShift L s))) : Derivable T (insert (^∀ p) s) := all_m (p := p) (by simp) (wk (by simp [hp, by simpa using dp.isFormulaSet]) (by intro x; simp; tauto) dp) lemma exs {p t s : V} (hp : IsSemiformula L 1 p) (ht : IsTerm L t) - (dp : Derivable L (insert (substs1 L t p) s)) : Derivable L (insert (^∃ p) s) := + (dp : Derivable T (insert (substs1 L t p) s)) : Derivable T (insert (^∃ p) s) := ex_m (p := p) (by simp) ht <| wk (by simp [hp, by simpa using dp.isFormulaSet]) (by intro x; simp; tauto) dp end Derivable -/-! ## Proof with axiom -/ - -variable (T : Theory L) [T.Δ₁] - -def IsProof (d φ : V) : Prop := (∀ x ∈ pi₁ d, x ∈ T.Δ₁Class) ∧ IsDerivationOf L (pi₂ d) (insert φ (setNeg L (pi₁ d))) - -def Provable (φ : V) : Prop := ∃ d, IsProof T d φ - -variable {T} - -lemma provable_iff_derivable {φ : V} : Provable T φ ↔ ∃ s : V, (∀ x ∈ s, x ∈ T.Δ₁Class) ∧ Derivable L (insert φ (setNeg L s)) := by - constructor - · rintro ⟨d, hT, hd⟩ - exact ⟨pi₁ d, hT, pi₂ d, hd⟩ - · rintro ⟨s, hT, d, hd⟩ - exact ⟨⟪s, d⟫, by simpa [IsProof] using And.intro hT hd⟩ - - -alias ⟨Provable.toDerivable, Derivable.toProvable⟩ := provable_iff_derivable - -variable (T) - -noncomputable def isProof : 𝚫₁.Semisentence 2 := .mkDelta - (.mkSigma “p φ. - ∃ s d, !pairDef p s d ∧ (∀ x ∈' s, !T.Δ₁ch.sigma x) ∧ - ∃ ns, !(setNegGraph L) ns s ∧ - ∃ ins, !insertDef ins φ ns ∧ !(isDerivationOf L).sigma d ins”) - (.mkPi “p φ. - ∀ s d, !pairDef p s d → (∀ x ∈' s, !T.Δ₁ch.pi x) ∧ - ∀ ns, !(setNegGraph L) ns s → - ∀ ins, !insertDef ins φ ns → !(isDerivationOf L).pi d ins”) - -set_option linter.flexible false in instance IsProof.defined : 𝚫₁-Relation[V] (IsProof T) via isProof T := ⟨fun x ↦ by - simp [isProof]; +lemma internal_provable_iff_internal_derivable {φ : V} : Provable T φ ↔ Derivable T (insert φ ∅ : V) := by constructor - · intro ⟨x, y, e, h⟩ x y e2 - simp [e] at e2 - rcases e2 with ⟨rfl, rfl⟩ - simpa - · intro h - refine ⟨pi₁ (x 0), pi₂ (x 0), by simp, ?_⟩ - grind, - .of_vec_two fun x y ↦ by - simp [isProof] - constructor - · rintro ⟨x, y, rfl, h⟩ - simpa [IsProof] - · rintro h - refine ⟨pi₁ x, pi₂ x, by simp, by simpa [IsProof]⟩⟩ - -instance IsProof.definable : 𝚫₁-Relation[V] (IsProof T) := (IsProof.defined T).to_definable - -instance IsProof.definable' : Γ-[m + 1]-Relation[V] (IsProof T) := (IsProof.definable T).of_deltaOne - -noncomputable def provable : 𝚺₁.Semisentence 1 := .mkSigma “φ. ∃ d, !(isProof T).sigma d φ” + · rintro ⟨b, hb⟩ + exact ⟨b, by simpa using hb⟩ + · rintro ⟨b, hb⟩ + exact ⟨b, by simpa using hb⟩ -instance Provable.defined : 𝚺₁-Predicate[V] (Provable T) via provable T := .mk fun v ↦ by simp [provable, Provable] - -instance Provable.definable : 𝚺₁-Predicate[V] (Provable T) := (Provable.defined T).to_definable - -instance Provable.definable' : 𝚺-[0 + 1]-Predicate[V] (Provable T) := Provable.definable T +alias ⟨Provable.toDerivable, Derivable.toProvable⟩ := internal_provable_iff_internal_derivable namespace Provable -lemma exists_common_axiom_set {ps : V} (ds : ∀ i < len ps, Provable T ps.[i]) : - ∃ s : V, (∀ x ∈ s, x ∈ T.Δ₁Class) ∧ IsFormulaSet L (setNeg L s) ∧ - ∀ i < len ps, Derivable L (insert ps.[i] (setNeg L s)) := by - have : ∀ i ∈ under (len ps), ∃ s : V, (∀ x ∈ s, x ∈ T.Δ₁Class) ∧ Derivable L (insert ps.[i] (setNeg L s)) := by - simpa [provable_iff_derivable] using ds - let ⟨f, hf, fdom, H⟩ := sigmaOne_skolem (by definability) this - let s := ⋃ʰᶠ range f - have hs : IsFormulaSet L (setNeg L s) := by - intro φ hφ - rcases mem_setNeg_iff.mp hφ with ⟨p, hp, rfl⟩ - have : ∃ s_i, (∃ i, ⟪i, s_i⟫ ∈ f) ∧ p ∈ s_i := by simpa [s, mem_range_iff] using hp - rcases this with ⟨s_i, ⟨i, hi⟩, hp⟩ - exact (H i s_i hi).2.isFormulaSet (neg L p) (by simp [neg_mem_setNeg hp]) - refine ⟨s, ?_, hs, ?_⟩ - · intro φ hφ - have : ∃ s_i, (∃ i, ⟪i, s_i⟫ ∈ f) ∧ φ ∈ s_i := by simpa [s, mem_range_iff] using hφ - rcases this with ⟨s_i, ⟨i, hi⟩, hφ⟩ - exact (H i s_i hi).1 φ hφ - · intro i hi - have hidom : i ∈ domain f := by simpa [fdom] using hi - rcases mem_domain_iff.mp hidom with ⟨s_i, hi⟩ - refine Derivable.wk ?_ ?_ (H i s_i hi).2 - · intro φ hφ - simp only [mem_bitInsert_iff] at hφ - rcases hφ with rfl | hφ - · exact (H i s_i hi).2.isFormulaSet ps.[i] (by simp) - · exact hs φ hφ - · intro φ - simp only [mem_bitInsert_iff] - rintro (rfl | hφ) - · simp - · right - exact setNeg_subset_of_subset (by intro p hp; exact mem_sUnion_iff.mpr ⟨s_i, mem_range_iff.mpr ⟨i, hi⟩, hp⟩) hφ - lemma conj (ps : V) - (ds : ∀ i < len ps, Provable T ps.[i]) : Provable T (^⋀ ps) := by - rcases exists_common_axiom_set (T := T) (ps := ps) ds with ⟨s, hT, hs, hds⟩ - exact Derivable.toProvable ⟨s, hT, Derivable.conj ps hs hds⟩ + (ds : ∀ i < len ps, Provable T ps.[i]) : Provable T (^⋀ ps) := + Derivable.toProvable <| Derivable.conj _ (by simp) fun i hi ↦ (ds i hi).toDerivable lemma disj (ps : V) {i} (hps : ∀ i < len ps, IsFormula L ps.[i]) (hi : i < len ps) (d : Provable T ps.[i]) : Provable T (^⋁ ps) := - let ⟨s, hT, d⟩ := d.toDerivable - Derivable.toProvable ⟨s, hT, Derivable.disj _ _ hps hi d⟩ + Derivable.toProvable <| Derivable.disj _ _ hps hi d.toDerivable end Provable -end FirstOrder.Arithmetic.Bootstrapping - -end LO +end LO.FirstOrder.Arithmetic.Bootstrapping diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean index 42051c1c5..8de393fd3 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean @@ -18,8 +18,6 @@ namespace Derivation2 variable (V) -def cast [L.DecidableEq] {T : Theory L} {Γ Δ : Finset (Proposition L)} (d : T ⟹₂ Γ) (h : Γ = Δ) : T ⟹₂ Δ := h ▸ d - noncomputable def Sequent.quote (Γ : Finset (Proposition L)) : V := ∑ φ ∈ Γ, Exp.exp (⌜φ⌝ : V) noncomputable instance : GödelQuote (Finset (Proposition L)) V := ⟨Sequent.quote V⟩ @@ -160,11 +158,10 @@ variable (V) noncomputable def typedQuote {Γ : Finset (Proposition L)} : T ⟹₂ Γ → T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝ | closed Δ φ h hn => TDerivation.em ⌜φ⌝ (by simpa) (by simpa using Sequent.quote_mem_quote.mpr hn) - | axm φ hT _ => TDerivation.byAxm ⌜φ⌝ (by - have : ∃ σ ∈ T, ↑σ = φ := by simpa [Theory.toSchema] using hT - rcases this with ⟨σ, hT', rfl⟩ + | axm φ hT hΓ => TDerivation.byAxm ⌜φ⌝ (by simp only [tmem, internalize_theory] - apply (Δ₁Class.mem_iff'' (T := T) (φ := σ)).mpr hT') (by simpa) + exact (Δ₁Class.mem_iff'' (T := T) (φ := φ)).mpr hT) (by + simpa using Sequent.quote_mem_quote.mpr hΓ) | verum h => TDerivation.verum (by simpa using Sequent.quote_mem_quote.mpr h) | and (φ := φ) (ψ := ψ) h bp bq => TDerivation.and' (show ⌜φ⌝ ⋏ ⌜ψ⌝ ∈ ⌜Γ⌝ by simpa using Sequent.quote_mem_quote.mpr h) (bp.typedQuote.cast (by simp)) (bq.typedQuote.cast (by simp)) @@ -183,15 +180,15 @@ noncomputable instance (Γ : Finset (Proposition L)) : GödelQuote (T ⟹₂ Γ) noncomputable instance (Γ : Finset (Proposition L)) : GödelQuote (T ⟹₂ Γ) V := ⟨fun d ↦ (⌜d⌝ : T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝).val⟩ -lemma quote_def (d : (T : Schema L) ⟹₂ Γ) : (⌜d⌝ : V) = (⌜d⌝ : T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝).val := rfl +lemma quote_def (d : T ⟹₂ Γ) : (⌜d⌝ : V) = (⌜d⌝ : T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝).val := rfl set_option backward.isDefEq.respectTransparency false in -lemma coe_typedQuote_val_eq (d : (T : Schema L) ⟹₂ Γ) : ↑(d.typedQuote ℕ).val = (d.typedQuote V).val := +lemma coe_typedQuote_val_eq (d : T ⟹₂ Γ) : ↑(d.typedQuote ℕ).val = (d.typedQuote V).val := match d with | closed Δ φ h hn => by simp [typedQuote, axL, nat_cast_pair, Sequent.coe_eq, Semiformula.coe_quote_eq_quote'] | axm φ hT _ => by - simp [typedQuote, Bootstrapping.axm, nat_cast_pair, Sequent.coe_eq, Semiformula.coe_quote_eq_quote'] + simpa [typedQuote, Bootstrapping.axm, nat_cast_pair, Sequent.coe_eq] using Sentence.coe_quote_eq_quote (V := V) φ | verum h => by simp [typedQuote, Bootstrapping.verumIntro, nat_cast_pair, Sequent.coe_eq] | and h b₁ b₂ => by @@ -216,38 +213,40 @@ lemma coe_typedQuote_val_eq (d : (T : Schema L) ⟹₂ Γ) : ↑(d.typedQuote simp [typedQuote, Bootstrapping.cutRule, nat_cast_pair, Sequent.coe_eq, Semiformula.coe_quote_eq_quote', b₁.coe_typedQuote_val_eq, b₂.coe_typedQuote_val_eq] -lemma coe_quote_eq (d : (T : Schema L) ⟹₂ Γ) : (↑(⌜d⌝ : ℕ) : V) = ⌜d⌝ := coe_typedQuote_val_eq V d +lemma coe_quote_eq (d : T ⟹₂ Γ) : (↑(⌜d⌝ : ℕ) : V) = ⌜d⌝ := coe_typedQuote_val_eq V d end Derivation2 -noncomputable instance (Γ : Sequent L) : GödelQuote ((T : Schema L) ⟹ Γ) V := ⟨fun b ↦ ⌜Derivation.toDerivation2 (T : Schema L) b⌝⟩ +noncomputable instance (Γ : Sequent L) : GödelQuote (⊢ᴸᴷ¹ Γ) V := ⟨fun b ↦ ⌜Derivation.toDerivation2 (∅ : Theory L) b⌝⟩ noncomputable instance (φ : Sentence L) : GödelQuote (T ⊢! φ) V := ⟨fun b ↦ - let b : (T : Schema L) ⟹ [↑φ] := b - ⌜b⌝⟩ + ⌜b.toProof2⌝⟩ -lemma quote_derivation_def {Γ : Sequent L} (b : (T : Schema L) ⟹ Γ) : (⌜b⌝ : V) = ⌜Derivation.toDerivation2 (T : Schema L) b⌝ := rfl +lemma quote_derivation_def {Γ : Sequent L} (b : ⊢ᴸᴷ¹ Γ) : (⌜b⌝ : V) = ⌜Derivation.toDerivation2 (∅ : Theory L) b⌝ := rfl -lemma quote_proof_def {φ : Sentence L} (b : T ⊢! φ) : (⌜b⌝ : V) = ⌜Derivation.toDerivation2 (T : Schema L) b⌝ := rfl +lemma quote_proof_def {φ : Sentence L} (b : T ⊢! φ) : (⌜b⌝ : V) = ⌜b.toProof2⌝ := rfl -@[simp] lemma derivation_of_quote_derivation {Γ : Sequent L} (b : (T : Schema L) ⟹ Γ) : T.DerivationOf (⌜b⌝ : V) ⌜Γ.toFinset⌝ := by - let x := Derivation2.typedQuote V (Derivation.toDerivation2 (T : Schema L) b) - suffices T.DerivationOf x.val ⌜List.toFinset Γ⌝ from this - simpa using x.derivationOf +@[simp] lemma derivation_of_quote_derivation {Γ : Sequent L} (b : ⊢ᴸᴷ¹ Γ) : DerivationOf T (⌜b⌝ : V) ⌜Γ.toFinset⌝ := by + let x := Derivation2.typedQuote V (Derivation.toDerivation2 (∅ : Theory L) b) + suffices DerivationOf T x.val ⌜List.toFinset Γ⌝ from this + exact ⟨x.derivationOf.1, x.derivationOf.2.of_ss (by + intro p hp + change V ⊧/![p] (⊥ : 𝚫₁.Semisentence 1).val at hp + simp at hp)⟩ -@[simp] lemma proof_of_quote_proof {φ : Sentence L} (b : T ⊢! φ) : T.Proof (⌜b⌝ : V) ⌜φ⌝ := by - let x := Derivation2.typedQuote V (Derivation.toDerivation2 (T : Schema L) b) - suffices T.Proof x.val ⌜φ⌝ from this +@[simp] lemma proof_of_quote_proof {φ : Sentence L} (b : T ⊢! φ) : Proof T (⌜b⌝ : V) ⌜φ⌝ := by + let x := Derivation2.typedQuote V b.toProof2 + suffices Proof T x.val ⌜φ⌝ from this simpa using x.derivationOf lemma coe_quote_proof_eq (d : T ⊢! φ) : (↑(⌜d⌝ : ℕ) : V) = ⌜d⌝ := by simp [quote_proof_def, Derivation2.coe_quote_eq] -namespace Theory +namespace Arithmetic.Bootstrapping open Derivation2 -lemma Derivation.sound {d : ℕ} (h : T.Derivation d) : ∃ Γ, ⌜Γ⌝ = fstIdx d ∧ (T : Schema L) ⟹₂! Γ := by +lemma Derivation.sound {d : ℕ} (h : Derivation T d) : ∃ Γ, ⌜Γ⌝ = fstIdx d ∧ T ⟹₂! Γ := by induction d using Nat.strongRec case ind d ih => rcases h.case with ⟨hs, H⟩ @@ -322,16 +321,20 @@ lemma Derivation.sound {d : ℕ} (h : T.Derivation d) : ∃ Γ, ⌜Γ⌝ = fstId rcases this with ⟨σ, hσ, rfl⟩ refine ⟨Derivation2.axm σ (by simp [hσ]) hφ⟩ -lemma Provable.sound2 {φ : Proposition L} (h : T.Provable (⌜φ⌝ : ℕ)) : T ⊢!₂! φ := by - rcases h with ⟨d, hp, hd⟩ - rcases hd.sound with ⟨Γ, e, b⟩ - have : Γ = {φ} := Sequent.quote_inj (V := ℕ) <| by simp [e, hp] - rcases this - exact b - -lemma Provable.sound {φ : Sentence L} (h : T.Provable (⌜φ⌝ : ℕ)) : T ⊢ φ := - provable_iff_derivable2.mpr <| Theory.Provable.sound2 (by simpa using h) - -end Theory +noncomputable def Provable.sound2 {φ : Proposition L} (h : Provable T (⌜φ⌝ : ℕ)) : T ⊢!₂! φ := by + let d := Classical.choose h + have hd : Proof T d (⌜φ⌝ : ℕ) := Classical.choose_spec h + let Γ := Classical.choose hd.2.sound + have hΓ := Classical.choose_spec hd.2.sound + rcases hΓ with ⟨e, b⟩ + have hΓ : Γ = {φ} := Sequent.quote_inj (V := ℕ) <| by + rw [e, hd.1] + simp + exact Derivation2.cast (Classical.choice b) hΓ + +lemma Provable.sound {φ : Sentence L} (h : Provable T (⌜φ⌝ : ℕ)) : T ⊢ φ := + provable_iff_derivable2.mpr ⟨Provable.sound2 (by simpa using h)⟩ + +end Arithmetic.Bootstrapping end LO.FirstOrder diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean index d56f721b6..1885452be 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean @@ -120,21 +120,15 @@ variable {V} omit [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] in @[simp] lemma internalize_theory (T : Theory L) [T.Δ₁] : (T.internalize V).theory = T := rfl -structure TIsDerivation (Γ : Sequent V L) where +structure TDerivation (T : InternalTheory V L) (Γ : Sequent V L) where val : V - derivationOf : IsDerivationOf L val Γ.val + derivationOf : DerivationOf T.theory val Γ.val -attribute [simp] TIsDerivation.derivationOf - -abbrev TDerivation (_T : InternalTheory V L) (Γ : Sequent V L) := TIsDerivation Γ +attribute [simp] TDerivation.derivationOf scoped infix:45 " ⊢!ᵈᵉʳ " => TDerivation -structure TIsProof (T : InternalTheory V L) (φ : Formula V L) where - val : V - proof : IsProof T.theory val φ.val - -def TProof (T : InternalTheory V L) (φ : Formula V L) := TIsProof T φ +def TProof (T : InternalTheory V L) (φ : Formula V L) := T ⊢!ᵈᵉʳ insert φ ∅ instance : Entailment (InternalTheory V L) (Formula V L) := ⟨TProof⟩ @@ -142,29 +136,24 @@ instance : HasSubset (InternalTheory V L) := ⟨fun T U ↦ T.theory.Δ₁Class variable {T U : InternalTheory V L} -noncomputable def Derivable.toTDerivation (Γ : Sequent V L) (h : Derivable L Γ.val) : T ⊢!ᵈᵉʳ Γ := by - exact ⟨Classical.choose h, Classical.choose_spec h⟩ +noncomputable def _root_.LO.FirstOrder.Arithmetic.Bootstrapping.Derivable.toTDerivation (Γ : Sequent V L) (h : Derivable T.theory Γ.val) : T ⊢!ᵈᵉʳ Γ := by + choose a ha using h; choose d hd using ha.2 + exact ⟨a, ha.1, d, hd⟩ -lemma TDerivation.toDerivable {Γ : (Sequent V L)} (d : T ⊢!ᵈᵉʳ Γ) : Derivable L Γ.val := +lemma TDerivation.toDerivable {Γ : (Sequent V L)} (d : T ⊢!ᵈᵉʳ Γ) : Derivable T.theory Γ.val := ⟨d.val, d.derivationOf⟩ -lemma TIsProof.toProvable {σ : Formula V L} (d : TIsProof T σ) : Provable T.theory σ.val := - ⟨d.val, d.proof⟩ - -noncomputable def Provable.toTIsProof {σ : Formula V L} (h : Provable T.theory σ.val) : TIsProof T σ := by - exact ⟨Classical.choose h, Classical.choose_spec h⟩ - lemma TProvable.iff_provable {σ : Formula V L} : T ⊢ σ ↔ Provable T.theory σ.val := by constructor · intro b - exact b.get.toProvable + simpa [←singleton_eq_insert] using TDerivation.toDerivable b.get · intro h - exact ⟨Provable.toTIsProof h⟩ + exact ⟨Derivable.toTDerivation _ <| by simpa [←singleton_eq_insert] using h⟩ -alias ⟨toProvable, Provable.toTProvable⟩ := TProvable.iff_provable +alias ⟨toProvable, _root_.LO.FirstOrder.Arithmetic.Bootstrapping.Provable.toTProvable⟩ := TProvable.iff_provable -noncomputable def proof_to_tDerivation {σ : Formula V L} (d : T ⊢!ᵈᵉʳ insert σ ∅) : T ⊢!ᵈᵉʳ insert σ ∅ := d +def proof_to_tDerivation {σ : Formula V L} : T ⊢! σ → T ⊢!ᵈᵉʳ insert σ ∅ := fun x ↦ x lemma tprovable_iff_provable {T : Theory L} [T.Δ₁] {σ : Formula V L} : T.internalize V ⊢ σ ↔ Provable T σ.val := TProvable.iff_provable @@ -175,15 +164,11 @@ lemma tprovable_tquote_iff_provable_quote {T : Theory L} [T.Δ₁] {φ : Proposi lemma tprovable_tquote_iff_provable_quote_sentence {T : Theory L} [T.Δ₁] {σ : Sentence L} : T.internalize V ⊢ ⌜σ⌝ ↔ Provable T (⌜σ⌝ : V) := TProvable.iff_provable -noncomputable def TDerivation.toTProof {φ} (d : T ⊢!ᵈᵉʳ insert φ ∅) : T ⊢! φ := - ⟨⟪∅, d.val⟫, by - constructor - · intro x hx; simpa using hx - · simpa [IsProof] using d.derivationOf⟩ +def TDerivation.toTProof {φ} (d : T ⊢!ᵈᵉʳ insert φ ∅) : T ⊢! φ := d def TDerivation.of_eq (d : T ⊢!ᵈᵉʳ Γ) (e : Γ = Δ) : T ⊢!ᵈᵉʳ Δ := by rcases e; exact d -lemma TProof.toProvable {φ} (d : T ⊢! φ) : Provable T.theory φ.val := TIsProof.toProvable d +def TProof.toTDerivation {φ} (d : T ⊢! φ) : T ⊢!ᵈᵉʳ insert φ ∅ := d namespace TDerivation @@ -195,55 +180,61 @@ protected noncomputable def cast {Γ Δ : Bootstrapping.Sequent V L} (e : Γ = @[simp] lemma cast_val {Γ Δ : Bootstrapping.Sequent V L} (e : Γ = Δ) (d : T ⊢!ᵈᵉʳ Γ) : (TDerivation.cast e d).val = d.val := by rcases e; simp [TDerivation.cast] +noncomputable def byAxm (φ) (h : φ ∈' T.theory) (hΓ : φ ∈ Γ) : T ⊢!ᵈᵉʳ Γ := + ⟨Bootstrapping.axm Γ.val φ.val, by simp, Derivation.axm (by simp) (by simpa) h⟩ + +@[simp] lemma byAxm_val (φ) (h : φ ∈' T.theory) (hΓ : φ ∈ Γ) : + (byAxm φ h hΓ).val = Bootstrapping.axm Γ.val φ.val := rfl + noncomputable def em (φ) (h : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : T ⊢!ᵈᵉʳ Γ := - ⟨identity Γ.val φ.val, by simp, IsDerivation.identity (by simp) h hn⟩ + ⟨axL Γ.val φ.val, by simp, Derivation.axL (by simp) h hn⟩ @[simp] lemma em_val (φ) (h : φ ∈ Γ) (hn : ∼φ ∈ Γ) : - (em φ h hn : T ⊢!ᵈᵉʳ Γ).val = Bootstrapping.identity Γ.val φ.val := rfl + (em φ h hn : T ⊢!ᵈᵉʳ Γ).val = Bootstrapping.axL Γ.val φ.val := rfl noncomputable def verum (h : ⊤ ∈ Γ := by simp) : T ⊢!ᵈᵉʳ Γ := - ⟨verumIntro Γ.val, by simp, IsDerivation.verumIntro (by simp) h⟩ + ⟨verumIntro Γ.val, by simp, Derivation.verumIntro (by simp) h⟩ @[simp] lemma verum_val (h : ⊤ ∈ Γ) : (verum h : T ⊢!ᵈᵉʳ Γ).val = Bootstrapping.verumIntro Γ.val := rfl noncomputable def and' (H : φ ⋏ ψ ∈ Γ) (dp : T ⊢!ᵈᵉʳ insert φ Γ) (dq : T ⊢!ᵈᵉʳ insert ψ Γ) : T ⊢!ᵈᵉʳ Γ := ⟨andIntro Γ.val φ.val ψ.val dp.val dq.val, by simp, - IsDerivation.andIntro (by simpa) (by simpa using dp.derivationOf) (by simpa using dq.derivationOf)⟩ + Derivation.andIntro (by simpa) (by simpa using dp.derivationOf) (by simpa using dq.derivationOf)⟩ @[simp] lemma and'_val (H : φ ⋏ ψ ∈ Γ) (dp : T ⊢!ᵈᵉʳ insert φ Γ) (dq : T ⊢!ᵈᵉʳ insert ψ Γ) : (and' H dp dq : T ⊢!ᵈᵉʳ Γ).val = andIntro Γ.val φ.val ψ.val dp.val dq.val := rfl noncomputable def or' (H : φ ⋎ ψ ∈ Γ) (dpq : T ⊢!ᵈᵉʳ insert φ (insert ψ Γ)) : T ⊢!ᵈᵉʳ Γ := - ⟨orIntro Γ.val φ.val ψ.val dpq.val, by simp, IsDerivation.orIntro (by simpa) (by simpa using dpq.derivationOf)⟩ + ⟨orIntro Γ.val φ.val ψ.val dpq.val, by simp, Derivation.orIntro (by simpa) (by simpa using dpq.derivationOf)⟩ @[simp] lemma or'_val (H : φ ⋎ ψ ∈ Γ) (dpq : T ⊢!ᵈᵉʳ insert φ (insert ψ Γ)) : (or' H dpq : T ⊢!ᵈᵉʳ Γ).val = orIntro Γ.val φ.val ψ.val dpq.val := rfl noncomputable def all' {φ : Semiformula V L 1} (H : ∀⁰ φ ∈ Γ) (dp : T ⊢!ᵈᵉʳ insert φ.free Γ.shift) : T ⊢!ᵈᵉʳ Γ := - ⟨allIntro Γ.val φ.val dp.val, by simp, IsDerivation.allIntro (by simpa) (by simpa using dp.derivationOf)⟩ + ⟨allIntro Γ.val φ.val dp.val, by simp, Derivation.allIntro (by simpa) (by simpa using dp.derivationOf)⟩ @[simp] lemma all'_val {φ : Semiformula V L 1} (H : ∀⁰ φ ∈ Γ) (dp : T ⊢!ᵈᵉʳ insert φ.free Γ.shift) : (all' H dp : T ⊢!ᵈᵉʳ Γ).val = allIntro Γ.val φ.val dp.val := rfl noncomputable def exs' {φ : Semiformula V L 1} (H : ∃⁰ φ ∈ Γ) (t : Term V L) (dp : T ⊢!ᵈᵉʳ insert (φ.subst ![t]) Γ) : T ⊢!ᵈᵉʳ Γ := - ⟨exsIntro Γ.val φ.val t.val dp.val, by simp, IsDerivation.exsIntro (by simpa) (by simp) (by simpa using dp.derivationOf)⟩ + ⟨exsIntro Γ.val φ.val t.val dp.val, by simp, Derivation.exsIntro (by simpa) (by simp) (by simpa using dp.derivationOf)⟩ @[simp] lemma exs'_val {φ : Semiformula V L 1} (H : ∃⁰ φ ∈ Γ) (t : Term V L) (dp : T ⊢!ᵈᵉʳ insert (φ.subst ![t]) Γ) : (exs' H t dp : T ⊢!ᵈᵉʳ Γ).val = exsIntro Γ.val φ.val t.val dp.val := rfl noncomputable def wk (d : T ⊢!ᵈᵉʳ Δ) (h : Δ ⊆ Γ) : T ⊢!ᵈᵉʳ Γ := - ⟨contraction Γ.val d.val, by simp, IsDerivation.contraction (by simp) h d.derivationOf⟩ + ⟨wkRule Γ.val d.val, by simp, Derivation.wkRule (s' := Δ.val) (by simp) (by simpa) (by simp)⟩ -@[simp] lemma wk_val (d : T ⊢!ᵈᵉʳ Δ) (h : Δ ⊆ Γ) : (wk d h).val = contraction Γ.val d.val := rfl +@[simp] lemma wk_val (d : T ⊢!ᵈᵉʳ Δ) (h : Δ ⊆ Γ) : (wk d h).val = wkRule Γ.val d.val := rfl noncomputable def shift (d : T ⊢!ᵈᵉʳ Γ) : T ⊢!ᵈᵉʳ Γ.shift := - ⟨shiftRule Γ.shift.val d.val, by simp [Sequent.shift], IsDerivation.shiftRule (by simpa using d.derivationOf)⟩ + ⟨shiftRule Γ.shift.val d.val, by simp, Derivation.shiftRule (by simp)⟩ @[simp] lemma shift_val (d : T ⊢!ᵈᵉʳ Γ) : (shift d).val = shiftRule Γ.shift.val d.val := rfl noncomputable def cut (d₁ : T ⊢!ᵈᵉʳ insert φ Γ) (d₂ : T ⊢!ᵈᵉʳ insert (∼φ) Γ) : T ⊢!ᵈᵉʳ Γ := - ⟨cutRule Γ.val φ.val d₁.val d₂.val, by simp, IsDerivation.cutRule (by simpa using d₁.derivationOf) (by simpa using d₂.derivationOf)⟩ + ⟨cutRule Γ.val φ.val d₁.val d₂.val, by simp, Derivation.cutRule (by simpa using d₁.derivationOf) (by simpa using d₂.derivationOf)⟩ @[simp] lemma cut_val (d₁ : T ⊢!ᵈᵉʳ insert φ Γ) (d₂ : T ⊢!ᵈᵉʳ insert (∼φ) Γ) : (cut d₁ d₂).val = cutRule Γ.val φ.val d₁.val d₂.val := rfl @@ -263,7 +254,9 @@ noncomputable def exs {φ : Semiformula V L 1} (t : Term V L) (dp : T ⊢!ᵈᵉ Derivable.toTDerivation _ <| by simpa using Derivable.exs (by simp) t.isSemiterm (by simpa using dp.toDerivable) -def ofSubset (h : T ⊆ U) (d : T ⊢!ᵈᵉʳ Γ) : U ⊢!ᵈᵉʳ Γ := d +def ofSubset (h : T ⊆ U) (d : T ⊢!ᵈᵉʳ Γ) : U ⊢!ᵈᵉʳ Γ where + val := d.val + derivationOf := ⟨d.derivationOf.1, d.derivationOf.2.of_ss h⟩ noncomputable def cut' (d₁ : T ⊢!ᵈᵉʳ insert φ Γ) (d₂ : T ⊢!ᵈᵉʳ insert (∼φ) Δ) : T ⊢!ᵈᵉʳ Γ ∪ Δ := cut (φ := φ) (d₁.wk (by intro x; simp; tauto)) (d₂.wk (by intro x; simp; tauto)) @@ -310,20 +303,9 @@ variable {T U : InternalTheory V L} {φ ψ : Formula V L} /-- Condition D2 -/ noncomputable def modusPonens (d : T ⊢! φ 🡒 ψ) (b : T ⊢! φ) : T ⊢! ψ := TDerivation.modusPonens d b -noncomputable def byAxm {φ : Formula V L} (h : φ ∈' T.theory) : T ⊢! φ := by - refine Provable.toTIsProof (T := T) (Derivable.toProvable (T := T.theory) ?_) - refine ⟨{φ.val}, ?_, ?_⟩ - · intro x hx - simpa using hx ▸ h - · apply Derivable.em - · simp - · simp - · simp [neg_mem_setNeg] +noncomputable def byAxm {φ : Formula V L} (h : φ ∈' T.theory) : T ⊢! φ := TDerivation.byAxm φ h (by simp) -noncomputable def ofSubset (h : T ⊆ U) {φ : Formula V L} (d : T ⊢! φ) : U ⊢! φ := - ⟨d.val, by - rcases d.proof with ⟨hT, hd⟩ - exact ⟨fun x hx ↦ h (hT x hx), hd⟩⟩ +noncomputable def ofSubset (h : T ⊆ U) {φ : Formula V L} : T ⊢! φ → U ⊢! φ := TDerivation.ofSubset h lemma of_subset (h : T ⊆ U) {φ : Formula V L} : T ⊢ φ → U ⊢ φ := by rintro ⟨b⟩; exact ⟨ofSubset h b⟩ @@ -332,8 +314,7 @@ noncomputable instance : Entailment.ModusPonens T := ⟨modusPonens⟩ noncomputable instance : Entailment.NegationEquiv T where negEquiv {φ} := by - apply TDerivation.toTProof - suffices T ⊢!ᵈᵉʳ insert ((φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ)) ∅ by + suffices T ⊢! (φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ) by simpa [Axioms.NegEquiv, LO.LogicalConnective.iff, Semiformula.imp_def] apply TDerivation.and · apply TDerivation.or @@ -348,14 +329,12 @@ noncomputable instance : Entailment.NegationEquiv T where noncomputable instance : Entailment.Minimal T where verum := TDerivation.toTProof <| TDerivation.verum implyK {φ ψ} := by - apply TDerivation.toTProof simp only [Axioms.ImplyK, Semiformula.imp_def] apply TDerivation.or apply TDerivation.rotate₁ apply TDerivation.or exact TDerivation.em φ implyS {φ ψ r} := by - apply TDerivation.toTProof simp only [Axioms.ImplyS, Semiformula.imp_def, DeMorgan.or, DeMorgan.neg] apply TDerivation.or apply TDerivation.rotate₁ @@ -372,19 +351,16 @@ noncomputable instance : Entailment.Minimal T where · exact TDerivation.em ψ · exact TDerivation.em r and₁ {φ ψ} := by - apply TDerivation.toTProof simp only [Axioms.AndElim₁, Semiformula.imp_def, DeMorgan.and] apply TDerivation.or apply TDerivation.or exact TDerivation.em φ and₂ {φ ψ} := by - apply TDerivation.toTProof simp only [Axioms.AndElim₂, Semiformula.imp_def, DeMorgan.and] apply TDerivation.or apply TDerivation.or exact TDerivation.em ψ and₃ {φ ψ} := by - apply TDerivation.toTProof simp only [Axioms.AndInst, Semiformula.imp_def] apply TDerivation.or apply TDerivation.rotate₁ @@ -394,23 +370,20 @@ noncomputable instance : Entailment.Minimal T where · exact TDerivation.em φ · exact TDerivation.em ψ or₁ {φ ψ} := by - apply TDerivation.toTProof simp only [Axioms.OrInst₁, Semiformula.imp_def] apply TDerivation.or apply TDerivation.rotate₁ apply TDerivation.or exact TDerivation.em φ or₂ {φ ψ} := by - apply TDerivation.toTProof - suffices T ⊢!ᵈᵉʳ insert (∼ψ ⋎ φ ⋎ ψ) ∅ by + suffices T ⊢! ∼ψ ⋎ φ ⋎ ψ by simpa [Axioms.OrInst₂, Semiformula.imp_def] apply TDerivation.or apply TDerivation.rotate₁ apply TDerivation.or exact TDerivation.em ψ or₃ {φ ψ r} := by - apply TDerivation.toTProof - suffices T ⊢!ᵈᵉʳ insert (φ ⋏ ∼r ⋎ ψ ⋏ ∼r ⋎ ∼φ ⋏ ∼ψ ⋎ r) ∅ by + suffices T ⊢! φ ⋏ ∼r ⋎ ψ ⋏ ∼r ⋎ ∼φ ⋏ ∼ψ ⋎ r by simpa [Axioms.OrElim, Semiformula.imp_def] apply TDerivation.or apply TDerivation.rotate₁ @@ -428,9 +401,7 @@ noncomputable instance : Entailment.Minimal T where · exact TDerivation.em r noncomputable instance : Entailment.Cl T where - dne {φ} := by - apply TDerivation.toTProof - simpa [Axioms.DNE, Semiformula.imp_def] using TDerivation.or (TDerivation.em φ) + dne {φ} := by simpa [Axioms.DNE, Semiformula.imp_def] using TDerivation.or (TDerivation.em φ) noncomputable def exsIntro (φ : Semiformula V L 1) (t : Term V L) (b : T ⊢! φ.subst ![t]) : T ⊢! (∃⁰ φ) := TDerivation.exs t b @@ -565,14 +536,14 @@ variable (A : InternalTheory V ℒₒᵣ) open Bootstrapping.Arithmetic -open Entailment Theory.Derivation +open Entailment lemma substItrDisj_right {i z : V} (w : TermVec V ℒₒᵣ m) (φ : Semiformula V ℒₒᵣ (m + 1)) (hi : i < z) : - A ⊢ φ.subst (𝕹 i :> w) 🡒 φ.substItrDisj w z := Theory.Provable.toTProvable <| Theory.Derivable.toProvable <| by - apply Theory.Derivable.or - apply Theory.Derivable.exchange - apply Theory.Derivable.disj (L := ℒₒᵣ) (i := z - (i + 1)) _ + A ⊢ φ.subst (𝕹 i :> w) 🡒 φ.substItrDisj w z := Provable.toTProvable <| Derivable.toProvable <| by + apply Derivable.or + apply Derivable.exchange + apply Derivable.disj (L := ℒₒᵣ) (i := z - (i + 1)) _ · intro i hi have hi : i < z := by simpa using hi rw [substItr_nth _ _ _ hi] @@ -583,7 +554,7 @@ lemma substItrDisj_right {i z : V} have : z - (z - (i + 1) + 1) = i := sub_succ_lt_selfs hi simp only [this, Nat.succ_eq_add_one, Semiformula.val_substs, SemitermVec.val_succ, Matrix.head_cons, Matrix.tail_cons] - apply Theory.Derivable.em (L := ℒₒᵣ) (p := subst ℒₒᵣ (numeral i ∷ SemitermVec.val w) φ.val) + apply Derivable.em (L := ℒₒᵣ) (p := subst ℒₒᵣ (numeral i ∷ SemitermVec.val w) φ.val) · simpa using φ.isSemiformula_succ.subst (w.isSemitermVec.adjoin (numeral_semiterm 0 i)) · simp · simp @@ -595,15 +566,15 @@ lemma substItrDisj_right_intro {ψ} {i z : V} {w : TermVec V ℒₒᵣ m} {φ : lemma substItrConj_right_intro {ψ} {w : TermVec V ℒₒᵣ m} {φ : Semiformula V ℒₒᵣ (m + 1)} {z : V} (h : ∀ i < z, A ⊢ ψ 🡒 φ.subst (𝕹 i :> w)) : - A ⊢ ψ 🡒 φ.substItrConj w z := Theory.Provable.toTProvable <| Theory.Derivable.toProvable <| by - apply Theory.Derivable.or - apply Theory.Derivable.exchange - apply Theory.Derivable.conj + A ⊢ ψ 🡒 φ.substItrConj w z := Provable.toTProvable <| Derivable.toProvable <| by + apply Derivable.or + apply Derivable.exchange + apply Derivable.conj · simp · intro i hi have hi : i < z := by simpa using hi rw [substItr_nth _ _ _ hi] - apply Theory.Derivable.exchange + apply Derivable.exchange suffices A ⊢!ᵈᵉʳ (∼ψ ⫽ φ.subst (𝕹 (z - (i + 1)) :> w) ⫽ ∅) by simpa using this.toDerivable have : A ⊢ ∼ψ ⋎ Semiformula.subst (typedNumeral (z - (i + 1)) :> w) φ := h (z - (i + 1)) (by simp [pos_of_gt hi]) diff --git a/Foundation/FirstOrder/Incompleteness/Consistency.lean b/Foundation/FirstOrder/Incompleteness/Consistency.lean index 0663c189d..404be5f95 100644 --- a/Foundation/FirstOrder/Incompleteness/Consistency.lean +++ b/Foundation/FirstOrder/Incompleteness/Consistency.lean @@ -21,26 +21,26 @@ section variable (T : Theory L) [T.Δ₁] (V) -def _root_.LO.FirstOrder.Theory.Consistent : Prop := ¬T.Provable (⌜(⊥ : Sentence L)⌝ : V) +def _root_.LO.FirstOrder.Theory.Consistent : Prop := ¬Provable T (⌜(⊥ : Sentence L)⌝ : V) variable {V} -def _root_.LO.FirstOrder.Theory.ConsistentWith (φ : V) : Prop := ¬T.Provable (neg L φ) +def _root_.LO.FirstOrder.Theory.ConsistentWith (φ : V) : Prop := ¬Provable T (neg L φ) lemma _root_.LO.FirstOrder.Theory.ConsistentWith.quote_iff {σ : Sentence L} : - T.ConsistentWith (⌜σ⌝ : V) ↔ ¬T.Provable (⌜∼σ⌝ : V) := by + T.ConsistentWith (⌜σ⌝ : V) ↔ ¬Provable T (⌜∼σ⌝ : V) := by simp [Theory.ConsistentWith, Sentence.quote_def, Semiformula.quote_def] section noncomputable def _root_.LO.FirstOrder.Theory.consistent : 𝚷₁.Sentence := - .mkPi (∼T.provabilityPred ⊥) + .mkPi (∼provabilityPred T ⊥) -@[simp] lemma consistent.defined : Semiformula.Evalbm V ![] (T.consistent : Sentence ℒₒᵣ) ↔ T.Consistent V := by +@[simp] lemma consistent.defined : _root_.LO.FirstOrder.Semiformula.Evalb (M := V) ![] (T.consistent : Sentence ℒₒᵣ) ↔ T.Consistent V := by simp [Theory.consistent, Theory.Consistent] noncomputable def _root_.LO.FirstOrder.Theory.consistentWith : 𝚷₁.Semisentence 1 := .mkPi - “φ. ∀ nφ, !(negGraph L) nφ φ → ¬!T.provable nφ” + “φ. ∀ nφ, !(negGraph L) nφ φ → ¬!(provable T) nφ” instance consistentWith.defined : 𝚷₁-Predicate (T.ConsistentWith : V → Prop) via T.consistentWith := .mk fun v ↦ by simp [Theory.ConsistentWith, Theory.consistentWith] @@ -85,7 +85,7 @@ open Entailment variable (T : ArithmeticTheory) [𝗜𝚺₁ ⪯ T] [T.Δ₁] -instance [ℕ ⊧ₘ* T] : ℕ ⊧ₘ* T + T.Con := by +instance [ℕ↓[ℒₒᵣ] ⊧* T] : ℕ↓[ℒₒᵣ] ⊧* (T ∪ T.Con) := by have : 𝗥₀ ⪯ 𝗜𝚺₁ := inferInstance have : 𝗥₀ ⪯ T := Entailment.WeakerThan.trans this inferInstance have : Entailment.Consistent T := ArithmeticTheory.consistent_of_sound T (Eq ⊥) rfl diff --git a/Foundation/FirstOrder/Incompleteness/First.lean b/Foundation/FirstOrder/Incompleteness/First.lean index b4237cbd7..e651d5a42 100644 --- a/Foundation/FirstOrder/Incompleteness/First.lean +++ b/Foundation/FirstOrder/Incompleteness/First.lean @@ -17,7 +17,7 @@ lemma re_iff_sigma1 {P : ℕ → Prop} : REPred P ↔ 𝚺₁-Predicate P := by intro v simpa [←Matrix.fun_eq_vec_one] using codeOfREPred_spec h (x := v 0) · rintro ⟨φ, hφ⟩ - have : REPred fun x ↦ (Semiformula.Evalm ℕ (x ::ᵥ List.Vector.nil).get id) _ := + have : REPred fun x ↦ (Semiformula.Eval (x ::ᵥ List.Vector.nil).get id) _ := (sigma1_re id (φ.sigma_prop)).comp (Primrec.to_comp <| Primrec.vector_cons.comp .id <| .const _) exact this.of_eq <| by intro x; simpa [List.Vector.cons_get, Matrix.empty_eq] using hφ ![x] @@ -29,10 +29,10 @@ theorem incomplete (T : ArithmeticTheory) [T.Δ₁] [𝗥₀ ⪯ T] [T.SoundOnHi Incomplete T := by have con : Consistent T := inferInstance let D : ℕ → Prop := fun φ : ℕ ↦ - IsSemiformula ℒₒᵣ 1 φ ∧ T.Provable (neg ℒₒᵣ <| subst ℒₒᵣ ?[numeral φ] φ) + IsSemiformula ℒₒᵣ 1 φ ∧ Provable T (neg ℒₒᵣ <| subst ℒₒᵣ ?[numeral φ] φ) have D_re : REPred D := by have : 𝚺₁-Predicate fun φ : ℕ ↦ - IsSemiformula ℒₒᵣ 1 φ ∧ T.Provable (neg ℒₒᵣ <| subst ℒₒᵣ ?[numeral φ] φ) := by + IsSemiformula ℒₒᵣ 1 φ ∧ Provable T (neg ℒₒᵣ <| subst ℒₒᵣ ?[numeral φ] φ) := by definability exact re_iff_sigma1.mpr this have D_spec (φ : Semisentence ℒₒᵣ 1) : D ⌜φ⌝ ↔ T ⊢ ∼φ/[⌜φ⌝] := by @@ -57,13 +57,13 @@ theorem incomplete (T : ArithmeticTheory) [T.Δ₁] [𝗥₀ ⪯ T] [T.SoundOnHi theorem exists_true_but_unprovable_sentence (T : ArithmeticTheory) [T.Δ₁] [𝗥₀ ⪯ T] [T.SoundOnHierarchy 𝚺 1] : - ∃ δ : Sentence ℒₒᵣ, ℕ ⊧ₘ δ ∧ T ⊬ δ := by + ∃ δ : Sentence ℒₒᵣ, ℕ↓[ℒₒᵣ] ⊧ δ ∧ T ⊬ δ := by obtain ⟨δ, hδ⟩ := incomplete_def.mp $ Arithmetic.incomplete T; - by_cases ℕ ⊧ₘ δ + by_cases ℕ↓[ℒₒᵣ] ⊧ δ . exact ⟨δ, by assumption, hδ.1⟩ . exact ⟨∼δ, by simpa, hδ.2⟩ -instance {T : ArithmeticTheory} [ℕ ⊧ₘ* T] [T.Δ₁] [𝗥₀ ⪯ T] [T.SoundOnHierarchy 𝚺 1] : T ⪱ 𝗧𝗔 := by +instance {T : ArithmeticTheory} [ℕ↓[ℒₒᵣ] ⊧* T] [T.Δ₁] [𝗥₀ ⪯ T] [T.SoundOnHierarchy 𝚺 1] : T ⪱ 𝗧𝗔 := by constructor; . infer_instance . obtain ⟨δ, δTrue, δUnprov⟩ := exists_true_but_unprovable_sentence T; diff --git a/Foundation/FirstOrder/Incompleteness/Halting.lean b/Foundation/FirstOrder/Incompleteness/Halting.lean index a7ce6a86e..62f72ab9e 100644 --- a/Foundation/FirstOrder/Incompleteness/Halting.lean +++ b/Foundation/FirstOrder/Incompleteness/Halting.lean @@ -23,14 +23,14 @@ lemma incomplete_of_REPred_not_ComputablePred_Nat' {P : ℕ → Prop} (hRE : REP constructor; . assumption; . suffices REPred fun a : ℕ ↦ T ⊬ φ/[a] by simpa [hP] using this; - have : 𝚺₁-Predicate fun b : ℕ ↦ T.Provable (Bootstrapping.neg ℒₒᵣ <| Bootstrapping.subst ℒₒᵣ ?[Bootstrapping.Arithmetic.numeral b] ⌜φ⌝) := by clear hP; definability; + have : 𝚺₁-Predicate fun b : ℕ ↦ Provable T (Bootstrapping.neg ℒₒᵣ <| Bootstrapping.subst ℒₒᵣ ?[Bootstrapping.Arithmetic.numeral b] ⌜φ⌝) := by clear hP; definability; apply REPred.of_eq (re_iff_sigma1.mpr this); intro a; push Not at h; apply Iff.trans ?_ $ show T ⊢ ∼φ/[a] ↔ ¬T ⊢ φ/[a] by simpa [hP] using h a |>.symm; constructor; . rintro hP - apply Theory.Provable.sound + apply Bootstrapping.Provable.sound simpa [Sentence.quote_def, Semiformula.quote_def, Rewriting.emb_subst_eq_subst_coe₁] using hP; . rintro hφ simpa [Sentence.quote_def, Semiformula.quote_def, Rewriting.emb_subst_eq_subst_coe₁] using diff --git a/Foundation/FirstOrder/Incompleteness/Jeroslow.lean b/Foundation/FirstOrder/Incompleteness/Jeroslow.lean index 1352983c7..cc7dcddd8 100644 --- a/Foundation/FirstOrder/Incompleteness/Jeroslow.lean +++ b/Foundation/FirstOrder/Incompleteness/Jeroslow.lean @@ -34,16 +34,16 @@ variable [L.Encodable] [L.LORDefinable] {T : Theory L} [T.Δ₁] def Refutable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] (T : Theory L) [T.Δ₁] (φ : V) : Prop - := T.Provable (neg L φ) + := Provable T (neg L φ) noncomputable def refutable (T : Theory L) [T.Δ₁] : 𝚺₁.Semisentence 1 - := .mkSigma “φ. ∃ nφ, !(negGraph L) nφ φ ∧ !T.provable nφ” + := .mkSigma “φ. ∃ nφ, !(negGraph L) nφ φ ∧ !(provable T) nφ” section variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] -lemma Refutable.quote_iff {σ : Sentence L} : T.Refutable (⌜σ⌝ : V) ↔ T.Provable (⌜∼σ⌝ : V) := by +lemma Refutable.quote_iff {σ : Sentence L} : T.Refutable (⌜σ⌝ : V) ↔ Provable T (⌜∼σ⌝ : V) := by simp [Theory.Refutable, Sentence.quote_def, Semiformula.quote_def] instance refutable_defined : 𝚺₁-Predicate[V] T.Refutable via T.refutable := .mk fun v ↦ by @@ -62,7 +62,7 @@ variable {T U : ArithmeticTheory} [T.Δ₁] noncomputable abbrev standardRefutability (T : ArithmeticTheory) [T.Δ₁] : Refutability 𝗜𝚺₁ T where refu := T.refutable.val - refu_def {σ} h := provable_of_models _ _ fun (V : Type) _ _ ↦ by + refu_def {σ} h := complete 𝗜𝚺₁ _ fun (V : Type) _ _ ↦ by simpa [models_iff, Refutable.quote_iff] using internalize_provability h (V := V) noncomputable abbrev jeroslow (T : ArithmeticTheory) [T.Δ₁] : ArithmeticSentence := fixedpoint T.refutable @@ -122,7 +122,7 @@ theorem unprovable_jeroslow [𝗜𝚺₁ ⪯ T] [T.SoundOnHierarchy 𝚺 1] is not provable in `T` itself. -/ theorem unprovable_formalized_law_of_noncontradiction [𝗜𝚺₁ ⪯ T] [Entailment.Consistent T] - : T ⊬ (∀⁰ ∼(T.provable ⋏ T.refutable) : ArithmeticSentence) := by + : T ⊬ (∀⁰ ∼(provable T ⋏ T.refutable) : ArithmeticSentence) := by simpa [flon, safe, -DeMorgan.and] using ProvabilityAbstraction.unprovable_flon (𝔅 := T.standardProvability) (𝔚 := T.standardRefutability) diff --git "a/Foundation/FirstOrder/Incompleteness/L\303\266b.lean" "b/Foundation/FirstOrder/Incompleteness/L\303\266b.lean" index 7281af3c6..87ac98921 100644 --- "a/Foundation/FirstOrder/Incompleteness/L\303\266b.lean" +++ "b/Foundation/FirstOrder/Incompleteness/L\303\266b.lean" @@ -9,14 +9,14 @@ public import Foundation.FirstOrder.Incompleteness.StandardProvability namespace LO.FirstOrder.Arithmetic -open LO.Entailment ProvabilityAbstraction +open LO.Entailment Bootstrapping ProvabilityAbstraction variable {T : ArithmeticTheory} [T.Δ₁] [𝗜𝚺₁ ⪯ T] {σ : ArithmeticSentence} -theorem löb_theorem : T ⊢ T.provabilityPred σ 🡒 σ → T ⊢ σ := +theorem löb_theorem : T ⊢ provabilityPred T σ 🡒 σ → T ⊢ σ := ProvabilityAbstraction.löb_theorem (𝔅 := T.standardProvability) -theorem formalized_löb_theorem : 𝗜𝚺₁ ⊢ T.provabilityPred (T.provabilityPred σ 🡒 σ) 🡒 T.provabilityPred σ := +theorem formalized_löb_theorem : 𝗜𝚺₁ ⊢ provabilityPred T (provabilityPred T σ 🡒 σ) 🡒 provabilityPred T σ := ProvabilityAbstraction.formalized_löb_theorem (𝔅 := T.standardProvability) end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Basic.lean b/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Basic.lean index 78523350d..e1ff4b549 100644 --- a/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Basic.lean +++ b/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Basic.lean @@ -101,14 +101,17 @@ class SoundOn [L.ReferenceableBy L₀] {T₀ : Theory L₀} {T : Theory L} (𝔅 : Provability T₀ T) (M : outParam Type*) [Nonempty M] [Structure L₀ M] where - sound_on {σ} : M ⊧ₘ 𝔅 σ → T ⊢ σ + sound_on {σ : Sentence L} : M↓[L₀] ⊧ (𝔅 σ : Sentence L₀) → T ⊢ σ export SoundOn (sound_on) attribute [simp, grind .] sound_on -lemma syntactical_sound (M) [Nonempty M] [Structure L M] [SoundOn 𝔅 M] [M ⊧ₘ* T₀] : ∀ {σ}, T₀ ⊢ 𝔅 σ → T ⊢ σ := by +omit [L.ReferenceableBy L₀] in +lemma syntactical_sound {T₀ T : Theory L} {𝔅 : Provability T₀ T} + (M : Type*) [Nonempty M] [Structure L M] [SoundOn 𝔅 M] [M↓[L] ⊧* T₀] : + ∀ {σ : Sentence L}, T₀ ⊢ 𝔅 σ → T ⊢ σ := by intro σ h; apply 𝔅.sound_on; - apply models_of_provable (T := T₀); + apply models_of_provable (L := L) (T := T₀); . infer_instance; . exact h; diff --git a/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Refutability.lean b/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Refutability.lean index a36ad305c..b428edd50 100644 --- a/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Refutability.lean +++ b/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Refutability.lean @@ -117,7 +117,7 @@ lemma jeroslow_not_safe [𝔅.FormalizedCompleteOn 𝐉] : T ⊢ 𝐉 🡒 (𝔅 lemma unprovable_flon [consis : Consistent T] [𝔅.FormalizedCompleteOn 𝐉] : T ⊬ flon 𝔅 𝔚 := by contrapose! consis; replace consis : T ⊢ ∀⁰ safe 𝔅 𝔚 := by simpa [flon] using consis; - have h₁ : T ⊢ ∼(𝔅 𝐉 ⋏ 𝔚 𝐉) := by simpa [safe] using FirstOrder.Theory.specialize _ _ ⨀ consis; + have h₁ : T ⊢ ∼(𝔅 𝐉 ⋏ 𝔚 𝐉) := by simpa [safe] using FirstOrder.Theory.Proof.specialize _ _ ⨀ consis; have h₂ : T ⊢ ∼𝐉 := (contra! jeroslow_not_safe) ⨀ h₁; have h₃ : T ⊢ 𝐉 🡘 𝔚 𝐉 := jeroslow_def'; have h₄ : T ⊢ 𝔚 𝐉 := R1' h₂; diff --git a/Foundation/FirstOrder/Incompleteness/RestrictedProvability.lean b/Foundation/FirstOrder/Incompleteness/RestrictedProvability.lean index 548d86626..4fb0906b0 100644 --- a/Foundation/FirstOrder/Incompleteness/RestrictedProvability.lean +++ b/Foundation/FirstOrder/Incompleteness/RestrictedProvability.lean @@ -22,9 +22,9 @@ variable {L : Language} [L.Encodable] [L.LORDefinable] variable {T U : Theory L} [T.Δ₁] [U.Δ₁] /-- Provability with restriction of proof size -/ -def RestrictedProvable (e : ℕ) (T : Theory L) [T.Δ₁] (φ : V) := ∃ d < Exp.exp (ORingStructure.numeral e), T.Proof d φ +def RestrictedProvable (e : ℕ) (T : Theory L) [T.Δ₁] (φ : V) := ∃ d < Exp.exp (ORingStructure.numeral e), Arithmetic.Bootstrapping.Proof T d φ -noncomputable def restrictedProvable (e : ℕ) : 𝚷₁.Semisentence 1 := .mkPi “φ. ∀ E, !expDef E !e → ∃ d < E, !T.proof.pi d φ” +noncomputable def restrictedProvable (e : ℕ) : 𝚷₁.Semisentence 1 := .mkPi “φ. ∀ E, !expDef E !e → ∃ d < E, !(proof T).pi d φ” noncomputable abbrev restrictedProvabilityPred (e : ℕ) (σ : Sentence L) : ArithmeticSentence := (T.restrictedProvable e).val/[⌜σ⌝] @@ -59,22 +59,22 @@ private lemma provable_E_restrictedGödel_restrictedGödel' [𝗜𝚺₁ ⪯ U] private lemma iff_provable_restrictedGödel_provable_restrictedGödel' [𝗜𝚺₁ ⪯ U] : U ⊢ (T.restrictedGödel e) ↔ U ⊢ (T.restrictedGödel' e) := by apply Entailment.iff_of_E! provable_E_restrictedGödel_restrictedGödel'; -private lemma iff_true_restrictedGödel_true_restrictedGödel' : ℕ ⊧ₘ (T.restrictedGödel e) ↔ ℕ ⊧ₘ (T.restrictedGödel' e) := by +private lemma iff_true_restrictedGödel_true_restrictedGödel' : ℕ↓[ℒₒᵣ] ⊧ (T.restrictedGödel e) ↔ ℕ↓[ℒₒᵣ] ⊧ (T.restrictedGödel' e) := by apply Semantics.models_iff.mp; apply models_of_provable (T := 𝗜𝚺₁) inferInstance; apply provable_E_restrictedGödel_restrictedGödel'; -lemma models_restrictedGödel : V ⊧ₘ T.restrictedGödel e ↔ ∀ x : V, x < Exp.exp (ORingStructure.numeral e) → ¬T.Proof x (⌜T.restrictedGödel e⌝) := by +lemma models_restrictedGödel : V↓[ℒₒᵣ] ⊧ T.restrictedGödel e ↔ ∀ x : V, x < Exp.exp (ORingStructure.numeral e) → ¬Arithmetic.Bootstrapping.Proof T x (⌜T.restrictedGödel e⌝) := by apply Iff.trans $ Semantics.models_iff.mp $ models_of_provable (T := 𝗜𝚺₁) inferInstance $ def_restrictedGödel; simp [models_iff, Theory.RestrictedProvable] -private lemma models_neg_restrictedGödel : ¬V ⊧ₘ T.restrictedGödel e ↔ ∃ x : V, x < Exp.exp (ORingStructure.numeral e) ∧ T.Proof x (⌜T.restrictedGödel e⌝) := by +private lemma models_neg_restrictedGödel : ¬V↓[ℒₒᵣ] ⊧ T.restrictedGödel e ↔ ∃ x : V, x < Exp.exp (ORingStructure.numeral e) ∧ Arithmetic.Bootstrapping.Proof T x (⌜T.restrictedGödel e⌝) := by simpa using models_restrictedGödel.not; variable [𝗜𝚺₁ ⪯ T] [T.SoundOnHierarchy 𝚺 1] /- Gödel sentence by restricted provability is true. -/ -theorem true_restrictedGödel : ℕ ⊧ₘ T.restrictedGödel e := by +theorem true_restrictedGödel : ℕ↓[ℒₒᵣ] ⊧ T.restrictedGödel e := by by_contra hC; obtain ⟨e, _, he⟩ := models_neg_restrictedGödel (e := e) |>.mp hC; apply hC; diff --git a/Foundation/FirstOrder/Incompleteness/RosserProvability.lean b/Foundation/FirstOrder/Incompleteness/RosserProvability.lean index 5a8587fab..335200dbb 100644 --- a/Foundation/FirstOrder/Incompleteness/RosserProvability.lean +++ b/Foundation/FirstOrder/Incompleteness/RosserProvability.lean @@ -42,20 +42,20 @@ lemma rosser_quote₀ {φ : Sentence L} : T.RosserProvable (V := V) ⌜φ⌝ ↔ simpa [Sentence.quote_def] using rosser_quote lemma rosser_quote_def {φ : Proposition L} : - T.RosserProvable (V := V) ⌜φ⌝ ↔ ∃ b : V, T.Proof b ⌜φ⌝ ∧ ∀ b' < b, ¬T.Proof b' ⌜∼φ⌝ := rosser_quote + T.RosserProvable (V := V) ⌜φ⌝ ↔ ∃ b : V, Proof T b ⌜φ⌝ ∧ ∀ b' < b, ¬Proof T b' ⌜∼φ⌝ := rosser_quote lemma rosser_quote_def₀ {φ : Sentence L} : - T.RosserProvable (V := V) ⌜φ⌝ ↔ ∃ b : V, T.Proof b ⌜φ⌝ ∧ ∀ b' < b, ¬T.Proof b' ⌜∼φ⌝ := by simpa [Sentence.quote_def] using rosser_quote + T.RosserProvable (V := V) ⌜φ⌝ ↔ ∃ b : V, Proof T b ⌜φ⌝ ∧ ∀ b' < b, ¬Proof T b' ⌜∼φ⌝ := by simpa [Sentence.quote_def] using rosser_quote -def RosserProvable.to_provable {φ : V} : T.RosserProvable φ → T.Provable φ := ProvabilityComparison.le_to_provable +def RosserProvable.to_provable {φ : V} : T.RosserProvable φ → Provable T φ := ProvabilityComparison.le_to_provable -lemma provable_of_standard_proof {n : ℕ} {φ : Sentence L} : T.Proof (n : V) ⌜φ⌝ → T ⊢ φ := fun h ↦ by - have : T.Proof n ⌜φ⌝ ↔ T.Proof (↑n : V) ⌜φ⌝ := by +lemma provable_of_standard_proof {n : ℕ} {φ : Sentence L} : Proof T (n : V) ⌜φ⌝ → T ⊢ φ := fun h ↦ by + have : Proof T n ⌜φ⌝ ↔ Proof T (↑n : V) ⌜φ⌝ := by simpa [Sentence.coe_quote_eq_quote] using - Defined.shigmaOne_absolute V (φ := T.proof) - (R := fun v ↦ T.Proof (v 0) (v 1)) (R' := fun v ↦ T.Proof (v 0) (v 1)) - Theory.Proof.defined Theory.Proof.defined ![n, ⌜φ⌝] - have : T.Provable (⌜φ⌝ : ℕ) := ⟨n, this.mpr h⟩ + Defined.shigmaOne_absolute V (φ := proof T) + (R := fun v ↦ Proof T (v 0) (v 1)) (R' := fun v ↦ Proof T (v 0) (v 1)) + Proof.defined Proof.defined ![n, ⌜φ⌝] + have : Provable T (⌜φ⌝ : ℕ) := ⟨n, this.mpr h⟩ exact provable_iff_provable.mp this open Classical @@ -63,7 +63,7 @@ open Classical def rosser_internalize [Entailment.Consistent T] {φ : Sentence L} : T ⊢ φ → T.RosserProvable (⌜φ⌝ : V) := by intro h let n : ℕ := ⌜h.get⌝ - have hn : T.Proof (↑n : V) ⌜φ⌝ := by simp [n, coe_quote_proof_eq] + have hn : Proof T (↑n : V) ⌜φ⌝ := by simp [n, coe_quote_proof_eq] refine rosser_quote_def₀.mpr ⟨n, hn, ?_⟩ intro b hb Hb rcases eq_nat_of_lt_nat hb with ⟨b, rfl⟩ @@ -79,7 +79,7 @@ open Classical in def not_rosserProvable [Entailment.Consistent T] {φ : Sentence L} : T ⊢ ∼φ → ¬T.RosserProvable (⌜φ⌝ : V) := by rintro h r let n : ℕ := ⌜h.get⌝ - have hn : T.Proof (↑n : V) ⌜∼φ⌝ := by simp [n, coe_quote_proof_eq] + have hn : Proof T (↑n : V) ⌜∼φ⌝ := by simp [n, coe_quote_proof_eq] rcases rosser_quote₀.mp r with ⟨b, hb, Hb⟩ have : b ≤ n := by grind; rcases eq_nat_of_le_nat this with ⟨b, rfl⟩ @@ -106,11 +106,11 @@ variable {T : Theory L} [T.Δ₁] [Entailment.Consistent T] local prefix:90 "𝗥" => T.rosserPred theorem rosserProvable_D1 {σ} : T ⊢ σ → 𝗜𝚺₁ ⊢ 𝗥σ := fun h ↦ - provable_of_models _ _ fun (V : Type) _ _ ↦ by + complete 𝗜𝚺₁ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using rosser_internalize_sentence h theorem rosserProvable_rosser {σ} : T ⊢ ∼σ → 𝗜𝚺₁ ⊢ ∼𝗥σ := fun h ↦ - provable_of_models _ _ fun (V : Type) _ _ ↦ by + complete 𝗜𝚺₁ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using not_rosserProvable_sentence h end diff --git a/Foundation/FirstOrder/Incompleteness/StandardProvability.lean b/Foundation/FirstOrder/Incompleteness/StandardProvability.lean index 856ccce79..e666b03f5 100644 --- a/Foundation/FirstOrder/Incompleteness/StandardProvability.lean +++ b/Foundation/FirstOrder/Incompleteness/StandardProvability.lean @@ -23,27 +23,27 @@ section variable {L : Language} [L.Encodable] [L.LORDefinable] {T : Theory L} [T.Δ₁] -local prefix:90 "□" => T.provabilityPred +local prefix:90 "□" => provabilityPred T /-- The derivability condition D1. -/ theorem provable_D1 {σ} : T ⊢ σ → 𝗜𝚺₁ ⊢ □σ := fun h ↦ - provable_of_models _ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using internalize_provability (V := V) h + complete 𝗜𝚺₁ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using internalize_provability (V := V) h /-- The derivability condition D2. -/ theorem provable_D2 {σ π} : 𝗜𝚺₁ ⊢ □(σ 🡒 π) 🡒 □σ 🡒 □π := - provable_of_models _ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using modus_ponens_sentence T + complete 𝗜𝚺₁ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using modus_ponens_sentence T variable (T) noncomputable abbrev _root_.LO.FirstOrder.Theory.standardProvability : Provability 𝗜𝚺₁ T where - prov := T.provable + prov := provable T bew_def := provable_D1 variable {T} instance : T.standardProvability.HBL2 := ⟨provable_D2⟩ -lemma standardProvability_def (σ : Sentence L) : T.standardProvability σ = T.provabilityPred σ := rfl +lemma standardProvability_def (σ : Sentence L) : T.standardProvability σ = provabilityPred T σ := rfl instance [T.Δ₁] : T.standardProvability.SoundOn ℕ := ⟨fun h ↦ by simpa [Arithmetic.standardProvability_def, models_iff] using h⟩ @@ -54,11 +54,11 @@ section arithmetic variable {T U : ArithmeticTheory} [T.Δ₁] -local prefix:90 "□" => T.provabilityPred +local prefix:90 "□" => provabilityPred T lemma provable_sigma_one_complete [𝗣𝗔⁻ ⪯ T] {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : 𝗜𝚺₁ ⊢ σ 🡒 □σ := - provable_of_models _ _ fun (V : Type) _ _ ↦ by + complete 𝗜𝚺₁ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using Bootstrapping.Arithmetic.sigma_one_complete (T := T) (V := V) hσ /-- The derivability condition D3. -/ @@ -68,13 +68,13 @@ theorem provable_D3 [𝗣𝗔⁻ ⪯ T] {σ : Sentence ℒₒᵣ} : open LO.Entailment LO.Entailment.FiniteContext lemma provable_D2_context [𝗜𝚺₁ ⪯ U] {Γ σ π} (hσπ : Γ ⊢[U] □(σ 🡒 π)) (hσ : Γ ⊢[U] □σ) : - Γ ⊢[U] □π := FiniteContext.of'! (weakening inferInstance provable_D2) ⨀! hσπ ⨀! hσ + Γ ⊢[U] □π := FiniteContext.of'! (weakening inferInstance provable_D2) ⨀ hσπ ⨀ hσ lemma provable_D3_context [𝗣𝗔⁻ ⪯ T] [𝗜𝚺₁ ⪯ U] {Γ σ} (hσπ : Γ ⊢[U] □σ) : - Γ ⊢[U] □□σ := FiniteContext.of'! (weakening inferInstance provable_D3) ⨀! hσπ + Γ ⊢[U] □□σ := FiniteContext.of'! (weakening inferInstance provable_D3) ⨀ hσπ lemma provable_sound [U.SoundOnHierarchy 𝚺 1] {σ} : U ⊢ □σ → T ⊢ σ := fun h ↦ by - have : ℕ ⊧ₘ T.provabilityPred σ := ArithmeticTheory.SoundOn.sound (F := Arithmetic.Hierarchy 𝚺 1) h (by simp) + have : ℕ↓[ℒₒᵣ] ⊧ provabilityPred T σ := ArithmeticTheory.SoundOn.sound (F := Arithmetic.Hierarchy 𝚺 1) h (by simp) simpa [models_iff] using this lemma provable_complete [U.SoundOnHierarchy 𝚺 1] [𝗜𝚺₁ ⪯ U] {σ} : T ⊢ σ ↔ U ⊢ □σ := diff --git a/Foundation/FirstOrder/Incompleteness/Tarski.lean b/Foundation/FirstOrder/Incompleteness/Tarski.lean index 69a55126e..a410e1ce6 100644 --- a/Foundation/FirstOrder/Incompleteness/Tarski.lean +++ b/Foundation/FirstOrder/Incompleteness/Tarski.lean @@ -18,7 +18,7 @@ lemma not_exists_tarski_predicate : ¬∃ τ : Semisentence ℒₒᵣ 1, ∀ σ, cl_prover [h₁, h₂]; /-- Tarski's Undefinability of Truth Theorem. -/ -theorem undefinability_of_truth : ¬∃ τ : Semisentence ℒₒᵣ 1, ∀ σ : Sentence ℒₒᵣ, ℕ ⊧ₘ σ ↔ ℕ ⊧ₘ τ/[⌜σ⌝] := by +theorem undefinability_of_truth : ¬∃ τ : Semisentence ℒₒᵣ 1, ∀ σ : Sentence ℒₒᵣ, ℕ↓[ℒₒᵣ] ⊧ σ ↔ ℕ↓[ℒₒᵣ] ⊧ τ/[⌜σ⌝] := by have := not_exists_tarski_predicate (T := 𝗧𝗔); contrapose! this; obtain ⟨τ, hτ⟩ := this; diff --git a/Foundation/FirstOrder/Incompleteness/WitnessComparison.lean b/Foundation/FirstOrder/Incompleteness/WitnessComparison.lean index da96679b4..94a5d6bf2 100644 --- a/Foundation/FirstOrder/Incompleteness/WitnessComparison.lean +++ b/Foundation/FirstOrder/Incompleteness/WitnessComparison.lean @@ -18,15 +18,15 @@ variable {L : Language} [L.Encodable] [L.LORDefinable] variable (T : Theory L) [T.Δ₁] def _root_.LO.FirstOrder.Theory.ProvabilityComparisonLE (φ ψ : V) : Prop := - ∃ b, T.Proof b φ ∧ ∀ b' < b, ¬T.Proof b' ψ + ∃ b, Proof T b φ ∧ ∀ b' < b, ¬Proof T b' ψ def _root_.LO.FirstOrder.Theory.ProvabilityComparisonLT (φ ψ : V) : Prop := - ∃ b, T.Proof b φ ∧ ∀ b' ≤ b, ¬T.Proof b' ψ + ∃ b, Proof T b φ ∧ ∀ b' ≤ b, ¬Proof T b' ψ section noncomputable def _root_.LO.FirstOrder.Theory.provabilityComparisonLE : 𝚺₁.Semisentence 2 := .mkSigma - “φ ψ. ∃ b, !T.proof.sigma b φ ∧ ∀ b' < b, ¬!T.proof.pi b' ψ” + “φ ψ. ∃ b, !(proof T).sigma b φ ∧ ∀ b' < b, ¬!(proof T).pi b' ψ” instance _root_.LO.FirstOrder.Theory.provability_comparison_le_defined : 𝚺₁-Relation[V] T.ProvabilityComparisonLE via T.provabilityComparisonLE := .mk fun v ↦ by @@ -41,7 +41,7 @@ instance _root_.LO.FirstOrder.Theory.provability_comparison_le_definable' : noncomputable def _root_.LO.FirstOrder.Theory.provabilityComparisonLT : 𝚺₁.Semisentence 2 := .mkSigma - “φ ψ. ∃ b, !T.proof.sigma b φ ∧ ∀ b' <⁺ b, ¬!T.proof.pi b' ψ” + “φ ψ. ∃ b, !(proof T).sigma b φ ∧ ∀ b' <⁺ b, ¬!(proof T).pi b' ψ” instance _root_.LO.FirstOrder.Theory.provability_comparison_lt_defined : 𝚺₁-Relation[V] T.ProvabilityComparisonLT via T.provabilityComparisonLT := .mk fun v ↦ by @@ -64,7 +64,7 @@ variable {φ ψ χ : V} local infixl:50 "≼" => T.ProvabilityComparisonLE local infixl:50 "≺" => T.ProvabilityComparisonLT -local prefix:50 "□" => T.Provable +local prefix:50 "□" => Provable T @[grind =>] lemma le_of_lt : φ ≺ ψ → φ ≼ ψ := by rintro ⟨b, _⟩; exact ⟨b, by grind⟩ @@ -82,7 +82,7 @@ lemma le_antisymm : φ ≼ ψ → ψ ≼ φ → φ = ψ := by by_contra ne wlog lt : b < d · grind; - have : ¬T.Proof b φ := Hd b lt + have : ¬Proof T b φ := Hd b lt contradiction have : ({φ} : V) = {ψ} := by simp [←hb.1, ←hd.1, this] simpa using this @@ -92,13 +92,13 @@ lemma iff_le_refl_provable : φ ≼ φ ↔ □φ := by constructor · exact le_to_provable · rintro ⟨b, hb⟩ - have : ∃ b, T.Proof b φ ∧ ∀ z < b, ¬T.Proof z φ := - InductionOnHierarchy.least_number_sigma 𝚺 1 (P := (T.Proof · φ)) (by definability) hb + have : ∃ b, Proof T b φ ∧ ∀ z < b, ¬Proof T z φ := + InductionOnHierarchy.least_number_sigma 𝚺 1 (P := (Proof T · φ)) (by definability) hb rcases this with ⟨b, bd, h⟩ exact ⟨b, bd, h⟩ @[grind .] -lemma lt_irrefl : ¬φ ≺ φ := by rintro ⟨b, hb, h⟩; have : ¬T.Proof b φ := h b (by simp); contradiction +lemma lt_irrefl : ¬φ ≺ φ := by rintro ⟨b, hb, h⟩; have : ¬Proof T b φ := h b (by simp); contradiction @[grind =>] lemma lt_trans : φ ≺ ψ → ψ ≺ χ → φ ≺ χ := by rintro ⟨b, hb, h⟩ ⟨d, hd, H⟩; use b; grind; @@ -110,10 +110,10 @@ lemma not_lt_of_le : φ ≼ ψ → ¬ψ ≺ φ := by grind; lemma find_minimal_proof_fintype [Fintype ι] (φ : ι → V) (H : □(φ i)) : ∃ j, ∀ k, (φ j) ≼ (φ k) := by - rcases show ∃ dᵢ, T.Proof dᵢ (φ i)from H with ⟨dᵢ, Hdᵢ⟩ - have : ∃ z, (∃ j, T.Proof z (φ j)) ∧ ∀ w < z, ∀ x, ¬T.Proof w (φ x) := by + rcases show ∃ dᵢ, Proof T dᵢ (φ i)from H with ⟨dᵢ, Hdᵢ⟩ + have : ∃ z, (∃ j, Proof T z (φ j)) ∧ ∀ w < z, ∀ x, ¬Proof T w (φ x) := by simpa using - InductionOnHierarchy.least_number_sigma 𝚺 1 (P := fun z ↦ ∃ j, T.Proof z (φ j)) + InductionOnHierarchy.least_number_sigma 𝚺 1 (P := fun z ↦ ∃ j, Proof T z (φ j)) (HierarchySymbol.Definable.fintype_exs fun j ↦ by definability) (x := dᵢ) ⟨i, Hdᵢ⟩ rcases this with ⟨z, ⟨j, hj⟩, H⟩ exact ⟨j, fun k ↦ ⟨z, hj, fun w hw ↦ H w hw k⟩⟩ diff --git a/Foundation/FirstOrder/Incompleteness/Yablo.lean b/Foundation/FirstOrder/Incompleteness/Yablo.lean index e7aeffc40..365d229e8 100644 --- a/Foundation/FirstOrder/Incompleteness/Yablo.lean +++ b/Foundation/FirstOrder/Incompleteness/Yablo.lean @@ -13,7 +13,7 @@ namespace LO.FirstOrder.Arithmetic open ORingStructure -variable {M : Type*} [ORingStructure M] [M ⊧ₘ* 𝗣𝗔⁻] +variable {M : Type*} [ORingStructure M] [M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] lemma numeral_lt_of_numeral_succ_lt {n : ℕ} {m : M} : (numeral (n + 1) : M) < m → (numeral n < m) := by apply Arithmetic.lt_trans; @@ -49,10 +49,10 @@ namespace Theory variable {V} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {T U : ArithmeticTheory} [T.Δ₁] -def YabloSystem (T : ArithmeticTheory) [T.Δ₁] (φ n : V) : Prop := ∀ m, n < m → ¬T.Provable (substNumeral φ m) +def YabloSystem (T : ArithmeticTheory) [T.Δ₁] (φ n : V) : Prop := ∀ m, n < m → ¬Provable T (substNumeral φ m) noncomputable def yabloSystem (T : ArithmeticTheory) [T.Δ₁] : 𝚷₁.Semisentence 2 := .mkPi - “φ n. ∀ m, n < m → ∀ nσ, !ssnum nσ φ m → ¬!T.provable (nσ)” + “φ n. ∀ m, n < m → ∀ nσ, !ssnum nσ φ m → ¬!(provable T) (nσ)” instance yabloSystem.defined : 𝚷₁-Relation[V] (T.YabloSystem) via T.yabloSystem := .mk fun f ↦ by simp [Theory.YabloSystem, Theory.yabloSystem]; @@ -79,43 +79,44 @@ variable {U : ArithmeticTheory} [𝗜𝚺₁ ⪯ U] lemma yablo_diagonal : U ⊢ ∀⁰ (T.yablo 🡘 (T.yabloSystem)/[⌜T.yablo⌝, #0]) := parameterized_diagonal₁ _ -lemma yablo_diagonal_modeled (n : V) : V ⊧/![n] (T.yablo) ↔ ∀ m, n < m → ¬T.Provable (substNumeral ⌜T.yablo⌝ m) := by - have : V ⊧ₘ ∀⁰ (T.yablo 🡘 ↑(T.yabloSystem)/[⌜T.yablo⌝, #0]) := models_of_provable (T := 𝗜𝚺₁) (by assumption) $ yablo_diagonal; +lemma yablo_diagonal_modeled (n : V) : V ⊧/![n] (T.yablo) ↔ ∀ m, n < m → ¬Provable T (substNumeral ⌜T.yablo⌝ m) := by + have : V↓[ℒₒᵣ] ⊧ ∀⁰ (T.yablo 🡘 ↑(T.yabloSystem)/[⌜T.yablo⌝, #0]) := models_of_provable (T := 𝗜𝚺₁) (by assumption) $ yablo_diagonal; have : ∀ (n : V), V ⊧/![n] (T.yablo) ↔ T.YabloSystem ⌜T.yablo⌝ n := by simpa [models_iff, Matrix.comp_vecCons'] using this; apply this; -lemma yablo_diagonal_neg_modeled (n : V) : ¬V ⊧/![n] (T.yablo) ↔ ∃ m, n < m ∧ T.Provable (substNumeral ⌜T.yablo⌝ m) := by +lemma yablo_diagonal_neg_modeled (n : V) : ¬V ⊧/![n] (T.yablo) ↔ ∃ m, n < m ∧ Provable T (substNumeral ⌜T.yablo⌝ m) := by simpa using yablo_diagonal_modeled n |>.not; -lemma iff_yablo_provable (n : ℕ) : U ⊢ T.yabloPred n ↔ U ⊢ “∀ m, ↑n < m → ∀ nσ, !ssnum nσ ⌜T.yablo⌝ m → ¬!T.provable (nσ)” := by - suffices U ⊢ T.yablo/[n] 🡘 “∀ m, ↑n < m → ∀ nσ, !ssnum nσ ⌜T.yablo⌝ m → ¬!T.provable (nσ)” by +lemma iff_yablo_provable (n : ℕ) : U ⊢ T.yabloPred n ↔ U ⊢ “∀ m, ↑n < m → ∀ nσ, !ssnum nσ ⌜T.yablo⌝ m → ¬!(provable T) (nσ)” := by + suffices U ⊢ T.yablo/[n] 🡘 “∀ m, ↑n < m → ∀ nσ, !ssnum nσ ⌜T.yablo⌝ m → ¬!(provable T) (nσ)” by constructor <;> . intro h; cl_prover [h, this]; - apply provable_of_models.{0}; + apply complete.{0} U _; intro V _ _; haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; haveI : V ⊧/![ORingStructure.numeral n] (T.yablo) ↔ T.YabloSystem ⌜T.yablo⌝ (ORingStructure.numeral n) := yablo_diagonal_modeled _; simpa [models_iff, Matrix.constant_eq_singleton, Matrix.comp_vecCons'] using this; -lemma iff_neg_yablo_provable (n : ℕ) : U ⊢ ∼(T.yabloPred n) ↔ U ⊢ “∃ m, ↑n < m ∧ ∃ nσ, !ssnum nσ ⌜T.yablo⌝ m ∧ !T.provable (nσ)” := by - suffices U ⊢ ∼T.yablo/[n] 🡘 “∃ m, ↑n < m ∧ ∃ nσ, !ssnum nσ ⌜T.yablo⌝ m ∧ !T.provable (nσ)” by +lemma iff_neg_yablo_provable (n : ℕ) : U ⊢ ∼(T.yabloPred n) ↔ U ⊢ “∃ m, ↑n < m ∧ ∃ nσ, !ssnum nσ ⌜T.yablo⌝ m ∧ !(provable T) (nσ)” := by + suffices U ⊢ ∼T.yablo/[n] 🡘 “∃ m, ↑n < m ∧ ∃ nσ, !ssnum nσ ⌜T.yablo⌝ m ∧ !(provable T) (nσ)” by constructor <;> . intro h; cl_prover [h, this]; - apply provable_of_models.{0}; + apply complete.{0} U _; intro V _ _; haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; haveI : ¬V ⊧/![ORingStructure.numeral n] (T.yablo) ↔ ∃ m, ORingStructure.numeral n < m ∧ Provable T (substNumeral ⌜T.yablo⌝ m) := yablo_diagonal_neg_modeled _; simpa [models_iff, Matrix.constant_eq_singleton, Matrix.comp_vecCons'] using this; lemma provable_greater_yablo {n m : ℕ} (hnm : n < m) : U ⊢ T.yabloPred n 🡒 T.yabloPred m := by - apply provable_of_models.{0}; + apply complete.{0} U _; intro V _ _; haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; - suffices - (∀ m, ORingStructure.numeral n < m → ¬Provable T (substNumeral ⌜yablo T⌝ m)) → - (∀ k, ORingStructure.numeral m < k → ¬Provable T (substNumeral ⌜yablo T⌝ k)) - by simpa [models_iff, Matrix.constant_eq_singleton, Matrix.comp_vecCons', yablo_diagonal_modeled] using this; - intro h k hmk; - apply h; - apply Arithmetic.lt_trans _ _ _ (by simpa) hmk; + apply Semantics.Imp.models_imply.mpr + intro h + have hn : V ⊧/![ORingStructure.numeral n] T.yablo := by simpa [models_iff] using h + have hm : V ⊧/![ORingStructure.numeral m] T.yablo := (yablo_diagonal_modeled (T := T) (n := (ORingStructure.numeral m : V))).mpr <| by + intro k hmk + exact (yablo_diagonal_modeled (T := T) (n := (ORingStructure.numeral n : V))).mp hn k + (Arithmetic.lt_trans _ _ _ (by simpa) hmk) + simpa [models_iff] using hm end @@ -126,17 +127,17 @@ variable [𝗜𝚺₁ ⪯ T] {n : ℕ} theorem yablo_unprovable [Entailment.Consistent T] : T ⊬ (T.yabloPred n) := by by_contra! hC; - have H₁ : T ⊢ T.provabilityPred (T.yabloPred (n + 1)) := by + have H₁ : T ⊢ provabilityPred T (T.yabloPred (n + 1)) := by apply Entailment.WeakerThan.pbl $ provable_D1 (T := T) ?_; apply provable_greater_yablo (show n < n + 1 by omega) ⨀ hC; - have H₂ : T ⊢ ∼T.provabilityPred (T.yabloPred (n + 1)) := by - apply provable_of_models.{0}; + have H₂ : T ⊢ ∼provabilityPred T (T.yabloPred (n + 1)) := by + apply complete.{0} T _; intro V _ _; haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance; - suffices ¬T.Provable (substNumeral ⌜T.yablo⌝ (n + 1 : V)) by + suffices ¬Provable T (substNumeral ⌜T.yablo⌝ (n + 1 : V)) by simpa [provabilityPred, models_iff, ←substNumeral_app_quote_nat_model]; - have : ∀ (x : V), ORingStructure.numeral n < x → ¬T.Provable (substNumeral ⌜T.yablo⌝ x) := by - have : V ⊧ₘ “∀ m, ↑n < m → ∀ nσ, !ssnum nσ ⌜T.yablo⌝ m → ¬!T.provable (nσ)” := + have : ∀ (x : V), ORingStructure.numeral n < x → ¬Provable T (substNumeral ⌜T.yablo⌝ x) := by + have : V↓[ℒₒᵣ] ⊧ “∀ m, ↑n < m → ∀ nσ, !ssnum nσ ⌜T.yablo⌝ m → ¬!(provable T) (nσ)” := models_of_provable (T := T) (by assumption) $ (iff_yablo_provable n |>.mp hC); simpa [models_iff, Matrix.comp_vecCons'] using this; apply this (n + 1) (by simp [numeral_eq_natCast]);