├── lean-toolchain ├── .gitignore ├── .editorconfig ├── Incompleteness.lean ├── .github └── workflows │ ├── ci.yml │ └── update.yml ├── lakefile.lean ├── README.md ├── Incompleteness ├── ToFoundation │ └── Basic.lean ├── Arith │ ├── DC.lean │ ├── First.lean │ ├── D3.lean │ ├── Second.lean │ ├── FormalizedArithmetic.lean │ ├── D1.lean │ └── Theory.lean ├── ProvabilityLogic │ └── Basic.lean └── DC │ └── Basic.lean ├── lake-manifest.json └── LICENSE /lean-toolchain: -------------------------------------------------------------------------------- 1 | leanprover/lean4:v4.16.0-rc2 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /lake-packages/* 3 | /.lake 4 | 5 | # import graph 6 | import_graph.* 7 | 8 | # VSCode 9 | .vscode/settings.json -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [*.{yml,yaml}] 12 | indent_style = space 13 | indent_size = 2 14 | -------------------------------------------------------------------------------- /Incompleteness.lean: -------------------------------------------------------------------------------- 1 | import Incompleteness.Arith.FormalizedArithmetic 2 | import Incompleteness.Arith.Theory 3 | import Incompleteness.Arith.D1 4 | import Incompleteness.Arith.D3 5 | import Incompleteness.Arith.First 6 | import Incompleteness.Arith.Second 7 | import Incompleteness.Arith.DC 8 | import Incompleteness.DC.Basic 9 | 10 | import Incompleteness.ProvabilityLogic.Basic 11 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | branches: 6 | - "master" 7 | pull_request: 8 | workflow_dispatch: 9 | 10 | concurrency: 11 | group: ${{ github.workflow }}-${{ github.ref }} 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | build: 16 | name: Build project 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v4 20 | - uses: leanprover/lean-action@v1 -------------------------------------------------------------------------------- /.github/workflows/update.yml: -------------------------------------------------------------------------------- 1 | name: Update 2 | 3 | on: 4 | schedule: 5 | - cron: "0 8 * * 0" # at 08:00 (UTC) on Sunday 6 | workflow_dispatch: 7 | 8 | jobs: 9 | update: 10 | runs-on: ubuntu-latest 11 | 12 | permissions: 13 | contents: write 14 | issues: write 15 | pull-requests: write 16 | 17 | steps: 18 | - uses: actions/checkout@v4 19 | - uses: oliver-butterley/lean-update@v1-alpha 20 | with: 21 | on_update_succeeds: pr 22 | -------------------------------------------------------------------------------- /lakefile.lean: -------------------------------------------------------------------------------- 1 | import Lake 2 | open Lake DSL 3 | 4 | package incompleteness where 5 | -- Settings applied to both builds and interactive editing 6 | leanOptions := #[ 7 | ⟨`pp.unicode.fun, true⟩ -- pretty-prints `fun a ↦ b` 8 | ] 9 | -- add any additional package configuration options here 10 | 11 | @[default_target] 12 | lean_lib Incompleteness where 13 | -- add any library configuration options here 14 | 15 | require "FormalizedFormalLogic" / "arithmetization" @ git "master" 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Incompleteness 2 | 3 | **Archived: This repository is integrated into [Foundation](https://github.com/FormalizedFormalLogic/Foundation) now.** 4 | 5 | Formalization of incompleteness theorem related results. This project depends on [Foundation](https://github.com/FormalizedFormalLogic/Foundation) and [Arithmetization](https://github.com/FormalizedFormalLogic/Arithmetization). 6 | 7 | ## Sponsor 8 | 9 | This project is supported by [Proxima Technology]. 10 | 11 | [][Proxima Technology] 12 | 13 | [Proxima Technology]: https://proxima-ai-tech.com/ -------------------------------------------------------------------------------- /Incompleteness/ToFoundation/Basic.lean: -------------------------------------------------------------------------------- 1 | import Foundation.FirstOrder.Arith.Hierarchy 2 | 3 | namespace Fin 4 | 5 | @[inline] def addCast (m) : Fin n → Fin (m + n) := 6 | castLE <| Nat.le_add_left n m 7 | 8 | @[simp] lemma addCast_val (i : Fin n) : (i.addCast m : ℕ) = i := rfl 9 | 10 | end Fin 11 | 12 | namespace Matrix 13 | 14 | variable {α : Type*} 15 | 16 | @[simp] lemma appeendr_addCast (u : Fin m → α) (v : Fin n → α) (i : Fin m) : 17 | appendr u v (i.addCast n) = u i := by simp [appendr, vecAppend_eq_ite] 18 | 19 | @[simp] lemma appeendr_addNat (u : Fin m → α) (v : Fin n → α) (i : Fin n) : 20 | appendr u v (i.addNat m) = v i := by simp [appendr, vecAppend_eq_ite] 21 | 22 | end Matrix 23 | 24 | namespace LO.FirstOrder 25 | 26 | variable {L : Language} 27 | 28 | namespace Semiformula 29 | 30 | open Rew 31 | 32 | variable (ω : Rew L ξ₁ n₁ ξ₂ n₂) 33 | 34 | 35 | end Semiformula 36 | 37 | end LO.FirstOrder 38 | -------------------------------------------------------------------------------- /Incompleteness/Arith/DC.lean: -------------------------------------------------------------------------------- 1 | import Incompleteness.Arith.First 2 | import Incompleteness.Arith.Second 3 | import Incompleteness.DC.Basic 4 | 5 | noncomputable section 6 | 7 | open LO.FirstOrder.DerivabilityCondition 8 | 9 | namespace LO.FirstOrder.Arith 10 | 11 | open LO.Arith LO.Arith.Formalized 12 | 13 | variable (T : Theory ℒₒᵣ) [𝐈𝚺₁ ⪯ T] 14 | 15 | variable (U : Theory ℒₒᵣ) [U.Delta1Definable] [ℕ ⊧ₘ* U] [𝐑₀ ⪯ U] 16 | 17 | instance : Diagonalization T where 18 | fixpoint := fixpoint 19 | diag θ := diagonal θ 20 | 21 | abbrev _root_.LO.FirstOrder.Theory.standardDP : ProvabilityPredicate T U where 22 | prov := U.provableₐ 23 | spec := provableₐ_D1 24 | 25 | instance : (Theory.standardDP T U).HBL2 := ⟨provableₐ_D2⟩ 26 | instance : (Theory.standardDP T U).HBL3 := ⟨provableₐ_D3⟩ 27 | instance : (Theory.standardDP T U).HBL := ⟨⟩ 28 | instance : (Theory.standardDP T U).GoedelSound := ⟨fun h ↦ by simpa using provableₐ_sound h⟩ 29 | 30 | end LO.FirstOrder.Arith 31 | 32 | end 33 | -------------------------------------------------------------------------------- /Incompleteness/Arith/First.lean: -------------------------------------------------------------------------------- 1 | import Incompleteness.Arith.D1 2 | 3 | 4 | namespace List.Vector 5 | 6 | variable {α : Type*} 7 | 8 | lemma cons_get {x : α} : (x ::ᵥ List.Vector.nil).get = ![x] := by 9 | ext i; 10 | simp; 11 | 12 | end List.Vector 13 | 14 | 15 | namespace LO.FirstOrder 16 | 17 | namespace Arith 18 | 19 | open LO.Arith LO.Entailment LO.Arith.Formalized 20 | 21 | lemma re_iff_sigma1 {P : ℕ → Prop} : RePred P ↔ 𝚺₁-Predicate P := by 22 | constructor 23 | · intro h 24 | exact ⟨.mkSigma (codeOfRePred P) (by simp [codeOfRePred, codeOfPartrec']), by 25 | intro v; symm; simp; simpa [←Matrix.constant_eq_singleton'] using codeOfRePred_spec h (x := v 0)⟩ 26 | · rintro ⟨φ, hφ⟩ 27 | have := (sigma1_re id (φ.sigma_prop)).comp 28 | (f := fun x : ℕ ↦ x ::ᵥ List.Vector.nil) (Primrec.to_comp <| Primrec.vector_cons.comp .id (.const _)) 29 | exact this.of_eq <| by intro x; symm; simpa [List.Vector.cons_get] using hφ ![x]; 30 | 31 | variable (T : Theory ℒₒᵣ) [𝐑₀ ⪯ T] [Sigma1Sound T] [T.Delta1Definable] 32 | 33 | /-- Gödel's First Incompleteness Theorem-/ 34 | theorem goedel_first_incompleteness : ¬Entailment.Complete T := by 35 | let D : ℕ → Prop := fun n : ℕ ↦ ∃ φ : SyntacticSemiformula ℒₒᵣ 1, n = ⌜φ⌝ ∧ T ⊢! ∼φ/[⌜φ⌝] 36 | have D_re : RePred D := by 37 | have : 𝚺₁-Predicate fun φ : ℕ ↦ 38 | ⌜ℒₒᵣ⌝.IsSemiformula 1 φ ∧ (T.codeIn ℕ).Provable (⌜ℒₒᵣ⌝.neg <| ⌜ℒₒᵣ⌝.substs ?[numeral φ] φ) := by definability 39 | exact (re_iff_sigma1.mpr this).of_eq <| by 40 | intro φ; constructor 41 | · rintro ⟨hφ, b⟩ 42 | rcases hφ.sound with ⟨φ, rfl⟩ 43 | refine ⟨φ, rfl, Language.Theory.Provable.sound (by simpa)⟩ 44 | · rintro ⟨φ, rfl, b⟩ 45 | exact ⟨by simp, by simpa using provable_of_provable (V := ℕ) b⟩ 46 | let σ : SyntacticSemiformula ℒₒᵣ 1 := codeOfRePred (D) 47 | let ρ : SyntacticFormula ℒₒᵣ := σ/[⌜σ⌝] 48 | have : ∀ n : ℕ, D n ↔ T ⊢! σ/[‘↑n’] := fun n ↦ by 49 | simpa [Semiformula.coe_substs_eq_substs_coe₁] using re_complete (T := T) (D_re) (x := n) 50 | have : T ⊢! ∼ρ ↔ T ⊢! ρ := by 51 | simpa [D, goedelNumber'_def, quote_eq_encode] using this ⌜σ⌝ 52 | have con : Entailment.Consistent T := consistent_of_sigma1Sound T 53 | refine LO.Entailment.incomplete_iff_exists_undecidable.mpr ⟨↑ρ, ?_, ?_⟩ 54 | · intro h 55 | have : T ⊢! ∼↑ρ := by simpa [provable₀_iff] using this.mpr h 56 | exact LO.Entailment.not_consistent_iff_inconsistent.mpr (inconsistent_of_provable_of_unprovable h this) inferInstance 57 | · intro h 58 | have : T ⊢! ↑ρ := this.mp (by simpa [provable₀_iff] using h) 59 | exact LO.Entailment.not_consistent_iff_inconsistent.mpr (inconsistent_of_provable_of_unprovable this h) inferInstance 60 | 61 | end LO.FirstOrder.Arith 62 | -------------------------------------------------------------------------------- /Incompleteness/ProvabilityLogic/Basic.lean: -------------------------------------------------------------------------------- 1 | import Incompleteness.Arith.DC 2 | import Incompleteness.DC.Basic 3 | import Foundation.Modal.Logic.WellKnown 4 | 5 | namespace LO 6 | 7 | open LO.FirstOrder LO.FirstOrder.DerivabilityCondition 8 | open LO.Modal 9 | open LO.Modal.Hilbert 10 | 11 | variable {α : Type u} 12 | variable [Semiterm.Operator.GoedelNumber L (Sentence L)] 13 | {T U : Theory L} 14 | 15 | 16 | namespace ProvabilityLogic 17 | 18 | /-- Mapping modal prop vars to first-order sentence -/ 19 | def Realization (L) := ℕ → FirstOrder.Sentence L 20 | 21 | /-- Mapping modal formulae to first-order sentence -/ 22 | def Realization.interpret 23 | {T U : FirstOrder.Theory L} 24 | (f : Realization L) (𝔅 : ProvabilityPredicate T U) : Formula ℕ → FirstOrder.Sentence L 25 | | .atom a => f a 26 | | □φ => 𝔅 (f.interpret 𝔅 φ) 27 | | ⊥ => ⊥ 28 | | φ ➝ ψ => (f.interpret 𝔅 φ) ➝ (f.interpret 𝔅 ψ) 29 | 30 | variable [Semiterm.Operator.GoedelNumber L (Sentence L)] 31 | 32 | class ArithmeticalSound (Λ : Modal.Logic) (𝔅 : ProvabilityPredicate T U) where 33 | sound : ∀ {φ}, (φ ∈ Λ) → (∀ {f : Realization L}, U ⊢!. (f.interpret 𝔅 φ)) 34 | 35 | class ArithmeticalComplete (Λ : Modal.Logic) (𝔅 : ProvabilityPredicate T U) where 36 | complete : ∀ {φ}, (∀ {f : Realization L}, U ⊢!. (f.interpret 𝔅 φ)) → (φ ∈ Λ) 37 | 38 | section ArithmeticalSoundness 39 | 40 | open Entailment 41 | open Modal 42 | open ProvabilityPredicate 43 | 44 | variable {L : FirstOrder.Language} [Semiterm.Operator.GoedelNumber L (Sentence L)] 45 | [L.DecidableEq] 46 | {T U : FirstOrder.Theory L} [T ⪯ U] 47 | {𝔅 : ProvabilityPredicate T U} 48 | 49 | lemma arithmetical_soundness_N (h : (Hilbert.N) ⊢! φ) : ∀ {f : Realization L}, U ⊢!. (f.interpret 𝔅 φ) := by 50 | intro f; 51 | induction h using Hilbert.Deduction.rec! with 52 | | maxm hp => simp at hp; 53 | | nec ihp => exact D1_shift ihp; 54 | | mdp ihpq ihp => exact ihpq ⨀ ihp; 55 | | imply₁ => exact imply₁!; 56 | | imply₂ => exact imply₂!; 57 | | ec => exact elim_contra_neg!; 58 | 59 | 60 | lemma arithmetical_soundness_GL [Diagonalization T] [𝔅.HBL] (h : (Hilbert.GL) ⊢! φ) : ∀ {f : Realization L}, U ⊢!. (f.interpret 𝔅 φ) := by 61 | intro f; 62 | induction h using Hilbert.Deduction.rec! with 63 | | maxm hp => 64 | rcases (by simpa using hp) with (⟨_, rfl⟩ | ⟨_, rfl⟩) 65 | . exact D2_shift; 66 | . exact FLT_shift; 67 | | nec ihp => exact D1_shift ihp; 68 | | mdp ihpq ihp => exact ihpq ⨀ ihp; 69 | | imply₁ => exact imply₁!; 70 | | imply₂ => exact imply₂!; 71 | | ec => exact elim_contra_neg!; 72 | 73 | end ArithmeticalSoundness 74 | 75 | 76 | section 77 | 78 | instance (T : Theory ℒₒᵣ) [𝐈𝚺₁ ⪯ T] [T.Delta1Definable] : ArithmeticalSound (Logic.GL) (T.standardDP T) := ⟨arithmetical_soundness_GL⟩ 79 | 80 | end 81 | 82 | 83 | end LO.ProvabilityLogic 84 | -------------------------------------------------------------------------------- /lake-manifest.json: -------------------------------------------------------------------------------- 1 | {"version": "1.1.0", 2 | "packagesDir": ".lake/packages", 3 | "packages": 4 | [{"url": "https://github.com/FormalizedFormalLogic/Arithmetization", 5 | "type": "git", 6 | "subDir": null, 7 | "scope": "FormalizedFormalLogic", 8 | "rev": "27ad29924ea48cbef2bb0f59e07154d460aae199", 9 | "name": "arithmetization", 10 | "manifestFile": "lake-manifest.json", 11 | "inputRev": "master", 12 | "inherited": false, 13 | "configFile": "lakefile.lean"}, 14 | {"url": "https://github.com/FormalizedFormalLogic/Foundation", 15 | "type": "git", 16 | "subDir": null, 17 | "scope": "FormalizedFormalLogic", 18 | "rev": "4f2f6d4b342fec1a390cd1075c3b05456f2e08fa", 19 | "name": "foundation", 20 | "manifestFile": "lake-manifest.json", 21 | "inputRev": "master", 22 | "inherited": true, 23 | "configFile": "lakefile.toml"}, 24 | {"url": "https://github.com/leanprover-community/mathlib4", 25 | "type": "git", 26 | "subDir": null, 27 | "scope": "leanprover-community", 28 | "rev": "5608064d3be9600af7deea2cbb3955c2805dfc01", 29 | "name": "mathlib", 30 | "manifestFile": "lake-manifest.json", 31 | "inputRev": "master", 32 | "inherited": true, 33 | "configFile": "lakefile.lean"}, 34 | {"url": "https://github.com/leanprover-community/plausible", 35 | "type": "git", 36 | "subDir": null, 37 | "scope": "leanprover-community", 38 | "rev": "1622a8693b31523c8f82db48e01b14c74bc1f155", 39 | "name": "plausible", 40 | "manifestFile": "lake-manifest.json", 41 | "inputRev": "v4.16.0-rc1", 42 | "inherited": true, 43 | "configFile": "lakefile.toml"}, 44 | {"url": "https://github.com/leanprover-community/LeanSearchClient", 45 | "type": "git", 46 | "subDir": null, 47 | "scope": "leanprover-community", 48 | "rev": "003ff459cdd85de551f4dcf95cdfeefe10f20531", 49 | "name": "LeanSearchClient", 50 | "manifestFile": "lake-manifest.json", 51 | "inputRev": "main", 52 | "inherited": true, 53 | "configFile": "lakefile.toml"}, 54 | {"url": "https://github.com/leanprover-community/import-graph", 55 | "type": "git", 56 | "subDir": null, 57 | "scope": "leanprover-community", 58 | "rev": "f72319c9686788305a8ab059f3c4d8c724785c83", 59 | "name": "importGraph", 60 | "manifestFile": "lake-manifest.json", 61 | "inputRev": "main", 62 | "inherited": true, 63 | "configFile": "lakefile.toml"}, 64 | {"url": "https://github.com/leanprover-community/ProofWidgets4", 65 | "type": "git", 66 | "subDir": null, 67 | "scope": "leanprover-community", 68 | "rev": "07f60e90998dfd6592688a14cd67bd4e384b77b2", 69 | "name": "proofwidgets", 70 | "manifestFile": "lake-manifest.json", 71 | "inputRev": "v0.0.50", 72 | "inherited": true, 73 | "configFile": "lakefile.lean"}, 74 | {"url": "https://github.com/leanprover-community/aesop", 75 | "type": "git", 76 | "subDir": null, 77 | "scope": "leanprover-community", 78 | "rev": "79402ad9ab4be9a2286701a9880697e2351e4955", 79 | "name": "aesop", 80 | "manifestFile": "lake-manifest.json", 81 | "inputRev": "v4.16.0-rc1", 82 | "inherited": true, 83 | "configFile": "lakefile.toml"}, 84 | {"url": "https://github.com/leanprover-community/quote4", 85 | "type": "git", 86 | "subDir": null, 87 | "scope": "leanprover-community", 88 | "rev": "f0c584bcb14c5adfb53079781eeea75b26ebbd32", 89 | "name": "Qq", 90 | "manifestFile": "lake-manifest.json", 91 | "inputRev": "v4.15.0", 92 | "inherited": true, 93 | "configFile": "lakefile.toml"}, 94 | {"url": "https://github.com/leanprover-community/batteries", 95 | "type": "git", 96 | "subDir": null, 97 | "scope": "leanprover-community", 98 | "rev": "43dc9fd41505ba34dd359550c94706b4f4abefec", 99 | "name": "batteries", 100 | "manifestFile": "lake-manifest.json", 101 | "inputRev": "main", 102 | "inherited": true, 103 | "configFile": "lakefile.toml"}, 104 | {"url": "https://github.com/leanprover/lean4-cli", 105 | "type": "git", 106 | "subDir": null, 107 | "scope": "leanprover", 108 | "rev": "0c8ea32a15a4f74143e4e1e107ba2c412adb90fd", 109 | "name": "Cli", 110 | "manifestFile": "lake-manifest.json", 111 | "inputRev": "main", 112 | "inherited": true, 113 | "configFile": "lakefile.toml"}], 114 | "name": "incompleteness", 115 | "lakeDir": ".lake"} 116 | -------------------------------------------------------------------------------- /Incompleteness/Arith/D3.lean: -------------------------------------------------------------------------------- 1 | import Incompleteness.Arith.D1 2 | 3 | /-! 4 | 5 | # Formalized $\Sigma_1$-Completeness 6 | 7 | -/ 8 | 9 | noncomputable section 10 | 11 | open Classical 12 | 13 | namespace LO.Arith 14 | 15 | open FirstOrder FirstOrder.Arith 16 | 17 | variable {V : Type*} [ORingStruc V] [V ⊧ₘ* 𝐈𝚺₁] 18 | 19 | namespace Formalized 20 | 21 | variable {T : LOR.TTheory (V := V)} [R₀Theory T] 22 | 23 | def toNumVec {n} (e : Fin n → V) : (Language.codeIn ℒₒᵣ V).SemitermVec n 0 := 24 | ⟨⌜fun i ↦ numeral (e i)⌝, 25 | Language.IsSemitermVec.iff.mpr <| ⟨by simp, by 26 | intro i hi 27 | rcases eq_fin_of_lt_nat hi with ⟨i, rfl⟩ 28 | simp [quote_nth_fin (fun i ↦ numeral (e i)) i]⟩⟩ 29 | 30 | @[simp] lemma toNumVec_nil : (toNumVec (![] : Fin 0 → V)) = .nil _ _ := by ext; simp [toNumVec] 31 | 32 | @[simp] lemma toNumVec_nth {n} (e : Fin n → V) (i : Fin n) : (toNumVec e).nth i = ↑(e i) := by ext; simp [toNumVec] 33 | 34 | @[simp] lemma toNumVec_val_nth {n} (e : Fin n → V) (i : Fin n) : (toNumVec e).val.[i] = numeral (e i) := by simp [toNumVec] 35 | 36 | /-- TODO: move-/ 37 | @[simp] lemma coe_coe_lt {n} (i : Fin n) : (i : V) < (n : V) := 38 | calc (i : V) < (i : V) + (n - i : V) := by simp 39 | _ = (n : V) := by simp 40 | 41 | @[simp] lemma len_semitermvec {L : Arith.Language V} {pL} [L.Defined pL] (v : L.SemitermVec k n) : len v.val = k := v.prop.lh 42 | 43 | @[simp] lemma cast_substs_numVec (φ : Semisentence ℒₒᵣ (n + 1)) : 44 | ((.cast (V := V) (n := ↑(n + 1)) (n' := ↑n + 1) ⌜Rew.embs ▹ φ⌝ (by simp)) ^/[(toNumVec e).q.substs (typedNumeral 0 x).sing]) = 45 | ⌜Rew.embs ▹ φ⌝ ^/[toNumVec (x :> e)] := by 46 | have : (toNumVec e).q.substs (typedNumeral 0 x).sing = x ∷ᵗ toNumVec e := by 47 | ext; simp 48 | apply nth_ext' ((↑n : V) + 1) 49 | (by rw [len_termSubstVec]; simpa using (toNumVec e).prop.qVec.isUTerm) 50 | (by simp [(toNumVec e).prop.lh]) 51 | intro i hi 52 | rw [nth_termSubstVec (by simpa using (toNumVec e).prop.qVec.isUTerm) hi] 53 | rcases zero_or_succ i with (rfl | ⟨i, rfl⟩) 54 | · simp [Language.qVec] 55 | · simp only [Language.qVec, nth_cons_succ, Language.SemitermVec.prop] 56 | rcases eq_fin_of_lt_nat (by simpa using hi) with ⟨i, rfl⟩ 57 | rw [nth_termBShiftVec (by simp), 58 | toNumVec_val_nth, numeral_bShift, 59 | numeral_substs (n := 1) (m := 0) (by simp)] 60 | simp 61 | rw [this] 62 | ext; simp [toNumVec] 63 | 64 | namespace TProof 65 | 66 | open Language.Theory.TProof Entailment 67 | 68 | variable (T) 69 | 70 | noncomputable def termEqComplete {n : ℕ} (e : Fin n → V) : 71 | (t : Semiterm ℒₒᵣ Empty n) → T ⊢ ⌜Rew.embs t⌝^ᵗ/[toNumVec e] =' ↑(t.valbm V e) 72 | | #z => by simpa using eqRefl T (e z) 73 | | &x => Empty.elim x 74 | | Semiterm.func Language.Zero.zero v => by simpa using eqRefl T _ 75 | | Semiterm.func Language.One.one v => by simpa using eqRefl T _ 76 | | Semiterm.func Language.Add.add v => by 77 | simp only [Rew.func, Semiterm.codeIn'_add, Fin.isValue, subst_add, Semiterm.val_func, 78 | Structure.add_eq_of_lang] 79 | have ih : T ⊢ (⌜Rew.embs (v 0)⌝^ᵗ/[toNumVec e] + ⌜Rew.embs (v 1)⌝^ᵗ/[toNumVec e]) =' (↑((v 0).valbm V e) + ↑((v 1).valbm V e)) := 80 | addExt T _ _ _ _ ⨀ termEqComplete e (v 0) ⨀ termEqComplete e (v 1) 81 | have : T ⊢ ((v 0).valbm V e + (v 1).valbm V e : ⌜ℒₒᵣ⌝[V].Semiterm 0) =' ↑((v 0).valbm V e + (v 1).valbm V e) := addComplete T _ _ 82 | exact eqTrans T _ _ _ ⨀ ih ⨀ this 83 | | Semiterm.func Language.Mul.mul v => by 84 | simp [Rew.func, Semiterm.val_func] 85 | have ih : T ⊢ (⌜Rew.embs (v 0)⌝^ᵗ/[toNumVec e] * ⌜Rew.embs (v 1)⌝^ᵗ/[toNumVec e]) =' (↑((v 0).valbm V e) * ↑((v 1).valbm V e)) := 86 | mulExt T _ _ _ _ ⨀ termEqComplete e (v 0) ⨀ termEqComplete e (v 1) 87 | have : T ⊢ ((v 0).valbm V e * (v 1).valbm V e : ⌜ℒₒᵣ⌝[V].Semiterm 0) =' ↑((v 0).valbm V e * (v 1).valbm V e) := mulComplete T _ _ 88 | exact eqTrans T _ _ _ ⨀ ih ⨀ this 89 | 90 | lemma termEq_complete! {n : ℕ} (e : Fin n → V) (t : Semiterm ℒₒᵣ Empty n) : 91 | T ⊢! ⌜Rew.embs t⌝^ᵗ/[toNumVec e] =' ↑(t.valbm V e) := ⟨termEqComplete T e t⟩ 92 | 93 | open FirstOrder.Arith 94 | 95 | theorem bold_sigma₁_complete {n} {φ : Semisentence ℒₒᵣ n} (hp : Hierarchy 𝚺 1 φ) {e} : 96 | V ⊧/e φ → T ⊢! ⌜Rew.embs ▹ φ⌝^/[toNumVec e] := by 97 | revert e 98 | apply sigma₁_induction' hp 99 | case hVerum => intro n; simp 100 | case hFalsum => 101 | intro n 102 | simp only [LogicalConnective.HomClass.map_bot, Prop.bot_eq_false, 103 | Semiformula.codeIn'_falsum, Language.Semiformula.substs_falsum, false_implies, implies_true] 104 | case hEQ => 105 | intro n t₁ t₂ e h 106 | have : t₁.valbm V e = t₂.valbm V e := by simpa using h 107 | suffices T ⊢! ⌜Rew.embs t₁⌝^ᵗ/[toNumVec e] =' ⌜Rew.embs t₂⌝^ᵗ/[toNumVec e] by 108 | simpa only [Semiformula.rew_rel2, Semiformula.codeIn'_eq, Fin.isValue, Matrix.cons_val_zero, 109 | Matrix.cons_val_one, Matrix.vecHead, Matrix.cons_val_fin_one, substs_equals] using this 110 | refine eq_ext T _ _ _ _ ⨀ ?_ ⨀ ?_ ⨀ eq_complete! T this 111 | · exact eq_symm'! _ <| termEq_complete! T e t₁ 112 | · exact eq_symm'! _ <| termEq_complete! T e t₂ 113 | case hNEQ => 114 | intro n t₁ t₂ e h 115 | have : t₁.valbm V e ≠ t₂.valbm V e := by simpa using h 116 | suffices T ⊢! ⌜Rew.embs t₁⌝^ᵗ/[toNumVec e] ≠' ⌜Rew.embs t₂⌝^ᵗ/[toNumVec e] by 117 | simpa only [Semiformula.rew_nrel2, Semiformula.codeIn'_neq, Fin.isValue, Matrix.cons_val_zero, 118 | Matrix.cons_val_one, Matrix.vecHead, Matrix.cons_val_fin_one, substs_notEquals] using this 119 | refine ne_ext T _ _ _ _ ⨀ ?_ ⨀ ?_ ⨀ ne_complete! T this 120 | · exact eq_symm'! _ <| termEq_complete! T e t₁ 121 | · exact eq_symm'! _ <| termEq_complete! T e t₂ 122 | case hLT => 123 | intro n t₁ t₂ e h 124 | have : t₁.valbm V e < t₂.valbm V e := by simpa using h 125 | suffices T ⊢! ⌜Rew.embs t₁⌝^ᵗ/[toNumVec e] <' ⌜Rew.embs t₂⌝^ᵗ/[toNumVec e] by 126 | simpa only [Semiformula.rew_rel2, Semiformula.codeIn'_lt, Fin.isValue, Matrix.cons_val_zero, 127 | Matrix.cons_val_one, Matrix.vecHead, Matrix.cons_val_fin_one, substs_lessThan] using this 128 | refine lt_ext! T _ _ _ _ ⨀ ?_ ⨀ ?_ ⨀ lt_complete! T this 129 | · exact eq_symm'! _ <| termEq_complete! T e t₁ 130 | · exact eq_symm'! _ <| termEq_complete! T e t₂ 131 | case hNLT => 132 | intro n t₁ t₂ e h 133 | have : t₂.valbm V e ≤ t₁.valbm V e := by simpa using h 134 | suffices T ⊢! ⌜Rew.embs t₁⌝^ᵗ/[toNumVec e] ≮' ⌜Rew.embs t₂⌝^ᵗ/[toNumVec e] by 135 | simpa only [Semiformula.rew_nrel2, Semiformula.codeIn'_nlt, Fin.isValue, Matrix.cons_val_zero, 136 | Matrix.cons_val_one, Matrix.vecHead, Matrix.cons_val_fin_one, substs_notLessThan] using this 137 | refine nlt_ext T _ _ _ _ ⨀ ?_ ⨀ ?_ ⨀ nlt_complete T this 138 | · exact eq_symm'! _ <| termEq_complete! T e t₁ 139 | · exact eq_symm'! _ <| termEq_complete! T e t₂ 140 | case hAnd => 141 | intro n φ ψ _ _ ihp ihq e h 142 | have h : Semiformula.Evalbm V e φ ∧ Semiformula.Evalbm V e ψ := by simpa using h 143 | simpa only [LogicalConnective.HomClass.map_and, Semiformula.codeIn'_and, 144 | Language.Semiformula.substs_and] using and_intro! (ihp h.1) (ihq h.2) 145 | case hOr => 146 | intro n φ ψ _ _ ihp ihq e h 147 | have : Semiformula.Evalbm V e φ ∨ Semiformula.Evalbm V e ψ := by simpa using h 148 | rcases this with (h | h) 149 | · simpa only [LogicalConnective.HomClass.map_or, Semiformula.codeIn'_or, 150 | Language.Semiformula.substs_or] using or₁'! (ihp h) 151 | · simpa only [LogicalConnective.HomClass.map_or, Semiformula.codeIn'_or, 152 | Language.Semiformula.substs_or] using or₂'! (ihq h) 153 | case hBall => 154 | intro n t φ _ ihp e h 155 | suffices T ⊢! Language.Semiformula.ball (⌜Rew.emb t⌝^ᵗ/[toNumVec e]) ((_)^/[(toNumVec e).q]) by 156 | simpa only [Rewriting.smul_ball, Rew.q_emb, Rew.hom_finitary2, Rew.emb_bvar, ← Rew.emb_bShift_term, 157 | Semiformula.codeIn'_ball, substs_ball] 158 | apply ball_replace! T _ _ _ ⨀ (eq_symm! T _ _ ⨀ termEq_complete! T e t) ⨀ ?_ 159 | apply ball_intro! 160 | intro x hx 161 | suffices T ⊢! ⌜Rew.embs ▹ φ⌝^/[toNumVec (x :> e)] by simpa [Language.TSemifromula.substs_substs] 162 | have : Semiformula.Evalbm V (x :> e) φ := by 163 | simp at h; exact h x hx 164 | exact ihp this 165 | case hEx => 166 | intro n φ _ ihp e h 167 | simp only [Rewriting.app_ex, Rew.q_emb, Semiformula.codeIn'_ex, Language.Semiformula.substs_ex] 168 | have : ∃ x, Semiformula.Evalbm V (x :> e) φ := by simpa using h 169 | rcases this with ⟨x, hx⟩ 170 | apply ex! x 171 | simpa [Language.TSemifromula.substs_substs] using ihp hx 172 | 173 | /-- Hilbert–Bernays provability condition D3 -/ 174 | theorem sigma₁_complete {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : V ⊧ₘ₀ σ → T ⊢! ⌜σ⌝ := by 175 | intro h; simpa using bold_sigma₁_complete T hσ (e := ![]) (by simpa [models₀_iff] using h) 176 | 177 | end TProof 178 | 179 | end Formalized 180 | 181 | section 182 | 183 | variable {T : Theory ℒₒᵣ} [T.Delta1Definable] 184 | 185 | theorem sigma₁_complete {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : 186 | V ⊧ₘ₀ σ → T.Provableₐ (⌜σ⌝ : V) := fun h ↦ by 187 | simpa [provableₐ_iff] using Formalized.TProof.sigma₁_complete _ hσ h 188 | 189 | end 190 | 191 | end LO.Arith 192 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Incompleteness/Arith/Second.lean: -------------------------------------------------------------------------------- 1 | import Incompleteness.Arith.D3 2 | import Foundation.Logic.HilbertStyle.Supplemental 3 | import Incompleteness.ToFoundation.Basic 4 | 5 | noncomputable section 6 | 7 | open Classical 8 | 9 | namespace LO.Arith.Formalized 10 | 11 | open LO.FirstOrder LO.FirstOrder.Arith 12 | 13 | variable {V : Type*} [ORingStruc V] [V ⊧ₘ* 𝐈𝚺₁] 14 | 15 | def substNumeral (φ x : V) : V := ⌜ℒₒᵣ⌝.substs₁ (numeral x) φ 16 | 17 | lemma substNumeral_app_quote (σ : Semisentence ℒₒᵣ 1) (n : ℕ) : 18 | substNumeral ⌜σ⌝ (n : V) = ⌜(σ/[‘↑n’] : Sentence ℒₒᵣ)⌝ := by 19 | dsimp [substNumeral] 20 | let w : Fin 1 → Semiterm ℒₒᵣ Empty 0 := ![‘↑n’] 21 | have : ?[numeral (n : V)] = (⌜fun i : Fin 1 ↦ ⌜w i⌝⌝ : V) := nth_ext' 1 (by simp) (by simp) (by simp [w]) 22 | rw [Language.substs₁, this, quote_substs' (L := ℒₒᵣ)] 23 | 24 | lemma substNumeral_app_quote_quote (σ π : Semisentence ℒₒᵣ 1) : 25 | substNumeral (⌜σ⌝ : V) ⌜π⌝ = ⌜(σ/[⌜π⌝] : Sentence ℒₒᵣ)⌝ := by 26 | simpa [coe_quote, quote_eq_encode] using substNumeral_app_quote σ ⌜π⌝ 27 | 28 | def substNumerals (φ : V) (v : Fin k → V) : V := ⌜ℒₒᵣ⌝.substs ⌜fun i ↦ numeral (v i)⌝ φ 29 | 30 | lemma substNumerals_app_quote (σ : Semisentence ℒₒᵣ k) (v : Fin k → ℕ) : 31 | (substNumerals ⌜σ⌝ (v ·) : V) = ⌜((Rew.substs (fun i ↦ ‘↑(v i)’)) ▹ σ : Sentence ℒₒᵣ)⌝ := by 32 | dsimp [substNumerals] 33 | let w : Fin k → Semiterm ℒₒᵣ Empty 0 := fun i ↦ ‘↑(v i)’ 34 | have : ⌜fun i ↦ numeral (v i : V)⌝ = (⌜fun i : Fin k ↦ ⌜w i⌝⌝ : V) := by 35 | apply nth_ext' (k : V) (by simp) (by simp) 36 | intro i hi; rcases eq_fin_of_lt_nat hi with ⟨i, rfl⟩ 37 | simp [w] 38 | rw [this, quote_substs' (L := ℒₒᵣ)] 39 | 40 | lemma substNumerals_app_quote_quote (σ : Semisentence ℒₒᵣ k) (π : Fin k → Semisentence ℒₒᵣ k) : 41 | substNumerals (⌜σ⌝ : V) (fun i ↦ ⌜π i⌝) = ⌜((Rew.substs (fun i ↦ ⌜π i⌝)) ▹ σ : Sentence ℒₒᵣ)⌝ := by 42 | simpa [coe_quote, quote_eq_encode] using substNumerals_app_quote σ (fun i ↦ ⌜π i⌝) 43 | 44 | section 45 | 46 | def _root_.LO.FirstOrder.Arith.ssnum : 𝚺₁.Semisentence 3 := .mkSigma 47 | “y p x. ∃ n, !numeralDef n x ∧ !p⌜ℒₒᵣ⌝.substs₁Def y n p” (by simp) 48 | 49 | lemma substNumeral_defined : 𝚺₁-Function₂ (substNumeral : V → V → V) via ssnum := by 50 | intro v; simp [ssnum, ⌜ℒₒᵣ⌝.substs₁_defined.df.iff, substNumeral] 51 | 52 | @[simp] lemma eval_ssnum (v) : 53 | Semiformula.Evalbm V v ssnum.val ↔ v 0 = substNumeral (v 1) (v 2) := substNumeral_defined.df.iff v 54 | 55 | def _root_.LO.FirstOrder.Arith.ssnums : 𝚺₁.Semisentence (k + 2) := .mkSigma 56 | “y p. ∃ n, !lenDef ↑k n ∧ 57 | (⋀ i, ∃ z, !nthDef z n ↑(i : Fin k) ∧ !numeralDef z #i.succ.succ.succ.succ) ∧ 58 | !p⌜ℒₒᵣ⌝.substsDef y n p” (by simp) 59 | 60 | lemma substNumerals_defined : 61 | Arith.HierarchySymbol.DefinedFunction (fun v ↦ substNumerals (v 0) (v ·.succ) : (Fin (k + 1) → V) → V) ssnums := by 62 | intro v 63 | suffices 64 | (v 0 = ⌜ℒₒᵣ⌝.substs ⌜fun (i : Fin k) ↦ numeral (v i.succ.succ)⌝ (v 1)) ↔ 65 | ∃ x, ↑k = len x ∧ (∀ (i : Fin k), x.[↑↑i] = numeral (v i.succ.succ)) ∧ v 0 = ⌜ℒₒᵣ⌝.substs x (v 1) by 66 | simpa [ssnums, ⌜ℒₒᵣ⌝.substs_defined.df.iff, substNumerals, numeral_eq_natCast] using this 67 | constructor 68 | · intro e 69 | refine ⟨_, by simp, by intro i; simp, e⟩ 70 | · rintro ⟨w, hk, h, e⟩ 71 | have : w = ⌜fun (i : Fin k) ↦ numeral (v i.succ.succ)⌝ := nth_ext' (k : V) hk.symm (by simp) 72 | (by intro i hi; rcases eq_fin_of_lt_nat hi with ⟨i, rfl⟩; simp [h]) 73 | rcases this; exact e 74 | 75 | @[simp] lemma eval_ssnums (v : Fin (k + 2) → V) : 76 | Semiformula.Evalbm V v ssnums.val ↔ v 0 = substNumerals (v 1) (fun i ↦ v i.succ.succ) := substNumerals_defined.df.iff v 77 | 78 | end 79 | 80 | end LO.Arith.Formalized 81 | 82 | namespace LO.FirstOrder.Arith 83 | 84 | open LO.Arith LO.Arith.Formalized 85 | 86 | variable {T : Theory ℒₒᵣ} [𝐈𝚺₁ ⪯ T] 87 | 88 | section Diagonalization 89 | 90 | def diag (θ : Semisentence ℒₒᵣ 1) : Semisentence ℒₒᵣ 1 := “x. ∀ y, !ssnum y x x → !θ y” 91 | 92 | def fixpoint (θ : Semisentence ℒₒᵣ 1) : Sentence ℒₒᵣ := (diag θ)/[⌜diag θ⌝] 93 | 94 | lemma substs_diag (θ σ : Semisentence ℒₒᵣ 1) : 95 | “!(diag θ) !!(⌜σ⌝ : Semiterm ℒₒᵣ Empty 0)” = (“∀ x, !ssnum x !!⌜σ⌝ !!⌜σ⌝ → !θ x” : Sentence ℒₒᵣ) := by 96 | simp [goedelNumber'_def, diag, Rew.q_substs, ← TransitiveRewriting.comp_app, Rew.substs_comp_substs] 97 | 98 | lemma fixpoint_eq (θ : Semisentence ℒₒᵣ 1) : 99 | fixpoint θ = (“∀ x, !ssnum x !!⌜diag θ⌝ !!⌜diag θ⌝ → !θ x” : Sentence ℒₒᵣ) := by 100 | simp [fixpoint, substs_diag] 101 | 102 | theorem diagonal (θ : Semisentence ℒₒᵣ 1) : 103 | T ⊢!. fixpoint θ ⭤ θ/[⌜fixpoint θ⌝] := 104 | haveI : 𝐄𝐐 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝐈𝚺₁) inferInstance inferInstance 105 | complete (T := T) <| oRing_consequence_of _ _ fun (V : Type) _ _ ↦ by 106 | haveI : V ⊧ₘ* 𝐈𝚺₁ := ModelsTheory.of_provably_subtheory V 𝐈𝚺₁ T inferInstance 107 | simp [models_iff] 108 | let Θ : V → Prop := fun x ↦ Semiformula.Evalbm V ![x] θ 109 | calc 110 | V ⊧/![] (fixpoint θ) 111 | ↔ Θ (substNumeral ⌜diag θ⌝ ⌜diag θ⌝) := by simp [Θ, fixpoint_eq] 112 | _ ↔ Θ ⌜fixpoint θ⌝ := by simp [substNumeral_app_quote_quote]; rfl 113 | 114 | end Diagonalization 115 | 116 | section Multidiagonalization 117 | 118 | /-- $\mathrm{diag}_i(\vec{x}) := (\forall \vec{y})\left[ \left(\bigwedge_j \mathrm{ssnums}(y_j, x_j, \vec{x})\right) \to \theta_i(\vec{y}) \right]$ -/ 119 | def multidiag (θ : Semisentence ℒₒᵣ k) : Semisentence ℒₒᵣ k := 120 | ∀^[k] ( 121 | (Matrix.conj fun j : Fin k ↦ (Rew.substs <| #(j.addCast k) :> #(j.addNat k) :> fun l ↦ #(l.addNat k)) ▹ ssnums.val) ➝ 122 | (Rew.substs fun j ↦ #(j.addCast k)) ▹ θ) 123 | 124 | def multifixpoint (θ : Fin k → Semisentence ℒₒᵣ k) (i : Fin k) : Sentence ℒₒᵣ := (Rew.substs fun j ↦ ⌜multidiag (θ j)⌝) ▹ (multidiag (θ i)) 125 | 126 | theorem multidiagonal (θ : Fin k → Semisentence ℒₒᵣ k) : 127 | T ⊢!. multifixpoint θ i ⭤ (Rew.substs fun j ↦ ⌜multifixpoint θ j⌝) ▹ (θ i) := 128 | haveI : 𝐄𝐐 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝐈𝚺₁) inferInstance inferInstance 129 | complete (T := T) <| oRing_consequence_of _ _ fun (V : Type) _ _ ↦ by 130 | haveI : V ⊧ₘ* 𝐈𝚺₁ := ModelsTheory.of_provably_subtheory V 𝐈𝚺₁ T inferInstance 131 | suffices V ⊧/![] (multifixpoint θ i) ↔ V ⊧/(fun i ↦ ⌜multifixpoint θ i⌝) (θ i) by simpa [models_iff] 132 | let t : Fin k → V := fun i ↦ ⌜multidiag (θ i)⌝ 133 | have ht : ∀ i, substNumerals (t i) t = ⌜multifixpoint θ i⌝ := by 134 | intro i; simp [t, multifixpoint, substNumerals_app_quote_quote] 135 | calc 136 | V ⊧/![] (multifixpoint θ i) ↔ V ⊧/t (multidiag (θ i)) := by simp [t, multifixpoint] 137 | _ ↔ V ⊧/(fun i ↦ substNumerals (t i) t) (θ i) := by simp [multidiag, ← funext_iff] 138 | _ ↔ V ⊧/(fun i ↦ ⌜multifixpoint θ i⌝) (θ i) := by simp [ht] 139 | 140 | end Multidiagonalization 141 | 142 | section 143 | 144 | variable (U : Theory ℒₒᵣ) [U.Delta1Definable] 145 | 146 | abbrev _root_.LO.FirstOrder.Theory.bewₐ (σ : Sentence ℒₒᵣ) : Sentence ℒₒᵣ := U.provableₐ/[⌜σ⌝] 147 | 148 | abbrev _root_.LO.FirstOrder.Theory.consistentₐ : Sentence ℒₒᵣ := ∼U.bewₐ ⊥ 149 | 150 | abbrev _root_.LO.FirstOrder.Theory.Consistentₐ : Theory ℒₒᵣ := {↑U.consistentₐ} 151 | 152 | notation "𝐂𝐨𝐧[" U "]" => LO.FirstOrder.Theory.Consistentₐ U 153 | 154 | abbrev _root_.LO.FirstOrder.Theory.Inconsistentₐ : Theory ℒₒᵣ := {∼↑U.consistentₐ} 155 | 156 | notation "¬𝐂𝐨𝐧[" U "]" => LO.FirstOrder.Theory.Inconsistentₐ U 157 | 158 | def _root_.LO.FirstOrder.Theory.goedelₐ : Sentence ℒₒᵣ := fixpoint (∼U.provableₐ) 159 | 160 | end 161 | 162 | section 163 | 164 | variable {U : Theory ℒₒᵣ} [U.Delta1Definable] 165 | 166 | theorem provableₐ_D1 {σ} : U ⊢!. σ → T ⊢!. U.bewₐ σ := by 167 | intro h 168 | haveI : 𝐄𝐐 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝐈𝚺₁) inferInstance inferInstance 169 | apply complete (T := T) <| oRing_consequence_of _ _ fun (V : Type) _ _ ↦ by 170 | haveI : V ⊧ₘ* 𝐈𝚺₁ := ModelsTheory.of_provably_subtheory V _ T inferInstance 171 | simpa [models_iff] using provableₐ_of_provable (T := U) (V := V) h 172 | 173 | theorem provableₐ_D2 {σ π} : T ⊢!. U.bewₐ (σ ➝ π) ➝ U.bewₐ σ ➝ U.bewₐ π := 174 | haveI : 𝐄𝐐 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝐈𝚺₁) inferInstance inferInstance 175 | complete (T := T) <| oRing_consequence_of _ _ fun (V : Type) _ _ ↦ by 176 | haveI : V ⊧ₘ* 𝐈𝚺₁ := ModelsTheory.of_provably_subtheory V _ T inferInstance 177 | simp [models_iff] 178 | intro hσπ hσ 179 | exact provableₐ_iff.mpr <| (by simpa using provableₐ_iff.mp hσπ) ⨀ provableₐ_iff.mp hσ 180 | 181 | lemma provableₐ_sigma₁_complete {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : 182 | T ⊢!. σ ➝ U.bewₐ σ := 183 | haveI : 𝐄𝐐 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝐈𝚺₁) inferInstance inferInstance 184 | complete (T := T) <| oRing_consequence_of _ _ fun (V : Type) _ _ ↦ by 185 | haveI : V ⊧ₘ* 𝐈𝚺₁ := ModelsTheory.of_provably_subtheory V _ T inferInstance 186 | simpa [models_iff] using sigma₁_complete (T := U) (V := V) hσ 187 | 188 | theorem provableₐ_D3 {σ : Sentence ℒₒᵣ} : 189 | T ⊢!. U.bewₐ σ ➝ U.bewₐ (U.bewₐ σ) := provableₐ_sigma₁_complete (by simp) 190 | 191 | lemma goedel_iff_unprovable_goedel : T ⊢!. U.goedelₐ ⭤ ∼U.bewₐ U.goedelₐ := by 192 | simpa [Theory.goedelₐ, Theory.bewₐ] using diagonal (∼U.provableₐ) 193 | 194 | open LO.Entailment LO.Entailment.FiniteContext 195 | 196 | lemma provableₐ_D2_context {Γ σ π} (hσπ : Γ ⊢[T.alt]! (U.bewₐ (σ ➝ π))) (hσ : Γ ⊢[T.alt]! U.bewₐ σ) : 197 | Γ ⊢[T.alt]! U.bewₐ π := of'! provableₐ_D2 ⨀ hσπ ⨀ hσ 198 | 199 | lemma provableₐ_D3_context {Γ σ} (hσπ : Γ ⊢[T.alt]! U.bewₐ σ) : Γ ⊢[T.alt]! U.bewₐ (U.bewₐ σ) := of'! provableₐ_D3 ⨀ hσπ 200 | 201 | variable [ℕ ⊧ₘ* T] [𝐑₀ ⪯ U] 202 | 203 | omit [𝐈𝚺₁ ⪯ T] in 204 | lemma provableₐ_sound {σ} : T ⊢!. U.bewₐ σ → U ⊢! ↑σ := by 205 | intro h 206 | have : U.Provableₐ (⌜σ⌝ : ℕ) := by simpa [models₀_iff] using consequence_iff.mp (sound! (T := T) h) ℕ inferInstance 207 | simpa using this 208 | 209 | lemma provableₐ_complete {σ} : U ⊢! ↑σ ↔ T ⊢!. U.bewₐ σ := ⟨provableₐ_D1, provableₐ_sound⟩ 210 | 211 | end 212 | 213 | section 214 | 215 | variable (T) 216 | 217 | variable [T.Delta1Definable] 218 | 219 | open LO.Entailment LO.Entailment.FiniteContext 220 | 221 | local notation "𝗚" => T.goedelₐ 222 | 223 | local notation "𝗖𝗼𝗻" => T.consistentₐ 224 | 225 | local prefix:max "□" => T.bewₐ 226 | 227 | lemma goedel_unprovable [Entailment.Consistent T] : T ⊬ ↑𝗚 := by 228 | intro h 229 | have hp : T ⊢! ↑□𝗚 := provableₐ_D1 h 230 | have hn : T ⊢! ∼↑□𝗚 := by simpa [provable₀_iff] using and_left! goedel_iff_unprovable_goedel ⨀ h 231 | exact not_consistent_iff_inconsistent.mpr (inconsistent_of_provable_of_unprovable hp hn) inferInstance 232 | 233 | lemma not_goedel_unprovable [ℕ ⊧ₘ* T] : T ⊬ ∼↑𝗚 := fun h ↦ by 234 | haveI : 𝐑₀ ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝐈𝚺₁) inferInstance inferInstance 235 | have : T ⊢!. □𝗚 := Entailment.contra₂'! (and_right! goedel_iff_unprovable_goedel) ⨀ (by simpa [provable₀_iff] using h) 236 | have : T ⊢! ↑𝗚 := provableₐ_sound this 237 | exact not_consistent_iff_inconsistent.mpr (inconsistent_of_provable_of_unprovable this h) 238 | (Sound.consistent_of_satisfiable ⟨_, (inferInstance : ℕ ⊧ₘ* T)⟩) 239 | 240 | lemma consistent_iff_goedel : T ⊢! ↑𝗖𝗼𝗻 ⭤ ↑𝗚 := by 241 | apply iff_intro! 242 | · have bew_G : [∼𝗚] ⊢[T.alt]! □𝗚 := deductInv'! <| contra₂'! <| and_right! goedel_iff_unprovable_goedel 243 | have bew_not_bew_G : [∼𝗚] ⊢[T.alt]! □(∼□𝗚) := by 244 | have : T ⊢!. □(𝗚 ➝ ∼□𝗚) := provableₐ_D1 <| and_left! goedel_iff_unprovable_goedel 245 | exact provableₐ_D2_context (of'! this) bew_G 246 | have bew_bew_G : [∼𝗚] ⊢[T.alt]! □□𝗚 := provableₐ_D3_context bew_G 247 | have : [∼𝗚] ⊢[T.alt]! □⊥ := 248 | provableₐ_D2_context (provableₐ_D2_context (of'! <| provableₐ_D1 <| efq_imply_not₁!) bew_not_bew_G) bew_bew_G 249 | simpa [provable₀_iff] using contra₂'! (deduct'! this) 250 | · have : [□⊥] ⊢[T.alt]! □𝗚 := by 251 | have : T ⊢!. □(⊥ ➝ 𝗚) := provableₐ_D1 efq! 252 | exact provableₐ_D2_context (of'! this) (by simp) 253 | have : [□⊥] ⊢[T.alt]! ∼𝗚 := 254 | of'! (contra₁'! <| and_left! <| goedel_iff_unprovable_goedel) ⨀ this 255 | simpa [provable₀_iff] using contra₁'! (deduct'! this) 256 | 257 | /-- Gödel's Second Incompleteness Theorem-/ 258 | theorem goedel_second_incompleteness [Entailment.Consistent T] : T ⊬ ↑𝗖𝗼𝗻 := fun h ↦ 259 | goedel_unprovable T <| and_left! (consistent_iff_goedel T) ⨀ h 260 | 261 | theorem inconsistent_unprovable [ℕ ⊧ₘ* T] : T ⊬ ∼↑𝗖𝗼𝗻 := fun h ↦ 262 | not_goedel_unprovable T <| contra₀'! (and_right! (consistent_iff_goedel T)) ⨀ h 263 | 264 | theorem inconsistent_undecidable [ℕ ⊧ₘ* T] : Entailment.Undecidable T ↑𝗖𝗼𝗻 := by 265 | haveI : Consistent T := Sound.consistent_of_satisfiable ⟨_, (inferInstance : ℕ ⊧ₘ* T)⟩ 266 | constructor 267 | · exact goedel_second_incompleteness T 268 | · exact inconsistent_unprovable T 269 | 270 | instance [Entailment.Consistent T] : T ⪱ T + 𝐂𝐨𝐧[T] := 271 | Entailment.StrictlyWeakerThan.of_unprovable_provable (φ := ↑𝗖𝗼𝗻) 272 | (goedel_second_incompleteness T) (Entailment.by_axm _ (by simp)) 273 | 274 | instance [Entailment.Consistent T] : ℕ ⊧ₘ* 𝐂𝐨𝐧[T] := by 275 | suffices ℕ ⊧ₘ₀ T.consistentₐ by simpa [Models₀] using this 276 | suffices ¬T.Provableₐ ⌜⊥⌝ by simpa [models₀_iff] using this 277 | intro H 278 | haveI : 𝐑₀ ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝐈𝚺₁) inferInstance inferInstance 279 | have : T ⊢! ⊥ := Arith.provableₐ_iff_provable₀.mp H 280 | have : Entailment.Inconsistent T := inconsistent_iff_provable_bot.mpr this 281 | exact Consistent.not_inconsistent this 282 | 283 | instance [ℕ ⊧ₘ* T] : ℕ ⊧ₘ* T + 𝐂𝐨𝐧[T] := 284 | haveI : Entailment.Consistent T := Sound.consistent_of_satisfiable ⟨_, inferInstanceAs (ℕ ⊧ₘ* T)⟩ 285 | ModelsTheory.add_iff.mpr ⟨inferInstance, inferInstance⟩ 286 | 287 | instance [ℕ ⊧ₘ* T] : T ⪱ T + ¬𝐂𝐨𝐧[T] := 288 | Entailment.StrictlyWeakerThan.of_unprovable_provable (φ := ∼↑𝗖𝗼𝗻) 289 | (inconsistent_unprovable T) (Entailment.by_axm _ (by simp)) 290 | 291 | end 292 | 293 | end LO.FirstOrder.Arith 294 | 295 | end 296 | -------------------------------------------------------------------------------- /Incompleteness/Arith/FormalizedArithmetic.lean: -------------------------------------------------------------------------------- 1 | import Arithmetization.ISigmaOne.Metamath 2 | 3 | /-! 4 | 5 | # Formalized Theory $\mathsf{R_0}$ 6 | 7 | -/ 8 | 9 | noncomputable section 10 | 11 | open Classical 12 | 13 | namespace LO.Arith 14 | 15 | open FirstOrder FirstOrder.Arith 16 | 17 | variable {V : Type*} [ORingStruc V] [V ⊧ₘ* 𝐈𝚺₁] 18 | 19 | variable {L : Arith.Language V} {pL : LDef} [Arith.Language.Defined L pL] 20 | 21 | namespace Formalized 22 | 23 | variable (V) 24 | 25 | abbrev LOR.Theory := @Language.Theory V _ ⌜ℒₒᵣ⌝ (Language.lDef ℒₒᵣ) _ 26 | 27 | variable {V} 28 | 29 | /-- TODO: move -/ 30 | @[simp] lemma two_lt_three : (2 : V) < (1 + 1 + 1 : V) := by simp [←one_add_one_eq_two] 31 | @[simp] lemma two_lt_four : (2 : V) < (1 + 1 + 1 + 1 : V) := by simp [←one_add_one_eq_two] 32 | @[simp] lemma three_lt_four : (3 : V) < (1 + 1 + 1 + 1 : V) := by simp [←two_add_one_eq_three, ←one_add_one_eq_two] 33 | @[simp] lemma two_sub_one_eq_one : (2 : V) - 1 = 1 := by simp [←one_add_one_eq_two] 34 | @[simp] lemma three_sub_one_eq_two : (3 : V) - 1 = 2 := by simp [←two_add_one_eq_three] 35 | 36 | class R₀Theory (T : LOR.TTheory (V := V)) where 37 | refl : T ⊢ (#'0 =' #'0).all 38 | replace (φ : ⌜ℒₒᵣ⌝.Semiformula (0 + 1)) : T ⊢ (#'1 =' #'0 ➝ φ^/[(#'1).sing] ➝ φ^/[(#'0).sing]).all.all 39 | add (n m : V) : T ⊢ (n + m : ⌜ℒₒᵣ⌝[V].Semiterm 0) =' ↑(n + m) 40 | mul (n m : V) : T ⊢ (n * m : ⌜ℒₒᵣ⌝[V].Semiterm 0) =' ↑(n * m) 41 | ne {n m : V} : n ≠ m → T ⊢ ↑n ≠' ↑m 42 | ltNumeral (n : V) : T ⊢ (#'0 <' ↑n ⭤ (tSubstItr (#'0).sing (#'1 =' #'0) n).disj).all 43 | 44 | abbrev oneAbbrev {n} : ⌜ℒₒᵣ⌝[V].Semiterm n := (1 : V) 45 | 46 | scoped notation "^1" => oneAbbrev 47 | 48 | /- 49 | section 50 | 51 | def _root_.LO.FirstOrder.Arith.eqTheory : 𝚺₁.Semisentence 0 := .mkSigma 52 | “(∃ b0, !qqBvarDef b0 0 ∧ !qqAllDef )” (by simp) 53 | 54 | end 55 | -/ 56 | 57 | variable (T : LOR.TTheory (V := V)) 58 | 59 | namespace TProof 60 | 61 | open Language.Theory.TProof Entailment Entailment.FiniteContext 62 | 63 | section R₀Theory 64 | 65 | variable [R₀Theory T] 66 | 67 | def eqRefl (t : ⌜ℒₒᵣ⌝.Term) : T ⊢ t =' t := by 68 | have : T ⊢ (#'0 =' #'0).all := R₀Theory.refl 69 | simpa [Language.Semiformula.substs₁] using specialize this t 70 | 71 | lemma eq_refl! (t : ⌜ℒₒᵣ⌝.Term) : T ⊢! t =' t := ⟨eqRefl T t⟩ 72 | 73 | noncomputable def replace (φ : ⌜ℒₒᵣ⌝.Semiformula (0 + 1)) (t u : ⌜ℒₒᵣ⌝.Term) : 74 | T ⊢ t =' u ➝ φ^/[t.sing] ➝ φ^/[u.sing] := by 75 | have : T ⊢ (#'1 =' #'0 ➝ φ^/[(#'1).sing] ➝ φ^/[(#'0).sing]).all.all := R₀Theory.replace φ 76 | have := by simpa using specialize this t 77 | simpa [Language.SemitermVec.q_of_pos, Language.Semiformula.substs₁, 78 | Language.TSemifromula.substs_substs] using specialize this u 79 | 80 | lemma replace! (φ : ⌜ℒₒᵣ⌝.Semiformula (0 + 1)) (t u : ⌜ℒₒᵣ⌝.Term) : T ⊢! t =' u ➝ φ^/[t.sing] ➝ φ^/[u.sing] := ⟨replace T φ t u⟩ 81 | 82 | def eqSymm (t₁ t₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢ t₁ =' t₂ ➝ t₂ =' t₁ := by 83 | apply deduct' 84 | let Γ := [t₁ =' t₂] 85 | have e₁ : Γ ⊢[T] t₁ =' t₂ := FiniteContext.byAxm (by simp [Γ]) 86 | have e₂ : Γ ⊢[T] t₁ =' t₁ := of <| eqRefl T t₁ 87 | have : Γ ⊢[T] t₁ =' t₂ ➝ t₁ =' t₁ ➝ t₂ =' t₁ := of <| by 88 | simpa using replace T (#'0 =' t₁.bShift) t₁ t₂ 89 | exact this ⨀ e₁ ⨀ e₂ 90 | 91 | lemma eq_symm! (t₁ t₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢! t₁ =' t₂ ➝ t₂ =' t₁ := ⟨eqSymm T t₁ t₂⟩ 92 | 93 | lemma eq_symm'! {t₁ t₂ : ⌜ℒₒᵣ⌝.Term} (h : T ⊢! t₁ =' t₂) : T ⊢! t₂ =' t₁ := eq_symm! T t₁ t₂ ⨀ h 94 | 95 | def eqTrans (t₁ t₂ t₃ : ⌜ℒₒᵣ⌝.Term) : T ⊢ t₁ =' t₂ ➝ t₂ =' t₃ ➝ t₁ =' t₃ := by 96 | apply deduct' 97 | apply deduct 98 | let Γ := [t₂ =' t₃, t₁ =' t₂] 99 | have e₁ : Γ ⊢[T] t₁ =' t₂ := FiniteContext.byAxm (by simp [Γ]) 100 | have e₂ : Γ ⊢[T] t₂ =' t₃ := FiniteContext.byAxm (by simp [Γ]) 101 | have : Γ ⊢[T] t₂ =' t₃ ➝ t₁ =' t₂ ➝ t₁ =' t₃ := of <| by 102 | simpa using replace T (t₁.bShift =' #'0) t₂ t₃ 103 | exact this ⨀ e₂ ⨀ e₁ 104 | 105 | lemma eq_trans! (t₁ t₂ t₃ : ⌜ℒₒᵣ⌝.Term) : T ⊢! t₁ =' t₂ ➝ t₂ =' t₃ ➝ t₁ =' t₃ := ⟨eqTrans T t₁ t₂ t₃⟩ 106 | 107 | noncomputable def addExt (t₁ t₂ u₁ u₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢ t₁ =' t₂ ➝ u₁ =' u₂ ➝ (t₁ + u₁) =' (t₂ + u₂) := by 108 | apply deduct' 109 | apply deduct 110 | let Γ := [u₁ =' u₂, t₁ =' t₂] 111 | have bt : Γ ⊢[T] t₁ =' t₂ := FiniteContext.byAxm <| by simp [Γ] 112 | have bu : Γ ⊢[T] u₁ =' u₂ := FiniteContext.byAxm <| by simp [Γ] 113 | have : T ⊢ t₁ =' t₂ ➝ (t₁ + u₁) =' (t₁ + u₁) ➝ (t₁ + u₁) =' (t₂ + u₁) := by 114 | have := replace T ((t₁.bShift + u₁.bShift) =' (#'0 + u₁.bShift)) t₁ t₂ 115 | simpa using this 116 | have b : Γ ⊢[T] (t₁ + u₁) =' (t₂ + u₁) := of (Γ := Γ) this ⨀ bt ⨀ of (eqRefl _ _) 117 | have : T ⊢ u₁ =' u₂ ➝ (t₁ + u₁) =' (t₂ + u₁) ➝ (t₁ + u₁) =' (t₂ + u₂) := by 118 | have := replace T ((t₁.bShift + u₁.bShift) =' (t₂.bShift + #'0)) u₁ u₂ 119 | simpa using this 120 | exact of (Γ := Γ) this ⨀ bu ⨀ b 121 | 122 | lemma add_ext! (t₁ t₂ u₁ u₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢! t₁ =' t₂ ➝ u₁ =' u₂ ➝ (t₁ + u₁) =' (t₂ + u₂) := ⟨addExt T t₁ t₂ u₁ u₂⟩ 123 | 124 | noncomputable def mulExt (t₁ t₂ u₁ u₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢ t₁ =' t₂ ➝ u₁ =' u₂ ➝ (t₁ * u₁) =' (t₂ * u₂) := by 125 | apply deduct' 126 | apply deduct 127 | let Γ := [u₁ =' u₂, t₁ =' t₂] 128 | have bt : Γ ⊢[T] t₁ =' t₂ := FiniteContext.byAxm <| by simp [Γ] 129 | have bu : Γ ⊢[T] u₁ =' u₂ := FiniteContext.byAxm <| by simp [Γ] 130 | have : T ⊢ t₁ =' t₂ ➝ (t₁ * u₁) =' (t₁ * u₁) ➝ (t₁ * u₁) =' (t₂ * u₁) := by 131 | have := replace T ((t₁.bShift * u₁.bShift) =' (#'0 * u₁.bShift)) t₁ t₂ 132 | simpa using this 133 | have b : Γ ⊢[T] (t₁ * u₁) =' (t₂ * u₁) := of (Γ := Γ) this ⨀ bt ⨀ of (eqRefl _ _) 134 | have : T ⊢ u₁ =' u₂ ➝ (t₁ * u₁) =' (t₂ * u₁) ➝ (t₁ * u₁) =' (t₂ * u₂) := by 135 | have := replace T ((t₁.bShift * u₁.bShift) =' (t₂.bShift * #'0)) u₁ u₂ 136 | simpa using this 137 | exact of (Γ := Γ) this ⨀ bu ⨀ b 138 | 139 | lemma mul_ext! (t₁ t₂ u₁ u₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢! t₁ =' t₂ ➝ u₁ =' u₂ ➝ (t₁ * u₁) =' (t₂ * u₂) := ⟨mulExt T t₁ t₂ u₁ u₂⟩ 140 | 141 | noncomputable def eqExt (t₁ t₂ u₁ u₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢ t₁ =' t₂ ➝ u₁ =' u₂ ➝ t₁ =' u₁ ➝ t₂ =' u₂ := by 142 | apply deduct' 143 | apply deduct 144 | apply deduct 145 | let Γ := [t₁ =' u₁, u₁ =' u₂, t₁ =' t₂] 146 | have e1 : Γ ⊢[T] t₂ =' t₁ := by 147 | refine (of <| eqSymm T t₁ t₂) ⨀ FiniteContext.byAxm (by simp [Γ]) 148 | have e2 : Γ ⊢[T] t₁ =' u₁ := FiniteContext.byAxm (by simp [Γ]) 149 | have e3 : Γ ⊢[T] u₁ =' u₂ := FiniteContext.byAxm (by simp [Γ]) 150 | exact (of <| eqTrans T t₂ u₁ u₂) ⨀ ((of <| eqTrans T t₂ t₁ u₁) ⨀ e1 ⨀ e2) ⨀ e3 151 | 152 | lemma eq_ext (t₁ t₂ u₁ u₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢! t₁ =' t₂ ➝ u₁ =' u₂ ➝ t₁ =' u₁ ➝ t₂ =' u₂ := 153 | ⟨eqExt T t₁ t₂ u₁ u₂⟩ 154 | 155 | noncomputable def neExt (t₁ t₂ u₁ u₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢ t₁ =' t₂ ➝ u₁ =' u₂ ➝ t₁ ≠' u₁ ➝ t₂ ≠' u₂ := by 156 | apply deduct' 157 | apply deduct 158 | apply deduct 159 | let Γ := [t₁ ≠' u₁, u₁ =' u₂, t₁ =' t₂] 160 | have bt : Γ ⊢[T] t₁ =' t₂ := FiniteContext.byAxm <| by simp [Γ] 161 | have bu : Γ ⊢[T] u₁ =' u₂ := FiniteContext.byAxm <| by simp [Γ] 162 | have bl : Γ ⊢[T] t₁ ≠' u₁ := FiniteContext.byAxm <| by simp [Γ] 163 | have : T ⊢ t₁ =' t₂ ➝ t₁ ≠' u₁ ➝ t₂ ≠' u₁ := by 164 | have := replace T (#'0 ≠' u₁.bShift) t₁ t₂ 165 | simpa using this 166 | have b : Γ ⊢[T] t₂ ≠' u₁ := of (Γ := Γ) this ⨀ bt ⨀ bl 167 | have : T ⊢ u₁ =' u₂ ➝ t₂ ≠' u₁ ➝ t₂ ≠' u₂ := by 168 | simpa using replace T (t₂.bShift ≠' #'0) u₁ u₂ 169 | exact of (Γ := Γ) this ⨀ bu ⨀ b 170 | 171 | lemma ne_ext (t₁ t₂ u₁ u₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢! t₁ =' t₂ ➝ u₁ =' u₂ ➝ t₁ ≠' u₁ ➝ t₂ ≠' u₂ := 172 | ⟨neExt T t₁ t₂ u₁ u₂⟩ 173 | 174 | noncomputable def ltExt (t₁ t₂ u₁ u₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢ t₁ =' t₂ ➝ u₁ =' u₂ ➝ t₁ <' u₁ ➝ t₂ <' u₂ := by 175 | apply deduct' 176 | apply deduct 177 | apply deduct 178 | let Γ := [t₁ <' u₁, u₁ =' u₂, t₁ =' t₂] 179 | have bt : Γ ⊢[T] t₁ =' t₂ := FiniteContext.byAxm <| by simp [Γ] 180 | have bu : Γ ⊢[T] u₁ =' u₂ := FiniteContext.byAxm <| by simp [Γ] 181 | have bl : Γ ⊢[T] t₁ <' u₁ := FiniteContext.byAxm <| by simp [Γ] 182 | have : T ⊢ t₁ =' t₂ ➝ t₁ <' u₁ ➝ t₂ <' u₁ := by 183 | have := replace T (#'0 <' u₁.bShift) t₁ t₂ 184 | simpa using this 185 | have b : Γ ⊢[T] t₂ <' u₁ := of (Γ := Γ) this ⨀ bt ⨀ bl 186 | have : T ⊢ u₁ =' u₂ ➝ t₂ <' u₁ ➝ t₂ <' u₂ := by 187 | have := replace T (t₂.bShift <' #'0) u₁ u₂ 188 | simpa using this 189 | exact of (Γ := Γ) this ⨀ bu ⨀ b 190 | 191 | lemma lt_ext! (t₁ t₂ u₁ u₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢! t₁ =' t₂ ➝ u₁ =' u₂ ➝ t₁ <' u₁ ➝ t₂ <' u₂ := ⟨ltExt T t₁ t₂ u₁ u₂⟩ 192 | 193 | noncomputable def nltExt (t₁ t₂ u₁ u₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢ t₁ =' t₂ ➝ u₁ =' u₂ ➝ t₁ ≮' u₁ ➝ t₂ ≮' u₂ := by 194 | apply deduct' 195 | apply deduct 196 | apply deduct 197 | let Γ := [t₁ ≮' u₁, u₁ =' u₂, t₁ =' t₂] 198 | have bt : Γ ⊢[T] t₁ =' t₂ := FiniteContext.byAxm <| by simp [Γ] 199 | have bu : Γ ⊢[T] u₁ =' u₂ := FiniteContext.byAxm <| by simp [Γ] 200 | have bl : Γ ⊢[T] t₁ ≮' u₁ := FiniteContext.byAxm <| by simp [Γ] 201 | have : T ⊢ t₁ =' t₂ ➝ t₁ ≮' u₁ ➝ t₂ ≮' u₁ := by 202 | have := replace T (#'0 ≮' u₁.bShift) t₁ t₂ 203 | simpa using this 204 | have b : Γ ⊢[T] t₂ ≮' u₁ := of (Γ := Γ) this ⨀ bt ⨀ bl 205 | have : T ⊢ u₁ =' u₂ ➝ t₂ ≮' u₁ ➝ t₂ ≮' u₂ := by 206 | have := replace T (t₂.bShift ≮' #'0) u₁ u₂ 207 | simpa using this 208 | exact of (Γ := Γ) this ⨀ bu ⨀ b 209 | 210 | lemma nlt_ext (t₁ t₂ u₁ u₂ : ⌜ℒₒᵣ⌝.Term) : T ⊢! t₁ =' t₂ ➝ u₁ =' u₂ ➝ t₁ ≮' u₁ ➝ t₂ ≮' u₂ := ⟨nltExt T t₁ t₂ u₁ u₂⟩ 211 | 212 | noncomputable def ballReplace (φ : ⌜ℒₒᵣ⌝.Semiformula (0 + 1)) (t u : ⌜ℒₒᵣ⌝.Term) : 213 | T ⊢ t =' u ➝ φ.ball t ➝ φ.ball u := by 214 | simpa [Language.TSemifromula.substs_substs] using replace T ((φ^/[(#'0).sing]).ball #'0) t u 215 | 216 | lemma ball_replace! (φ : ⌜ℒₒᵣ⌝.Semiformula (0 + 1)) (t u : ⌜ℒₒᵣ⌝.Term) : 217 | T ⊢! t =' u ➝ φ.ball t ➝ φ.ball u := ⟨ballReplace T φ t u⟩ 218 | 219 | noncomputable def bexReplace (φ : ⌜ℒₒᵣ⌝.Semiformula (0 + 1)) (t u : ⌜ℒₒᵣ⌝.Term) : 220 | T ⊢ t =' u ➝ φ.bex t ➝ φ.bex u := by 221 | simpa [Language.TSemifromula.substs_substs] using replace T ((φ^/[(#'0).sing]).bex #'0) t u 222 | 223 | lemma bex_replace! (φ : ⌜ℒₒᵣ⌝.Semiformula (0 + 1)) (t u : ⌜ℒₒᵣ⌝.Term) : 224 | T ⊢! t =' u ➝ φ.bex t ➝ φ.bex u := ⟨bexReplace T φ t u⟩ 225 | 226 | def eqComplete {n m : V} (h : n = m) : T ⊢ ↑n =' ↑m := by 227 | rcases h; exact eqRefl T _ 228 | 229 | lemma eq_complete! {n m : V} (h : n = m) : T ⊢! ↑n =' ↑m := ⟨eqComplete T h⟩ 230 | 231 | def addComplete (n m : V) : T ⊢ (n + m : ⌜ℒₒᵣ⌝[V].Semiterm 0) =' ↑(n + m) := R₀Theory.add n m 232 | 233 | lemma add_complete! (n m : V) : T ⊢! (n + m : ⌜ℒₒᵣ⌝[V].Semiterm 0) =' ↑(n + m) := ⟨addComplete T n m⟩ 234 | 235 | def mulComplete (n m : V) : T ⊢ (n * m : ⌜ℒₒᵣ⌝[V].Semiterm 0) =' ↑(n * m) := R₀Theory.mul n m 236 | 237 | lemma mul_complete! (n m : V) : T ⊢! (n * m : ⌜ℒₒᵣ⌝[V].Semiterm 0) =' ↑(n * m) := ⟨mulComplete T n m⟩ 238 | 239 | def neComplete {n m : V} (h : n ≠ m) : T ⊢ ↑n ≠' ↑m := R₀Theory.ne h 240 | 241 | lemma ne_complete! {n m : V} (h : n ≠ m) : T ⊢! ↑n ≠' ↑m := ⟨neComplete T h⟩ 242 | 243 | def ltNumeral (t : ⌜ℒₒᵣ⌝.Term) (n : V) : T ⊢ t <' ↑n ⭤ (tSubstItr t.sing (#'1 =' #'0) n).disj := by 244 | have : T ⊢ (#'0 <' ↑n ⭤ (tSubstItr (#'0).sing (#'1 =' #'0) n).disj).all := R₀Theory.ltNumeral n 245 | simpa [Language.SemitermVec.q_of_pos, Language.Semiformula.substs₁] using specialize this t 246 | 247 | noncomputable def nltNumeral (t : ⌜ℒₒᵣ⌝.Term) (n : V) : T ⊢ t ≮' ↑n ⭤ (tSubstItr t.sing (#'1 ≠' #'0) n).conj := by 248 | simpa using negReplaceIff' <| ltNumeral T t n 249 | 250 | def ltComplete {n m : V} (h : n < m) : T ⊢ ↑n <' ↑m := by 251 | have : T ⊢ ↑n <' ↑m ⭤ _ := ltNumeral T n m 252 | apply andRight this ⨀ ?_ 253 | apply disj (i := m - (n + 1)) _ (by simpa using sub_succ_lt_self h) 254 | simpa [nth_tSubstItr', h] using eqRefl T ↑n 255 | 256 | lemma lt_complete! {n m : V} (h : n < m) : T ⊢! ↑n <' ↑m := ⟨ltComplete T h⟩ 257 | 258 | noncomputable def nltComplete {n m : V} (h : m ≤ n) : T ⊢ ↑n ≮' ↑m := by 259 | have : T ⊢ ↑n ≮' ↑m ⭤ (tSubstItr (↑n : ⌜ℒₒᵣ⌝.Term).sing (#'1 ≠' #'0) m).conj := by 260 | simpa using negReplaceIff' <| ltNumeral T n m 261 | refine andRight this ⨀ ?_ 262 | apply conj' 263 | intro i hi 264 | have hi : i < m := by simpa using hi 265 | have : n ≠ i := Ne.symm <| ne_of_lt <| lt_of_lt_of_le hi h 266 | simpa [nth_tSubstItr', hi] using neComplete T this 267 | 268 | lemma nlt_complete {n m : V} (h : m ≤ n) : T ⊢! ↑n ≮' ↑m := ⟨nltComplete T h⟩ 269 | 270 | noncomputable def ballIntro (φ : ⌜ℒₒᵣ⌝.Semiformula (0 + 1)) (n : V) 271 | (bs : ∀ i < n, T ⊢ φ ^/[(i : ⌜ℒₒᵣ⌝.Term).sing]) : 272 | T ⊢ φ.ball ↑n := by 273 | apply all 274 | suffices T ⊢ &'0 ≮' ↑n ⋎ φ.shift^/[(&'0).sing] by 275 | simpa [Language.Semiformula.free, Language.Semiformula.substs₁] 276 | have : T ⊢ (tSubstItr (&'0).sing (#'1 ≠' #'0) n).conj ⋎ φ.shift^/[(&'0).sing] := by 277 | apply conjOr' 278 | intro i hi 279 | have hi : i < n := by simpa using hi 280 | let Γ := [&'0 =' typedNumeral 0 i] 281 | suffices Γ ⊢[T] φ.shift^/[(&'0).sing] by 282 | simpa [nth_tSubstItr', hi, Language.Semiformula.imp_def] using deduct' this 283 | have e : Γ ⊢[T] ↑i =' &'0 := of (eqSymm T &'0 ↑i) ⨀ (FiniteContext.byAxm <| by simp [Γ]) 284 | have : T ⊢ φ.shift^/[(i : ⌜ℒₒᵣ⌝.Term).sing] := by 285 | simpa [Language.TSemifromula.shift_substs] using shift (bs i hi) 286 | exact of (replace T φ.shift ↑i &'0) ⨀ e ⨀ of this 287 | exact orReplaceLeft' this (andRight (nltNumeral T (&'0) n)) 288 | 289 | lemma ball_intro! (φ : ⌜ℒₒᵣ⌝.Semiformula (0 + 1)) (n : V) 290 | (bs : ∀ i < n, T ⊢! φ ^/[(i : ⌜ℒₒᵣ⌝.Term).sing]) : 291 | T ⊢! φ.ball ↑n := ⟨ballIntro T φ n fun i hi ↦ (bs i hi).get⟩ 292 | 293 | noncomputable def bexIntro (φ : ⌜ℒₒᵣ⌝.Semiformula (0 + 1)) (n : V) {i} 294 | (hi : i < n) (b : T ⊢ φ ^/[(i : ⌜ℒₒᵣ⌝.Term).sing]) : 295 | T ⊢ φ.bex ↑n := by 296 | apply ex i 297 | suffices T ⊢ i <' n ⋏ φ^/[(i : ⌜ℒₒᵣ⌝.Term).sing] by simpa 298 | exact Entailment.andIntro (ltComplete T hi) b 299 | 300 | lemma bex_intro! (φ : ⌜ℒₒᵣ⌝.Semiformula (0 + 1)) (n : V) {i} 301 | (hi : i < n) (b : T ⊢! φ ^/[(i : ⌜ℒₒᵣ⌝.Term).sing]) : 302 | T ⊢! φ.bex ↑n := ⟨bexIntro T φ n hi b.get⟩ 303 | 304 | end R₀Theory 305 | 306 | end TProof 307 | 308 | end Formalized 309 | 310 | end LO.Arith 311 | 312 | end 313 | -------------------------------------------------------------------------------- /Incompleteness/DC/Basic.lean: -------------------------------------------------------------------------------- 1 | import Foundation.FirstOrder.Arith.Theory 2 | import Foundation.Logic.HilbertStyle.Supplemental 3 | import Incompleteness.ToFoundation.Basic 4 | 5 | namespace LO.FirstOrder 6 | 7 | namespace Theory.Alt 8 | 9 | variable {L : Language} {T U : Theory L} 10 | 11 | instance [s : T ⪯ U] : T ⪯ U.alt.thy := s 12 | 13 | instance [s : T ⪯ U] : T.alt ⪯ U.alt := ⟨fun _ b ↦ s.pbl b⟩ 14 | 15 | end Theory.Alt 16 | 17 | 18 | namespace DerivabilityCondition 19 | 20 | variable [Semiterm.Operator.GoedelNumber L (Sentence L)] 21 | 22 | structure ProvabilityPredicate (T₀ : Theory L) (T : Theory L) where 23 | prov : Semisentence L 1 24 | spec {σ : Sentence L} : T ⊢!. σ → T₀ ⊢!. prov/[⌜σ⌝] 25 | 26 | namespace ProvabilityPredicate 27 | 28 | variable {T₀ T : Theory L} 29 | 30 | @[coe] def pr (𝔅 : ProvabilityPredicate T₀ T) (σ : Sentence L) : Sentence L := 𝔅.prov/[⌜σ⌝] 31 | 32 | instance : CoeFun (ProvabilityPredicate T₀ T) (fun _ => Sentence L → Sentence L) := ⟨pr⟩ 33 | 34 | def con (𝔅 : ProvabilityPredicate T₀ T) : Sentence L := ∼(𝔅 ⊥) 35 | 36 | end ProvabilityPredicate 37 | 38 | class Diagonalization (T : Theory L) where 39 | fixpoint : Semisentence L 1 → Sentence L 40 | diag (θ) : T ⊢!. fixpoint θ ⭤ θ/[⌜fixpoint θ⌝] 41 | 42 | namespace ProvabilityPredicate 43 | 44 | variable {T₀ T : Theory L} 45 | 46 | class HBL2 (𝔅 : ProvabilityPredicate T₀ T) where 47 | D2 {σ τ : Sentence L} : T₀ ⊢!. 𝔅 (σ ➝ τ) ➝ (𝔅 σ) ➝ (𝔅 τ) 48 | 49 | class HBL3 (𝔅 : ProvabilityPredicate T₀ T) where 50 | D3 {σ : Sentence L} : T₀ ⊢!. (𝔅 σ) ➝ 𝔅 (𝔅 σ) 51 | 52 | class HBL (𝔅 : ProvabilityPredicate T₀ T) extends 𝔅.HBL2, 𝔅.HBL3 53 | 54 | class Loeb (𝔅 : ProvabilityPredicate T₀ T) where 55 | LT {σ : Sentence L} : T ⊢!. (𝔅 σ) ➝ σ → T ⊢!. σ 56 | 57 | class FormalizedLoeb (𝔅 : ProvabilityPredicate T₀ T) where 58 | FLT {σ : Sentence L} : T₀ ⊢!. 𝔅 ((𝔅 σ) ➝ σ) ➝ (𝔅 σ) 59 | 60 | class Rosser (𝔅 : ProvabilityPredicate T₀ T) where 61 | Ro {σ : Sentence L} : T ⊢!. ∼σ → T₀ ⊢!. ∼(𝔅 σ) 62 | 63 | section 64 | 65 | open LO.Entailment 66 | 67 | variable [L.DecidableEq] 68 | {T₀ T : Theory L} [T₀ ⪯ T] 69 | {𝔅 : ProvabilityPredicate T₀ T} [𝔅.HBL] 70 | {σ τ : Sentence L} 71 | 72 | abbrev D1 : T ⊢!. σ → T₀ ⊢!. (𝔅 σ) := 𝔅.spec 73 | alias D2 := HBL2.D2 74 | alias D3 := HBL3.D3 75 | alias LT := Loeb.LT 76 | alias FLT := FormalizedLoeb.FLT 77 | alias Ro := Rosser.Ro 78 | 79 | def D1_shift : T ⊢!. σ → T ⊢!. (𝔅 σ) := by 80 | intro h; 81 | apply Entailment.WeakerThan.pbl (𝓢 := T₀.alt); 82 | apply D1 h; 83 | 84 | def D2_shift [𝔅.HBL2] : T ⊢!. 𝔅 (σ ➝ τ) ➝ (𝔅 σ) ➝ (𝔅 τ) := by 85 | apply Entailment.WeakerThan.pbl (𝓢 := T₀.alt); 86 | apply D2; 87 | 88 | def D3_shift [𝔅.HBL3] : T ⊢!. (𝔅 σ) ➝ 𝔅 (𝔅 σ) := by 89 | apply Entailment.WeakerThan.pbl (𝓢 := T₀.alt); 90 | apply D3; 91 | 92 | def FLT_shift [𝔅.FormalizedLoeb] : T ⊢!. 𝔅 ((𝔅 σ) ➝ σ) ➝ (𝔅 σ) := by 93 | apply Entailment.WeakerThan.pbl (𝓢 := T₀.alt); 94 | apply 𝔅.FLT; 95 | 96 | def D2' [𝔅.HBL2] [Entailment.ModusPonens T] : T₀ ⊢!. 𝔅 (σ ➝ τ) → T₀ ⊢!. (𝔅 σ) ➝ (𝔅 τ) := by 97 | intro h; 98 | exact D2 ⨀ h; 99 | 100 | def prov_distribute_imply (h : T ⊢!. σ ➝ τ) : T₀ ⊢!. (𝔅 σ) ➝ (𝔅 τ) := D2' $ D1 h 101 | 102 | def prov_distribute_iff (h : T ⊢!. σ ⭤ τ) : T₀ ⊢!. (𝔅 σ) ⭤ (𝔅 τ) := by 103 | apply iff_intro!; 104 | . exact prov_distribute_imply $ and₁'! h; 105 | . exact prov_distribute_imply $ and₂'! h; 106 | 107 | def prov_distribute_and : T₀ ⊢!. 𝔅 (σ ⋏ τ) ➝ (𝔅 σ) ⋏ (𝔅 τ) := by 108 | have h₁ : T₀ ⊢!. 𝔅 (σ ⋏ τ) ➝ (𝔅 σ) := D2' <| D1 and₁!; 109 | have h₂ : T₀ ⊢!. 𝔅 (σ ⋏ τ) ➝ (𝔅 τ) := D2' <| D1 and₂!; 110 | exact imply_right_and! h₁ h₂; 111 | 112 | def prov_distribute_and' : T₀ ⊢!. 𝔅 (σ ⋏ τ) → T₀ ⊢!. (𝔅 σ) ⋏ (𝔅 τ) := λ h => prov_distribute_and ⨀ h 113 | 114 | def prov_collect_and : T₀ ⊢!. (𝔅 σ) ⋏ (𝔅 τ) ➝ 𝔅 (σ ⋏ τ) := by 115 | have h₁ : T₀ ⊢!. (𝔅 σ) ➝ 𝔅 (τ ➝ σ ⋏ τ) := prov_distribute_imply $ and₃!; 116 | have h₂ : T₀ ⊢!. 𝔅 (τ ➝ σ ⋏ τ) ➝ (𝔅 τ) ➝ 𝔅 (σ ⋏ τ) := D2; 117 | apply and_imply_iff_imply_imply'!.mpr; 118 | exact imp_trans''! h₁ h₂; 119 | 120 | end 121 | 122 | end ProvabilityPredicate 123 | 124 | variable {T₀ T : Theory L} {𝔅 : ProvabilityPredicate T₀ T} 125 | 126 | open LO.Entailment 127 | open Diagonalization 128 | open ProvabilityPredicate 129 | 130 | def ProvabilityPredicate.goedel [Diagonalization T₀] (𝔅 : ProvabilityPredicate T₀ T) : Sentence L := 131 | fixpoint T₀ “x. ¬!𝔅.prov x” 132 | 133 | section GoedelSentence 134 | 135 | variable [Diagonalization T₀] 136 | 137 | local notation "γ" => 𝔅.goedel 138 | 139 | lemma goedel_spec : T₀ ⊢!. γ ⭤ ∼𝔅 γ := by 140 | convert (diag (T := T₀) “x. ¬!𝔅.prov x”); 141 | simp [goedel, ← TransitiveRewriting.comp_app, Rew.substs_comp_substs]; 142 | rfl; 143 | 144 | variable [T₀ ⪯ T] 145 | 146 | private lemma goedel_specAux₁ : T ⊢!. γ ⭤ ∼𝔅 γ := WeakerThan.pbl (𝓢 := T₀.alt) goedel_spec 147 | 148 | private lemma goedel_specAux₂ [L.DecidableEq] : T ⊢!. ∼γ ➝ 𝔅 γ := contra₂'! $ and₂'! goedel_specAux₁ 149 | 150 | end GoedelSentence 151 | 152 | class ProvabilityPredicate.GoedelSound (𝔅 : ProvabilityPredicate T₀ T) [Diagonalization T₀] where 153 | γ_sound : T ⊢!. 𝔅 𝔅.goedel → T ⊢!. 𝔅.goedel 154 | 155 | open GoedelSound 156 | 157 | section First 158 | 159 | variable [T₀ ⪯ T] [Diagonalization T₀] 160 | 161 | local notation "γ" => 𝔅.goedel 162 | 163 | variable [Entailment.Consistent T] 164 | 165 | theorem unprovable_goedel : T ⊬. γ := by 166 | intro h; 167 | have h₁ : T ⊢!. 𝔅 γ := D1_shift h; 168 | have h₂ : T ⊢!. ∼𝔅 γ := (and₁'! goedel_specAux₁) ⨀ h; 169 | have : T ⊢!. ⊥ := (neg_equiv'!.mp h₂) ⨀ h₁; 170 | have : ¬Consistent T := not_consistent_iff_inconsistent.mpr <| 171 | inconsistent_iff_provable_bot.mpr (by simpa [provable₀_iff] using this) 172 | contradiction; 173 | 174 | theorem unrefutable_goedel [(k : ℕ) → DecidableEq (L.Func k)] [(k : ℕ) → DecidableEq (L.Rel k)] [𝔅.GoedelSound] : T ⊬. ∼γ := by 175 | intro h₂; 176 | have h₁ : T ⊢!. γ := γ_sound $ goedel_specAux₂ ⨀ h₂; 177 | have : T ⊢!. ⊥ := (neg_equiv'!.mp h₂) ⨀ h₁; 178 | have : ¬Consistent T := not_consistent_iff_inconsistent.mpr <| 179 | inconsistent_iff_provable_bot.mpr (by simpa [provable₀_iff] using this); 180 | contradiction; 181 | 182 | theorem goedel_independent [L.DecidableEq] [𝔅.GoedelSound] : Entailment.Undecidable T ↑γ := by 183 | suffices T ⊬. γ ∧ T ⊬. ∼γ by simpa [Entailment.Undecidable, not_or, unprovable₀_iff] using this 184 | constructor 185 | . apply unprovable_goedel 186 | . apply unrefutable_goedel 187 | 188 | theorem first_incompleteness [L.DecidableEq] [𝔅.GoedelSound] 189 | : ¬Entailment.Complete T := Entailment.incomplete_iff_exists_undecidable.mpr ⟨γ, goedel_independent⟩ 190 | 191 | end First 192 | 193 | section Second 194 | 195 | variable [L.DecidableEq] [𝔅.HBL] 196 | 197 | local notation "γ" => 𝔅.goedel 198 | 199 | lemma formalized_consistent_of_existance_unprovable : T₀ ⊢!. ∼(𝔅 σ) ➝ 𝔅.con := contra₀'! $ 𝔅.D2 ⨀ (D1 efq!) 200 | 201 | private lemma consistency_lemma_1 [T₀ ⪯ U] : (U ⊢!. 𝔅.con ➝ ∼(𝔅 σ)) ↔ (U ⊢!. (𝔅 σ) ➝ 𝔅 (∼σ)) := by 202 | constructor; 203 | . intro H; 204 | exact contra₃'! $ imp_trans''! (WeakerThan.pbl (𝓢 := T₀.alt) formalized_consistent_of_existance_unprovable) H; 205 | . intro H 206 | apply contra₀'! 207 | have : T₀ ⊢!. (𝔅 σ) ⋏ 𝔅 (∼σ) ➝ 𝔅 ⊥ := imp_trans''! prov_collect_and $ prov_distribute_imply lac!; 208 | have : U ⊢!. (𝔅 σ) ➝ 𝔅 (∼σ) ➝ 𝔅 ⊥ := WeakerThan.pbl $ and_imply_iff_imply_imply'!.mp $ this; 209 | exact this ⨀₁ H; 210 | 211 | private lemma consistency_lemma_2 : T₀ ⊢!. ((𝔅 σ) ➝ 𝔅 (∼σ)) ➝ (𝔅 σ) ➝ 𝔅 ⊥ := by 212 | have : T ⊢!. σ ➝ ∼σ ➝ ⊥ := and_imply_iff_imply_imply'!.mp lac! 213 | have : T₀ ⊢!. (𝔅 σ) ➝ 𝔅 (∼σ ➝ ⊥) := prov_distribute_imply this; 214 | have : T₀ ⊢!. (𝔅 σ) ➝ (𝔅 (∼σ) ➝ 𝔅 ⊥) := imp_trans''! this D2; 215 | -- TODO: more simple proof 216 | apply FiniteContext.deduct'!; 217 | apply FiniteContext.deduct!; 218 | have d₁ : [(𝔅 σ), (𝔅 σ) ➝ 𝔅 (∼σ)] ⊢[T₀.alt]! (𝔅 σ) := FiniteContext.by_axm!; 219 | have d₂ : [(𝔅 σ), (𝔅 σ) ➝ 𝔅 (∼σ)] ⊢[T₀.alt]! (𝔅 σ) ➝ 𝔅 (∼σ) := FiniteContext.by_axm!; 220 | have d₃ : [(𝔅 σ), (𝔅 σ) ➝ 𝔅 (∼σ)] ⊢[T₀.alt]! 𝔅 (∼σ) := d₂ ⨀ d₁; 221 | exact ((FiniteContext.of'! this) ⨀ d₁) ⨀ d₃; 222 | 223 | variable [T₀ ⪯ T] [Diagonalization T₀] 224 | 225 | /-- Formalized First Incompleteness Theorem -/ 226 | theorem formalized_unprovable_goedel : T ⊢!. 𝔅.con ➝ ∼𝔅 γ := by 227 | have h₁ : T₀ ⊢!. 𝔅 γ ➝ 𝔅 (𝔅 γ) := D3; 228 | have h₂ : T ⊢!. 𝔅 γ ➝ ∼γ := WeakerThan.pbl $ contra₁'! $ and₁'! goedel_spec; 229 | have h₃ : T₀ ⊢!. 𝔅 (𝔅 γ) ➝ 𝔅 (∼γ) := prov_distribute_imply h₂; 230 | exact WeakerThan.pbl $ contra₀'! $ consistency_lemma_2 ⨀ (imp_trans''! h₁ h₃); 231 | 232 | theorem iff_goedel_consistency : T ⊢!. γ ⭤ 𝔅.con := 233 | iff_trans''! goedel_specAux₁ $ iff_intro! (WeakerThan.pbl (𝓢 := T₀.alt) formalized_consistent_of_existance_unprovable) formalized_unprovable_goedel 234 | 235 | theorem unprovable_consistency [Entailment.Consistent T] : T ⊬. 𝔅.con := 236 | unprovable_iff! iff_goedel_consistency |>.mp $ unprovable_goedel 237 | 238 | theorem unrefutable_consistency [Entailment.Consistent T] [𝔅.GoedelSound] : T ⊬. ∼𝔅.con := 239 | unprovable_iff! (neg_replace_iff'! $ iff_goedel_consistency) |>.mp $ unrefutable_goedel 240 | 241 | end Second 242 | 243 | 244 | section Loeb 245 | 246 | def ProvabilityPredicate.kreisel [Diagonalization T₀] 247 | (𝔅 : ProvabilityPredicate T₀ T) [𝔅.HBL] 248 | (σ : Sentence L) : Sentence L := fixpoint T₀ “x. !𝔅.prov x → !σ” 249 | 250 | section KrieselSentence 251 | 252 | variable {𝔅 : ProvabilityPredicate T₀ T} [𝔅.HBL] [Diagonalization T₀] 253 | 254 | local notation "κ(" σ ")" => 𝔅.kreisel σ 255 | 256 | lemma kreisel_spec (σ : Sentence L) : T₀ ⊢!. κ(σ) ⭤ (𝔅 (κ(σ)) ➝ σ) := by 257 | convert (diag (T := T₀) “x. !𝔅.prov x → !σ”); 258 | simp [kreisel, ← TransitiveRewriting.comp_app, Rew.substs_comp_substs]; 259 | rfl; 260 | 261 | private lemma kreisel_specAux₁ [T₀ ⪯ T] (σ : Sentence L) : T₀ ⊢!. 𝔅 κ(σ) ➝ (𝔅 σ) := (imp_trans''! (D2 ⨀ (D1 (WeakerThan.pbl <| and₁'! (kreisel_spec σ)))) D2) ⨀₁ D3 262 | 263 | private lemma kreisel_specAux₂ (σ : Sentence L) : T₀ ⊢!. (𝔅 κ(σ) ➝ σ) ➝ κ(σ) := and₂'! (kreisel_spec σ) 264 | 265 | end KrieselSentence 266 | 267 | section LoebTheorem 268 | 269 | variable [T₀ ⪯ T] [Diagonalization T₀] [𝔅.HBL] 270 | 271 | local notation "κ(" σ ")" => 𝔅.kreisel σ 272 | 273 | theorem loeb_theorm (H : T ⊢!. (𝔅 σ) ➝ σ) : T ⊢!. σ := by 274 | have d₁ : T ⊢!. 𝔅 (𝔅.kreisel σ) ➝ σ := imp_trans''! (WeakerThan.pbl (kreisel_specAux₁ σ)) H; 275 | have d₂ : T ⊢!. 𝔅 (𝔅.kreisel σ) := WeakerThan.pbl (𝓢 := T₀.alt) (D1 $ WeakerThan.pbl (kreisel_specAux₂ σ) ⨀ d₁); 276 | exact d₁ ⨀ d₂; 277 | 278 | instance : 𝔅.Loeb := ⟨loeb_theorm (T := T)⟩ 279 | 280 | theorem formalized_loeb_theorem [L.DecidableEq] : T₀ ⊢!. 𝔅 ((𝔅 σ) ➝ σ) ➝ (𝔅 σ) := by 281 | have hκ₁ : T₀ ⊢!. 𝔅 (κ(σ)) ➝ (𝔅 σ) := kreisel_specAux₁ σ; 282 | have : T₀ ⊢!. ((𝔅 σ) ➝ σ) ➝ (𝔅 κ(σ) ➝ σ) := replace_imply_left! hκ₁; 283 | have : T ⊢!. ((𝔅 σ) ➝ σ) ➝ κ(σ) := WeakerThan.pbl (𝓢 := T₀.alt) $ imp_trans''! this (kreisel_specAux₂ σ); 284 | exact imp_trans''! (D2 ⨀ (D1 this)) hκ₁; 285 | 286 | instance [L.DecidableEq] : 𝔅.FormalizedLoeb := ⟨formalized_loeb_theorem (T := T)⟩ 287 | 288 | end LoebTheorem 289 | 290 | variable [Entailment.Consistent T] 291 | 292 | lemma unprovable_consistency_via_loeb [𝔅.Loeb] : T ⊬. 𝔅.con := by 293 | by_contra hC; 294 | have : T ⊢!. ⊥ := Loeb.LT $ neg_equiv'!.mp hC; 295 | have : ¬Consistent T := not_consistent_iff_inconsistent.mpr $ inconsistent_iff_provable_bot.mpr (by simpa [provable₀_iff] using this) 296 | contradiction 297 | 298 | variable [L.DecidableEq] [Diagonalization T₀] [T₀ ⪯ T] [𝔅.HBL] [𝔅.GoedelSound] 299 | 300 | lemma formalized_unprovable_not_consistency 301 | : T ⊬. 𝔅.con ➝ ∼𝔅 (∼𝔅.con) := by 302 | by_contra hC; 303 | have : T ⊢!. ∼𝔅.con := Loeb.LT $ contra₁'! hC; 304 | have : T ⊬. ∼𝔅.con := unrefutable_consistency; 305 | contradiction; 306 | 307 | lemma formalized_unrefutable_goedel 308 | : T ⊬. 𝔅.con ➝ ∼𝔅 (∼𝔅.goedel) := by 309 | by_contra hC; 310 | have : T ⊬. 𝔅.con ➝ ∼𝔅 (∼𝔅.con) := formalized_unprovable_not_consistency; 311 | have : T ⊢!. 𝔅.con ➝ ∼𝔅 (∼𝔅.con) := imp_trans''! hC $ WeakerThan.pbl $ and₁'! $ neg_replace_iff'! $ prov_distribute_iff $ neg_replace_iff'! iff_goedel_consistency; 312 | contradiction; 313 | 314 | end Loeb 315 | 316 | abbrev ProvabilityPredicate.rosser 317 | [Diagonalization T₀] 318 | (𝔅 : ProvabilityPredicate T₀ T) [𝔅.Rosser] : Sentence L := 319 | fixpoint T₀ “x. ¬!𝔅.prov x” 320 | 321 | section RosserSentence 322 | 323 | local notation "ρ" => 𝔅.rosser 324 | 325 | variable [Diagonalization T₀] [𝔅.Rosser] 326 | 327 | lemma rosser_spec : T₀ ⊢!. ρ ⭤ ∼(𝔅 ρ) := goedel_spec 328 | 329 | private lemma rosser_specAux₁ [T₀ ⪯ T] : T ⊢!. ρ ⭤ ∼(𝔅 ρ) := goedel_specAux₁ 330 | 331 | end RosserSentence 332 | 333 | section 334 | 335 | variable [Diagonalization T₀] [T₀ ⪯ T] [Entailment.Consistent T] [𝔅.Rosser] 336 | 337 | local notation "ρ" => 𝔅.rosser 338 | 339 | lemma unprovable_rosser : T ⊬. ρ := unprovable_goedel 340 | 341 | theorem unrefutable_rosser : T ⊬. ∼ρ := by 342 | intro hnρ; 343 | have hρ : T ⊢!. ρ := WeakerThan.pbl $ (and₂'! rosser_spec) ⨀ (Ro hnρ); 344 | have : ¬Consistent T := not_consistent_iff_inconsistent.mpr $ inconsistent_iff_provable_bot.mpr <| 345 | by simpa [provable₀_iff] using (neg_equiv'!.mp hnρ) ⨀ hρ; 346 | contradiction 347 | 348 | theorem rosser_independent : Entailment.Undecidable T ↑ρ := by 349 | suffices T ⊬. ρ ∧ T ⊬. ∼ρ by simpa [Entailment.Undecidable, not_or, unprovable₀_iff] using this; 350 | constructor 351 | . apply unprovable_rosser 352 | . apply unrefutable_rosser 353 | 354 | theorem rosser_first_incompleteness (𝔅 : ProvabilityPredicate T₀ T) [𝔅.Rosser] : ¬Entailment.Complete T := 355 | Entailment.incomplete_iff_exists_undecidable.mpr ⟨𝔅.rosser, rosser_independent ⟩ 356 | 357 | omit [Diagonalization T₀] [Consistent T] 358 | /-- If `𝔅` satisfies Rosser provability condition, then `𝔅.con` is provable in `T`. -/ 359 | theorem kriesel_remark : T ⊢!. 𝔅.con := by 360 | have : T₀ ⊢!. ∼𝔅 ⊥ := Ro (neg_equiv'!.mpr (by simp)); 361 | exact WeakerThan.pbl $ this; 362 | 363 | end 364 | 365 | end DerivabilityCondition 366 | 367 | end LO.FirstOrder 368 | -------------------------------------------------------------------------------- /Incompleteness/Arith/D1.lean: -------------------------------------------------------------------------------- 1 | import Incompleteness.Arith.Theory 2 | 3 | noncomputable section 4 | 5 | namespace LO.FirstOrder 6 | 7 | open LO.Arith FirstOrder.Arith 8 | 9 | variable {V : Type*} [ORingStruc V] [V ⊧ₘ* 𝐈𝚺₁] 10 | 11 | variable {L : Language} [L.DecidableEq] [(k : ℕ) → Encodable (L.Func k)] [(k : ℕ) → Encodable (L.Rel k)] 12 | 13 | variable (V) 14 | 15 | namespace Derivation2 16 | 17 | def cast [L.DecidableEq] {T : Theory L} (d : T ⊢₂ Γ) (h : Γ = Δ) : T ⊢₂ Δ := h ▸ d 18 | 19 | noncomputable def Sequent.codeIn (Γ : Finset (SyntacticFormula L)) : V := ∑ φ ∈ Γ, exp (⌜φ⌝ : V) 20 | 21 | noncomputable instance : GoedelQuote (Finset (SyntacticFormula L)) V := ⟨Sequent.codeIn V⟩ 22 | 23 | omit [L.DecidableEq] in 24 | lemma Sequent.codeIn_def (Γ : Finset (SyntacticFormula L)) : ⌜Γ⌝ = ∑ φ ∈ Γ, exp (⌜φ⌝ : V) := rfl 25 | 26 | variable {V} 27 | 28 | open Classical 29 | 30 | omit [L.DecidableEq] in 31 | @[simp] lemma Sequent.codeIn_empty : (⌜(∅ : Finset (SyntacticFormula L))⌝ : V) = ∅ := by 32 | simp [Sequent.codeIn_def, emptyset_def] 33 | 34 | lemma Sequent.mem_codeIn_iff {Γ : Finset (SyntacticFormula L)} {φ} : ⌜φ⌝ ∈ (⌜Γ⌝ : V) ↔ φ ∈ Γ := by 35 | induction Γ using Finset.induction generalizing φ 36 | case empty => simp [Sequent.codeIn_def] 37 | case insert a Γ ha ih => 38 | have : exp ⌜a⌝ + ∑ φ ∈ Γ, exp (⌜φ⌝ : V) = insert (⌜a⌝ : V) (⌜Γ⌝ : V) := by 39 | simp [insert, bitInsert, (not_iff_not.mpr ih.symm).mp ha, add_comm] 40 | rw [Sequent.codeIn_def] 41 | simp [ha, Sequent.codeIn_def] 42 | rw [this] 43 | simp [←ih] 44 | 45 | lemma Sequent.quote_inj {Γ Δ : Finset (SyntacticFormula L)} : (⌜Γ⌝ : V) = ⌜Δ⌝ → Γ = Δ := fun h ↦ by 46 | ext φ; simp [←Sequent.mem_codeIn_iff (V := V), h] 47 | 48 | lemma Sequent.subset_of_quote_subset_quote {Γ Δ : Finset (SyntacticFormula L)} : 49 | (⌜Γ⌝ : V) ⊆ ⌜Δ⌝ → Γ ⊆ Δ := fun h _ hp ↦ 50 | Sequent.mem_codeIn_iff.mp <| h <| Sequent.mem_codeIn_iff.mpr hp 51 | 52 | omit [L.DecidableEq] in 53 | @[simp] lemma Sequent.codeIn_singleton [L.DecidableEq] (φ : SyntacticFormula L) : 54 | (⌜({φ} : Finset (SyntacticFormula L))⌝ : V) = {⌜φ⌝} := by simp [Sequent.codeIn_def]; rfl 55 | 56 | omit [L.DecidableEq] in 57 | @[simp] lemma Sequent.codeIn_insert [L.DecidableEq] (Γ : Finset (SyntacticFormula L)) (φ) : (⌜(insert φ Γ)⌝ : V) = insert ⌜φ⌝ ⌜Γ⌝ := by 58 | by_cases hp : φ ∈ Γ 59 | · simp [Sequent.mem_codeIn_iff, hp, insert_eq_self_of_mem] 60 | · have : (⌜insert φ Γ⌝ : V) = exp ⌜φ⌝ + ⌜Γ⌝ := by simp [Sequent.codeIn_def, hp] 61 | simp [Sequent.mem_codeIn_iff, this, insert_eq, bitInsert, hp, add_comm] 62 | 63 | omit [L.DecidableEq] in 64 | lemma Sequent.mem_codeIn [L.DecidableEq] {Γ : Finset (SyntacticFormula L)} (hx : x ∈ (⌜Γ⌝ : V)) : ∃ φ ∈ Γ, x = ⌜φ⌝ := by 65 | induction Γ using Finset.induction 66 | case empty => simp at hx 67 | case insert a Γ _ ih => 68 | have : x = ⌜a⌝ ∨ x ∈ (⌜Γ⌝ : V) := by simpa using hx 69 | rcases this with (rfl | hx) 70 | · exact ⟨a, by simp⟩ 71 | · rcases ih hx with ⟨p, hx, rfl⟩ 72 | exact ⟨p, by simp [*]⟩ 73 | 74 | lemma Sequent.mem_codeIn_iff' {Γ : Finset (SyntacticFormula L)} : x ∈ (⌜Γ⌝ : V) ↔ (∃ φ ∈ Γ, x = ⌜φ⌝) := by 75 | constructor 76 | · intro h; exact Sequent.mem_codeIn h 77 | · rintro ⟨p, hp, rfl⟩; simp [Sequent.mem_codeIn_iff, hp] 78 | 79 | lemma setShift_quote [DefinableLanguage L] (Γ : Finset (SyntacticFormula L)) : (L.codeIn V).setShift ⌜Γ⌝ = ⌜Finset.image Rewriting.shift Γ⌝ := by 80 | apply mem_ext 81 | intro x; simp [mem_setShift_iff] 82 | constructor 83 | · rintro ⟨x, hx, rfl⟩ 84 | rcases Sequent.mem_codeIn hx with ⟨p, _, rfl⟩ 85 | rw [←quote_shift, Sequent.mem_codeIn_iff] 86 | simp 87 | exact ⟨p, by simpa [Sequent.mem_codeIn_iff] using hx, rfl⟩ 88 | · intro hx 89 | rcases Sequent.mem_codeIn hx with ⟨p', hp', rfl⟩ 90 | rcases by simpa using hp' with ⟨p, hp, rfl⟩ 91 | exact ⟨⌜p⌝, by simpa [Sequent.mem_codeIn_iff] using hp, by simp⟩ 92 | 93 | variable (V) 94 | 95 | variable {T : Theory L} 96 | 97 | def codeIn [L.DecidableEq] : {Γ : Finset (SyntacticFormula L)} → T ⊢₂ Γ → V 98 | | _, closed Δ φ _ _ => Arith.axL ⌜Δ⌝ ⌜φ⌝ 99 | | _, root (Δ := Δ) φ _ _ => Arith.root ⌜Δ⌝ ⌜φ⌝ 100 | | _, verum (Δ := Δ) _ => Arith.verumIntro ⌜Δ⌝ 101 | | _, and (Δ := Δ) _ (φ := φ) (ψ := ψ) bp bq => Arith.andIntro ⌜Δ⌝ ⌜φ⌝ ⌜ψ⌝ bp.codeIn bq.codeIn 102 | | _, or (Δ := Δ) (φ := φ) (ψ := ψ) _ d => Arith.orIntro ⌜Δ⌝ ⌜φ⌝ ⌜ψ⌝ d.codeIn 103 | | _, all (Δ := Δ) (φ := φ) _ d => Arith.allIntro ⌜Δ⌝ ⌜φ⌝ d.codeIn 104 | | _, ex (Δ := Δ) (φ := φ) _ t d => Arith.exIntro ⌜Δ⌝ ⌜φ⌝ ⌜t⌝ d.codeIn 105 | | _, wk (Γ := Γ) d _ => Arith.wkRule ⌜Γ⌝ d.codeIn 106 | | _, shift (Δ := Δ) d => Arith.shiftRule ⌜Δ.image Rewriting.shift⌝ d.codeIn 107 | | _, cut (Δ := Δ) (φ := φ) d dn => Arith.cutRule ⌜Δ⌝ ⌜φ⌝ d.codeIn dn.codeIn 108 | 109 | instance (Γ : Finset (SyntacticFormula L)) : GoedelQuote (T ⊢₂ Γ) V := ⟨codeIn V⟩ 110 | 111 | lemma quote_derivation_def {Γ : Finset (SyntacticFormula L)} (d : T ⊢₂ Γ) : (⌜d⌝ : V) = d.codeIn V := rfl 112 | 113 | @[simp] lemma fstidx_quote {Γ : Finset (SyntacticFormula L)} (d : T ⊢₂ Γ) : fstIdx (⌜d⌝ : V) = ⌜Γ⌝ := by 114 | induction d <;> simp [quote_derivation_def, codeIn] 115 | 116 | end Derivation2 117 | 118 | end LO.FirstOrder 119 | 120 | namespace LO.Arith 121 | 122 | open FirstOrder FirstOrder.Arith FirstOrder.Semiformula 123 | 124 | variable {V : Type*} [ORingStruc V] [V ⊧ₘ* 𝐈𝚺₁] 125 | 126 | variable {L : Language} [(k : ℕ) → Encodable (L.Func k)] [(k : ℕ) → Encodable (L.Rel k)] [DefinableLanguage L] 127 | 128 | variable {T : Theory L} [T.Delta1Definable] 129 | 130 | open Classical 131 | 132 | @[simp] lemma formulaSet_codeIn_finset (Γ : Finset (SyntacticFormula L)) : (L.codeIn V).IsFormulaSet ⌜Γ⌝ := by 133 | intro x hx 134 | rcases Derivation2.Sequent.mem_codeIn hx with ⟨p, _, rfl⟩; 135 | apply semiformula_quote (n := 0) 136 | 137 | open Derivation2 138 | 139 | lemma quote_image_shift [L.DecidableEq] (Γ : Finset (SyntacticFormula L)) : (L.codeIn V).setShift (⌜Γ⌝ : V) = ⌜Γ.image Rewriting.shift⌝ := by 140 | induction Γ using Finset.induction 141 | case empty => simp 142 | case insert φ Γ _ ih => simp [ih] 143 | 144 | @[simp] lemma derivation_quote [L.DecidableEq] {Γ : Finset (SyntacticFormula L)} (d : T ⊢₂ Γ) : (T.codeIn V).Derivation ⌜d⌝ := by 145 | induction d 146 | case closed φ hp hn => 147 | exact Language.Theory.Derivation.axL (by simp) 148 | (by simp [Sequent.mem_codeIn_iff, hp]) 149 | (by rw [←quote_neg, Sequent.mem_codeIn_iff]; simp [hn]) 150 | case root Δ φ hT hp => 151 | apply Language.Theory.Derivation.root (by simp) 152 | (by simp [Sequent.mem_codeIn_iff, hp]) 153 | (by simp [hT]) 154 | case verum Δ h => 155 | exact Language.Theory.Derivation.verumIntro (by simp) 156 | (by simpa [quote_verum] using (Sequent.mem_codeIn_iff (V := V)).mpr h) 157 | case and Δ φ ψ hpq dp dq ihp ihq => 158 | apply Language.Theory.Derivation.andIntro 159 | (by simpa [quote_and] using (Sequent.mem_codeIn_iff (V := V)).mpr hpq) 160 | ⟨by simp [fstidx_quote], ihp⟩ 161 | ⟨by simp [fstidx_quote], ihq⟩ 162 | case or Δ φ ψ hpq d ih => 163 | apply Language.Theory.Derivation.orIntro 164 | (by simpa [quote_or] using (Sequent.mem_codeIn_iff (V := V)).mpr hpq) 165 | ⟨by simp [fstidx_quote], ih⟩ 166 | case all Δ φ h d ih => 167 | apply Language.Theory.Derivation.allIntro 168 | (by simpa [quote_all] using (Sequent.mem_codeIn_iff (V := V)).mpr h) 169 | ⟨by simp [fstidx_quote, quote_image_shift, free_quote], ih⟩ 170 | case ex Δ φ h t d ih => 171 | apply Language.Theory.Derivation.exIntro 172 | (by simpa [quote_ex] using (Sequent.mem_codeIn_iff (V := V)).mpr h) 173 | (semiterm_codeIn t) 174 | ⟨by simp [fstidx_quote, Language.substs₁], ih⟩ 175 | case wk Δ Γ d h ih => 176 | apply Language.Theory.Derivation.wkRule (s' := ⌜Δ⌝) 177 | (by simp) 178 | (by intro x hx; rcases Sequent.mem_codeIn hx with ⟨p, hp, rfl⟩ 179 | simp [Sequent.mem_codeIn_iff, h hp]) 180 | ⟨by simp [fstidx_quote], ih⟩ 181 | case shift Δ d ih => 182 | simp [quote_derivation_def, Derivation2.codeIn, ←quote_image_shift] 183 | apply Language.Theory.Derivation.shiftRule 184 | ⟨by simp [fstidx_quote], ih⟩ 185 | case cut Δ φ d dn ih ihn => 186 | apply Language.Theory.Derivation.cutRule 187 | ⟨by simp [fstidx_quote], ih⟩ 188 | ⟨by simp [fstidx_quote], ihn⟩ 189 | 190 | @[simp] lemma derivationOf_quote {Γ : Finset (SyntacticFormula L)} (d : T ⊢₂ Γ) : (T.codeIn V).DerivationOf ⌜d⌝ ⌜Γ⌝ := 191 | ⟨by simp, by simp⟩ 192 | 193 | lemma derivable_of_quote {Γ : Finset (SyntacticFormula L)} (d : T ⊢₂ Γ) : (T.codeIn V).Derivable ⌜Γ⌝ := 194 | ⟨⌜d⌝, by simp⟩ 195 | 196 | section 197 | 198 | variable {T : Theory L} [T.Delta1Definable] 199 | 200 | theorem provable_of_provable {φ} : T ⊢! φ → (T.codeIn V).Provable ⌜φ⌝ := fun h ↦ by 201 | simpa using derivable_of_quote (V := V) (provable_iff_derivable2.mp h).some 202 | 203 | /-- Hilbert–Bernays provability condition D1 -/ 204 | theorem tprovable_of_provable {φ} : T ⊢! φ → T.tCodeIn V ⊢! ⌜φ⌝ := fun h ↦ by 205 | simpa [Language.Theory.TProvable.iff_provable] using provable_of_provable (V := V) h 206 | 207 | end 208 | 209 | section 210 | 211 | variable {T : Theory ℒₒᵣ} [T.Delta1Definable] 212 | 213 | theorem provableₐ_of_provable {σ} : T ⊢! σ → T.Provableₐ (⌜σ⌝ : V) := fun h ↦ 214 | Language.Theory.Derivable.of_ss Formalized.theory_subset_AddR₀ (provable_of_provable h) 215 | 216 | end 217 | 218 | end LO.Arith 219 | 220 | namespace Nat 221 | 222 | lemma double_add_one_div_of_double (n m : ℕ) : (2 * n + 1) / (2 * m) = n / m := calc 223 | (2 * n + 1) / (2 * m) 224 | = (1 + 2 * n) / 2 / m := by simp [add_comm, Nat.div_div_eq_div_mul] 225 | _ = n / m := by simp [Nat.add_mul_div_left] 226 | 227 | example (x : ℕ) : ¬Odd (2 * x) := by { refine not_odd_iff_even.mpr (even_two_mul x) } 228 | 229 | lemma mem_bitIndices_iff {x s : ℕ} : x ∈ s.bitIndices ↔ Odd (s / 2 ^ x) := by 230 | induction s using Nat.binaryRec generalizing x 231 | case z => simp [Nat.dvd_zero] 232 | case f b s ih => 233 | cases b <;> simp [ih] 234 | · constructor 235 | · rintro ⟨x, hx, rfl⟩ 236 | rw [show 2 ^ (x + 1) = 2 * 2 ^ x by simp [Nat.pow_add_one, mul_comm], Nat.mul_div_mul_left _ _ (by simp)] 237 | exact hx 238 | · intro h 239 | cases' x with x 240 | · simp [not_odd_iff_even.mpr (even_two_mul s)] at h 241 | · refine ⟨x, ?_, rfl⟩ 242 | rwa [show 2 ^ (x + 1) = 2 * 2 ^ x by simp [Nat.pow_add_one, mul_comm], Nat.mul_div_mul_left _ _ (by simp)] at h 243 | · constructor 244 | · rintro (rfl | ⟨x, hx, rfl⟩) 245 | · simp 246 | · rw [show 2 ^ (x + 1) = 2 * 2 ^ x by simp [Nat.pow_add_one, mul_comm], double_add_one_div_of_double] 247 | exact hx 248 | · intro h 249 | cases' x with x 250 | · simp 251 | · right; refine ⟨x, ?_, rfl⟩ 252 | rwa [show 2 ^ (x + 1) = 2 * 2 ^ x by simp [Nat.pow_add_one, mul_comm], double_add_one_div_of_double] at h 253 | 254 | end Nat 255 | 256 | namespace LO.FirstOrder 257 | 258 | variable {L : Language} {T : Theory L} 259 | 260 | end LO.FirstOrder 261 | 262 | namespace LO.Arith 263 | 264 | open FirstOrder Encodable 265 | 266 | variable {L : Language} [L.DecidableEq] [(k : ℕ) → Encodable (L.Func k)] [(k : ℕ) → Encodable (L.Rel k)] [DefinableLanguage L] 267 | 268 | lemma isFormulaSet_sound {s : ℕ} : (L.codeIn ℕ).IsFormulaSet s → ∃ S : Finset (SyntacticFormula L), ⌜S⌝ = s := by 269 | intro h 270 | have : ∀ x, ∃ φ : SyntacticFormula L, x ∈ s → ⌜φ⌝ = x := by 271 | intro x; 272 | by_cases hx : x ∈ s <;> simp [hx] 273 | exact (h x hx).sound 274 | choose ps hps using this 275 | exact ⟨(s.bitIndices.map ps).toFinset, by 276 | apply mem_ext 277 | intro x 278 | constructor 279 | · intro h 280 | rcases Derivation2.Sequent.mem_codeIn h with ⟨p, hp, rfl⟩ 281 | rcases by simpa using hp with ⟨x, hx, rfl⟩ 282 | simpa [hps x (mem_iff_mem_bitIndices.mpr hx)] using mem_iff_mem_bitIndices.mpr hx 283 | · intro h 284 | rw [←hps x h] 285 | simp [Derivation2.Sequent.mem_codeIn_iff, ←mem_iff_mem_bitIndices] 286 | exact ⟨x, h, rfl⟩⟩ 287 | 288 | section 289 | 290 | variable {T : Theory L} [T.Delta1Definable] 291 | 292 | open Derivation2 293 | 294 | lemma Language.Theory.Derivation.sound {d : ℕ} (h : (T.codeIn ℕ).Derivation d) : ∃ Γ, ⌜Γ⌝ = fstIdx d ∧ T ⊢₂! Γ := by 295 | induction d using Nat.strongRec 296 | case ind d ih => 297 | rcases h.case with ⟨hs, H⟩ 298 | rcases isFormulaSet_sound hs with ⟨Γ, hΓ⟩ 299 | refine ⟨Γ, hΓ, ?_⟩ 300 | rcases H with (⟨s, φ, rfl, hφ, hnp⟩ | ⟨s, rfl, hv⟩ | 301 | ⟨s, φ, ψ, dp, dq, rfl, hpq, ⟨hφ, hdφ⟩, ⟨hψ, hdq⟩⟩ | ⟨s, φ, ψ, d, rfl, hpq, ⟨h, hd⟩⟩ | 302 | ⟨s, φ, d, rfl, hps, hd, dd⟩ | ⟨s, φ, t, d, rfl, hps, ht, hd, dd⟩ | 303 | ⟨s, d, rfl, hs, dd⟩ | ⟨s, d, rfl, rfl, dd⟩ | 304 | ⟨s, φ, d₁, d₂, rfl, ⟨h₁, dd₁⟩, ⟨h₂, dd₂⟩⟩ | ⟨s, φ, rfl, hs, hT⟩) 305 | · rcases (hs φ (by simp [hφ])).sound with ⟨φ, rfl⟩ 306 | refine ⟨Derivation2.closed Γ φ 307 | (by simp [←Sequent.mem_codeIn_iff (V := ℕ), hΓ, hφ]) 308 | (by simp [←Sequent.mem_codeIn_iff (V := ℕ), hΓ, hφ, hnp])⟩ 309 | · refine ⟨Derivation2.verum (by simp [←Sequent.mem_codeIn_iff (V := ℕ), hΓ, Semiformula.quote_verum, hv])⟩ 310 | · have fpq : (L.codeIn ℕ).IsFormula φ ∧ (L.codeIn ℕ).IsFormula ψ := by simpa using hs (φ ^⋏ ψ) (by simp [hpq]) 311 | rcases by simpa using hΓ 312 | rcases fpq.1.sound with ⟨φ, rfl⟩ 313 | rcases fpq.2.sound with ⟨ψ, rfl⟩ 314 | rcases ih dp (by simp) hdφ with ⟨Γφ, hΓφ, ⟨bφ⟩⟩ 315 | rcases ih dq (by simp) hdq with ⟨Γψ, hΓψ, ⟨bψ⟩⟩ 316 | refine ⟨Derivation2.and (φ := φ) (ψ := ψ) 317 | (by simp [←Sequent.mem_codeIn_iff (V := ℕ), Semiformula.quote_and, hpq]) 318 | (bφ.cast <| Sequent.quote_inj (V := ℕ) (by simp [hΓφ, hφ])) 319 | (bψ.cast <| Sequent.quote_inj (V := ℕ) (by simp [hΓψ, hψ]))⟩ 320 | · have fpq : (L.codeIn ℕ).IsFormula φ ∧ (L.codeIn ℕ).IsFormula ψ := by simpa using hs (φ ^⋎ ψ) (by simp [hpq]) 321 | rcases by simpa using hΓ 322 | rcases fpq.1.sound with ⟨φ, rfl⟩ 323 | rcases fpq.2.sound with ⟨ψ, rfl⟩ 324 | rcases ih d (by simp) hd with ⟨Δ, hΔ, ⟨b⟩⟩ 325 | refine ⟨Derivation2.or (φ := φ) (ψ := ψ) 326 | (by simp [←Sequent.mem_codeIn_iff (V := ℕ), Semiformula.quote_or, hpq]) 327 | (b.cast <| Sequent.quote_inj (V := ℕ) (by simp [hΔ, h]))⟩ 328 | · rcases by simpa using hΓ 329 | have : (L.codeIn ℕ).IsSemiformula 1 φ := by simpa using hs (^∀ φ) (by simp [hps]) 330 | rcases this.sound with ⟨φ, rfl⟩ 331 | rcases ih d (by simp) dd with ⟨Δ, hΔ, ⟨b⟩⟩ 332 | refine ⟨Derivation2.all (φ := φ) 333 | (by simp [←Sequent.mem_codeIn_iff (V := ℕ), Semiformula.quote_all, hps]) 334 | (b.cast <| Sequent.quote_inj (V := ℕ) <| by simp [hΔ, hd, ←free_quote, setShift_quote])⟩ 335 | · rcases by simpa using hΓ 336 | have : (L.codeIn ℕ).IsSemiformula 1 φ := by simpa using hs (^∃ φ) (by simp [hps]) 337 | rcases this.sound with ⟨φ, rfl⟩ 338 | rcases ht.sound with ⟨t, rfl⟩ 339 | rcases ih d (by simp) dd with ⟨Δ, hΔ, ⟨b⟩⟩ 340 | refine ⟨Derivation2.ex (φ := φ) 341 | (by simp [←Sequent.mem_codeIn_iff (V := ℕ), Semiformula.quote_ex, hps]) t 342 | (b.cast <| Sequent.quote_inj (V := ℕ) <| by simp [hΔ, hd, Language.substs₁])⟩ 343 | · rcases by simpa using hΓ 344 | rcases ih d (by simp) dd with ⟨Δ, hΔ, ⟨b⟩⟩ 345 | refine ⟨Derivation2.wk (Δ := Δ) b 346 | (Sequent.subset_of_quote_subset_quote (V := ℕ) <| by simp [hΔ, hs])⟩ 347 | · rcases ih d (by simp) dd with ⟨Δ, hΔ, ⟨b⟩⟩ 348 | have : Γ = Finset.image Rewriting.shift Δ := 349 | Sequent.quote_inj <| by simpa [←hΔ, setShift_quote] using hΓ 350 | rcases this 351 | refine ⟨Derivation2.shift b⟩ 352 | · rcases by simpa using hΓ 353 | have : (L.codeIn ℕ).IsFormula φ := dd₁.isFormulaSet φ (by simp [h₁]) 354 | rcases this.sound with ⟨φ, rfl⟩ 355 | rcases ih d₁ (by simp) dd₁ with ⟨Δ₁, hΔ₁, ⟨b₁⟩⟩ 356 | have : Δ₁ = (φ ⫽ Γ) := Sequent.quote_inj (V := ℕ) <| by simp [hΔ₁, h₁] 357 | rcases this 358 | rcases ih d₂ (by simp) dd₂ with ⟨Δ₂, hΔ₂, ⟨b₂⟩⟩ 359 | have : Δ₂ = (∼φ ⫽ Γ) := Sequent.quote_inj (V := ℕ) <| by simp [hΔ₂, h₂] 360 | rcases this 361 | refine ⟨Derivation2.cut b₁ b₂⟩ 362 | · rcases by simpa using hΓ 363 | rcases Sequent.mem_codeIn hs with ⟨φ, hφ, rfl⟩ 364 | refine ⟨Derivation2.root φ (by simpa using hT) hφ⟩ 365 | 366 | lemma Language.Theory.Provable.sound2 {φ : SyntacticFormula L} (h : (T.codeIn ℕ).Provable ⌜φ⌝) : T ⊢₂.! φ := by 367 | rcases h with ⟨d, hp, hd⟩ 368 | rcases hd.sound with ⟨Γ, e, b⟩ 369 | have : Γ = {φ} := Sequent.quote_inj (V := ℕ) <| by simp [e, hp] 370 | rcases this 371 | exact b 372 | 373 | end 374 | 375 | variable {T : Theory L} [T.Delta1Definable] 376 | 377 | lemma Language.Theory.Provable.sound {φ : SyntacticFormula L} (h : (T.codeIn ℕ).Provable ⌜φ⌝) : T ⊢! φ := 378 | provable_iff_derivable2.mpr <| Language.Theory.Provable.sound2 (by simpa using h) 379 | 380 | lemma Language.Theory.Provable.sound₀ {σ : Sentence L} (h : (T.codeIn ℕ).Provable ⌜σ⌝) : T ⊢! ↑σ := 381 | provable_iff_derivable2.mpr <| Language.Theory.Provable.sound2 (by simpa using h) 382 | 383 | lemma Language.Theory.Provable.complete {φ : SyntacticFormula L} : 384 | T.tCodeIn ℕ ⊢! ⌜φ⌝ ↔ T ⊢! φ := 385 | ⟨by simpa [Language.Theory.TProvable.iff_provable] using Language.Theory.Provable.sound, tprovable_of_provable⟩ 386 | 387 | lemma Language.Theory.Provable.complete₀ {σ : Sentence L} : 388 | T.tCodeIn ℕ ⊢! ⌜σ⌝ ↔ T ⊢! ↑σ := 389 | ⟨by simpa [Language.Theory.TProvable.iff_provable] using Language.Theory.Provable.sound₀, tprovable_of_provable⟩ 390 | 391 | @[simp] lemma provableₐ_iff_provable₀ {T : Theory ℒₒᵣ} [T.Delta1Definable] [𝐑₀ ⪯ T] {σ : Sentence ℒₒᵣ} : 392 | T.Provableₐ (⌜σ⌝ : ℕ) ↔ T ⊢! ↑σ := by 393 | simpa [provableₐ_iff, Language.Theory.Provable.complete₀] using FirstOrder.Arith.add_cobhamR0'.symm 394 | 395 | end LO.Arith 396 | -------------------------------------------------------------------------------- /Incompleteness/Arith/Theory.lean: -------------------------------------------------------------------------------- 1 | import Incompleteness.Arith.FormalizedArithmetic 2 | 3 | /-! 4 | 5 | # Formalized $\Sigma_1$-Completeness 6 | 7 | -/ 8 | 9 | namespace LO.FirstOrder 10 | 11 | variable {L : Language} 12 | 13 | section 14 | 15 | open Lean PrettyPrinter Delaborator 16 | 17 | syntax:max "let " ident " := " term:max first_order_term:61* "; " first_order_formula:0 : first_order_formula 18 | syntax:max "let' " ident " := " term:max first_order_term:61* "; " first_order_formula:0 : first_order_formula 19 | 20 | macro_rules 21 | | `(⤫formula[$binders* | $fbinders* | let $x:ident := $f:term $vs:first_order_term* ; $φ:first_order_formula]) => 22 | `(⤫formula[$binders* | $fbinders* | ∃ $x, !$f:term #0 $vs:first_order_term* ∧ $φ]) 23 | | `(⤫formula[$binders* | $fbinders* | let' $x:ident := $f:term $vs:first_order_term* ; $φ:first_order_formula]) => 24 | `(⤫formula[$binders* | $fbinders* | ∀ $x, !$f:term #0 $vs:first_order_term* → $φ]) 25 | 26 | end 27 | 28 | namespace Theory 29 | 30 | inductive CobhamR0' : Theory ℒₒᵣ 31 | | eq_refl : CobhamR0' “∀ x, x = x” 32 | | replace (φ : SyntacticSemiformula ℒₒᵣ 1) : CobhamR0' “∀ x y, x = y → !φ x → !φ y” 33 | | Ω₁ (n m : ℕ) : CobhamR0' “↑n + ↑m = ↑(n + m)” 34 | | Ω₂ (n m : ℕ) : CobhamR0' “↑n * ↑m = ↑(n * m)” 35 | | Ω₃ (n m : ℕ) : n ≠ m → CobhamR0' “↑n ≠ ↑m” 36 | | Ω₄ (n : ℕ) : CobhamR0' “∀ x, x < ↑n ↔ ⋁ i < n, x = ↑i” 37 | 38 | notation "𝐑₀'" => CobhamR0' 39 | 40 | abbrev addCobhamR0' (T : Theory ℒₒᵣ) : Theory ℒₒᵣ := T + 𝐑₀' 41 | 42 | end Theory 43 | 44 | namespace Arith 45 | /- 46 | 47 | 48 | namespace CobhamR0' 49 | 50 | variable {M : Type*} [Nonempty M] [s : Structure ℒₒᵣ M] [M ⊧ₘ* 𝐑₀'] {a b c : M} 51 | 52 | abbrev eql (x y : M) : Prop := s.rel Language.Eq.eq ![x, y] 53 | 54 | abbrev add (x y : M) : M := s.func Language.Add.add ![x, y] 55 | 56 | abbrev mul (x y : M) : M := s.func Language.Mul.mul ![x, y] 57 | 58 | lemma operator_eq_eq (v : Fin 2 → M) : (Semiformula.Operator.Eq.eq (L := ℒₒᵣ)).val v = eql (v 0) (v 1) := by 59 | rw [Matrix.fun_eq_vec₂ (v := v)]; simp; rfl 60 | 61 | lemma operator_lt_eq : (Semiformula.Operator.LT.lt (L := ℒₒᵣ)).val ![a, b] = s.rel Language.LT.lt ![a, b] := rfl 62 | 63 | @[simp] lemma eq_refl (a : M) : eql a a := by 64 | have := by simpa using ModelsTheory.models M Theory.CobhamR0'.eq_refl (fun _ ↦ a) 65 | exact this a 66 | 67 | lemma eq_symm {a b : M} : eql a b → eql b a := fun h ↦ by 68 | have : ∀ x y, eql x y → eql x a → eql y a := by 69 | simpa [operator_eq_eq] using ModelsTheory.models M (Theory.CobhamR0'.replace “x. x = &0”) (fun _ ↦ a) 70 | exact this a b h (by simp) 71 | 72 | lemma eq_trans {a b c : M} : eql a b → eql b c → eql a c := fun hab hbc ↦ by 73 | have := by simpa [operator_eq_eq] using ModelsTheory.models M (Theory.CobhamR0'.replace “x. &0 = x”) (fun _ ↦ a) 74 | exact this b c hbc hab 75 | 76 | lemma add_ext {a₁ a₂ b₁ b₂ : M} (ha : eql a₁ a₂) (hb : eql b₁ b₂) : 77 | eql (s.func Language.Add.add ![a₁, b₁]) (s.func Language.Add.add ![a₂, b₂]) := by 78 | have e : eql (s.func Language.Add.add ![a₁, b₁]) (s.func Language.Add.add ![a₂, b₁]) := by 79 | have := by simpa [operator_eq_eq] using ModelsTheory.models M (Theory.CobhamR0'.replace “x. &0 + &1 = x + &1”) (a₁ :>ₙ fun _ ↦ b₁) 80 | exact this a₁ a₂ ha (by simp) 81 | have := by simpa [operator_eq_eq] using ModelsTheory.models M (Theory.CobhamR0'.replace “x. &0 + &1 = &2 + x”) (a₁ :>ₙ b₁ :>ₙ fun _ ↦ a₂) 82 | exact this b₁ b₂ hb e 83 | 84 | lemma mul_ext {a₁ a₂ b₁ b₂ : M} (ha : eql a₁ a₂) (hb : eql b₁ b₂) : 85 | eql (s.func Language.Mul.mul ![a₁, b₁]) (s.func Language.Mul.mul ![a₂, b₂]) := by 86 | have e : eql (s.func Language.Mul.mul ![a₁, b₁]) (s.func Language.Mul.mul ![a₂, b₁]) := by 87 | have := by simpa [operator_eq_eq] using ModelsTheory.models M (Theory.CobhamR0'.replace “x. &0 * &1 = x * &1”) (a₁ :>ₙ fun _ ↦ b₁) 88 | exact this a₁ a₂ ha (by simp) 89 | have := by simpa [operator_eq_eq] using ModelsTheory.models M (Theory.CobhamR0'.replace “x. &0 * &1 = &2 * x”) (a₁ :>ₙ b₁ :>ₙ fun _ ↦ a₂) 90 | exact this b₁ b₂ hb e 91 | 92 | noncomputable instance : 𝐄𝐐 ⪯ 𝐑₀' := Entailment.WeakerThan.ofAxm! <| by { 93 | intro φ hp 94 | cases hp 95 | · apply complete (consequence_iff.mpr fun M _ _ s f ↦ ?_) 96 | simp [operator_eq_eq] 97 | · apply complete (consequence_iff.mpr fun M _ _ s f ↦ ?_) 98 | simp [operator_eq_eq]; exact eq_symm 99 | · apply complete (consequence_iff.mpr fun M _ _ s f ↦ ?_) 100 | simp [operator_eq_eq]; exact eq_trans 101 | case funcExt k f => 102 | match k, f with 103 | | _, Language.Zero.zero => 104 | apply complete (consequence_iff.mpr fun M _ _ s f ↦ ?_) 105 | simp [operator_eq_eq] 106 | | _, Language.One.one => 107 | apply complete (consequence_iff.mpr fun M _ _ s f ↦ ?_) 108 | simp [operator_eq_eq] 109 | | _, Language.Add.add => 110 | apply complete (consequence_iff.mpr fun M _ _ s f ↦ ?_) 111 | simp [operator_eq_eq, Semiterm.val_func] 112 | intro h; rw [Matrix.fun_eq_vec₂ (v := fun i : Fin 2 ↦ f i), Matrix.fun_eq_vec₂ (v := fun i : Fin 2 ↦ f (2 + i))] 113 | apply add_ext (by simpa using h 0) (by simpa using h 1) 114 | | _, Language.Mul.mul => 115 | apply complete (consequence_iff.mpr fun M _ _ s f ↦ ?_) 116 | simp [operator_eq_eq, Semiterm.val_func] 117 | intro h; rw [Matrix.fun_eq_vec₂ (v := fun i : Fin 2 ↦ f i), Matrix.fun_eq_vec₂ (v := fun i : Fin 2 ↦ f (2 + i))] 118 | apply mul_ext (by simpa using h 0) (by simpa using h 1) 119 | case relExt k R => 120 | match k, R with 121 | | _, Language.Eq.eq => 122 | apply complete (consequence_iff.mpr fun M _ _ s f ↦ ?_) 123 | simp [operator_eq_eq, Semiterm.val_func, Semiformula.eval_rel] 124 | rw [Matrix.fun_eq_vec₂ (v := fun i : Fin 2 ↦ f i), Matrix.fun_eq_vec₂ (v := fun i : Fin 2 ↦ f (2 + i))] 125 | intro hs h; 126 | have e20 : eql (f 2) (f 0) := by simpa using eq_symm (hs 0) 127 | have e01 : eql (f 0) (f 1) := by simpa using h 128 | have e13 : eql (f 1) (f 3) := by simpa using (hs 1) 129 | simpa using eq_trans (eq_trans e20 e01) e13 130 | | _, Language.LT.lt => 131 | apply complete (consequence_iff.mpr fun M _ _ s f ↦ ?_) 132 | simp [operator_eq_eq, Semiterm.val_func, Semiformula.eval_rel] 133 | rw [Matrix.fun_eq_vec₂ (v := fun i : Fin 2 ↦ f i), Matrix.fun_eq_vec₂ (v := fun i : Fin 2 ↦ f (2 + i))] 134 | intro hs h; 135 | 136 | 137 | 138 | } 139 | 140 | -/ 141 | 142 | open LO.Arith 143 | 144 | noncomputable instance CobhamR0'.subtheoryOfCobhamR0 : 𝐑₀' ⪯ 𝐑₀ := Entailment.WeakerThan.ofAxm! <| by 145 | intro φ hp 146 | rcases hp 147 | · apply complete <| oRing_consequence_of.{0} _ _ <| fun M _ _ => by simp [models_iff] 148 | · apply complete <| oRing_consequence_of.{0} _ _ <| fun M _ _ => by simp [models_iff] 149 | case Ω₁ n m => exact Entailment.by_axm _ (Theory.CobhamR0.Ω₁ n m) 150 | case Ω₂ n m => exact Entailment.by_axm _ (Theory.CobhamR0.Ω₂ n m) 151 | case Ω₃ n m h => exact Entailment.by_axm _ (Theory.CobhamR0.Ω₃ n m h) 152 | case Ω₄ n => exact Entailment.by_axm _ (Theory.CobhamR0.Ω₄ n) 153 | 154 | variable {T : Theory ℒₒᵣ} [𝐑₀ ⪯ T] 155 | 156 | lemma add_cobhamR0' {φ} : T ⊢! φ ↔ T + 𝐑₀' ⊢! φ := by 157 | constructor 158 | · intro h; exact Entailment.wk! (by simp [Theory.add_def]) h 159 | · intro h 160 | exact Entailment.StrongCut.cut! 161 | (by 162 | rintro φ (hp | hp) 163 | · exact Entailment.by_axm _ hp 164 | · have : 𝐑₀' ⊢! φ := Entailment.by_axm _ hp 165 | have : 𝐑₀ ⊢! φ := Entailment.WeakerThan.pbl this 166 | exact Entailment.WeakerThan.pbl this) h 167 | 168 | end Arith 169 | 170 | end LO.FirstOrder 171 | 172 | noncomputable section 173 | 174 | open Classical 175 | 176 | namespace LO.Arith 177 | 178 | open FirstOrder FirstOrder.Arith 179 | 180 | variable {V : Type*} [ORingStruc V] [V ⊧ₘ* 𝐈𝚺₁] 181 | 182 | section 183 | 184 | variable {L : Language} [(k : ℕ) → Encodable (L.Func k)] [(k : ℕ) → Encodable (L.Rel k)] [DefinableLanguage L] 185 | 186 | def singleton (φ : SyntacticFormula L) : 187 | Theory.Delta1Definable {φ} where 188 | ch := .ofZero (.mkSigma “x. x = ↑⌜φ⌝” (by simp)) _ 189 | mem_iff {ψ} := by simp 190 | isDelta1 := Arith.HierarchySymbol.Semiformula.ProvablyProperOn.ofProperOn.{0} _ fun V _ _ ↦ by simp 191 | 192 | @[simp] lemma singleton_toTDef_ch_val (φ : FirstOrder.SyntacticFormula L) : 193 | letI := singleton φ 194 | (Theory.Delta1Definable.toTDef {φ}).ch.val = “x. x = ↑⌜φ⌝” := rfl 195 | 196 | end 197 | 198 | namespace Formalized 199 | 200 | namespace Theory.CobhamR0' 201 | 202 | def eqRefl : FirstOrder.Theory.Delta1Definable {(“∀ x, x = x” : SyntacticFormula ℒₒᵣ)} := singleton _ 203 | 204 | def replace : 205 | FirstOrder.Theory.Delta1Definable {“∀ x y, x = y → !φ x → !φ y” | φ : SyntacticSemiformula ℒₒᵣ 1} where 206 | ch := .mkDelta 207 | (.mkSigma 208 | “p. 209 | ∃ q < p, !p⌜ℒₒᵣ⌝.isSemiformulaDef.sigma 1 q ∧ 210 | let x0 := qqBvarDef 0; 211 | let x1 := qqBvarDef 1; 212 | let eq := qqEQDef x1 x0; 213 | let v0 := mkVec₁Def x0; 214 | let v1 := mkVec₁Def x1; 215 | let q0 := p⌜ℒₒᵣ⌝.substsDef v1 q; 216 | let q1 := p⌜ℒₒᵣ⌝.substsDef v0 q; 217 | let imp0 := p⌜ℒₒᵣ⌝.impDef q0 q1; 218 | let imp1 := p⌜ℒₒᵣ⌝.impDef eq imp0; 219 | let all0 := qqAllDef imp1; 220 | !qqAllDef p all0” (by simp)) 221 | (.mkPi 222 | “p. 223 | ∃ q < p, !p⌜ℒₒᵣ⌝.isSemiformulaDef.pi 1 q ∧ 224 | let' x0 := qqBvarDef 0; 225 | let' x1 := qqBvarDef 1; 226 | let' eq := qqEQDef x1 x0; 227 | let' v0 := mkVec₁Def x0; 228 | let' v1 := mkVec₁Def x1; 229 | let' q0 := p⌜ℒₒᵣ⌝.substsDef v1 q; 230 | let' q1 := p⌜ℒₒᵣ⌝.substsDef v0 q; 231 | let' imp0 := p⌜ℒₒᵣ⌝.impDef q0 q1; 232 | let' imp1 := p⌜ℒₒᵣ⌝.impDef eq imp0; 233 | let' all0 := qqAllDef imp1; 234 | !qqAllDef p all0” (by simp)) 235 | mem_iff {φ} := by 236 | /- 237 | simp? [HierarchySymbol.Semiformula.val_sigma, (Language.isSemiformula_defined (LOR (V := ℕ))).df.iff, 238 | (Language.substs_defined (LOR (V := ℕ))).df.iff, (Language.imp_defined (LOR (V := ℕ))).df.iff] 239 | -/ 240 | simp only [Nat.reduceAdd, Fin.isValue, Nat.succ_eq_add_one, Set.mem_setOf_eq, 241 | HierarchySymbol.Semiformula.val_sigma, HierarchySymbol.Semiformula.val_mkDelta, 242 | HierarchySymbol.Semiformula.val_mkSigma, Semiformula.eval_bexLT, Semiterm.val_bvar, 243 | Matrix.cons_val_fin_one, LogicalConnective.HomClass.map_and, Semiformula.eval_substs, 244 | Matrix.comp_vecCons', Semiterm.val_operator₀, Structure.numeral_eq_numeral, 245 | ORingStruc.one_eq_one, Matrix.cons_val_zero, Matrix.constant_eq_singleton, 246 | (Language.isSemiformula_defined (LOR (V := ℕ))).df.iff, Matrix.cons_val_one, Matrix.vecHead, 247 | Semiformula.eval_ex, ORingStruc.zero_eq_zero, eval_qqBvarDef, Matrix.cons_val_two, 248 | Matrix.vecTail, Function.comp_apply, Fin.succ_zero_eq_one, eval_qqEQDef, 249 | Matrix.cons_val_three, Fin.succ_one_eq_two, eval_mkVec₁Def, Matrix.cons_app_six, 250 | Matrix.cons_app_five, Matrix.cons_val_four, Matrix.cons_val_succ, 251 | (Language.substs_defined (LOR (V := ℕ))).df.iff, Matrix.cons_app_seven, 252 | (Language.imp_defined (LOR (V := ℕ))).df.iff, eval_qqAllDef, 253 | Language.TermRec.Construction.cons_app_11, Language.TermRec.Construction.cons_app_10, 254 | Language.TermRec.Construction.cons_app_9, Matrix.cons_app_eight, 255 | LogicalConnective.Prop.and_eq, exists_eq_left] 256 | constructor 257 | · rintro ⟨x, _, hx, h⟩ 258 | rcases hx.sound with ⟨q, rfl⟩ 259 | exact ⟨q, by symm; apply (quote_inj_iff (V := ℕ)).mp; simpa using h⟩ 260 | · rintro ⟨q, rfl⟩ 261 | exact ⟨⌜q⌝, by 262 | simp [subst_eq_self₁] 263 | refine lt_trans ?_ (lt_forall _) 264 | refine lt_trans ?_ (lt_forall _) 265 | refine lt_trans ?_ (lt_or_right _ _) 266 | exact lt_or_right _ _, by simp⟩ 267 | isDelta1 := Arith.HierarchySymbol.Semiformula.ProvablyProperOn.ofProperOn.{0} _ fun V _ _ v ↦ by 268 | /- 269 | simp? [HierarchySymbol.Semiformula.val_sigma, 270 | (Language.isSemiformula_defined (LOR (V := V))).df.iff, (Language.isSemiformula_defined (LOR (V := V))).proper.iff', 271 | (Language.substs_defined (LOR (V := V))).df.iff, (Language.imp_defined (LOR (V := V))).df.iff] 272 | -/ 273 | simp only [Fin.isValue, Nat.reduceAdd, Nat.succ_eq_add_one, 274 | HierarchySymbol.Semiformula.val_sigma, HierarchySymbol.Semiformula.sigma_mkDelta, 275 | HierarchySymbol.Semiformula.val_mkSigma, Semiformula.eval_bexLT, Semiterm.val_bvar, 276 | LogicalConnective.HomClass.map_and, Semiformula.eval_substs, Matrix.comp_vecCons', 277 | Semiterm.val_operator₀, Structure.numeral_eq_numeral, ORingStruc.one_eq_one, 278 | Matrix.cons_val_fin_one, Matrix.cons_val_zero, Matrix.constant_eq_singleton, 279 | (Language.isSemiformula_defined (LOR (V := V))).df.iff, Matrix.cons_val_one, Matrix.vecHead, 280 | Semiformula.eval_ex, ORingStruc.zero_eq_zero, eval_qqBvarDef, Matrix.cons_val_two, 281 | Matrix.vecTail, Function.comp_apply, Fin.succ_zero_eq_one, eval_qqEQDef, 282 | Matrix.cons_val_three, Fin.succ_one_eq_two, eval_mkVec₁Def, Matrix.cons_app_six, 283 | Matrix.cons_app_five, Matrix.cons_val_four, Matrix.cons_val_succ, 284 | (Language.substs_defined (LOR (V := V))).df.iff, Matrix.cons_app_seven, 285 | (Language.imp_defined (LOR (V := V))).df.iff, eval_qqAllDef, 286 | Language.TermRec.Construction.cons_app_11, Language.TermRec.Construction.cons_app_10, 287 | Language.TermRec.Construction.cons_app_9, Matrix.cons_app_eight, 288 | LogicalConnective.Prop.and_eq, exists_eq_left, HierarchySymbol.Semiformula.pi_mkDelta, 289 | HierarchySymbol.Semiformula.val_mkPi, 290 | (Language.isSemiformula_defined (LOR (V := V))).proper.iff', Semiformula.eval_all, 291 | LogicalConnective.HomClass.map_imply, LogicalConnective.Prop.arrow_eq, forall_eq] 292 | 293 | def Ω₁ : 294 | FirstOrder.Theory.Delta1Definable {φ : SyntacticFormula ℒₒᵣ | ∃ n m : ℕ, φ = “↑n + ↑m = ↑(n + m)”} where 295 | ch := .mkDelta 296 | (.mkSigma “p. 297 | ∃ n < p, ∃ m < p, 298 | let numn := numeralDef n; 299 | let numm := numeralDef m; 300 | let lhd := qqAddDef numn numm; 301 | let rhd := numeralDef (n + m); 302 | !qqEQDef p lhd rhd” (by simp)) 303 | (.mkPi “p. 304 | ∃ n < p, ∃ m < p, 305 | let' numn := numeralDef n; 306 | let' numm := numeralDef m; 307 | let' lhd := qqAddDef numn numm; 308 | let' rhd := numeralDef (n + m); 309 | ∀ p', !qqEQDef p' lhd rhd → p = p'” (by simp)) 310 | mem_iff {φ} := by 311 | /- 312 | simp? [HierarchySymbol.Semiformula.val_sigma, (Language.isSemiformula_defined (LOR (V := ℕ))).df.iff, 313 | (Language.substs_defined (LOR (V := ℕ))).df.iff, (Language.imp_defined (LOR (V := ℕ))).df.iff] 314 | -/ 315 | simp only [Set.mem_setOf_eq, Nat.succ_eq_add_one, Nat.reduceAdd, Fin.isValue, 316 | HierarchySymbol.Semiformula.val_mkDelta, HierarchySymbol.Semiformula.val_mkSigma, 317 | Semiformula.eval_bexLT, Semiterm.val_bvar, Matrix.cons_val_fin_one, Matrix.cons_val_one, 318 | Matrix.vecHead, Semiformula.eval_ex, LogicalConnective.HomClass.map_and, 319 | Semiformula.eval_substs, Matrix.comp_vecCons', Matrix.cons_val_zero, Matrix.cons_val_two, 320 | Matrix.vecTail, Function.comp_apply, Fin.succ_zero_eq_one, Matrix.constant_eq_singleton, 321 | eval_numeralDef, eval_qqAddDef, Semiterm.val_operator₂, Matrix.cons_app_five, 322 | Matrix.cons_val_four, Fin.succ_one_eq_two, Matrix.cons_val_succ, Structure.Add.add, 323 | Matrix.cons_app_six, eval_qqEQDef, LogicalConnective.Prop.and_eq, exists_eq_left] 324 | constructor 325 | · rintro ⟨n, _, m, _, h⟩ 326 | use n; use m 327 | exact (quote_inj_iff (V := ℕ)).mp (by simpa using h) 328 | · rintro ⟨n, m, rfl⟩ 329 | refine ⟨n, by 330 | simp 331 | apply lt_trans ?_ (lt_qqEQ_left _ _) 332 | apply lt_of_le_of_lt (by simp [le_iff_eq_or_lt, ←LO.Arith.le_def]) (lt_qqAdd_left _ _), 333 | m, by 334 | simp 335 | apply lt_trans ?_ (lt_qqEQ_left _ _) 336 | apply lt_of_le_of_lt (by simp [le_iff_eq_or_lt, ←LO.Arith.le_def]) (lt_qqAdd_right _ _), by simp⟩ 337 | isDelta1 := Arith.HierarchySymbol.Semiformula.ProvablyProperOn.ofProperOn.{0} _ fun V _ _ v ↦ by 338 | /- 339 | simp? [HierarchySymbol.Semiformula.val_sigma, 340 | (Language.isSemiformula_defined (LOR (V := V))).df.iff, (Language.isSemiformula_defined (LOR (V := V))).proper.iff', 341 | (Language.substs_defined (LOR (V := V))).df.iff, (Language.imp_defined (LOR (V := V))).df.iff] 342 | -/ 343 | simp only [Fin.isValue, Nat.reduceAdd, Nat.succ_eq_add_one, 344 | HierarchySymbol.Semiformula.sigma_mkDelta, HierarchySymbol.Semiformula.val_mkSigma, 345 | Semiformula.eval_bexLT, Semiterm.val_bvar, Matrix.cons_val_one, Matrix.vecHead, 346 | Semiformula.eval_ex, LogicalConnective.HomClass.map_and, Semiformula.eval_substs, 347 | Matrix.comp_vecCons', Matrix.cons_val_zero, Matrix.cons_val_fin_one, Matrix.cons_val_two, 348 | Matrix.vecTail, Function.comp_apply, Fin.succ_zero_eq_one, Matrix.constant_eq_singleton, 349 | eval_numeralDef, eval_qqAddDef, Semiterm.val_operator₂, Matrix.cons_app_five, 350 | Matrix.cons_val_four, Fin.succ_one_eq_two, Matrix.cons_val_succ, Structure.Add.add, 351 | Matrix.cons_app_six, eval_qqEQDef, LogicalConnective.Prop.and_eq, exists_eq_left, 352 | HierarchySymbol.Semiformula.pi_mkDelta, HierarchySymbol.Semiformula.val_mkPi, 353 | Semiformula.eval_all, LogicalConnective.HomClass.map_imply, Semiformula.eval_operator₂, 354 | Matrix.cons_app_seven, Structure.Eq.eq, LogicalConnective.Prop.arrow_eq, forall_eq] 355 | 356 | def Ω₂ : 357 | FirstOrder.Theory.Delta1Definable {φ : SyntacticFormula ℒₒᵣ | ∃ n m : ℕ, φ = “↑n * ↑m = ↑(n * m)”} where 358 | ch := .mkDelta 359 | (.mkSigma “p. 360 | ∃ n < p, ∃ m < p, 361 | let numn := numeralDef n; 362 | let numm := numeralDef m; 363 | let lhd := qqMulDef numn numm; 364 | let rhd := numeralDef (n * m); 365 | !qqEQDef p lhd rhd” (by simp)) 366 | (.mkPi “p. 367 | ∃ n < p, ∃ m < p, 368 | let' numn := numeralDef n; 369 | let' numm := numeralDef m; 370 | let' lhd := qqMulDef numn numm; 371 | let' rhd := numeralDef (n * m); 372 | ∀ p', !qqEQDef p' lhd rhd → p = p'” (by simp)) 373 | mem_iff {φ} := by 374 | /- 375 | simp? [HierarchySymbol.Semiformula.val_sigma, (Language.isSemiformula_defined (LOR (V := ℕ))).df.iff, 376 | (Language.substs_defined (LOR (V := ℕ))).df.iff, (Language.imp_defined (LOR (V := ℕ))).df.iff] 377 | -/ 378 | simp only [Set.mem_setOf_eq, Nat.succ_eq_add_one, Nat.reduceAdd, Fin.isValue, 379 | HierarchySymbol.Semiformula.val_mkDelta, HierarchySymbol.Semiformula.val_mkSigma, 380 | Semiformula.eval_bexLT, Semiterm.val_bvar, Matrix.cons_val_fin_one, Matrix.cons_val_one, 381 | Matrix.vecHead, Semiformula.eval_ex, LogicalConnective.HomClass.map_and, 382 | Semiformula.eval_substs, Matrix.comp_vecCons', Matrix.cons_val_zero, Matrix.cons_val_two, 383 | Matrix.vecTail, Function.comp_apply, Fin.succ_zero_eq_one, Matrix.constant_eq_singleton, 384 | eval_numeralDef, eval_qqMulDef, Semiterm.val_operator₂, Matrix.cons_app_five, 385 | Matrix.cons_val_four, Fin.succ_one_eq_two, Matrix.cons_val_succ, Structure.Mul.mul, 386 | Matrix.cons_app_six, eval_qqEQDef, LogicalConnective.Prop.and_eq, exists_eq_left] 387 | constructor 388 | · rintro ⟨n, _, m, _, h⟩ 389 | use n; use m 390 | exact (quote_inj_iff (V := ℕ)).mp (by simpa using h) 391 | · rintro ⟨n, m, rfl⟩ 392 | refine ⟨n, by 393 | simp 394 | apply lt_trans ?_ (lt_qqEQ_left _ _) 395 | apply lt_of_le_of_lt (by simp [le_iff_eq_or_lt, ←LO.Arith.le_def]) (lt_qqMul_left _ _), 396 | m, by 397 | simp 398 | apply lt_trans ?_ (lt_qqEQ_left _ _) 399 | apply lt_of_le_of_lt (by simp [le_iff_eq_or_lt, ←LO.Arith.le_def]) (lt_qqMul_right _ _), by simp⟩ 400 | isDelta1 := Arith.HierarchySymbol.Semiformula.ProvablyProperOn.ofProperOn.{0} _ fun V _ _ v ↦ by 401 | /- 402 | simp? [HierarchySymbol.Semiformula.val_sigma, 403 | (Language.isSemiformula_defined (LOR (V := V))).df.iff, (Language.isSemiformula_defined (LOR (V := V))).proper.iff', 404 | (Language.substs_defined (LOR (V := V))).df.iff, (Language.imp_defined (LOR (V := V))).df.iff] 405 | -/ 406 | simp only [Fin.isValue, Nat.reduceAdd, Nat.succ_eq_add_one, 407 | HierarchySymbol.Semiformula.sigma_mkDelta, HierarchySymbol.Semiformula.val_mkSigma, 408 | Semiformula.eval_bexLT, Semiterm.val_bvar, Matrix.cons_val_one, Matrix.vecHead, 409 | Semiformula.eval_ex, LogicalConnective.HomClass.map_and, Semiformula.eval_substs, 410 | Matrix.comp_vecCons', Matrix.cons_val_zero, Matrix.cons_val_fin_one, Matrix.cons_val_two, 411 | Matrix.vecTail, Function.comp_apply, Fin.succ_zero_eq_one, Matrix.constant_eq_singleton, 412 | eval_numeralDef, eval_qqMulDef, Semiterm.val_operator₂, Matrix.cons_app_five, 413 | Matrix.cons_val_four, Fin.succ_one_eq_two, Matrix.cons_val_succ, Structure.Mul.mul, 414 | Matrix.cons_app_six, eval_qqEQDef, LogicalConnective.Prop.and_eq, exists_eq_left, 415 | HierarchySymbol.Semiformula.pi_mkDelta, HierarchySymbol.Semiformula.val_mkPi, 416 | Semiformula.eval_all, LogicalConnective.HomClass.map_imply, Semiformula.eval_operator₂, 417 | Matrix.cons_app_seven, Structure.Eq.eq, LogicalConnective.Prop.arrow_eq, forall_eq] 418 | 419 | def Ω₃ : 420 | FirstOrder.Theory.Delta1Definable {φ : SyntacticFormula ℒₒᵣ | ∃ n m : ℕ, n ≠ m ∧ φ = “↑n ≠ ↑m”} where 421 | ch := .mkDelta 422 | (.mkSigma “p. ∃ n < p, ∃ m < p, n ≠ m ∧ 423 | let numn := numeralDef n; 424 | let numm := numeralDef m; 425 | !qqNEQDef p numn numm” (by simp)) 426 | (.mkPi “p. ∃ n < p, ∃ m < p, n ≠ m ∧ 427 | let' numn := numeralDef n; 428 | let' numm := numeralDef m; 429 | ∀ p', !qqNEQDef p' numn numm → p = p'” (by simp)) 430 | mem_iff {φ} := by 431 | /- 432 | simp? 433 | -/ 434 | simp only [ne_eq, Set.mem_setOf_eq, Nat.succ_eq_add_one, Nat.reduceAdd, Fin.isValue, 435 | HierarchySymbol.Semiformula.val_mkDelta, HierarchySymbol.Semiformula.val_mkSigma, 436 | Semiformula.eval_bexLT, Semiterm.val_bvar, Matrix.cons_val_fin_one, Matrix.cons_val_one, 437 | Matrix.vecHead, LogicalConnective.HomClass.map_and, LogicalConnective.HomClass.map_neg, 438 | Semiformula.eval_operator₂, Matrix.cons_val_zero, Structure.Eq.eq, 439 | LogicalConnective.Prop.neg_eq, Semiformula.eval_ex, Semiformula.eval_substs, 440 | Matrix.comp_vecCons', Matrix.cons_val_two, Matrix.vecTail, Function.comp_apply, 441 | Fin.succ_zero_eq_one, Matrix.constant_eq_singleton, eval_numeralDef, Matrix.cons_val_four, 442 | Fin.succ_one_eq_two, Matrix.cons_val_succ, eval_qqNEQDef, LogicalConnective.Prop.and_eq, 443 | exists_eq_left] 444 | constructor 445 | · rintro ⟨n, _, m, _, ne, h⟩ 446 | refine ⟨n, m, ne, ?_⟩ 447 | exact (quote_inj_iff (V := ℕ)).mp (by simp; rw [neg_eq (by simp) (by simp)]; simpa using h) 448 | · rintro ⟨n, m, ne, rfl⟩ 449 | refine ⟨n, by 450 | simp 451 | rw [neg_eq (by simp) (by simp)] 452 | exact lt_of_le_of_lt (by simp [le_iff_eq_or_lt, ←LO.Arith.le_def]) (lt_qqNEQ_left _ _), 453 | m, by 454 | simp 455 | rw [neg_eq (by simp) (by simp)] 456 | exact lt_of_le_of_lt (by simp [le_iff_eq_or_lt, ←LO.Arith.le_def]) (lt_qqNEQ_right _ _), ne, ?_⟩ 457 | simp; rw [neg_eq (by simp) (by simp)] 458 | isDelta1 := Arith.HierarchySymbol.Semiformula.ProvablyProperOn.ofProperOn.{0} _ fun V _ _ v ↦ by simp 459 | 460 | private lemma quote_disjLt_eq (n : ℕ) : 461 | ⌜(disjLt (fun i ↦ “#0 = ↑i”) n : SyntacticSemiformula ℒₒᵣ 1)⌝ = 462 | ^⋁ substItr (^#0 ∷ 0) (^#1 ^= ^#0) n := by 463 | induction n 464 | case zero => simp 465 | case succ n ih => 466 | simp [ih]; rw [substs_eq (by simp) (by simp)]; simp 467 | 468 | def Ω₄ : 469 | FirstOrder.Theory.Delta1Definable {(“∀ x, x < ↑n ↔ ⋁ i < n, x = ↑i” : SyntacticFormula ℒₒᵣ) | n} where 470 | ch := .mkDelta 471 | (.mkSigma “p. ∃ n < p, 472 | let numn := numeralDef n; 473 | let x₀ := qqBvarDef 0; 474 | let x₁ := qqBvarDef 1; 475 | let lhd := qqLTDef x₀ numn; 476 | let v := consDef x₀ 0; 477 | let e := qqEQDef x₁ x₀; 478 | let ti := substItrDef v e n; 479 | let rhd := qqDisjDef ti; 480 | let iff := p⌜ℒₒᵣ⌝.qqIffDef lhd rhd; 481 | !qqAllDef p iff” (by simp)) 482 | (.mkPi “p. ∃ n < p, 483 | let' numn := numeralDef n; 484 | let' x₀ := qqBvarDef 0; 485 | let' x₁ := qqBvarDef 1; 486 | let' lhd := qqLTDef x₀ numn; 487 | let' v := consDef x₀ 0; 488 | let' e := qqEQDef x₁ x₀; 489 | let' ti := substItrDef v e n; 490 | let' rhd := qqDisjDef ti; 491 | let' iff := p⌜ℒₒᵣ⌝.qqIffDef lhd rhd; 492 | !qqAllDef p iff” (by simp)) 493 | mem_iff {p} := by 494 | /- 495 | simp? [HierarchySymbol.Semiformula.val_sigma, (Language.isSemiformula_defined (LOR (V := ℕ))).df.iff, 496 | (Language.substs_defined (LOR (V := ℕ))).df.iff, (Language.imp_defined (LOR (V := ℕ))).df.iff, 497 | (Language.iff_defined (LOR (V := ℕ))).df.iff] 498 | -/ 499 | simp only [Nat.reduceAdd, Fin.isValue, Set.mem_setOf_eq, Nat.succ_eq_add_one, 500 | HierarchySymbol.Semiformula.val_mkDelta, HierarchySymbol.Semiformula.val_mkSigma, 501 | Semiformula.eval_bexLT, Semiterm.val_bvar, Matrix.cons_val_fin_one, Semiformula.eval_ex, 502 | LogicalConnective.HomClass.map_and, Semiformula.eval_substs, Matrix.comp_vecCons', 503 | Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.vecHead, Matrix.constant_eq_singleton, 504 | eval_numeralDef, Semiterm.val_operator₀, Structure.numeral_eq_numeral, 505 | ORingStruc.zero_eq_zero, eval_qqBvarDef, ORingStruc.one_eq_one, Matrix.cons_val_two, 506 | Matrix.vecTail, Function.comp_apply, Fin.succ_zero_eq_one, Matrix.cons_val_three, 507 | Fin.succ_one_eq_two, eval_qqLTDef, eval_cons, Matrix.cons_val_four, Matrix.cons_val_succ, 508 | eval_qqEQDef, Matrix.cons_app_seven, Matrix.cons_app_six, Matrix.cons_app_five, 509 | substItr_defined_iff, eval_qqDisj, (Language.iff_defined (LOR (V := ℕ))).df.iff, 510 | Language.TermRec.Construction.cons_app_10, Language.TermRec.Construction.cons_app_9, 511 | Matrix.cons_app_eight, eval_qqAllDef, LogicalConnective.Prop.and_eq, exists_eq_left] 512 | constructor 513 | · rintro ⟨n, _, h⟩ 514 | use n 515 | symm; 516 | exact (quote_inj_iff (V := ℕ)).mp (by simpa [quote_disjLt_eq] using h) 517 | · rintro ⟨n, rfl⟩ 518 | refine ⟨n, by 519 | simp 520 | apply lt_trans ?_ (lt_forall _) 521 | apply lt_trans ?_ (lt_iff_left _ _) 522 | apply lt_of_le_of_lt (by simp [le_iff_eq_or_lt, ←LO.Arith.le_def]) (lt_qqLT_right _ _), ?_⟩ 523 | simp [quote_disjLt_eq] 524 | isDelta1 := Arith.HierarchySymbol.Semiformula.ProvablyProperOn.ofProperOn.{0} _ fun V _ _ v ↦ by 525 | /- 526 | simp? [HierarchySymbol.Semiformula.val_sigma, 527 | (Language.isSemiformula_defined (LOR (V := V))).df.iff, (Language.isSemiformula_defined (LOR (V := V))).proper.iff', 528 | (Language.substs_defined (LOR (V := V))).df.iff, (Language.imp_defined (LOR (V := V))).df.iff, 529 | (Language.iff_defined (LOR (V := V))).df.iff] 530 | -/ 531 | simp only [Fin.isValue, Nat.reduceAdd, Nat.succ_eq_add_one, 532 | HierarchySymbol.Semiformula.sigma_mkDelta, HierarchySymbol.Semiformula.val_mkSigma, 533 | Semiformula.eval_bexLT, Semiterm.val_bvar, Semiformula.eval_ex, 534 | LogicalConnective.HomClass.map_and, Semiformula.eval_substs, Matrix.comp_vecCons', 535 | Matrix.cons_val_zero, Matrix.cons_val_fin_one, Matrix.cons_val_one, Matrix.vecHead, 536 | Matrix.constant_eq_singleton, eval_numeralDef, Semiterm.val_operator₀, 537 | Structure.numeral_eq_numeral, ORingStruc.zero_eq_zero, eval_qqBvarDef, ORingStruc.one_eq_one, 538 | Matrix.cons_val_two, Matrix.vecTail, Function.comp_apply, Fin.succ_zero_eq_one, 539 | Matrix.cons_val_three, Fin.succ_one_eq_two, eval_qqLTDef, eval_cons, Matrix.cons_val_four, 540 | Matrix.cons_val_succ, eval_qqEQDef, Matrix.cons_app_seven, Matrix.cons_app_six, 541 | Matrix.cons_app_five, substItr_defined_iff, eval_qqDisj, 542 | (Language.iff_defined (LOR (V := V))).df.iff, Language.TermRec.Construction.cons_app_10, 543 | Language.TermRec.Construction.cons_app_9, Matrix.cons_app_eight, eval_qqAllDef, 544 | LogicalConnective.Prop.and_eq, exists_eq_left, HierarchySymbol.Semiformula.pi_mkDelta, 545 | HierarchySymbol.Semiformula.val_mkPi, Semiformula.eval_all, 546 | LogicalConnective.HomClass.map_imply, LogicalConnective.Prop.arrow_eq, forall_eq] 547 | 548 | end Theory.CobhamR0' 549 | 550 | open Theory.CobhamR0' 551 | 552 | instance Theory.CobhamR0'Delta1Definable : 𝐑₀'.Delta1Definable := (eqRefl.add <| replace.add <| Ω₁.add <| Ω₂.add <| Ω₃.add Ω₄).ofEq <| by 553 | ext φ; constructor 554 | · rintro (hφ | hφ | hφ | hφ | hφ | hφ) <;> simp at hφ 555 | · rcases hφ; exact Theory.CobhamR0'.eq_refl 556 | · rcases hφ with ⟨φ, rfl⟩; exact FirstOrder.Theory.CobhamR0'.replace φ 557 | · rcases hφ with ⟨n, m, rfl⟩; exact FirstOrder.Theory.CobhamR0'.Ω₁ n m 558 | · rcases hφ with ⟨n, m, rfl⟩; exact FirstOrder.Theory.CobhamR0'.Ω₂ n m 559 | · rcases hφ with ⟨n, m, ne, rfl⟩; exact FirstOrder.Theory.CobhamR0'.Ω₃ n m ne 560 | · rcases hφ with ⟨n, rfl⟩; exact FirstOrder.Theory.CobhamR0'.Ω₄ n 561 | · intro hφ; cases hφ 562 | case eq_refl => left; simp 563 | case replace φ => right; left; exact ⟨φ, by simp⟩ 564 | case Ω₁ n m => right; right; left; exact ⟨n, m, by simp⟩ 565 | case Ω₂ n m => right; right; right; left; exact ⟨n, m, by simp⟩ 566 | case Ω₃ n m ne => right; right; right; right; left; exact ⟨n, m, ne, by simp⟩ 567 | case Ω₄ n => right; right; right; right; right; exact ⟨n, by simp⟩ 568 | 569 | abbrev Theory.CobhamR0' : ⌜ℒₒᵣ⌝[V].Theory := 𝐑₀'.codeIn V 570 | 571 | abbrev TTheory.CobhamR0' : ⌜ℒₒᵣ⌝[V].TTheory := 𝐑₀'.tCodeIn V 572 | 573 | notation "⌜𝐑₀'⌝" => TTheory.CobhamR0' 574 | notation "⌜𝐑₀'⌝[" V "]" => TTheory.CobhamR0' (V := V) 575 | 576 | namespace Theory.CobhamR0' 577 | 578 | def eqRefl.proof : ⌜𝐑₀'⌝[V] ⊢ (#'0 =' #'0).all := Language.Theory.TProof.byAxm <| by 579 | apply FirstOrder.Semiformula.curve_mem_left 580 | unfold eqRefl 581 | simp [HierarchySymbol.Semiformula.val_sigma, Theory.tDef, Semiformula.curve, numeral_eq_natCast] 582 | simp [qqAll, nat_cast_pair, qqEQ, qqRel, cons_absolute, qqBvar] 583 | 584 | def replace.proof (φ : ⌜ℒₒᵣ⌝[V].Semiformula (0 + 1)) : 585 | ⌜𝐑₀'⌝[V] ⊢ (#'1 =' #'0 ➝ φ^/[(#'1).sing] ➝ φ^/[(#'0).sing]).all.all := Language.Theory.TProof.byAxm <| by 586 | apply FirstOrder.Semiformula.curve_mem_right 587 | apply FirstOrder.Semiformula.curve_mem_left 588 | unfold replace 589 | simp [HierarchySymbol.Semiformula.val_sigma, Theory.tDef, Semiformula.curve, 590 | (Language.isSemiformula_defined (LOR (V := V))).df.iff, 591 | (Language.substs_defined (LOR (V := V))).df.iff, (Language.imp_defined (LOR (V := V))).df.iff] 592 | refine ⟨φ.val, ?_, by simpa using φ.prop, rfl⟩ 593 | · rw [subst_eq_self₁ (by simpa using φ.prop)] 594 | refine lt_trans ?_ (lt_forall _) 595 | refine lt_trans ?_ (lt_forall _) 596 | refine lt_trans ?_ (lt_or_right _ _) 597 | exact lt_or_right _ _ 598 | 599 | def Ω₁.proof (n m : V) : 600 | ⌜𝐑₀'⌝[V] ⊢ (n + m : ⌜ℒₒᵣ⌝[V].Semiterm 0) =' ↑(n + m) := Language.Theory.TProof.byAxm <| by 601 | apply FirstOrder.Semiformula.curve_mem_right 602 | apply FirstOrder.Semiformula.curve_mem_right 603 | apply FirstOrder.Semiformula.curve_mem_left 604 | unfold Ω₁ 605 | simp [HierarchySymbol.Semiformula.val_sigma, Theory.tDef, Semiformula.curve] 606 | refine ⟨n, ?_, m, ?_, rfl⟩ 607 | · apply lt_trans ?_ (lt_qqEQ_left _ _) 608 | apply lt_of_le_of_lt (by simp) (lt_qqAdd_left _ _) 609 | · apply lt_trans ?_ (lt_qqEQ_left _ _) 610 | apply lt_of_le_of_lt (by simp) (lt_qqAdd_right _ _) 611 | 612 | def Ω₂.proof (n m : V) : 613 | ⌜𝐑₀'⌝[V] ⊢ (n * m : ⌜ℒₒᵣ⌝[V].Semiterm 0) =' ↑(n * m) := Language.Theory.TProof.byAxm <| by 614 | apply FirstOrder.Semiformula.curve_mem_right 615 | apply FirstOrder.Semiformula.curve_mem_right 616 | apply FirstOrder.Semiformula.curve_mem_right 617 | apply FirstOrder.Semiformula.curve_mem_left 618 | unfold Ω₂ 619 | simp [HierarchySymbol.Semiformula.val_sigma, Theory.tDef, Semiformula.curve] 620 | refine ⟨n, ?_, m, ?_, rfl⟩ 621 | · apply lt_trans ?_ (lt_qqEQ_left _ _) 622 | apply lt_of_le_of_lt (by simp) (lt_qqMul_left _ _) 623 | · apply lt_trans ?_ (lt_qqEQ_left _ _) 624 | apply lt_of_le_of_lt (by simp) (lt_qqMul_right _ _) 625 | 626 | def Ω₃.proof {n m : V} (ne : n ≠ m) : ⌜𝐑₀'⌝[V] ⊢ ↑n ≠' ↑m := Language.Theory.TProof.byAxm <| by 627 | apply FirstOrder.Semiformula.curve_mem_right 628 | apply FirstOrder.Semiformula.curve_mem_right 629 | apply FirstOrder.Semiformula.curve_mem_right 630 | apply FirstOrder.Semiformula.curve_mem_right 631 | apply FirstOrder.Semiformula.curve_mem_left 632 | unfold Ω₃ 633 | simp [HierarchySymbol.Semiformula.val_sigma, Theory.tDef, Semiformula.curve] 634 | refine ⟨n, ?_, m, ?_, ne, rfl⟩ 635 | · exact lt_of_le_of_lt (by simp) (lt_qqNEQ_left _ _) 636 | · exact lt_of_le_of_lt (by simp) (lt_qqNEQ_right _ _) 637 | 638 | def Ω₄.proof (n : V): ⌜𝐑₀'⌝[V] ⊢ (#'0 <' ↑n ⭤ (tSubstItr (#'0).sing (#'1 =' #'0) n).disj).all := Language.Theory.TProof.byAxm <| by 639 | apply FirstOrder.Semiformula.curve_mem_right 640 | apply FirstOrder.Semiformula.curve_mem_right 641 | apply FirstOrder.Semiformula.curve_mem_right 642 | apply FirstOrder.Semiformula.curve_mem_right 643 | apply FirstOrder.Semiformula.curve_mem_right 644 | unfold Ω₄ 645 | simp [HierarchySymbol.Semiformula.val_sigma, Theory.tDef, Semiformula.curve, 646 | (Language.iff_defined (LOR (V := V))).df.iff] 647 | refine ⟨n, ?_, rfl⟩ 648 | apply lt_trans ?_ (lt_forall _) 649 | apply lt_trans ?_ (lt_iff_left _ _) 650 | apply lt_of_le_of_lt (by simp) (lt_qqLT_right _ _) 651 | 652 | end Theory.CobhamR0' 653 | 654 | instance Theory.addCobhamR0'Delta1Definable (T : Theory ℒₒᵣ) [d : T.Delta1Definable] : (T + 𝐑₀').Delta1Definable := 655 | d.add Theory.CobhamR0'Delta1Definable 656 | section 657 | 658 | variable (T : Theory ℒₒᵣ) [T.Delta1Definable] 659 | 660 | abbrev _root_.LO.FirstOrder.Theory.AddR₀TTheory : ⌜ℒₒᵣ⌝[V].TTheory := (T + 𝐑₀').tCodeIn V 661 | 662 | variable {T} 663 | 664 | @[simp] lemma R₀'_subset_AddR₀ : ⌜𝐑₀'⌝[V] ⊆ T.AddR₀TTheory := Set.subset_union_right 665 | 666 | @[simp] lemma theory_subset_AddR₀ : T.tCodeIn V ⊆ T.AddR₀TTheory := FirstOrder.Theory.Delta1Definable.add_subset_left _ _ 667 | 668 | instance : R₀Theory (T.AddR₀TTheory (V := V)) where 669 | refl := Language.Theory.TProof.ofSubset (by simp) Theory.CobhamR0'.eqRefl.proof 670 | replace := fun φ ↦ Language.Theory.TProof.ofSubset (by simp) (Theory.CobhamR0'.replace.proof φ) 671 | add := fun n m ↦ Language.Theory.TProof.ofSubset (by simp) (Theory.CobhamR0'.Ω₁.proof n m) 672 | mul := fun n m ↦ Language.Theory.TProof.ofSubset (by simp) (Theory.CobhamR0'.Ω₂.proof n m) 673 | ne := fun h ↦ Language.Theory.TProof.ofSubset (by simp) (Theory.CobhamR0'.Ω₃.proof h) 674 | ltNumeral := fun n ↦ Language.Theory.TProof.ofSubset (by simp) (Theory.CobhamR0'.Ω₄.proof n) 675 | 676 | end 677 | 678 | end Formalized 679 | 680 | open Formalized 681 | 682 | section 683 | 684 | variable (T : Theory ℒₒᵣ) [T.Delta1Definable] 685 | 686 | /-- Provability predicate for arithmetic stronger than $\mathbf{R_0}$. -/ 687 | def _root_.LO.FirstOrder.Theory.Provableₐ (φ : V) : Prop := ((T + 𝐑₀').codeIn V).Provable φ 688 | 689 | variable {T} 690 | 691 | lemma provableₐ_iff {σ : Sentence ℒₒᵣ} : T.Provableₐ (⌜σ⌝ : V) ↔ (T + 𝐑₀').tCodeIn V ⊢! ⌜σ⌝ := by 692 | simp [Language.Theory.TProvable.iff_provable]; rfl 693 | 694 | section 695 | 696 | variable (T) 697 | 698 | def _root_.LO.FirstOrder.Theory.provableₐ : 𝚺₁.Semisentence 1 := .mkSigma 699 | “p. !(T + 𝐑₀').tDef.prv p” (by simp) 700 | 701 | lemma provableₐ_defined : 𝚺₁-Predicate (T.Provableₐ : V → Prop) via T.provableₐ := by 702 | intro v; simp [FirstOrder.Theory.provableₐ, FirstOrder.Theory.Provableₐ, ((T + 𝐑₀').codeIn V).provable_defined.df.iff] 703 | 704 | @[simp] lemma eval_provableₐ (v) : 705 | Semiformula.Evalbm V v T.provableₐ.val ↔ T.Provableₐ (v 0) := (provableₐ_defined T).df.iff v 706 | 707 | instance provableₐ_definable : 𝚺₁-Predicate (T.Provableₐ : V → Prop) := (provableₐ_defined T).to_definable 708 | 709 | /-- instance for definability tactic-/ 710 | instance provableₐ_definable' : 𝚺-[0 + 1]-Predicate (T.Provableₐ : V → Prop) := provableₐ_definable T 711 | 712 | end 713 | 714 | end 715 | 716 | end LO.Arith 717 | --------------------------------------------------------------------------------