From 1d2563f737a2c136aaaf1e53e5ee40e5e91493b1 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 28 Feb 2026 20:30:55 +0900 Subject: [PATCH 01/61] wip --- Foundation/FirstOrder/Basic/Calculus.lean | 3 +- Foundation/Logic/Calculus.lean | 192 +++++++++------------- Foundation/Logic/LogicSymbol.lean | 81 +++++---- 3 files changed, 127 insertions(+), 149 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index 960e83ac8..2cc7533fd 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -1,5 +1,5 @@ module -public import Foundation.Logic.Calculus +/- public import Foundation.Logic.Calculus -/ public import Foundation.FirstOrder.Basic.Syntax.Theory public import Mathlib.Data.List.MinMax @@ -28,6 +28,7 @@ inductive Derivation (𝓢 : Schema L) : Sequent L → Type _ | wk : Derivation 𝓢 Δ → Δ ⊆ Γ → Derivation 𝓢 Γ | cut : Derivation 𝓢 (φ :: Γ) → Derivation 𝓢 (∼φ :: Γ) → Derivation 𝓢 Γ +/--/ instance : OneSided (Schema L) (SyntacticFormula L) := ⟨Derivation⟩ abbrev Schema.pureLK : Schema L := ∅ diff --git a/Foundation/Logic/Calculus.lean b/Foundation/Logic/Calculus.lean index ad5c9c59b..d365c8ce7 100644 --- a/Foundation/Logic/Calculus.lean +++ b/Foundation/Logic/Calculus.lean @@ -18,135 +18,91 @@ public section namespace LO -class OneSided (K : Type*) (F : outParam Type*) where - Derivation : K → List F → Type* - -infix:45 " ⟹ " => OneSided.Derivation - -abbrev OneSided.Derivation₁ [OneSided K F] (𝓚 : K) (φ : F) : Type _ := 𝓚 ⟹ [φ] - -infix:45 " ⟹. " => OneSided.Derivation₁ - -abbrev OneSided.Derivable [OneSided K F] (𝓚 : K) (Δ : List F) : Prop := Nonempty (𝓚 ⟹ Δ) - -infix:45 " ⟹! " => OneSided.Derivable - -abbrev OneSided.Derivable₁ [OneSided K F] (𝓚 : K) (φ : F) : Prop := Nonempty (𝓚 ⟹. φ) - -infix:45 " ⟹!. " => OneSided.Derivable₁ - -noncomputable def OneSided.Derivable.get [OneSided K F] (𝓚 : K) (Δ : List F) (h : 𝓚 ⟹! Δ) : 𝓚 ⟹ Δ := - Classical.choice h - -class Tait (F K : Type*) [LogicalConnective F] [DeMorgan F] [AdjunctiveSet F K] extends OneSided K F where - verum (𝓚 : K) (Δ : List F) : 𝓚 ⟹ ⊤ :: Δ - and {𝓚 : K} {φ ψ : F} {Δ : List F} : 𝓚 ⟹ φ :: Δ → 𝓚 ⟹ ψ :: Δ → 𝓚 ⟹ φ ⋏ ψ :: Δ - or {𝓚 : K} {φ ψ : F} {Δ : List F} : 𝓚 ⟹ φ :: ψ :: Δ → 𝓚 ⟹ φ ⋎ ψ :: Δ - wk {𝓚 : K} {Δ Δ' : List F} : 𝓚 ⟹ Δ → Δ ⊆ Δ' → 𝓚 ⟹ Δ' - em {𝓚 : K} {φ} {Δ : List F} : φ ∈ Δ → ∼φ ∈ Δ → 𝓚 ⟹ Δ - -class Tait.Cut (F K : Type*) [LogicalConnective F] [DeMorgan F] [AdjunctiveSet F K] [Tait F K] where - cut {𝓚 : K} {Δ : List F} {φ} : 𝓚 ⟹ φ :: Δ → 𝓚 ⟹ ∼φ :: Δ → 𝓚 ⟹ Δ - -class Tait.Axiomatized (F K : Type*) [LogicalConnective F] [DeMorgan F] [AdjunctiveSet F K] [Tait F K] where - axm {𝓚 : K} {φ} : φ ∈ 𝓚 → 𝓚 ⟹. φ - trans {𝓚 𝓛 : K} {Γ} : ((ψ : F) → ψ ∈ 𝓚 → 𝓛 ⟹. ψ) → 𝓚 ⟹ Γ → 𝓛 ⟹ Γ +class OneSidedLK {F : Type*} [LogicalConnective F] [DeMorgan F] (𝔇 : List F → Type*) where + identity (φ) : 𝔇 [φ, ∼φ] + wk : 𝔇 Δ → Δ ⊆ Γ → 𝔇 Γ + verum : 𝔇 [⊤] + and : 𝔇 (φ :: Γ) → 𝔇 (ψ :: Γ) → 𝔇 (φ ⋏ ψ :: Γ) + or : 𝔇 (φ :: ψ :: Γ) → 𝔇 (φ ⋎ ψ :: Γ) + +class OneSidedLK.Cut + {F : Type*} [LogicalConnective F] [DeMorgan F] (𝔇 : List F → Type*) extends OneSidedLK 𝔇 where + cut : 𝔇 (φ :: Γ) → 𝔇 (∼φ :: Γ) → 𝔇 Γ + +class OneSidedLK.EquivEntailment + {F : Type*} [LogicalConnective F] [DeMorgan F] (𝔇 : outParam (List F → Type*)) + (S : Type*) [Entailment S F] [AdjunctiveSet F S] where + equiv {𝓢 : S} : (l : {l : List F // ∀ φ ∈ l, φ ∈ 𝓢}) × 𝔇 (φ :: ∼l) ≃ 𝓢 ⊢! φ variable {F S K : Type*} [LogicalConnective F] [AdjunctiveSet F K] -namespace OneSided - -variable [OneSided K F] {𝓚 : K} {Γ Δ : List F} - -protected abbrev cast (d : 𝓚 ⟹ Δ) (e : Δ = Γ) : 𝓚 ⟹ Γ := cast (congrArg _ e) d - -end OneSided - -namespace Tait - -open Entailment - -variable [DeMorgan F] [Tait F K] - -variable {𝓚 : K} {Γ Δ : List F} {φ ψ φ₁ φ₂ φ₃ φ₄ : F} - -def ofEq (b : 𝓚 ⟹ Γ) (h : Γ = Δ) : 𝓚 ⟹ Δ := h ▸ b - -lemma of_eq (b : 𝓚 ⟹! Γ) (h : Γ = Δ) : 𝓚 ⟹! Δ := h ▸ b - -def em' (φ : F) (hp : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : 𝓚 ⟹ Γ := em hp hn - -def verum' (h : ⊤ ∈ Γ := by simp) : 𝓚 ⟹ Γ := wk (verum 𝓚 Γ) (by simp [h]) - -lemma verum! (𝓚 : K) (Γ : List F) : 𝓚 ⟹! ⊤ :: Γ := ⟨verum _ _⟩ +namespace OneSidedLK -lemma verum'! (h : ⊤ ∈ Γ) : 𝓚 ⟹! Γ := ⟨verum' h⟩ +variable {F : Type*} [LogicalConnective F] [DeMorgan F] {𝔇 : List F → Type*} [OneSidedLK 𝔇] -lemma and! (hp : 𝓚 ⟹! φ :: Γ) (hq : 𝓚 ⟹! ψ :: Γ) : 𝓚 ⟹! φ ⋏ ψ :: Γ := ⟨and hp.get hq.get⟩ +def cast (b : 𝔇 Γ) (h : Γ = Δ := by simp) : 𝔇 Δ := h ▸ b -lemma or! (h : 𝓚 ⟹! φ :: ψ :: Γ) : 𝓚 ⟹! φ ⋎ ψ :: Γ := ⟨or h.get⟩ +def close (φ : F) (hp : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : 𝔇 Γ := wk (identity φ) (by simp_all) -lemma wk! (h : 𝓚 ⟹! Γ) (ss : Γ ⊆ Δ := by simp) : 𝓚 ⟹! Δ := ⟨wk h.get ss⟩ +def verum' (h : ⊤ ∈ Γ := by simp) : 𝔇 Γ := wk verum (by simp [h]) -lemma em! (hp : φ ∈ Γ) (hn : ∼φ ∈ Γ) : 𝓚 ⟹! Γ := ⟨em hp hn⟩ - -def close (φ : F) (hp : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : 𝓚 ⟹ Γ := em hp hn - -lemma close! (φ : F) (hp : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : 𝓚 ⟹! Γ := em! hp hn - -def and' {φ ψ : F} (h : φ ⋏ ψ ∈ Γ) (dp : 𝓚 ⟹ φ :: Γ) (dq : 𝓚 ⟹ ψ :: Γ) : 𝓚 ⟹ Γ := +def and' {φ ψ : F} (h : φ ⋏ ψ ∈ Γ) (dp : 𝔇 (φ :: Γ)) (dq : 𝔇 (ψ :: Γ)) : 𝔇 Γ := wk (and dp dq) (by simp [h]) -def or' {φ ψ : F} (h : φ ⋎ ψ ∈ Γ) (dpq : 𝓚 ⟹ φ :: ψ :: Γ) : 𝓚 ⟹ Γ := +def or' {φ ψ : F} (h : φ ⋎ ψ ∈ Γ) (dpq : 𝔇 (φ :: ψ :: Γ)) : 𝔇 Γ := wk (or dpq) (by simp [h]) -def wkTail (d : 𝓚 ⟹ Γ) : 𝓚 ⟹ φ :: Γ := wk d (by simp) +def wkTail (d : 𝔇 Γ) : 𝔇 (φ :: Γ) := wk d (by simp) -def wkAppendLeft (d : 𝓚 ⟹ Δ) : 𝓚 ⟹ Δ ++ Γ := wk d (by simp) +def wkAppendLeft (d : 𝔇 Δ) : 𝔇 (Δ ++ Γ) := wk d (by simp) -def wkAppendRight (d : 𝓚 ⟹ Γ) : 𝓚 ⟹ Δ ++ Γ := wk d (by simp) +def wkAppendRight (d : 𝔇 Γ) : 𝔇 (Δ ++ Γ) := wk d (by simp) -def rotate₁ (d : 𝓚 ⟹ φ₂ :: φ₁ :: Γ) : 𝓚 ⟹ φ₁ :: φ₂ :: Γ := wk d (by simp) +def rotate₁ (d : 𝔇 (φ₂ :: φ₁ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: Γ) := wk d (by simp) -def rotate₂ (d : 𝓚 ⟹ φ₃ :: φ₁ :: φ₂ :: Γ) : 𝓚 ⟹ φ₁ :: φ₂ :: φ₃ :: Γ := +def rotate₂ (d : 𝔇 (φ₃ :: φ₁ :: φ₂ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: φ₃ :: Γ) := wk d (by simpa using List.subset_cons_of_subset _ (List.subset_cons_of_subset _ <| by simp)) -def rotate₃ (d : 𝓚 ⟹ φ₄ :: φ₁ :: φ₂ :: φ₃ :: Γ) : 𝓚 ⟹ φ₁ :: φ₂ :: φ₃ :: φ₄ :: Γ := +def rotate₃ (d : 𝔇 (φ₄ :: φ₁ :: φ₂ :: φ₃ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: φ₃ :: φ₄ :: Γ) := wk d (by simpa using List.subset_cons_of_subset _ (List.subset_cons_of_subset _ <| List.subset_cons_of_subset _ <| by simp)) -variable {𝓚 𝓛 : K} {Γ : List F} - -alias cut := Tait.Cut.cut +alias cut := OneSidedLK.Cut.cut -alias axm := Tait.Axiomatized.axm +open Entailment -lemma cut! [Cut F K] (hp : 𝓚 ⟹! φ :: Δ) (hn : 𝓚 ⟹! ∼φ :: Δ) : 𝓚 ⟹! Δ := ⟨cut hp.get hn.get⟩ +variable {S : Type*} [Entailment S F] [AdjunctiveSet F S] -lemma root! [Tait.Axiomatized F K] {φ} (h : φ ∈ 𝓚) : 𝓚 ⟹!. φ := ⟨axm h⟩ +def ofAxiom [OneSidedLK.EquivEntailment 𝔇 S] {𝓢 : S} (h : φ ∈ 𝓢) : 𝓢 ⊢! φ := + OneSidedLK.EquivEntailment.equiv ⟨⟨[φ], by simp_all⟩, identity φ⟩ -def byAxm [Tait.Axiomatized F K] (φ) (h : φ ∈ 𝓚) (hΓ : φ ∈ Γ := by simp) : 𝓚 ⟹ Γ := wk (axm h) (by simp_all) +def ofAxiomSubset [OneSidedLK.EquivEntailment 𝔇 S] {𝓢 𝓤 : S} : 𝓢 ⊢! φ → 𝓢 ⊆ 𝓤 → 𝓤 ⊢! φ := fun b h ↦ + have ⟨l, d⟩ := OneSidedLK.EquivEntailment.equiv.symm b + OneSidedLK.EquivEntailment.equiv + ⟨⟨l, fun φ hφ ↦ AdjunctiveSet.subset_iff.mp h _ (l.prop φ hφ)⟩, d⟩ -lemma byAxm! [Tait.Axiomatized F K] (φ) (h : φ ∈ 𝓚) (hΓ : φ ∈ Γ := by simp) : 𝓚 ⟹! Γ := ⟨byAxm φ h hΓ⟩ +instance [OneSidedLK.EquivEntailment 𝔇 S] : Entailment.Axiomatized S where + prfAxm h := ofAxiom h + weakening h d := ofAxiomSubset d h -def ofAxiomSubset [Tait.Axiomatized F K] (h : 𝓚 ⊆ 𝓛) : 𝓚 ⟹ Γ → 𝓛 ⟹ Γ := - Tait.Axiomatized.trans fun _ hq ↦ Tait.Axiomatized.axm (AdjunctiveSet.subset_iff.mp h _ hq) +lemma waekerThan_of_subset [OneSidedLK.EquivEntailment 𝔇 S] {𝓢 𝓤 : S} (h : 𝓢 ⊆ 𝓤) : 𝓢 ⪯ 𝓤 := + ⟨fun _ ↦ Entailment.Axiomatized.weakening! h⟩ -lemma of_axiom_subset [Tait.Axiomatized F K] (h : 𝓚 ⊆ 𝓛) : 𝓚 ⟹! Γ → 𝓛 ⟹! Γ := fun b ↦ ⟨ofAxiomSubset h b.get⟩ +instance [OneSidedLK.EquivEntailment 𝔇 S] : Entailment.StrongCut S S where + cut {T U φ bs b} := by { } +/--/ +lemma of_axiom_subset [Tait.Axiomatized F K] (h : 𝓚 ⊆ 𝓛) : 𝔇! Γ → 𝓛 ⟹! Γ := fun b ↦ ⟨ofAxiomSubset h b.get⟩ instance system : Entailment K F := ⟨(· ⟹. ·)⟩ -instance [Tait.Axiomatized F K] : Entailment.Axiomatized K where - prfAxm := fun hf ↦ Tait.Axiomatized.axm <| hf - weakening := Tait.ofAxiomSubset -lemma provable_bot_iff_derivable_nil [Cut F K] : 𝓚 ⟹! [] ↔ 𝓚 ⊢ ⊥ := + +lemma provable_bot_iff_derivable_nil [Cut F K] : 𝔇! [] ↔ 𝓚 ⊢ ⊥ := ⟨fun b ↦ wk! b (by simp), fun b ↦ cut! b (by simpa using verum! _ _)⟩ -lemma waekerThan_of_subset [Tait.Axiomatized F K] (h : 𝓚 ⊆ 𝓛) : 𝓚 ⪯ 𝓛 := ⟨fun _ ↦ Entailment.Axiomatized.weakening! h⟩ -instance [Tait.Axiomatized F K] : Entailment.StrongCut K K where - cut {_ _ _ bs b} := Tait.Axiomatized.trans (fun _ hq ↦ bs hq) b + + instance [Cut F K] : DeductiveExplosion K where dexp {𝓚 b φ} := wk (Tait.Cut.cut b (by simpa using verum _ _)) (by simp) @@ -155,22 +111,22 @@ instance [Cut F K] : DeductiveExplosion K where instance : Entailment.Deduction K where ofInsert {φ ψ 𝓚 b} := by { } inv {φ ψ 𝓚 b} := - let h : cons φ 𝓚 ⟹ [∼φ ⋎ ψ, ψ] := - wk (show cons φ 𝓚 ⟹ [∼φ ⋎ ψ] from ofEq (ofAxiomSubset (by simp) b) (by simp [DeMorgan.imply])) (by simp) - let n : cons φ 𝓚 ⟹ [∼(∼φ ⋎ ψ), ψ] := - let hp : cons φ 𝓚 ⟹ [φ, ψ] := wk (show cons φ 𝓚 ⊢! φ from byAxm (by simp)) (by simp) - let hq : cons φ 𝓚 ⟹ [∼ψ, ψ] := em (φ := ψ) (by simp) (by simp) + let h : cons φ 𝔇 [∼φ ⋎ ψ, ψ] := + wk (show cons φ 𝔇 [∼φ ⋎ ψ] from ofEq (ofAxiomSubset (by simp) b) (by simp [DeMorgan.imply])) (by simp) + let n : cons φ 𝔇 [∼(∼φ ⋎ ψ), ψ] := + let hp : cons φ 𝔇 [φ, ψ] := wk (show cons φ 𝓚 ⊢! φ from byAxm (by simp)) (by simp) + let hq : cons φ 𝔇 [∼ψ, ψ] := em (φ := ψ) (by simp) (by simp) ofEq (and hp hq) (by simp) cut h n -/ lemma inconsistent_iff_provable [Cut F K] : - Inconsistent 𝓚 ↔ 𝓚 ⟹! [] := + Inconsistent 𝓚 ↔ 𝔇! [] := ⟨fun b ↦ ⟨cut (inconsistent_iff_provable_bot.mp b).get (by simpa using verum _ _)⟩, fun h ↦ inconsistent_iff_provable_bot.mpr (wk! h (by simp))⟩ lemma consistent_iff_unprovable [Tait.Axiomatized F K] [Cut F K] : - Consistent 𝓚 ↔ IsEmpty (𝓚 ⟹ []) := + Consistent 𝓚 ↔ IsEmpty (𝔇 []) := not_iff_not.mp <| by simp [not_consistent_iff_inconsistent, inconsistent_iff_provable] /- @@ -195,9 +151,9 @@ lemma inconsistent_of_provable_and_refutable {φ} (bp : 𝓚 ⊢ φ) (br : 𝓚 instance [NegInvolutive F] [Cut F K] : Entailment.Cl 𝓚 where mdp {φ ψ dpq dp} := - let dpq : 𝓚 ⟹ [∼φ ⋎ ψ, ψ] := wk dpq (by simp [DeMorgan.imply]) - let dnq : 𝓚 ⟹ [∼(∼φ ⋎ ψ), ψ] := - let d : 𝓚 ⟹ [φ ⋏ ∼ψ, ψ] := and (wk dp <| by simp) (close ψ) + let dpq : 𝔇 [∼φ ⋎ ψ, ψ] := wk dpq (by simp [DeMorgan.imply]) + let dnq : 𝔇 [∼(∼φ ⋎ ψ), ψ] := + let d : 𝔇 [φ ⋏ ∼ψ, ψ] := and (wk dp <| by simp) (close ψ) ofEq d (by simp) cut dpq dnq negEquiv {φ} := ofEq @@ -239,45 +195,45 @@ instance [NegInvolutive F] [Cut F K] : Entailment.Cl 𝓚 where have : 𝓚 ⊢! ∼φ ⋎ φ := or <| close φ ofEq this (by simp [DeMorgan.imply]) -lemma wkCut [Cut F K] (hp : 𝓚 ⟹! φ :: Δ) (hn : 𝓚 ⟹! ∼φ :: Δ) : 𝓚 ⟹! Δ := ⟨cut hp.get hn.get⟩ +lemma wkCut [Cut F K] (hp : 𝔇! φ :: Δ) (hn : 𝔇! ∼φ :: Δ) : 𝔇! Δ := ⟨cut hp.get hn.get⟩ -def modusPonens [NegInvolutive F] [Cut F K] (b : 𝓚 ⊢! φ ➝ ψ) : 𝓚 ⟹ φ :: Γ → 𝓚 ⟹ ψ :: Γ := fun d ↦ +def modusPonens [NegInvolutive F] [Cut F K] (b : 𝓚 ⊢! φ ➝ ψ) : 𝔇 φ :: Γ → 𝔇 ψ :: Γ := fun d ↦ cut (φ := φ) (wk d <| by simp) <| cut (φ := φ ➝ ψ) (wk b <| by simp) <| - have : 𝓚 ⟹ φ ⋏ ∼ψ :: ∼φ :: ψ :: Γ := and (em' φ) (em' ψ) + have : 𝔇 φ ⋏ ∼ψ :: ∼φ :: ψ :: Γ := and (em' φ) (em' ψ) ofEq this <| by simp [DeMorgan.imply] -def modusPonens! [NegInvolutive F] [Cut F K] (b : 𝓚 ⊢ φ ➝ ψ) : 𝓚 ⟹! φ :: Γ → 𝓚 ⟹! ψ :: Γ := fun d ↦ ⟨modusPonens b.get d.get⟩ +def modusPonens! [NegInvolutive F] [Cut F K] (b : 𝓚 ⊢ φ ➝ ψ) : 𝔇! φ :: Γ → 𝔇! ψ :: Γ := fun d ↦ ⟨modusPonens b.get d.get⟩ -def cutFalsum [Cut F K] (d : 𝓚 ⟹ ⊥ :: Γ) : 𝓚 ⟹ Γ := Tait.cut (φ := ⊥) (Tait.wk d <| by simp) (ofEq (verum _ Γ) <| by simp) +def cutFalsum [Cut F K] (d : 𝔇 ⊥ :: Γ) : 𝔇 Γ := Tait.cut (φ := ⊥) (Tait.wk d <| by simp) (ofEq (verum _ Γ) <| by simp) -def orReversion [Cut F K] (d : 𝓚 ⟹ φ ⋎ ψ :: Γ) : 𝓚 ⟹ φ :: ψ :: Γ := +def orReversion [Cut F K] (d : 𝔇 φ ⋎ ψ :: Γ) : 𝔇 φ :: ψ :: Γ := Tait.cut (φ := φ ⋎ ψ) (wk d <| List.cons_subset_cons _ <| by simp) - ( have : 𝓚 ⟹ ∼φ ⋏ ∼ψ :: φ :: ψ :: Γ := and (em' φ) (em' ψ) + ( have : 𝔇 ∼φ ⋏ ∼ψ :: φ :: ψ :: Γ := and (em' φ) (em' ψ) ofEq this (by simp) ) -def disjConsOfAppend {Γ Δ} (d : 𝓚 ⟹ Γ ++ Δ) : 𝓚 ⟹ Γ.disj :: Δ := +def disjConsOfAppend {Γ Δ} (d : 𝔇 Γ ++ Δ) : 𝔇 Γ.disj :: Δ := match Γ with | [] => wk d (by simp) | φ :: Γ => or <| - have : 𝓚 ⟹ Γ ++ φ :: Δ := wk d <| by simp + have : 𝔇 Γ ++ φ :: Δ := wk d <| by simp wk (disjConsOfAppend this) (by simp) -def proofOfDerivation (d : 𝓚 ⟹ Γ) : 𝓚 ⊢! Γ.disj := disjConsOfAppend (Γ := Γ) (Δ := []) (ofEq d (by simp)) +def proofOfDerivation (d : 𝔇 Γ) : 𝓚 ⊢! Γ.disj := disjConsOfAppend (Γ := Γ) (Δ := []) (ofEq d (by simp)) -def AppendOfDisjCons [Cut F K] {Γ Δ} (d : 𝓚 ⟹ Γ.disj :: Δ) : 𝓚 ⟹ Γ ++ Δ := +def AppendOfDisjCons [Cut F K] {Γ Δ} (d : 𝔇 Γ.disj :: Δ) : 𝔇 Γ ++ Δ := match Γ with | [] => ofEq (cutFalsum d) (by simp) | φ :: Γ => - have : 𝓚 ⟹ Γ.disj :: φ :: Δ := wk (orReversion d) (by simp) + have : 𝔇 Γ.disj :: φ :: Δ := wk (orReversion d) (by simp) wk (AppendOfDisjCons this) (by simp) -def derivationOfProof [Cut F K] (d : 𝓚 ⊢! Γ.disj) : 𝓚 ⟹ Γ := ofEq (AppendOfDisjCons d) (by simp) +def derivationOfProof [Cut F K] (d : 𝓚 ⊢! Γ.disj) : 𝔇 Γ := ofEq (AppendOfDisjCons d) (by simp) -lemma derivable_iff_provable_disj [Cut F K] : 𝓚 ⟹! Γ ↔ 𝓚 ⊢ Γ.disj := +lemma derivable_iff_provable_disj [Cut F K] : 𝔇! Γ ↔ 𝓚 ⊢ Γ.disj := ⟨fun h ↦ ⟨proofOfDerivation h.get⟩, fun h ↦ ⟨derivationOfProof h.get⟩⟩ end Tait diff --git a/Foundation/Logic/LogicSymbol.lean b/Foundation/Logic/LogicSymbol.lean index a0d320dc6..04b4f4404 100644 --- a/Foundation/Logic/LogicSymbol.lean +++ b/Foundation/Logic/LogicSymbol.lean @@ -338,6 +338,23 @@ variable {α : Type*} variable {φ ψ : α} +section tilde + +variable [Tilde α] + +instance : Tilde (List α) := ⟨fun l ↦ l.map (∼·)⟩ + +@[simp] lemma tilde_nil : ∼([] : List α) = [] := rfl + +@[simp] lemma tilde_cons (a : α) (l : List α) : ∼(a :: l) = ∼a :: ∼l := rfl + +@[simp] lemma tilde_append (l k : List α) : ∼(l ++ k) = ∼l ++ ∼k := by + induction l with + | nil => simp [*] + | cons a as ih => simp [*, List.cons_append] + +end tilde + section conjunction variable [Top α] [Wedge α] @@ -420,63 +437,67 @@ def disj' (f : ι → α) (l : List ι) : α := (l.map f).disj₂ end disjunction -variable [LogicalConnective α] +section + +variable [LogicalConnective α] [LogicalConnective β] [FunLike G α β] [LogicalConnective.HomClass G α β] -lemma map_conj [LogicalConnective β] [FunLike G α β] [LogicalConnective.HomClass G α β] - (f : G) (l : List α) : f l.conj = (l.map f).conj := by +lemma map_tilde (f : G) (l : List α) : (∼l : List α).map f = ∼(l.map f) := by induction l <;> simp [*] -@[simp] lemma map_conj_prop [FunLike G α Prop] [LogicalConnective.HomClass G α Prop] - {f : G} {l : List α} : f l.conj ↔ ∀ a ∈ l, f a := by +lemma map_conj (f : G) (l : List α) : f l.conj = (l.map f).conj := by induction l <;> simp [*] -@[simp] lemma map_conj₂_prop [FunLike G α Prop] [LogicalConnective.HomClass G α Prop] - {f : G} {l : List α} : f l.conj₂ ↔ ∀ a ∈ l, f a := by +lemma map_conj₂ (f : G) (l : List α) : f l.conj₂ = (l.map f).conj₂ := by induction l using List.induction_with_singleton' <;> simp [*] -lemma map_conj₂ [LogicalConnective β] [FunLike G α β] [LogicalConnective.HomClass G α β] - (f : G) (l : List α) : f l.conj₂ = (l.map f).conj₂ := by +lemma map_conj' (F : G) (l : List ι) (f : ι → α) : F (l.conj' f) = l.conj' (F ∘ f) := by induction l using List.induction_with_singleton' <;> simp [*] -lemma map_conj_append_prop [FunLike G α Prop] [LogicalConnective.HomClass G α Prop] - (f : G) (l₁ l₂ : List α) : f (l₁ ++ l₂).conj ↔ f (l₁.conj ⋏ l₂.conj) := by - induction l₁ <;> induction l₂ <;> aesop; +lemma map_disj (f : G) (l : List α) : f l.disj = (l.map f).disj := by + induction l <;> simp [*] -lemma map_conj' [LogicalConnective β] [FunLike G α β] [LogicalConnective.HomClass G α β] - (F : G) (l : List ι) (f : ι → α) : F (l.conj' f) = l.conj' (F ∘ f) := by +lemma map_disj₂ (f : G) (l : List α) : f l.disj₂ = (l.map f).disj₂ := by induction l using List.induction_with_singleton' <;> simp [*] -@[simp] lemma map_conj'_prop [FunLike G α Prop] [LogicalConnective.HomClass G α Prop] - {F : G} {l : List ι} {f : ι → α} : F (l.conj' f) ↔ ∀ i ∈ l, F (f i) := by +lemma map_disj' (F : G) (l : List ι) (f : ι → α) : F (l.disj' f) = l.disj' (F ∘ f) := by induction l using List.induction_with_singleton' <;> simp [*] -lemma map_disj [LogicalConnective β] [FunLike G α β] [LogicalConnective.HomClass G α β] - (f : G) (l : List α) : f l.disj = (l.map f).disj := by - induction l <;> simp [*] +end + +section + +variable [LogicalConnective α] [FunLike G α Prop] [LogicalConnective.HomClass G α Prop] -@[simp] lemma map_disj_prop [FunLike F α Prop] [LogicalConnective.HomClass F α Prop] - {f : F} {l : List α} : f l.disj ↔ ∃ a ∈ l, f a := by +@[simp] lemma map_conj_prop {f : G} {l : List α} : f l.conj ↔ ∀ a ∈ l, f a := by induction l <;> simp [*] -lemma map_disj₂ [LogicalConnective β] [FunLike G α β] [LogicalConnective.HomClass G α β] - (f : G) (l : List α) : f l.disj₂ = (l.map f).disj₂ := by +@[simp] lemma map_conj₂_prop {f : G} {l : List α} : f l.conj₂ ↔ ∀ a ∈ l, f a := by induction l using List.induction_with_singleton' <;> simp [*] -@[simp] lemma map_disj₂_prop [FunLike F α Prop] [LogicalConnective.HomClass F α Prop] - {f : F} {l : List α} : f l.disj₂ ↔ ∃ a ∈ l, f a := by +lemma map_conj_append_prop + (f : G) (l₁ l₂ : List α) : f (l₁ ++ l₂).conj ↔ f (l₁.conj ⋏ l₂.conj) := by + induction l₁ <;> induction l₂ <;> aesop; + +@[simp] lemma map_conj'_prop + {F : G} {l : List ι} {f : ι → α} : F (l.conj' f) ↔ ∀ i ∈ l, F (f i) := by induction l using List.induction_with_singleton' <;> simp [*] -lemma map_disj_append_prop [FunLike F α Prop] [LogicalConnective.HomClass F α Prop] (f : F) (l₁ l₂ : List α) : f (l₁ ++ l₂).disj ↔ f (l₁.disj ⋎ l₂.disj) := by - induction l₁ <;> induction l₂ <;> aesop; +@[simp] lemma map_disj_prop + {f : G} {l : List α} : f l.disj ↔ ∃ a ∈ l, f a := by + induction l <;> simp [*] -lemma map_disj' [LogicalConnective β] [FunLike G α β] [LogicalConnective.HomClass G α β] - (F : G) (l : List ι) (f : ι → α) : F (l.disj' f) = l.disj' (F ∘ f) := by +@[simp] lemma map_disj₂_prop {f : G} {l : List α} : f l.disj₂ ↔ ∃ a ∈ l, f a := by induction l using List.induction_with_singleton' <;> simp [*] -@[simp] lemma map_disj'_prop [FunLike G α Prop] [LogicalConnective.HomClass G α Prop] +lemma map_disj_append_prop (f : G) (l₁ l₂ : List α) : f (l₁ ++ l₂).disj ↔ f (l₁.disj ⋎ l₂.disj) := by + induction l₁ <;> induction l₂ <;> aesop; + +@[simp] lemma map_disj'_prop {F : G} {l : List ι} {f : ι → α} : F (l.disj' f) ↔ ∃ i ∈ l, F (f i) := by induction l using List.induction_with_singleton' <;> simp [*] +end + end List namespace Finset From 615ece2adb770442962ae0f983d8a2efe57bbdfe Mon Sep 17 00:00:00 2001 From: palalansouki Date: Fri, 6 Mar 2026 01:53:36 +0900 Subject: [PATCH 02/61] calculus --- Foundation/FirstOrder/Basic/Calculus.lean | 2 +- Foundation/Logic/Calculus.lean | 235 ++++++------------ Foundation/Logic/Entailment.lean | 38 +-- .../Entailment/Minimal/Basic.lean | 52 ++-- .../Classification/LetterlessTrace.lean | 4 +- 5 files changed, 122 insertions(+), 209 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index 2cc7533fd..2bdc00d30 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -574,7 +574,7 @@ instance : Entailment.StrongCut (Theory L) (Theory L) where lemma compact' [L.DecidableEq] {T : Theory L} {φ : Sentence L} (b : T ⊢ φ) : ∃ (s : { s : Finset (Sentence L) // ↑s ⊆ T}), (∅ : Theory L) ⊢ s.val.conj ➝ φ := by let ⟨s, b⟩ := compact b - let bc : ({s.val.conj} : Theory L) ⊢ s.val.conj := Axiomatized.provable_axm _ (by simp) + let bc : ({s.val.conj} : Theory L) ⊢ s.val.conj := Axiomatized.provable_refl _ (by simp) have : {s.val.conj} ⊢ φ := StrongCut.cut! (fun {ψ} hψ ↦ Entailment.left_Fconj!_intro (by simpa) ⨀ bc) b have : (insert s.val.conj ∅ : Theory L) ⊢ φ := by simpa using this exact ⟨s, ⟨deduction this.get⟩⟩ diff --git a/Foundation/Logic/Calculus.lean b/Foundation/Logic/Calculus.lean index d365c8ce7..9acb53d4b 100644 --- a/Foundation/Logic/Calculus.lean +++ b/Foundation/Logic/Calculus.lean @@ -8,9 +8,7 @@ public import Foundation.Propositional.Entailment.Cl.Basic This file defines a characterization of Tait style calculus and Gentzen style calculus. ## Main Definitions -* `LO.Tait` -* `LO.Gentzen` - +- `LO.OneSidedLK` -/ @[expose] @@ -18,7 +16,9 @@ public section namespace LO -class OneSidedLK {F : Type*} [LogicalConnective F] [DeMorgan F] (𝔇 : List F → Type*) where +/-! ## One-sided $\mathbf{LK}$ -/ + +class OneSidedLK {F : Type*} [LogicalConnective F] [DeMorgan F] [NegInvolutive F] (𝔇 : List F → Type*) where identity (φ) : 𝔇 [φ, ∼φ] wk : 𝔇 Δ → Δ ⊆ Γ → 𝔇 Γ verum : 𝔇 [⊤] @@ -26,19 +26,12 @@ class OneSidedLK {F : Type*} [LogicalConnective F] [DeMorgan F] (𝔇 : List F or : 𝔇 (φ :: ψ :: Γ) → 𝔇 (φ ⋎ ψ :: Γ) class OneSidedLK.Cut - {F : Type*} [LogicalConnective F] [DeMorgan F] (𝔇 : List F → Type*) extends OneSidedLK 𝔇 where - cut : 𝔇 (φ :: Γ) → 𝔇 (∼φ :: Γ) → 𝔇 Γ - -class OneSidedLK.EquivEntailment - {F : Type*} [LogicalConnective F] [DeMorgan F] (𝔇 : outParam (List F → Type*)) - (S : Type*) [Entailment S F] [AdjunctiveSet F S] where - equiv {𝓢 : S} : (l : {l : List F // ∀ φ ∈ l, φ ∈ 𝓢}) × 𝔇 (φ :: ∼l) ≃ 𝓢 ⊢! φ - -variable {F S K : Type*} [LogicalConnective F] [AdjunctiveSet F K] + {F : Type*} [LogicalConnective F] [DeMorgan F] [NegInvolutive F] (𝔇 : List F → Type*) extends OneSidedLK 𝔇 where + cut : 𝔇 (φ :: Γ) → 𝔇 (∼φ :: Δ) → 𝔇 (Γ ++ Δ) namespace OneSidedLK -variable {F : Type*} [LogicalConnective F] [DeMorgan F] {𝔇 : List F → Type*} [OneSidedLK 𝔇] +variable {F : Type*} [LogicalConnective F] [DeMorgan F] [NegInvolutive F] {𝔇 : List F → Type*} [OneSidedLK 𝔇] def cast (b : 𝔇 Γ) (h : Γ = Δ := by simp) : 𝔇 Δ := h ▸ b @@ -46,11 +39,8 @@ def close (φ : F) (hp : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : def verum' (h : ⊤ ∈ Γ := by simp) : 𝔇 Γ := wk verum (by simp [h]) -def and' {φ ψ : F} (h : φ ⋏ ψ ∈ Γ) (dp : 𝔇 (φ :: Γ)) (dq : 𝔇 (ψ :: Γ)) : 𝔇 Γ := - wk (and dp dq) (by simp [h]) - -def or' {φ ψ : F} (h : φ ⋎ ψ ∈ Γ) (dpq : 𝔇 (φ :: ψ :: Γ)) : 𝔇 Γ := - wk (or dpq) (by simp [h]) +def tensor {φ ψ : F} (dφ : 𝔇 (φ :: Γ)) (dψ : 𝔇 (ψ :: Δ)) : 𝔇 (φ ⋏ ψ :: Γ ++ Δ) := + and (wk dφ (by simp)) (wk dψ (by simp)) def wkTail (d : 𝔇 Γ) : 𝔇 (φ :: Γ) := wk d (by simp) @@ -69,174 +59,93 @@ def rotate₃ (d : 𝔇 (φ₄ :: φ₁ :: φ₂ :: φ₃ :: Γ)) : 𝔇 (φ₁ alias cut := OneSidedLK.Cut.cut +protected class Entailment (𝔇 : outParam (List F → Type*)) (S : Type*) [Entailment S F] [AdjunctiveSet F S] where + equiv {𝓢 : S} : 𝓢 ⊢! φ ≃ (l : {l : List F // ∀ φ ∈ l, φ ∈ 𝓢}) × 𝔇 (φ :: ∼l) + open Entailment -variable {S : Type*} [Entailment S F] [AdjunctiveSet F S] +variable {S : Type*} [Entailment S F] [AdjunctiveSet F S] [OneSidedLK.Entailment 𝔇 S] -def ofAxiom [OneSidedLK.EquivEntailment 𝔇 S] {𝓢 : S} (h : φ ∈ 𝓢) : 𝓢 ⊢! φ := - OneSidedLK.EquivEntailment.equiv ⟨⟨[φ], by simp_all⟩, identity φ⟩ +def toProof (𝓢 : S) (d : 𝔇 [φ]) : 𝓢 ⊢! φ := OneSidedLK.Entailment.equiv.symm ⟨⟨[], by simp⟩, d⟩ -def ofAxiomSubset [OneSidedLK.EquivEntailment 𝔇 S] {𝓢 𝓤 : S} : 𝓢 ⊢! φ → 𝓢 ⊆ 𝓤 → 𝓤 ⊢! φ := fun b h ↦ - have ⟨l, d⟩ := OneSidedLK.EquivEntailment.equiv.symm b - OneSidedLK.EquivEntailment.equiv +def ofAxiom {𝓢 : S} (h : φ ∈ 𝓢) : 𝓢 ⊢! φ := + OneSidedLK.Entailment.equiv.symm ⟨⟨[φ], by simp_all⟩, identity φ⟩ + +def ofAxiomSubset {𝓢 𝓤 : S} : 𝓢 ⊢! φ → 𝓢 ⊆ 𝓤 → 𝓤 ⊢! φ := fun b h ↦ + have ⟨l, d⟩ := OneSidedLK.Entailment.equiv b + OneSidedLK.Entailment.equiv.symm ⟨⟨l, fun φ hφ ↦ AdjunctiveSet.subset_iff.mp h _ (l.prop φ hφ)⟩, d⟩ -instance [OneSidedLK.EquivEntailment 𝔇 S] : Entailment.Axiomatized S where +instance : Entailment.Axiomatized S where prfAxm h := ofAxiom h weakening h d := ofAxiomSubset d h -lemma waekerThan_of_subset [OneSidedLK.EquivEntailment 𝔇 S] {𝓢 𝓤 : S} (h : 𝓢 ⊆ 𝓤) : 𝓢 ⪯ 𝓤 := - ⟨fun _ ↦ Entailment.Axiomatized.weakening! h⟩ - -instance [OneSidedLK.EquivEntailment 𝔇 S] : Entailment.StrongCut S S where - cut {T U φ bs b} := by { } -/--/ -lemma of_axiom_subset [Tait.Axiomatized F K] (h : 𝓚 ⊆ 𝓛) : 𝔇! Γ → 𝓛 ⟹! Γ := fun b ↦ ⟨ofAxiomSubset h b.get⟩ - -instance system : Entailment K F := ⟨(· ⟹. ·)⟩ - - - -lemma provable_bot_iff_derivable_nil [Cut F K] : 𝔇! [] ↔ 𝓚 ⊢ ⊥ := - ⟨fun b ↦ wk! b (by simp), fun b ↦ cut! b (by simpa using verum! _ _)⟩ - - - - - -instance [Cut F K] : DeductiveExplosion K where - dexp {𝓚 b φ} := wk (Tait.Cut.cut b (by simpa using verum _ _)) (by simp) - -/- -instance : Entailment.Deduction K where - ofInsert {φ ψ 𝓚 b} := by { } - inv {φ ψ 𝓚 b} := - let h : cons φ 𝔇 [∼φ ⋎ ψ, ψ] := - wk (show cons φ 𝔇 [∼φ ⋎ ψ] from ofEq (ofAxiomSubset (by simp) b) (by simp [DeMorgan.imply])) (by simp) - let n : cons φ 𝔇 [∼(∼φ ⋎ ψ), ψ] := - let hp : cons φ 𝔇 [φ, ψ] := wk (show cons φ 𝓚 ⊢! φ from byAxm (by simp)) (by simp) - let hq : cons φ 𝔇 [∼ψ, ψ] := em (φ := ψ) (by simp) (by simp) - ofEq (and hp hq) (by simp) - cut h n --/ - -lemma inconsistent_iff_provable [Cut F K] : - Inconsistent 𝓚 ↔ 𝔇! [] := - ⟨fun b ↦ ⟨cut (inconsistent_iff_provable_bot.mp b).get (by simpa using verum _ _)⟩, - fun h ↦ inconsistent_iff_provable_bot.mpr (wk! h (by simp))⟩ - -lemma consistent_iff_unprovable [Tait.Axiomatized F K] [Cut F K] : - Consistent 𝓚 ↔ IsEmpty (𝔇 []) := - not_iff_not.mp <| by simp [not_consistent_iff_inconsistent, inconsistent_iff_provable] - -/- -lemma provable_iff_inconsistent {φ} : - 𝓚 ⊢ φ ↔ Inconsistent (cons (∼φ) 𝓚) := by - simp [inconsistent_iff_provable, deduction_iff, DeMorgan.imply] - constructor - · intro h; exact cut! (of_axiom_subset (by simp) h) (root! <| by simp) - · rintro ⟨b⟩ - exact ⟨by simpa using Tait.Axiomatized.proofOfContra b⟩ - -lemma refutable_iff_inconsistent {φ} : - 𝓚 ⊢ ∼φ ↔ Inconsistent (cons φ 𝓚) := by simpa using provable_iff_inconsistent (𝓚 := 𝓚) (φ := ∼φ) - -lemma consistent_insert_iff_not_refutable {φ} : - Entailment.Consistent (cons φ 𝓚) ↔ 𝓚 ⊬ ∼φ := by - simp [Entailment.Unprovable, refutable_iff_inconsistent, Entailment.not_inconsistent_iff_consistent] - -lemma inconsistent_of_provable_and_refutable {φ} (bp : 𝓚 ⊢ φ) (br : 𝓚 ⊢ ∼φ) : Inconsistent 𝓚 := - inconsistent_iff_provable.mpr <| cut! bp br --/ - -instance [NegInvolutive F] [Cut F K] : Entailment.Cl 𝓚 where - mdp {φ ψ dpq dp} := - let dpq : 𝔇 [∼φ ⋎ ψ, ψ] := wk dpq (by simp [DeMorgan.imply]) - let dnq : 𝔇 [∼(∼φ ⋎ ψ), ψ] := - let d : 𝔇 [φ ⋏ ∼ψ, ψ] := and (wk dp <| by simp) (close ψ) - ofEq d (by simp) - cut dpq dnq - negEquiv {φ} := ofEq - (show 𝓚 ⊢! (φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ) from - and (or <| rotate₁ <| or <| close φ) (or <| and (close φ) verum')) +variable [OneSidedLK.Cut 𝔇] [OneSidedLK.Entailment 𝔇 S] + +instance (𝓢 : S) : Entailment.ModusPonens 𝓢 where + mdp {φ ψ} b₁ b₂ := + let ⟨Γ₁, b₁⟩ := OneSidedLK.Entailment.equiv b₁ + let ⟨Γ₂, b₂⟩ := OneSidedLK.Entailment.equiv b₂ + have : 𝔇 [∼(φ ➝ ψ), ∼φ, ψ] := cast (tensor (𝔇 := 𝔇) (identity φ) (identity (∼ψ))) (by simp [DeMorgan.imply]) + have : 𝔇 (∼φ :: ψ :: ∼↑Γ₁) := wk (cut b₁ this) (by simp) + have : 𝔇 (ψ :: ∼↑Γ₁ ++ ∼↑Γ₂) := wk (cut b₂ this) (by simp) + OneSidedLK.Entailment.equiv.symm ⟨⟨Γ₁ ++ Γ₂, by simp; grind⟩, cast this⟩ + +instance : Entailment.StrongCut S S where + cut {T U φ bs b} := + let rec bl (l : List F) (hl : ∀ ψ ∈ l, ψ ∈ U) (χ) (d : 𝔇 (χ :: ∼l)) : T ⊢! χ := + match l with + | [] => OneSidedLK.Entailment.equiv.symm ⟨⟨[], by simp⟩, d⟩ + | ψ :: l => + have bχ : T ⊢! ψ ➝ χ := + Entailment.cast (bl l (by simp at hl; grind) (∼ψ ⋎ χ) (OneSidedLK.or <| OneSidedLK.rotate₁ d)) + (by simp [DeMorgan.imply]) + have bψ : T ⊢! ψ := bs (show ψ ∈ U by simp at hl; grind) + Entailment.mdp bχ bψ + have ⟨l, hl⟩ := OneSidedLK.Entailment.equiv b + bl l l.prop φ hl + +instance (𝓢 : S) : Entailment.Cl 𝓢 where + negEquiv {φ} := Entailment.cast + (show 𝓢 ⊢! (φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ) from + toProof _ <| and (or <| rotate₁ <| or <| close φ) (or <| and (identity φ) verum')) (by simp [Axioms.NegEquiv, DeMorgan.imply, LogicalConnective.iff]) - verum := verum _ _ + verum := toProof _ <| verum implyK {φ ψ} := - have : 𝓚 ⊢! ∼φ ⋎ ∼ψ ⋎ φ := or <| rotate₁ <| or <| close φ - ofEq this (by simp [DeMorgan.imply]) + have : 𝓢 ⊢! ∼φ ⋎ ∼ψ ⋎ φ := toProof _ <| or <| rotate₁ <| or <| close φ + Entailment.cast this (by simp [DeMorgan.imply]) implyS {φ ψ χ} := - have : 𝓚 ⊢! φ ⋏ ψ ⋏ ∼χ ⋎ φ ⋏ ∼ψ ⋎ ∼φ ⋎ χ := - or <| rotate₁ <| or <| rotate₁ <| or <| rotate₃ <| and + have : 𝓢 ⊢! φ ⋏ ψ ⋏ ∼χ ⋎ φ ⋏ ∼ψ ⋎ ∼φ ⋎ χ := + toProof _ <| or <| rotate₁ <| or <| rotate₁ <| or <| rotate₃ <| and (close φ) (and (rotate₃ <| and (close φ) (close ψ)) (close χ)) - ofEq this (by simp [DeMorgan.imply]) + Entailment.cast this (by simp [DeMorgan.imply]) and₁ {φ ψ} := - have : 𝓚 ⊢! (∼φ ⋎ ∼ψ) ⋎ φ := or <| or <| close φ - ofEq this (by simp [DeMorgan.imply]) + have : 𝓢 ⊢! (∼φ ⋎ ∼ψ) ⋎ φ := toProof _ <|or <| or <| close φ + Entailment.cast this (by simp [DeMorgan.imply]) and₂ {φ ψ} := - have : 𝓚 ⊢! (∼φ ⋎ ∼ψ) ⋎ ψ := or <| or <| close ψ - ofEq this (by simp [DeMorgan.imply]) + have : 𝓢 ⊢! (∼φ ⋎ ∼ψ) ⋎ ψ := toProof _ <| or <| or <| close ψ + Entailment.cast this (by simp [DeMorgan.imply]) and₃ {φ ψ} := - have : 𝓚 ⊢! ∼φ ⋎ ∼ψ ⋎ φ ⋏ ψ := or <| rotate₁ <| or <| rotate₁ <| and (close φ) (close ψ) - ofEq this (by simp [DeMorgan.imply]) + have : 𝓢 ⊢! ∼φ ⋎ ∼ψ ⋎ φ ⋏ ψ := toProof _ <| or <| rotate₁ <| or <| rotate₁ <| and (close φ) (close ψ) + Entailment.cast this (by simp [DeMorgan.imply]) or₁ {φ ψ} := - have : 𝓚 ⊢! ∼φ ⋎ φ ⋎ ψ := or <| rotate₁ <| or <| close φ - ofEq this (by simp [DeMorgan.imply]) + have : 𝓢 ⊢! ∼φ ⋎ φ ⋎ ψ := toProof _ <| or <| rotate₁ <| or <| close φ + Entailment.cast this (by simp [DeMorgan.imply]) or₂ {φ ψ} := - have : 𝓚 ⊢! ∼ψ ⋎ φ ⋎ ψ := or <| rotate₁ <| or <| close ψ - ofEq this (by simp [DeMorgan.imply]) + have : 𝓢 ⊢! ∼ψ ⋎ φ ⋎ ψ := toProof _ <| or <| rotate₁ <| or <| close ψ + Entailment.cast this (by simp [DeMorgan.imply]) or₃ {φ ψ χ} := - have : 𝓚 ⊢! φ ⋏ ∼χ ⋎ ψ ⋏ ∼ χ ⋎ ∼φ ⋏ ∼ψ ⋎ χ := - or <| rotate₁ <| or <| rotate₁ <| or <| and + have : 𝓢 ⊢! φ ⋏ ∼χ ⋎ ψ ⋏ ∼ χ ⋎ ∼φ ⋏ ∼ψ ⋎ χ := + toProof _ <| or <| rotate₁ <| or <| rotate₁ <| or <| and (rotate₃ <| and (close φ) (close χ)) (rotate₂ <| and (close ψ) (close χ)) - ofEq this (by simp [DeMorgan.imply]) + Entailment.cast this (by simp [DeMorgan.imply]) dne {φ} := - have : 𝓚 ⊢! ∼φ ⋎ φ := or <| close φ - ofEq this (by simp [DeMorgan.imply]) - -lemma wkCut [Cut F K] (hp : 𝔇! φ :: Δ) (hn : 𝔇! ∼φ :: Δ) : 𝔇! Δ := ⟨cut hp.get hn.get⟩ - -def modusPonens [NegInvolutive F] [Cut F K] (b : 𝓚 ⊢! φ ➝ ψ) : 𝔇 φ :: Γ → 𝔇 ψ :: Γ := fun d ↦ - cut (φ := φ) - (wk d <| by simp) <| - cut (φ := φ ➝ ψ) - (wk b <| by simp) <| - have : 𝔇 φ ⋏ ∼ψ :: ∼φ :: ψ :: Γ := and (em' φ) (em' ψ) - ofEq this <| by simp [DeMorgan.imply] - -def modusPonens! [NegInvolutive F] [Cut F K] (b : 𝓚 ⊢ φ ➝ ψ) : 𝔇! φ :: Γ → 𝔇! ψ :: Γ := fun d ↦ ⟨modusPonens b.get d.get⟩ - -def cutFalsum [Cut F K] (d : 𝔇 ⊥ :: Γ) : 𝔇 Γ := Tait.cut (φ := ⊥) (Tait.wk d <| by simp) (ofEq (verum _ Γ) <| by simp) - -def orReversion [Cut F K] (d : 𝔇 φ ⋎ ψ :: Γ) : 𝔇 φ :: ψ :: Γ := - Tait.cut (φ := φ ⋎ ψ) - (wk d <| List.cons_subset_cons _ <| by simp) - ( have : 𝔇 ∼φ ⋏ ∼ψ :: φ :: ψ :: Γ := and (em' φ) (em' ψ) - ofEq this (by simp) ) - -def disjConsOfAppend {Γ Δ} (d : 𝔇 Γ ++ Δ) : 𝔇 Γ.disj :: Δ := - match Γ with - | [] => wk d (by simp) - | φ :: Γ => or <| - have : 𝔇 Γ ++ φ :: Δ := wk d <| by simp - wk (disjConsOfAppend this) (by simp) - -def proofOfDerivation (d : 𝔇 Γ) : 𝓚 ⊢! Γ.disj := disjConsOfAppend (Γ := Γ) (Δ := []) (ofEq d (by simp)) - -def AppendOfDisjCons [Cut F K] {Γ Δ} (d : 𝔇 Γ.disj :: Δ) : 𝔇 Γ ++ Δ := - match Γ with - | [] => ofEq (cutFalsum d) (by simp) - | φ :: Γ => - have : 𝔇 Γ.disj :: φ :: Δ := wk (orReversion d) (by simp) - wk (AppendOfDisjCons this) (by simp) - -def derivationOfProof [Cut F K] (d : 𝓚 ⊢! Γ.disj) : 𝔇 Γ := ofEq (AppendOfDisjCons d) (by simp) - -lemma derivable_iff_provable_disj [Cut F K] : 𝔇! Γ ↔ 𝓚 ⊢ Γ.disj := - ⟨fun h ↦ ⟨proofOfDerivation h.get⟩, fun h ↦ ⟨derivationOfProof h.get⟩⟩ + have : 𝓢 ⊢! ∼φ ⋎ φ := toProof _ <| or <| close φ + Entailment.cast this (by simp [DeMorgan.imply]) -end Tait +end OneSidedLK end LO diff --git a/Foundation/Logic/Entailment.lean b/Foundation/Logic/Entailment.lean index c6050d061..31d9c9e9f 100644 --- a/Foundation/Logic/Entailment.lean +++ b/Foundation/Logic/Entailment.lean @@ -55,7 +55,7 @@ infix:45 " ⊢ " => Provable infix:45 " ⊬ " => Unprovable /-- Proofs of set of formulae. -/ -def PrfSet (s : Set F) : Type _ := {φ : F} → φ ∈ s → 𝓢 ⊢! φ +def PrfSet (s : Set F) : Type _ := ⦃φ : F⦄ → φ ∈ s → 𝓢 ⊢! φ /-- Proposition for existance of proofs of set of formulae. -/ def ProvableSet (s : Set F) : Prop := ∀ {φ}, φ ∈ s → 𝓢 ⊢ φ @@ -69,9 +69,9 @@ def theory : Set F := {φ | 𝓢 ⊢ φ} end -def cast {𝓢 : S} {φ ψ : F} (e : φ = ψ) (b : 𝓢 ⊢! φ) : 𝓢 ⊢! ψ := e ▸ b +def cast {𝓢 : S} {φ ψ : F} (b : 𝓢 ⊢! φ) (e : φ = ψ := by simp) : 𝓢 ⊢! ψ := e ▸ b -@[grind ⇒] lemma cast! {𝓢 : S} {φ ψ : F} (e : φ = ψ) (b : 𝓢 ⊢ φ) : 𝓢 ⊢ ψ := ⟨cast e b.some⟩ +@[grind ⇒] lemma cast! {𝓢 : S} {φ ψ : F} (b : 𝓢 ⊢ φ) (e : φ = ψ := by simp) : 𝓢 ⊢ ψ := ⟨cast b.some e⟩ lemma unprovable_iff_isEmpty {𝓢 : S} {φ : F} : 𝓢 ⊬ φ ↔ IsEmpty (𝓢 ⊢! φ) := by simp [Provable, Unprovable] @@ -171,11 +171,11 @@ lemma Equiv.iff : 𝓢 ≊ 𝓣 ↔ (∀ φ, 𝓢 ⊢ φ ↔ 𝓣 ⊢ φ) := @[instance, simp, refl] protected lemma Equiv.refl (𝓢 : S) : 𝓢 ≊ 𝓢 := ⟨rfl⟩ -@[symm, grind] lemma Equiv.symm : 𝓢 ≊ 𝓣 → 𝓣 ≊ 𝓢 := fun e ↦ ⟨Eq.symm e.eq⟩ +@[symm, grind .] lemma Equiv.symm : 𝓢 ≊ 𝓣 → 𝓣 ≊ 𝓢 := fun e ↦ ⟨Eq.symm e.eq⟩ @[trans] lemma Equiv.trans : 𝓢 ≊ 𝓣 → 𝓣 ≊ 𝓤 → 𝓢 ≊ 𝓤 := fun e₁ e₂ ↦ ⟨Eq.trans e₁.eq e₂.eq⟩ -@[grind] +@[grind =] lemma Equiv.antisymm_iff : 𝓢 ≊ 𝓣 ↔ 𝓢 ⪯ 𝓣 ∧ 𝓣 ⪯ 𝓢 := by constructor · intro e @@ -185,7 +185,7 @@ lemma Equiv.antisymm_iff : 𝓢 ≊ 𝓣 ↔ 𝓢 ⪯ 𝓣 ∧ 𝓣 ⪯ 𝓢 := alias ⟨_, Equiv.antisymm⟩ := Equiv.antisymm_iff -@[grind] lemma Equiv.le : 𝓢 ≊ 𝓣 → 𝓢 ⪯ 𝓣 := fun e ↦ ⟨by rw [e.eq]⟩ +@[grind ->] lemma Equiv.le : 𝓢 ≊ 𝓣 → 𝓢 ⪯ 𝓣 := fun e ↦ ⟨by rw [e.eq]⟩ instance : Trans (α := S) (β := T) (γ := U) (· ≊ ·) (· ≊ ·) (· ≊ ·) where trans := Equiv.trans @@ -205,7 +205,7 @@ instance : Trans (α := S) (β := T) (γ := U) (· ≊ ·) (· ⪱ ·) (· ⪱ instance : Trans (α := S) (β := T) (γ := U) (· ⪱ ·) (· ≊ ·) (· ⪱ ·) where trans h₁ h₂ := swt_of_swt_of_wt h₁ h₂.le -@[grind] +@[grind =] lemma iff_strictlyWeakerThan_weakerThan_not_equiv : 𝓢 ⪱ 𝓣 ↔ 𝓢 ⪯ 𝓣 ∧ ¬(𝓢 ≊ 𝓣) := by constructor · rintro ⟨_, _⟩; grind; @@ -343,7 +343,6 @@ class Axiomatized [AdjunctiveSet F S] where prfAxm {𝓢 : S} : 𝓢 ⊢!* AdjunctiveSet.set 𝓢 weakening {𝓢 𝓣 : S} : 𝓢 ⊆ 𝓣 → 𝓢 ⊢! φ → 𝓣 ⊢! φ -alias byAxm := Axiomatized.prfAxm alias wk := Axiomatized.weakening class StrongCut [AdjunctiveSet F T] where @@ -357,13 +356,17 @@ namespace Axiomatized variable [AdjunctiveSet F S] [Axiomatized S] {𝓢 𝓣 : S} -@[simp] lemma provable_axm (𝓢 : S) : 𝓢 ⊢* AdjunctiveSet.set 𝓢 := fun hf ↦ ⟨prfAxm hf⟩ +def byAxm {𝓢 : S} (h : φ ∈ 𝓢) : 𝓢 ⊢! φ := prfAxm (by simp [h]) -lemma axm_subset (𝓢 : S) : AdjunctiveSet.set 𝓢 ⊆ theory 𝓢 := fun _ hp ↦ provable_axm 𝓢 hp +lemma by_axm {𝓢 : S} (h : φ ∈ 𝓢) : 𝓢 ⊢ φ := ⟨byAxm h⟩ + +@[simp] lemma provable_refl (𝓢 : S) : 𝓢 ⊢* AdjunctiveSet.set 𝓢 := fun hf ↦ ⟨prfAxm hf⟩ + +lemma axm_subset (𝓢 : S) : AdjunctiveSet.set 𝓢 ⊆ theory 𝓢 := fun _ hp ↦ provable_refl 𝓢 hp protected def adjoin (φ : F) (𝓢 : S) : adjoin φ 𝓢 ⊢! φ := prfAxm (by simp) -@[simp] def adjoin! (φ : F) (𝓢 : S) : adjoin φ 𝓢 ⊢ φ := provable_axm _ (by simp) +@[simp] def adjoin! (φ : F) (𝓢 : S) : adjoin φ 𝓢 ⊢ φ := provable_refl _ (by simp) lemma le_of_subset (h : 𝓢 ⊆ 𝓣) : 𝓢 ⪯ 𝓣 := ⟨by rintro φ ⟨b⟩; exact ⟨weakening h b⟩⟩ @@ -377,7 +380,8 @@ def to_adjoin {𝓢 : S} : 𝓢 ⊢ ψ → adjoin φ 𝓢 ⊢ ψ := fun b ↦ we end Axiomatized -alias by_axm := Axiomatized.provable_axm +alias byAxm := Axiomatized.byAxm +alias by_axm := Axiomatized.by_axm alias wk! := Axiomatized.weakening! section axiomatized @@ -413,10 +417,10 @@ def WeakerThan.ofSubset [AdjunctiveSet F S] [Axiomatized S] {𝓢 𝓣 : S} (h : variable (S) class Compact [AdjunctiveSet F S] where - Γ {𝓢 : S} {φ : F} : 𝓢 ⊢! φ → S - ΓPrf {𝓢 : S} {φ : F} (b : 𝓢 ⊢! φ) : Γ b ⊢! φ - Γ_subset {𝓢 : S} {φ : F} (b : 𝓢 ⊢! φ) : Γ b ⊆ 𝓢 - Γ_finite {𝓢 : S} {φ : F} (b : 𝓢 ⊢! φ) : AdjunctiveSet.Finite (Γ b) + core {𝓢 : S} {φ : F} : 𝓢 ⊢! φ → S + corePrf {𝓢 : S} {φ : F} (b : 𝓢 ⊢! φ) : core b ⊢! φ + core_subset {𝓢 : S} {φ : F} (b : 𝓢 ⊢! φ) : core b ⊆ 𝓢 + core_finite {𝓢 : S} {φ : F} (b : 𝓢 ⊢! φ) : AdjunctiveSet.Finite (core b) variable {S} @@ -426,7 +430,7 @@ variable [AdjunctiveSet F S] [Compact S] lemma finite_provable {𝓢 : S} (h : 𝓢 ⊢ φ) : ∃ 𝓕 : S, 𝓕 ⊆ 𝓢 ∧ AdjunctiveSet.Finite 𝓕 ∧ 𝓕 ⊢ φ := by rcases h with ⟨b⟩ - exact ⟨Γ b, Γ_subset b, Γ_finite b, ⟨ΓPrf b⟩⟩ + exact ⟨core b, core_subset b, core_finite b, ⟨corePrf b⟩⟩ end Compact diff --git a/Foundation/Propositional/Entailment/Minimal/Basic.lean b/Foundation/Propositional/Entailment/Minimal/Basic.lean index a60273e45..1b7ec0f89 100644 --- a/Foundation/Propositional/Entailment/Minimal/Basic.lean +++ b/Foundation/Propositional/Entailment/Minimal/Basic.lean @@ -58,7 +58,7 @@ lemma mdp! [ModusPonens 𝓢] : 𝓢 ⊢ φ ➝ ψ → 𝓢 ⊢ φ → 𝓢 ⊢ rintro ⟨hpq⟩ ⟨hp⟩; exact ⟨hpq ⨀ hp⟩ infixl:90 "⨀" => mdp! -infixl:90 "⨀!" => mdp! +infixl:90 "⨀!" => mdp @@ -111,13 +111,13 @@ export HasAxiomAndElim (and₁ and₂) @[simp] lemma and₁! [HasAxiomAndElim 𝓢] : 𝓢 ⊢ φ ⋏ ψ ➝ φ := ⟨and₁⟩ def K_left [ModusPonens 𝓢] [HasAxiomAndElim 𝓢] (d : 𝓢 ⊢! φ ⋏ ψ) : 𝓢 ⊢! φ := and₁ ⨀ d -@[grind] lemma K!_left [ModusPonens 𝓢] [HasAxiomAndElim 𝓢] (d : 𝓢 ⊢ φ ⋏ ψ) : 𝓢 ⊢ φ := ⟨K_left d.some⟩ +@[grind ->] lemma K!_left [ModusPonens 𝓢] [HasAxiomAndElim 𝓢] (d : 𝓢 ⊢ φ ⋏ ψ) : 𝓢 ⊢ φ := ⟨K_left d.some⟩ @[simp] lemma and₂! [HasAxiomAndElim 𝓢] : 𝓢 ⊢ φ ⋏ ψ ➝ ψ := ⟨and₂⟩ def K_right [ModusPonens 𝓢] [HasAxiomAndElim 𝓢] (d : 𝓢 ⊢! φ ⋏ ψ) : 𝓢 ⊢! ψ := and₂ ⨀ d -@[grind] lemma K!_right [ModusPonens 𝓢] [HasAxiomAndElim 𝓢] (d : 𝓢 ⊢ φ ⋏ ψ) : 𝓢 ⊢ ψ := ⟨K_right d.some⟩ +@[grind ->] lemma K!_right [ModusPonens 𝓢] [HasAxiomAndElim 𝓢] (d : 𝓢 ⊢ φ ⋏ ψ) : 𝓢 ⊢ ψ := ⟨K_right d.some⟩ class HasAxiomAndInst (𝓢 : S) where @@ -127,7 +127,7 @@ export HasAxiomAndInst (and₃) @[simp] lemma and₃! [HasAxiomAndInst 𝓢] : 𝓢 ⊢ φ ➝ ψ ➝ φ ⋏ ψ := ⟨and₃⟩ def K_intro [ModusPonens 𝓢] [HasAxiomAndInst 𝓢] (d₁ : 𝓢 ⊢! φ) (d₂: 𝓢 ⊢! ψ) : 𝓢 ⊢! φ ⋏ ψ := and₃ ⨀ d₁ ⨀ d₂ -@[grind] lemma K!_intro [ModusPonens 𝓢] [HasAxiomAndInst 𝓢] (d₁ : 𝓢 ⊢ φ) (d₂: 𝓢 ⊢ ψ) : 𝓢 ⊢ φ ⋏ ψ := ⟨K_intro d₁.some d₂.some⟩ +@[grind <-] lemma K!_intro [ModusPonens 𝓢] [HasAxiomAndInst 𝓢] (d₁ : 𝓢 ⊢ φ) (d₂: 𝓢 ⊢ ψ) : 𝓢 ⊢ φ ⋏ ψ := ⟨K_intro d₁.some d₂.some⟩ class HasAxiomOrInst (𝓢 : S) where @@ -138,12 +138,12 @@ export HasAxiomOrInst (or₁ or₂) @[simp] lemma or₁! [HasAxiomOrInst 𝓢] : 𝓢 ⊢ φ ➝ φ ⋎ ψ := ⟨or₁⟩ def A_intro_left [HasAxiomOrInst 𝓢] [ModusPonens 𝓢] (d : 𝓢 ⊢! φ) : 𝓢 ⊢! φ ⋎ ψ := or₁ ⨀ d -@[grind] lemma A!_intro_left [HasAxiomOrInst 𝓢] [ModusPonens 𝓢] (d : 𝓢 ⊢ φ) : 𝓢 ⊢ φ ⋎ ψ := ⟨A_intro_left d.some⟩ +@[grind .] lemma A!_intro_left [HasAxiomOrInst 𝓢] [ModusPonens 𝓢] (d : 𝓢 ⊢ φ) : 𝓢 ⊢ φ ⋎ ψ := ⟨A_intro_left d.some⟩ @[simp] lemma or₂! [HasAxiomOrInst 𝓢] : 𝓢 ⊢ ψ ➝ φ ⋎ ψ := ⟨or₂⟩ def A_intro_right [HasAxiomOrInst 𝓢] [ModusPonens 𝓢] (d : 𝓢 ⊢! ψ) : 𝓢 ⊢! φ ⋎ ψ := or₂ ⨀ d -@[grind] lemma A!_intro_right [HasAxiomOrInst 𝓢] [ModusPonens 𝓢] (d : 𝓢 ⊢ ψ) : 𝓢 ⊢ φ ⋎ ψ := ⟨A_intro_right d.some⟩ +@[grind .] lemma A!_intro_right [HasAxiomOrInst 𝓢] [ModusPonens 𝓢] (d : 𝓢 ⊢ ψ) : 𝓢 ⊢ φ ⋎ ψ := ⟨A_intro_right d.some⟩ class HasAxiomOrElim (𝓢 : S) where @@ -182,7 +182,7 @@ variable {𝓢 : S} [ModusPonens 𝓢] {φ ψ χ : F} def CO_of_N [HasAxiomAndElim 𝓢] [NegationEquiv 𝓢] : 𝓢 ⊢! ∼φ → 𝓢 ⊢! φ ➝ ⊥ := λ h => (K_left negEquiv) ⨀ h def N_of_CO [HasAxiomAndElim 𝓢] [NegationEquiv 𝓢] : 𝓢 ⊢! φ ➝ ⊥ → 𝓢 ⊢! ∼φ := λ h => (K_right negEquiv) ⨀ h -@[grind] lemma N!_iff_CO! [HasAxiomAndElim 𝓢] [NegationEquiv 𝓢] : 𝓢 ⊢ ∼φ ↔ 𝓢 ⊢ φ ➝ ⊥ := ⟨λ ⟨h⟩ => ⟨CO_of_N h⟩, λ ⟨h⟩ => ⟨N_of_CO h⟩⟩ +@[grind =] lemma N!_iff_CO! [HasAxiomAndElim 𝓢] [NegationEquiv 𝓢] : 𝓢 ⊢ ∼φ ↔ 𝓢 ⊢ φ ➝ ⊥ := ⟨λ ⟨h⟩ => ⟨CO_of_N h⟩, λ ⟨h⟩ => ⟨N_of_CO h⟩⟩ def E_intro [HasAxiomAndInst 𝓢] (b₁ : 𝓢 ⊢! φ ➝ ψ) (b₂ : 𝓢 ⊢! ψ ➝ φ) : 𝓢 ⊢! φ ⭤ ψ := K_intro b₁ b₂ @@ -291,7 +291,8 @@ def ECKCC [HasAxiomAndInst 𝓢] [HasAxiomAndElim 𝓢] [HasAxiomImplyK 𝓢] [H def CC_of_CK [HasAxiomAndInst 𝓢] [HasAxiomAndElim 𝓢] [HasAxiomImplyK 𝓢] [HasAxiomImplyS 𝓢] (d : 𝓢 ⊢! φ ⋏ ψ ➝ χ) : 𝓢 ⊢! φ ➝ ψ ➝ χ := (K_left $ ECKCC) ⨀ d def CK_of_CC [HasAxiomAndInst 𝓢] [HasAxiomAndElim 𝓢] [HasAxiomImplyK 𝓢] [HasAxiomImplyS 𝓢] (d : 𝓢 ⊢! φ ➝ ψ ➝ χ) : 𝓢 ⊢! φ ⋏ ψ ➝ χ := (K_right $ ECKCC) ⨀ d -@[grind] lemma CK!_iff_CC! [HasAxiomAndInst 𝓢] [HasAxiomAndElim 𝓢] [HasAxiomImplyK 𝓢] [HasAxiomImplyS 𝓢]: (𝓢 ⊢ φ ⋏ ψ ➝ χ) ↔ (𝓢 ⊢ φ ➝ ψ ➝ χ) := iff_of_E! ECKCC! +@[grind =] lemma CK!_iff_CC! [HasAxiomAndInst 𝓢] [HasAxiomAndElim 𝓢] [HasAxiomImplyK 𝓢] [HasAxiomImplyS 𝓢] : + (𝓢 ⊢ φ ⋏ ψ ➝ χ) ↔ (𝓢 ⊢ φ ➝ ψ ➝ χ) := iff_of_E! ECKCC! def CV [HasAxiomVerum 𝓢] [HasAxiomImplyK 𝓢] : 𝓢 ⊢! φ ➝ ⊤ := C_of_conseq verum @[simp] lemma CV! [HasAxiomImplyK 𝓢] [HasAxiomVerum 𝓢] : 𝓢 ⊢ φ ➝ ⊤ := ⟨CV⟩ @@ -353,8 +354,7 @@ def CConjConj [DecidableEq F] (h : Δ ⊆ Γ) : 𝓢 ⊢! Γ.conj ➝ Δ.conj := def left_Conj₂_intro [DecidableEq F] {Γ : List F} {φ : F} (h : φ ∈ Γ) : 𝓢 ⊢! ⋀Γ ➝ φ := have : Γ.idxOf φ < Γ.length := List.idxOf_lt_length_of_mem h - have : Γ[Γ.idxOf φ] = φ := List.getElem_idxOf this - cast (by rw [this]) <| conj₂Nth Γ (Γ.idxOf φ) (by assumption) + cast <| conj₂Nth Γ (Γ.idxOf φ) (by assumption) lemma left_Conj₂!_intro [DecidableEq F] (h : φ ∈ Γ) : 𝓢 ⊢ ⋀Γ ➝ φ := ⟨left_Conj₂_intro h⟩ def Conj₂_intro (Γ : List F) (b : (φ : F) → φ ∈ Γ → 𝓢 ⊢! φ) : 𝓢 ⊢! ⋀Γ := @@ -482,17 +482,17 @@ instance [DecidableEq F] : Axiomatized (FiniteContext F 𝓢) where weakening := fun H b ↦ C_trans (CConj₂Conj₂ H) b instance : Compact (FiniteContext F 𝓢) where - Γ := fun {Γ} _ _ ↦ Γ - ΓPrf := id - Γ_subset := by simp - Γ_finite := by rintro ⟨Γ⟩; simp [AdjunctiveSet.Finite, AdjunctiveSet.set] + core := fun {Γ} _ _ ↦ Γ + corePrf := id + core_subset := by simp + core_finite := by rintro ⟨Γ⟩; simp [AdjunctiveSet.Finite, AdjunctiveSet.set] def nthAxm {Γ} (n : ℕ) (h : n < Γ.length := by simp) : Γ ⊢[𝓢]! Γ[n] := conj₂Nth Γ n h lemma nth_axm! {Γ} (n : ℕ) (h : n < Γ.length := by simp) : Γ ⊢[𝓢] Γ[n] := ⟨nthAxm n h⟩ def byAxm [DecidableEq F] {φ} (h : φ ∈ Γ := by simp) : Γ ⊢[𝓢]! φ := Axiomatized.prfAxm (by simpa) -lemma by_axm! [DecidableEq F] {φ} (h : φ ∈ Γ := by simp) : Γ ⊢[𝓢] φ := Axiomatized.provable_axm _ (by simpa) +lemma by_axm! [DecidableEq F] {φ} (h : φ ∈ Γ := by simp) : Γ ⊢[𝓢] φ := Axiomatized.provable_refl _ (by simpa) def weakening [DecidableEq F] (h : Γ ⊆ Δ) {φ} : Γ ⊢[𝓢]! φ → Δ ⊢[𝓢]! φ := Axiomatized.weakening (by simpa) @@ -666,13 +666,13 @@ instance [DecidableEq F] : Axiomatized (Context F 𝓢) where def byAxm [DecidableEq F] {Γ : Set F} {φ : F} (h : φ ∈ Γ) : Γ *⊢[𝓢]! φ := Axiomatized.prfAxm (by simpa) -lemma by_axm [DecidableEq F] {Γ : Set F} {φ : F} (h : φ ∈ Γ) : Γ *⊢[𝓢] φ := Axiomatized.provable_axm _ (by simpa) +lemma by_axm [DecidableEq F] {Γ : Set F} {φ : F} (h : φ ∈ Γ) : Γ *⊢[𝓢] φ := Axiomatized.provable_refl _ (by simpa) instance : Compact (Context F 𝓢) where - Γ := fun b ↦ AdjunctiveSet.set b.ctx - ΓPrf := fun b ↦ ⟨b.ctx, by simp [AdjunctiveSet.set], b.prf⟩ - Γ_subset := by rintro ⟨Γ⟩ φ b; exact b.subset - Γ_finite := by rintro ⟨Γ⟩; simp [AdjunctiveSet.Finite, AdjunctiveSet.set] + core := fun b ↦ AdjunctiveSet.set b.ctx + corePrf := fun b ↦ ⟨b.ctx, by simp [AdjunctiveSet.set], b.prf⟩ + core_subset := by rintro ⟨Γ⟩ φ b; exact b.subset + core_finite := by rintro ⟨Γ⟩; simp [AdjunctiveSet.Finite, AdjunctiveSet.set] -- lemma provable_iff' [DecidableEq F] {φ : F} : Γ *⊢[𝓢] φ ↔ ∃ Δ : Finset F, (↑Δ ⊆ Γ) ∧ Δ *⊢[𝓢] φ @@ -681,7 +681,7 @@ def deduct [DecidableEq F] {φ ψ : F} {Γ : Set F} : (insert φ Γ) *⊢[𝓢]! have h : ∀ ψ ∈ Δ, ψ = φ ∨ ψ ∈ Γ := by simpa using h let b' : (φ :: Δ.filter (· ≠ φ)) ⊢[𝓢]! ψ := FiniteContext.weakening - (by simp [List.subset_def, List.mem_filter]; rintro χ hr; simp [hr]; tauto) + (by simp [List.subset_def, List.mem_filter]; grind) b ⟨ Δ.filter (· ≠ φ), by intro ψ; simp [List.mem_filter] @@ -714,7 +714,7 @@ def mdp [DecidableEq F] {Γ : Set F} (bpq : Γ *⊢[𝓢]! φ ➝ ψ) (bp : Γ * · exact bp.subset χ hr, FiniteContext.mdp' bpq.prf bp.prf ⟩ -lemma by_axm! [DecidableEq F] (h : φ ∈ Γ) : Γ *⊢[𝓢] φ := Entailment.by_axm _ (by simpa) +lemma by_axm! [DecidableEq F] (h : φ ∈ Γ) : Γ *⊢[𝓢] φ := Entailment.by_axm (by simpa) def emptyPrf {φ : F} : ∅ *⊢[𝓢]! φ → 𝓢 ⊢! φ := by rintro ⟨Γ, hΓ, h⟩; @@ -1386,7 +1386,7 @@ def right_Disj_intro [DecidableEq F] (Γ : List F) (h : φ ∈ Γ) : 𝓢 ⊢! match Γ with | [] => by simp at h | ψ :: Γ => - if e : φ = ψ then cast (by simp [e]) (or₁ : 𝓢 ⊢! φ ➝ φ ⋎ Γ.disj) + if e : φ = ψ then cast (or₁ : 𝓢 ⊢! φ ➝ φ ⋎ Γ.disj) (by simp [e]) else have : φ ∈ Γ := by simpa [e] using h C_trans (right_Disj_intro Γ this) or₂ @@ -1401,14 +1401,14 @@ def right_Disj₂_intro [DecidableEq F] (Γ : List F) (h : φ ∈ Γ) : 𝓢 ⊢ | [] => by simp at h | [ψ] => (show ⋁[ψ] = φ by simp_all) ▸ C_id | ψ :: χ :: Γ => - if e : φ = ψ then cast (by simp [e]) (or₁ : 𝓢 ⊢! φ ➝ φ ⋎ ⋁(χ :: Γ)) + if e : φ = ψ then cast (or₁ : 𝓢 ⊢! φ ➝ φ ⋎ ⋁(χ :: Γ)) (by simp [e]) else have : φ ∈ χ :: Γ := by simpa [e] using h C_trans (right_Disj₂_intro _ this) or₂ def right_Disj₂!_intro [DecidableEq F] (Γ : List F) (h : φ ∈ Γ) : 𝓢 ⊢ φ ➝ ⋁Γ := ⟨right_Disj₂_intro Γ h⟩ def right_Disj'_intro [DecidableEq F] (φ : ι → F) (l : List ι) (h : i ∈ l) : 𝓢 ⊢! φ i ➝ l.disj' φ := - right_Disj₂_intro (l.map φ) (by simp; exact ⟨i, h, rfl⟩) + right_Disj₂_intro (l.map φ) (by simpa using ⟨i, h, rfl⟩) lemma right_Disj'!_intro [DecidableEq F] (φ : ι → F) (l : List ι) (h : i ∈ l) : 𝓢 ⊢ φ i ➝ l.disj' φ := ⟨right_Disj'_intro φ l h⟩ lemma right_Fdisj!_intro [DecidableEq F] (s : Finset F) (h : φ ∈ s) : 𝓢 ⊢ φ ➝ s.disj := right_Disj₂!_intro _ (by simp [h]) @@ -1471,7 +1471,7 @@ end namespace Context -lemma provable_iff_finset [DecidableEq F] {Γ : Set F} {φ : F} : Γ *⊢[𝓢] φ ↔ ∃ Δ : Finset F, (Δ.toSet ⊆ Γ) ∧ Δ *⊢[𝓢] φ := by +lemma provable_iff_finset [DecidableEq F] {Γ : Set F} {φ : F} : Γ *⊢[𝓢] φ ↔ ∃ Δ : Finset F, (↑Δ ⊆ Γ) ∧ Δ *⊢[𝓢] φ := by apply Iff.trans Context.provable_iff; constructor; . rintro ⟨Δ, hΔ₁, hΔ₂⟩; diff --git a/Foundation/ProvabilityLogic/Classification/LetterlessTrace.lean b/Foundation/ProvabilityLogic/Classification/LetterlessTrace.lean index 66eca6382..6429d982f 100644 --- a/Foundation/ProvabilityLogic/Classification/LetterlessTrace.lean +++ b/Foundation/ProvabilityLogic/Classification/LetterlessTrace.lean @@ -995,7 +995,7 @@ lemma compact_add_right (h : (T + U) ⊢ φ) : ∃ (s : { s : Finset (Sentence L apply Entailment.mdp! $ Axiomatized.weakening! (λ _ => by simp) this; apply Entailment.FConj!_iff_forall_provable.mpr; intro ψ hψ; - apply Axiomatized.provable_axm; + apply Axiomatized.provable_refl; grind; lemma compact_add_left (h : (T + U) ⊢ φ) : ∃ (s : { s : Finset (Sentence L) // ↑s ⊆ T }), U ⊢ s.1.conj ➝ φ := by @@ -1044,7 +1044,7 @@ theorem letterless_provabilityLogic apply Entailment.mdp! $ WeakerThan.pbl H; apply Realization.interpret.iff_provable_fconj.mpr; intro B hB; - apply Axiomatized.provable_axm; + apply Axiomatized.provable_refl; right; use B; tauto; From fff8b134b623aadf7f85470f0ca241709b5f8398 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Fri, 6 Mar 2026 20:29:43 +0900 Subject: [PATCH 03/61] rename --- Foundation/FirstOrder/Basic/Calculus.lean | 55 ++++++++------- Foundation/FirstOrder/Basic/Calculus2.lean | 22 +++--- .../FirstOrder/Basic/Semantics/Semantics.lean | 8 +-- .../FirstOrder/Basic/Syntax/Formula.lean | 16 ++--- Foundation/FirstOrder/Basic/Syntax/Rew.lean | 56 +++++++-------- .../DerivabilityCondition/D1.lean | 2 +- .../DerivabilityCondition/D2.lean | 2 +- .../Bootstrapping/Syntax/Formula/Coding.lean | 70 +++++++++---------- .../Bootstrapping/Syntax/Proof/Coding.lean | 66 ++++++++--------- .../Bootstrapping/Syntax/Proof/Typed.lean | 2 +- .../Bootstrapping/Syntax/Theory.lean | 6 +- .../FirstOrder/Completeness/Coding.lean | 16 ++--- .../FirstOrder/Completeness/SearchTree.lean | 32 ++++----- Foundation/FirstOrder/Hauptsatz.lean | 38 +++++----- .../Incompleteness/RosserProvability.lean | 4 +- .../FirstOrder/Intuitionistic/Deduction.lean | 26 +++---- .../FirstOrder/Intuitionistic/Formula.lean | 4 +- Foundation/FirstOrder/Intuitionistic/Rew.lean | 4 +- .../FirstOrder/Kripke/Intuitionistic.lean | 2 +- .../NegationTranslation/GoedelGentzen.lean | 16 ++--- .../FirstOrder/SetTheory/Basic/Axioms.lean | 10 +-- .../FirstOrder/ClassicalEmbedding.lean | 2 +- 22 files changed, 230 insertions(+), 229 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index 2bdc00d30..cecadcbdc 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -1,4 +1,5 @@ module + /- public import Foundation.Logic.Calculus -/ public import Foundation.FirstOrder.Basic.Syntax.Theory public import Mathlib.Data.List.MinMax @@ -11,7 +12,7 @@ namespace LO namespace FirstOrder -abbrev Sequent (L : Language) := List (SyntacticFormula L) +abbrev Sequent (L : Language) := List (Proposition L) open Semiformula @@ -29,7 +30,7 @@ inductive Derivation (𝓢 : Schema L) : Sequent L → Type _ | cut : Derivation 𝓢 (φ :: Γ) → Derivation 𝓢 (∼φ :: Γ) → Derivation 𝓢 Γ /--/ -instance : OneSided (Schema L) (SyntacticFormula L) := ⟨Derivation⟩ +instance : OneSided (Schema L) (Proposition L) := ⟨Derivation⟩ abbrev Schema.pureLK : Schema L := ∅ @@ -47,7 +48,7 @@ notation "𝐋𝐊" => Theory.pureLK namespace Derivation -variable {𝓢 U : Schema L} {Δ Δ₁ Δ₂ Γ : Sequent L} {φ ψ r : SyntacticFormula L} +variable {𝓢 U : Schema L} {Δ Δ₁ Δ₂ Γ : Sequent L} {φ ψ r : Proposition L} open Rewriting LawfulSyntacticRewriting @@ -159,10 +160,10 @@ def exs' {φ} (h : ∃⁰ φ ∈ Δ) (t) (d : 𝓢 ⟹ φ/[t] :: Δ) : 𝓢 ⟹ @[simp] lemma ne_step_max' (n m : ℕ) : n ≠ max m n + 1 := ne_of_lt $ Nat.lt_succ_of_le $ by simp -private lemma neg_ne_and {φ ψ : SyntacticFormula L} : ¬∼φ = φ ⋏ ψ := +private lemma neg_ne_and {φ ψ : Proposition L} : ¬∼φ = φ ⋏ ψ := ne_of_ne_complexity (by simp) -def em {Δ : Sequent L} : {φ : SyntacticFormula L} → (hpos : φ ∈ Δ) → (hneg : ∼φ ∈ Δ) → 𝓢 ⟹ Δ +def em {Δ : Sequent L} : {φ : Proposition L} → (hpos : φ ∈ Δ) → (hneg : ∼φ ∈ Δ) → 𝓢 ⟹ Δ | ⊤, hpos, hneg => verum' hpos | ⊥, hpos, hneg => verum' hneg | .rel R v, hpos, hneg => axL' R v hpos hneg @@ -195,21 +196,21 @@ def em {Δ : Sequent L} : {φ : SyntacticFormula L} → (hpos : φ ∈ Δ) → ( this.all.wk (by simpa using hneg) termination_by φ => φ.complexity -instance : Tait (SyntacticFormula L) (Schema L) where +instance : Tait (Proposition L) (Schema L) where verum := fun _ Δ => verum' (by simp) and := fun dp dq => dp.and dq or := fun d => d.or wk := fun d ss => d.wk ss em := fun hp hn => em hp hn -instance : Tait.Cut (SyntacticFormula L) (Schema L) where +instance : Tait.Cut (Proposition L) (Schema L) where cut {_ _ _ dp dn} := cut dp dn protected def id {φ} (hφ : φ ∈ 𝓢) : 𝓢 ⟹ ∼φ :: Δ → 𝓢 ⟹ Δ := fun b ↦ Tait.cut (Tait.wk (axm hφ) (by simp)) b def provableOfDerivable {φ} (b : 𝓢 ⟹. φ) : 𝓢 ⊢! φ := b -def specialize {φ : SyntacticSemiformula L 1} (t : SyntacticTerm L) : +def specialize {φ : Semiproposition L 1} (t : SyntacticTerm L) : 𝓢 ⟹ (∀⁰ φ) :: Γ → 𝓢 ⟹ φ/[t] :: Γ := fun d ↦ have : 𝓢 ⟹ ∼φ/[t] :: φ/[t] :: Γ := Tait.em (φ := φ/[t]) (by simp) (by simp) have dn : 𝓢 ⟹ ∼(∀⁰ φ) :: φ/[t] :: Γ := by @@ -219,7 +220,7 @@ def specialize {φ : SyntacticSemiformula L 1} (t : SyntacticTerm L) : Derivation.wk d (List.cons_subset_cons _ <| by simp) Derivation.cut dp dn -def specializes : {k : ℕ} → {φ : SyntacticSemiformula L k} → {Γ : Sequent L} → (v : Fin k → SyntacticTerm L) → +def specializes : {k : ℕ} → {φ : Semiproposition L k} → {Γ : Sequent L} → (v : Fin k → SyntacticTerm L) → 𝓢 ⟹ (∀⁰* φ) :: Γ → 𝓢 ⟹ (φ ⇜ v) :: Γ | 0, φ, Γ, _, b => Derivation.cast b (by simp) | k + 1, φ, Γ, v, b => @@ -229,7 +230,7 @@ def specializes : {k : ℕ} → {φ : SyntacticSemiformula L k} → {Γ : Sequen ext x <;> simp [Rew.comp_app] cases x using Fin.cases <;> simp) -def instances : {k : ℕ} → {φ : SyntacticSemiformula L k} → {Γ : Sequent L} → {v : Fin k → SyntacticTerm L} → +def instances : {k : ℕ} → {φ : Semiproposition L k} → {Γ : Sequent L} → {v : Fin k → SyntacticTerm L} → 𝓢 ⟹ (φ ⇜ v) :: Γ → 𝓢 ⟹ (∃⁰* φ) :: Γ | 0, φ, Γ, _, b => Derivation.cast b (by simp) | k + 1, φ, Γ, v, b => @@ -240,7 +241,7 @@ def instances : {k : ℕ} → {φ : SyntacticSemiformula L k} → {Γ : Sequent cases x using Fin.cases <;> simp instances (k := k) (v := (v ·.succ)) (Derivation.cast this (by simp)) -def allClosureFixitr {φ : SyntacticFormula L} (dp : 𝓢 ⊢! φ) : (m : ℕ) → 𝓢 ⊢! ∀⁰* Rew.fixitr 0 m ▹ φ +def allClosureFixitr {φ : Proposition L} (dp : 𝓢 ⊢! φ) : (m : ℕ) → 𝓢 ⊢! ∀⁰* Rew.fixitr 0 m ▹ φ | 0 => by simpa | m + 1 => by simp only [allClosure_fixitr, Nat.reduceAdd] @@ -300,7 +301,7 @@ def trans (F : U ⊢!* 𝓢) {Γ : Sequent L} : 𝓢 ⟹ Γ → U ⟹ Γ | cut d₁ d₂ => cut (trans F d₁) (trans F d₂) | axm h => F h -instance : Tait.Axiomatized (SyntacticFormula L) (Schema L) where +instance : Tait.Axiomatized (Proposition L) (Schema L) where axm {_ _ h} := axm h trans {_ _ _ F d} := trans (fun h ↦ F _ h) d @@ -314,13 +315,13 @@ def invClose (b : 𝓢 ⊢! φ.univCl') : 𝓢 ⊢! φ := cut (wk b (by simp)) ( def invClose! (b : 𝓢 ⊢ φ.univCl') : 𝓢 ⊢ φ := ⟨invClose b.get⟩ -def compact {Γ : Sequent L} : 𝓢 ⟹ Γ → (s : { s : Finset (SyntacticFormula L) // ↑s ⊆ 𝓢}) × (s : Schema L) ⟹ Γ +def compact {Γ : Sequent L} : 𝓢 ⟹ Γ → (s : { s : Finset (Proposition L) // ↑s ⊆ 𝓢}) × (s : Schema L) ⟹ Γ | axL r v => ⟨⟨∅, by simp⟩, axL r v⟩ | verum => ⟨⟨∅, by simp⟩, verum⟩ | and d₁ d₂ => let ⟨s₁, d₁⟩ := compact d₁ let ⟨s₂, d₂⟩ := compact d₂ - ⟨⟨(s₁ ∪ s₂ : Finset (SyntacticFormula L)), by simp [s₁.prop, s₂.prop]⟩, + ⟨⟨(s₁ ∪ s₂ : Finset (Proposition L)), by simp [s₁.prop, s₂.prop]⟩, and (Tait.ofAxiomSubset (by simp) d₁) (Tait.ofAxiomSubset (by simp) d₂)⟩ | or d => let ⟨s, d⟩ := compact d @@ -331,7 +332,7 @@ def compact {Γ : Sequent L} : 𝓢 ⟹ Γ → (s : { s : Finset (SyntacticFormu | cut d₁ d₂ => let ⟨s₁, d₁⟩ := compact d₁ let ⟨s₂, d₂⟩ := compact d₂ - ⟨⟨(s₁ ∪ s₂ : Finset (SyntacticFormula L)), by simp [s₁.prop, s₂.prop]⟩, + ⟨⟨(s₁ ∪ s₂ : Finset (Proposition L)), by simp [s₁.prop, s₂.prop]⟩, cut (Tait.ofAxiomSubset (by simp) d₁) (Tait.ofAxiomSubset (by simp) d₂)⟩ | axm (φ := φ) h => ⟨⟨{φ}, by simp [h]⟩, axm (by simp)⟩ @@ -380,7 +381,7 @@ section Hom variable {L₁ : Language} {L₂ : Language} {𝓢₁ : Schema L₁} {Δ₁ : Sequent L₁} -lemma shifts_image (Φ : L₁ →ᵥ L₂) {Δ : List (SyntacticFormula L₁)} : +lemma shifts_image (Φ : L₁ →ᵥ L₂) {Δ : List (Proposition L₁)} : (Δ.map <| Semiformula.lMap Φ)⁺ = (Δ⁺.map <| Semiformula.lMap Φ) := by simp [Rewriting.shifts, Function.comp_def, Semiformula.lMap_shift] @@ -420,8 +421,8 @@ end Hom omit [L.DecidableEq] -private lemma map_subst_eq_free (φ : SyntacticSemiformula L 1) (h : ¬φ.FVar? m) : - (@Rew.rewriteMap L ℕ ℕ 0 (fun x ↦ if x = m then 0 else x + 1)) ▹ (φ/[&m] : SyntacticFormula L) = Rewriting.free φ := by +private lemma map_subst_eq_free (φ : Semiproposition L 1) (h : ¬φ.FVar? m) : + (@Rew.rewriteMap L ℕ ℕ 0 (fun x ↦ if x = m then 0 else x + 1)) ▹ (φ/[&m] : Proposition L) = Rewriting.free φ := by simp only [← TransitiveRewriting.comp_app] exact Semiformula.rew_eq_of_funEqOn (by simp [Rew.comp_app]) (fun x hx => by simp [Rew.comp_app, ne_of_mem_of_not_mem hx h]) @@ -432,20 +433,20 @@ private lemma map_rewriteMap_eq_shifts (Δ : Sequent L) (h : ∀ φ ∈ Δ, ¬φ intro φ hp; exact rew_eq_of_funEqOn₀ (by intro x hx; simp [ne_of_mem_of_not_mem hx (h φ hp)]) -def genelalizeByNewver {φ : SyntacticSemiformula L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) +def genelalizeByNewver {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) (d : 𝓢 ⟹ φ/[&m] :: Δ) : 𝓢 ⟹ (∀⁰ φ) :: Δ := by have : 𝓢 ⟹ (Rewriting.free φ) :: Δ⁺ := Derivation.cast (Derivation.map d (fun x => if x = m then 0 else x + 1)) (by simp [map_subst_eq_free φ hp, map_rewriteMap_eq_shifts Δ hΔ]) exact all this -def exOfInstances (v : List (SyntacticTerm L)) (φ : SyntacticSemiformula L 1) +def exOfInstances (v : List (SyntacticTerm L)) (φ : Semiproposition L 1) (h : 𝓢 ⟹ v.map (φ/[·]) ++ Γ) : 𝓢 ⟹ (∃⁰ φ) :: Γ := by induction' v with t v ih generalizing Γ · exact weakening h (List.subset_cons_self _ _) · exact (ih (Γ := (∃⁰ φ) :: Γ) ((exs t h).wk (by simp))).wk (by simp) -def exOfInstances' (v : List (SyntacticTerm L)) (φ : SyntacticSemiformula L 1) +def exOfInstances' (v : List (SyntacticTerm L)) (φ : Semiproposition L 1) (h : 𝓢 ⟹ (∃⁰ φ) :: v.map (φ/[·]) ++ Γ) : 𝓢 ⟹ (∃⁰ φ) :: Γ := (exOfInstances (Γ := (∃⁰ φ) :: Γ) v φ (h.wk <| by simp)).wk (by simp) @@ -453,13 +454,13 @@ end Derivation def newVar (Γ : Sequent L) : ℕ := (Γ.map Semiformula.fvSup).foldr max 0 -lemma not_fvar?_newVar {φ : SyntacticFormula L} {Γ : Sequent L} (h : φ ∈ Γ) : ¬FVar? φ (newVar Γ) := +lemma not_fvar?_newVar {φ : Proposition L} {Γ : Sequent L} (h : φ ∈ Γ) : ¬FVar? φ (newVar Γ) := not_fvar?_of_lt_fvSup φ (by simpa [newVar] using List.le_max_of_le (List.mem_map_of_mem h) (by simp)) namespace Derivation open Semiformula -variable {P : SyntacticFormula L → Prop} {𝓢 : Schema L} {Δ : Sequent L} +variable {P : Proposition L → Prop} {𝓢 : Schema L} {Δ : Sequent L} def allNvar {φ} (h : ∀⁰ φ ∈ Δ) : 𝓢 ⟹ φ/[&(newVar Δ)] :: Δ → 𝓢 ⟹ Δ := fun b ↦ let b : 𝓢 ⟹ (∀⁰ φ) :: Δ := @@ -634,10 +635,10 @@ def coe_provable_iff_provable_coe {σ : Sentence L} : def coe_unprovable_iff_unprovable_coe {σ} : (𝓢 : Theory L) ⊬ σ ↔ 𝓢 ⊬ ↑σ := coe_provable_iff_provable_coe.not -def provable_univCl_iff {φ : SyntacticFormula L} : +def provable_univCl_iff {φ : Proposition L} : (𝓢 : Theory L) ⊢ φ.univCl ↔ 𝓢 ⊢ φ := Iff.trans coe_provable_iff_provable_coe (by simp [Schema.close!_iff]) -def unprovable_univCl_iff {φ : SyntacticFormula L} : +def unprovable_univCl_iff {φ : Proposition L} : (𝓢 : Theory L) ⊬ φ.univCl ↔ 𝓢 ⊬ φ := provable_univCl_iff.not instance (𝓢 𝓣 : Schema L) [𝓢 ⪯ 𝓣] : 𝓢.toTheory ⪯ 𝓣.toTheory := @@ -657,12 +658,12 @@ namespace Schema variable {𝓢 : Schema L} -def specialize! (φ : SyntacticSemiformula L 1) (t : SyntacticTerm L) : 𝓢 ⊢! ∀⁰ φ ➝ φ/[t] := +def specialize! (φ : Semiproposition L 1) (t : SyntacticTerm L) : 𝓢 ⊢! ∀⁰ φ ➝ φ/[t] := have : 𝓢 ⟹ [(∼φ)/[t], φ/[t]] := Derivation.em (φ := φ/[t]) (by simp) (by simp) have : 𝓢 ⟹ [∃⁰ ∼φ, φ/[t]] := this.exs t this.or.cast (by simp [Semiformula.imp_eq]) -lemma specialize (φ : SyntacticSemiformula L 1) (t : SyntacticTerm L) : 𝓢 ⊢ ∀⁰ φ ➝ φ/[t] := ⟨specialize! φ t⟩ +lemma specialize (φ : Semiproposition L 1) (t : SyntacticTerm L) : 𝓢 ⊢ ∀⁰ φ ➝ φ/[t] := ⟨specialize! φ t⟩ end Schema diff --git a/Foundation/FirstOrder/Basic/Calculus2.lean b/Foundation/FirstOrder/Basic/Calculus2.lean index ca3484579..bef5f2be7 100644 --- a/Foundation/FirstOrder/Basic/Calculus2.lean +++ b/Foundation/FirstOrder/Basic/Calculus2.lean @@ -10,25 +10,25 @@ variable {L : Language} [L.DecidableEq] section derivation2 -inductive Derivation2 (𝓢 : Schema L) : Finset (SyntacticFormula L) → Type _ -| closed (Γ) (φ : SyntacticFormula L) : φ ∈ Γ → ∼φ ∈ Γ → Derivation2 𝓢 Γ -| axm {Γ} (φ : SyntacticFormula L) : φ ∈ 𝓢 → φ ∈ Γ → Derivation2 𝓢 Γ +inductive Derivation2 (𝓢 : Schema L) : Finset (Proposition L) → Type _ +| closed (Γ) (φ : Proposition L) : φ ∈ Γ → ∼φ ∈ Γ → Derivation2 𝓢 Γ +| axm {Γ} (φ : Proposition L) : φ ∈ 𝓢 → φ ∈ Γ → Derivation2 𝓢 Γ | verum {Γ} : ⊤ ∈ Γ → Derivation2 𝓢 Γ -| and {Γ} {φ ψ : SyntacticFormula L} : φ ⋏ ψ ∈ Γ → Derivation2 𝓢 (insert φ Γ) → Derivation2 𝓢 (insert ψ Γ) → Derivation2 𝓢 Γ -| or {Γ} {φ ψ : SyntacticFormula L} : φ ⋎ ψ ∈ Γ → Derivation2 𝓢 (insert φ (insert ψ Γ)) → Derivation2 𝓢 Γ -| all {Γ} {φ : SyntacticSemiformula L 1} : ∀⁰ φ ∈ Γ → Derivation2 𝓢 (insert (Rewriting.free φ) (Γ.image Rewriting.shift)) → Derivation2 𝓢 Γ -| exs {Γ} {φ : SyntacticSemiformula L 1} : ∃⁰ φ ∈ Γ → (t : SyntacticTerm L) → Derivation2 𝓢 (insert (φ/[t]) Γ) → Derivation2 𝓢 Γ +| and {Γ} {φ ψ : Proposition L} : φ ⋏ ψ ∈ Γ → Derivation2 𝓢 (insert φ Γ) → Derivation2 𝓢 (insert ψ Γ) → Derivation2 𝓢 Γ +| or {Γ} {φ ψ : Proposition L} : φ ⋎ ψ ∈ Γ → Derivation2 𝓢 (insert φ (insert ψ Γ)) → Derivation2 𝓢 Γ +| all {Γ} {φ : Semiproposition L 1} : ∀⁰ φ ∈ Γ → Derivation2 𝓢 (insert (Rewriting.free φ) (Γ.image Rewriting.shift)) → Derivation2 𝓢 Γ +| exs {Γ} {φ : Semiproposition L 1} : ∃⁰ φ ∈ Γ → (t : SyntacticTerm L) → Derivation2 𝓢 (insert (φ/[t]) Γ) → Derivation2 𝓢 Γ | wk {Δ Γ} : Derivation2 𝓢 Δ → Δ ⊆ Γ → Derivation2 𝓢 Γ | shift {Γ} : Derivation2 𝓢 Γ → Derivation2 𝓢 (Γ.image Rewriting.shift) | cut {Γ φ} : Derivation2 𝓢 (insert φ Γ) → Derivation2 𝓢 (insert (∼φ) Γ) → Derivation2 𝓢 Γ scoped infix:45 " ⟹₂" => Derivation2 -abbrev Derivable2 (𝓢 : Schema L) (Γ : Finset (SyntacticFormula L)) := Nonempty (𝓢 ⟹₂ Γ) +abbrev Derivable2 (𝓢 : Schema L) (Γ : Finset (Proposition L)) := Nonempty (𝓢 ⟹₂ Γ) scoped infix:45 " ⟹₂! " => Derivable2 -abbrev Derivable2SingleConseq (𝓢 : Schema L) (φ : SyntacticFormula L) : Prop := 𝓢 ⟹₂! {φ} +abbrev Derivable2SingleConseq (𝓢 : Schema L) (φ : Proposition L) : Prop := 𝓢 ⟹₂! {φ} scoped infix: 45 " ⊢!₂! " => Derivable2SingleConseq @@ -63,7 +63,7 @@ def Derivation.toDerivation2 (𝓢) {Γ : Sequent L} : 𝓢 ⟹ Γ → 𝓢 ⟹ (Derivation2.wk (Derivation.toDerivation2 𝓢 d₁) (by simp)) (Derivation2.wk (Derivation.toDerivation2 𝓢 d₂) (by simp)) -noncomputable def Derivation2.toDerivation {Γ : Finset (SyntacticFormula L)} : 𝓢 ⟹₂ Γ → 𝓢 ⟹ Γ.toList +noncomputable def Derivation2.toDerivation {Γ : Finset (Proposition L)} : 𝓢 ⟹₂ Γ → 𝓢 ⟹ Γ.toList | Derivation2.closed Γ φ hp hn => Derivation.em (φ := φ) (by simp [hp]) (by simp [hn]) | Derivation2.axm φ hp h => Tait.wk (Derivation.axm hp) (by simp_all) | Derivation2.verum h => Tait.verum' (by simp [h]) @@ -86,7 +86,7 @@ noncomputable def Derivation2.toDerivation {Γ : Finset (SyntacticFormula L)} : (Tait.wk d.toDerivation <| by intro x; simp) (Tait.wk dn.toDerivation <| by intro x; simp) -lemma derivable_iff_derivable2 {Γ : List (SyntacticFormula L)} : 𝓢 ⟹! Γ ↔ 𝓢 ⟹₂! Γ.toFinset := by +lemma derivable_iff_derivable2 {Γ : List (Proposition L)} : 𝓢 ⟹! Γ ↔ 𝓢 ⟹₂! Γ.toFinset := by constructor · rintro ⟨d⟩; exact ⟨by simpa using Derivation.toDerivation2 𝓢 d⟩ · rintro ⟨d⟩; exact ⟨.wk d.toDerivation (by intro x; simp)⟩ diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index 59b80ee4f..a55fc1bd1 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -413,12 +413,12 @@ section Syntactic variable (ε : ℕ → M) -@[simp] lemma eval_free (φ : SyntacticSemiformula L (n + 1)) : +@[simp] lemma eval_free (φ : Semiproposition L (n + 1)) : Eval s e (a :>ₙ ε) (@Rew.free L n ▹ φ) ↔ Eval s (e <: a) ε φ := by simp only [eval_rew, Function.comp_def, Rew.free_fvar, Semiterm.val_fvar, Nat.cases_succ, Nat.succ_eq_add_one] apply iff_of_eq; congr; funext x; cases x using Fin.lastCases <;> simp -@[simp] lemma eval_shift (φ : SyntacticSemiformula L n) : +@[simp] lemma eval_shift (φ : Semiproposition L n) : Eval s e (a :>ₙ ε) (@Rew.shift L n ▹ φ) ↔ Eval s e ε φ := by simp [eval_rew, Function.comp_def] @@ -483,7 +483,7 @@ lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeV fun x ↦ eval_toEmpty (φ := φ) (e := (x :> e)) (by simpa using hp) simp [this] -@[simp] lemma eval_univCl' {ε} (φ : SyntacticFormula L) : +@[simp] lemma eval_univCl' {ε} (φ : Proposition L) : Evalf s ε φ.univCl' ↔ ∀ f, Evalf s f φ := by simp only [univCl', eval_allClosure, eval_rew, Matrix.empty_eq, Function.comp_def] constructor @@ -494,7 +494,7 @@ lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeV refine (eval_iff_of_funEqOn φ ?_).mp (h (fun x ↦ if hx : x < φ.fvSup then f ⟨x, by simp [hx]⟩ else ε 0)) intro x hx; simp [Rew.fixitr_fvar, lt_fvSup_of_fvar? hx] -@[simp] lemma eval_univCl [Nonempty M] (φ : SyntacticFormula L) : +@[simp] lemma eval_univCl [Nonempty M] (φ : Proposition L) : Evalb s ![] φ.univCl ↔ ∀ f, Evalf s f φ := by haveI : Inhabited M := Classical.inhabited_of_nonempty inferInstance simp [Semiformula.univCl, ←eval_toEmpty (f := default)] diff --git a/Foundation/FirstOrder/Basic/Syntax/Formula.lean b/Foundation/FirstOrder/Basic/Syntax/Formula.lean index f6955fb5a..7d30a0eb1 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Formula.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Formula.lean @@ -37,9 +37,9 @@ abbrev Sentence (L : Language) := Formula L Empty abbrev Semisentence (L : Language) (n : ℕ) := Semiformula L Empty n -abbrev SyntacticSemiformula (L : Language) (n : ℕ) := Semiformula L ℕ n +abbrev Semiproposition (L : Language) (n : ℕ) := Semiformula L ℕ n -abbrev SyntacticFormula (L : Language) := SyntacticSemiformula L 0 +abbrev Proposition (L : Language) := Semiproposition L 0 abbrev ArithmeticSemiformula (ξ : Type*) (n : ℕ) := Semiformula ℒₒᵣ ξ n @@ -49,9 +49,9 @@ abbrev ArithmeticSemisentence (n : ℕ) := Semisentence ℒₒᵣ n abbrev ArithmeticSentence := Sentence ℒₒᵣ -abbrev ArithmeticSyntacticSemiformula (n : ℕ) := SyntacticSemiformula ℒₒᵣ n +abbrev ArithmeticSemiproposition (n : ℕ) := Semiproposition ℒₒᵣ n -abbrev ArithmeticSyntacticFormula := SyntacticFormula ℒₒᵣ +abbrev ArithmeticProposition := Proposition ℒₒᵣ namespace Semiformula @@ -450,9 +450,9 @@ abbrev FVar? (φ : Semiformula L ξ n) (x : ξ) : Prop := x ∈ φ.freeVariables @[simp] lemma fvar?_allClosure (x) (φ : Semiformula L ξ n) : (∀⁰* φ).FVar? x ↔ φ.FVar? x := by simp [FVar?] -def fvSup (φ : SyntacticSemiformula L n) : ℕ := (φ.freeVariables.max).recBotCoe 0 .succ +def fvSup (φ : Semiproposition L n) : ℕ := (φ.freeVariables.max).recBotCoe 0 .succ -lemma lt_fvSup_of_fvar? {φ : SyntacticSemiformula L n} : φ.FVar? m → m < φ.fvSup := by +lemma lt_fvSup_of_fvar? {φ : Semiproposition L n} : φ.FVar? m → m < φ.fvSup := by unfold fvSup FVar? intro hm have : ∃ s : ℕ, φ.freeVariables.max = s := Finset.max_of_mem hm @@ -462,10 +462,10 @@ lemma lt_fvSup_of_fvar? {φ : SyntacticSemiformula L n} : φ.FVar? m → m < φ. exact WithBot.coe_le_coe.mp this simpa [hs, WithBot.recBotCoe] using Nat.lt_add_one_of_le this -lemma not_fvar?_of_lt_fvSup (φ : SyntacticSemiformula L n) (h : φ.fvSup ≤ m) : ¬φ.FVar? m := +lemma not_fvar?_of_lt_fvSup (φ : Semiproposition L n) (h : φ.fvSup ≤ m) : ¬φ.FVar? m := fun hm ↦ (lt_self_iff_false _).mp (lt_of_le_of_lt h <| lt_fvSup_of_fvar? hm) -@[simp] lemma not_fvar?_fvSup (φ : SyntacticSemiformula L n) : ¬φ.FVar? φ.fvSup := +@[simp] lemma not_fvar?_fvSup (φ : Semiproposition L n) : ¬φ.FVar? φ.fvSup := not_fvar?_of_lt_fvSup φ (by simp) end FreeVariables diff --git a/Foundation/FirstOrder/Basic/Syntax/Rew.lean b/Foundation/FirstOrder/Basic/Syntax/Rew.lean index 607b089f9..59de2020e 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Rew.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Rew.lean @@ -73,9 +73,9 @@ abbrev subst (φ : Semiformula L ξ n) (v : Fin n → Semiterm L ξ m) : Semifor @[coe] abbrev emb [IsEmpty o] (φ : Semiformula L o n) : Semiformula L ξ n := Rewriting.emb φ -abbrev free (φ : SyntacticSemiformula L (n + 1)) : SyntacticSemiformula L n := Rewriting.free φ +abbrev free (φ : Semiproposition L (n + 1)) : Semiproposition L n := Rewriting.free φ -abbrev shift (φ : SyntacticSemiformula L n) : SyntacticSemiformula L n := Rewriting.shift φ +abbrev shift (φ : Semiproposition L n) : Semiproposition L n := Rewriting.shift φ lemma rew_rel (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} (r : L.Rel k) (v : Fin k → Semiterm L ξ₁ n₁) : ω ▹ rel r v = rel r fun i ↦ ω (v i) := rfl @@ -169,7 +169,7 @@ instance : TransitiveRewriting L ξ₁ (Semiformula L ξ₁) ξ₂ (Semiformula instance : InjMapRewriting L ξ (Semiformula L ξ) ζ (Semiformula L ζ) where smul_map_injective := map_inj -instance : LawfulSyntacticRewriting L (SyntacticSemiformula L) where +instance : LawfulSyntacticRewriting L (Semiproposition L) where @[simp] lemma complexity_rew (ω : Rew L ξ₁ n₁ ξ₂ n₂) (φ : Semiformula L ξ₁ n₁) : (ω ▹ φ).complexity = φ.complexity := by induction φ using Semiformula.rec' generalizing n₂ <;> simp [*, rew_rel, rew_nrel] @@ -238,9 +238,9 @@ lemma eq_bexs_iff {φ : Semiformula L ξ₁ n₁} {ψ₁ ψ₂ : Semiformula L end -instance : Coe (Semisentence L n) (SyntacticSemiformula L n) := ⟨Rewriting.emb (ξ := ℕ)⟩ +instance : Coe (Semisentence L n) (Semiproposition L n) := ⟨Rewriting.emb (ξ := ℕ)⟩ -@[simp] lemma coe_inj (σ π : Semisentence L n) : (σ : SyntacticSemiformula L n) = π ↔ σ = π := Rewriting.emb_injective.eq_iff +@[simp] lemma coe_inj (σ π : Semisentence L n) : (σ : Semiproposition L n) = π ↔ σ = π := Rewriting.emb_injective.eq_iff lemma coe_rel [IsEmpty ο] {k : ℕ} (R : L.Rel k) (v : Fin k → Semiterm L ο n) : (Rewriting.emb (rel R v) : Semiformula L ξ n) = (rel R fun i ↦ Rew.emb (v i)) := by rfl @@ -249,24 +249,24 @@ lemma coe_nrel [IsEmpty ο] {k : ℕ} (R : L.Rel k) (v : Fin k → Semiterm L ο (Rewriting.emb (nrel R v) : Semiformula L ξ n) = (nrel R fun i ↦ Rew.emb (v i)) := by rfl lemma coe_subst_eq_subst_coe (φ : Semisentence L k) (v : Fin k → ClosedSemiterm L n) : - (↑(φ ⇜ v) : SyntacticSemiformula L n) = (↑φ : SyntacticSemiformula L k)⇜(fun i ↦ (↑(v i) : Semiterm L ℕ n)) := + (↑(φ ⇜ v) : Semiproposition L n) = (↑φ : Semiproposition L k)⇜(fun i ↦ (↑(v i) : Semiterm L ℕ n)) := Rewriting.emb_subst_eq_subst_emb φ v lemma coe_subst_eq_subst_coe₁ (φ : Semisentence L 1) (t : ClosedSemiterm L n) : - (↑(φ/[t]) : SyntacticSemiformula L n) = (↑φ : SyntacticSemiformula L 1)/[(↑t : Semiterm L ℕ n)] := + (↑(φ/[t]) : Semiproposition L n) = (↑φ : Semiproposition L 1)/[(↑t : Semiterm L ℕ n)] := Rewriting.emb_subst_eq_subst_coe₁ φ t @[elab_as_elim] -def formulaRec {C : SyntacticFormula L → Sort _} +def formulaRec {C : Proposition L → Sort _} (verum : C ⊤) (falsum : C ⊥) (rel : ∀ {l : ℕ} (r : L.Rel l) (v : Fin l → SyntacticTerm L), C (rel r v)) (nrel : ∀ {l : ℕ} (r : L.Rel l) (v : Fin l → SyntacticTerm L), C (nrel r v)) - (and : ∀ (φ ψ : SyntacticFormula L), C φ → C ψ → C (φ ⋏ ψ)) - (or : ∀ (φ ψ : SyntacticFormula L), C φ → C ψ → C (φ ⋎ ψ)) - (all : ∀ (φ : SyntacticSemiformula L 1), C (Rewriting.free φ) → C (∀⁰ φ)) - (ex : ∀ (φ : SyntacticSemiformula L 1), C (Rewriting.free φ) → C (∃⁰ φ)) : - ∀ (φ : SyntacticFormula L), C φ + (and : ∀ (φ ψ : Proposition L), C φ → C ψ → C (φ ⋏ ψ)) + (or : ∀ (φ ψ : Proposition L), C φ → C ψ → C (φ ⋎ ψ)) + (all : ∀ (φ : Semiproposition L 1), C (Rewriting.free φ) → C (∀⁰ φ)) + (ex : ∀ (φ : Semiproposition L 1), C (Rewriting.free φ) → C (∃⁰ φ)) : + ∀ (φ : Proposition L), C φ | ⊤ => verum | ⊥ => falsum | .rel r v => rel r v @@ -392,7 +392,7 @@ section univCl @[simp] lemma fvSup_sentence (σ : Semisentence L n) : (Rewriting.emb σ).fvSup = 0 := by induction σ using rec' <;> simp [fvSup] -private lemma not_fvar?_fixitr_fvSup (φ : SyntacticFormula L) : ¬(Rew.fixitr 0 φ.fvSup ▹ φ).FVar? x := by +private lemma not_fvar?_fixitr_fvSup (φ : Proposition L) : ¬(Rew.fixitr 0 φ.fvSup ▹ φ).FVar? x := by rw [Rew.eq_bind (Rew.fixitr 0 φ.fvSup)] simp only [Function.comp_def, Rew.fixitr_bvar, Rew.fixitr_fvar, Fin.natAdd_mk, zero_add] intro h @@ -401,7 +401,7 @@ private lemma not_fvar?_fixitr_fvSup (φ : SyntacticFormula L) : ¬(Rew.fixitr 0 · have : z < φ.fvSup := lt_fvSup_of_fvar? hz simp [this] at hx -@[simp] lemma subst_comp_fixitr_eq_map (φ : SyntacticFormula L) (f : ℕ → SyntacticTerm L) : +@[simp] lemma subst_comp_fixitr_eq_map (φ : Proposition L) (f : ℕ → SyntacticTerm L) : (Rew.fixitr 0 φ.fvSup ▹ φ)⇜(fun x ↦ f x) = Rew.rewrite f ▹ φ := by unfold Rewriting.subst; rw [← TransitiveRewriting.comp_app] apply rew_eq_of_funEqOn @@ -409,7 +409,7 @@ private lemma not_fvar?_fixitr_fvSup (φ : SyntacticFormula L) : ¬(Rew.fixitr 0 · intro x hx simp [Rew.comp_app, Rew.fixitr_fvar, Semiformula.lt_fvSup_of_fvar? hx] -@[simp] lemma subst_comp_fixitr (φ : SyntacticFormula L) : +@[simp] lemma subst_comp_fixitr (φ : Proposition L) : (Rew.fixitr 0 φ.fvSup ▹ φ)⇜(fun x ↦ (&x : SyntacticTerm L)) = φ := by unfold Rewriting.subst; rw [← TransitiveRewriting.comp_app] apply rew_eq_self_of @@ -417,24 +417,24 @@ private lemma not_fvar?_fixitr_fvSup (φ : SyntacticFormula L) : ¬(Rew.fixitr 0 · intro x hx simp [Rew.comp_app, Rew.fixitr_fvar, Semiformula.lt_fvSup_of_fvar? hx] -def univCl' (φ : SyntacticFormula L) : SyntacticFormula L := ∀⁰* (@Rew.fixitr L 0 φ.fvSup ▹ φ) +def univCl' (φ : Proposition L) : Proposition L := ∀⁰* (@Rew.fixitr L 0 φ.fvSup ▹ φ) -@[simp] lemma rew_univCl' (φ : SyntacticFormula L) (ω : SyntacticRew L 0 0) : +@[simp] lemma rew_univCl' (φ : Proposition L) (ω : SyntacticRew L 0 0) : ω ▹ φ.univCl' = φ.univCl' := rew_eq_self_of (by simp) (by simp [univCl', not_fvar?_fixitr_fvSup]) -lemma univCl'_eq_self_of (φ : SyntacticFormula L) (h : φ.freeVariables = ∅) : φ.univCl' = φ := by +lemma univCl'_eq_self_of (φ : Proposition L) (h : φ.freeVariables = ∅) : φ.univCl' = φ := by have : φ.fvSup = 0 := by simp [fvSup, h] simp only [univCl']; rw [this]; simp @[simp] lemma senetnce_univCl'_eq_self (σ : Sentence L) : - (σ : SyntacticFormula L).univCl' = σ := univCl'_eq_self_of _ (by simp) + (σ : Proposition L).univCl' = σ := univCl'_eq_self_of _ (by simp) -@[simp] lemma fvarList_univCl' (φ : SyntacticFormula L) : φ.univCl'.freeVariables = ∅ := by +@[simp] lemma fvarList_univCl' (φ : Proposition L) : φ.univCl'.freeVariables = ∅ := by ext x suffices x ∉ φ.univCl'.freeVariables by simpa simpa [univCl'] using not_fvar?_fixitr_fvSup φ -@[simp] lemma univCl'_univCl'_eq_univCl' (φ : SyntacticFormula L) : +@[simp] lemma univCl'_univCl'_eq_univCl' (φ : Proposition L) : φ.univCl'.univCl' = φ.univCl' := univCl'_eq_self_of φ.univCl' (by simp) @@ -475,11 +475,11 @@ def toEmpty [DecidableEq ξ] {n : ℕ} : (φ : Semiformula L ξ n) → φ.freeVa @[simp] lemma toEmpty_ex [DecidableEq ξ] (φ : Semiformula L ξ (n + 1)) (h) : (∃⁰ φ).toEmpty h = ∃⁰ (φ.toEmpty (by simpa using h)) := rfl /-- An universal closure of formula -/ -def univCl (φ : SyntacticFormula L) : Sentence L := φ.univCl'.toEmpty (by simp) +def univCl (φ : Proposition L) : Sentence L := φ.univCl'.toEmpty (by simp) -@[simp] lemma coe_univCl_eq_univCl' (φ : SyntacticFormula L) : (φ.univCl : SyntacticFormula L) = φ.univCl' := by simp [univCl] +@[simp] lemma coe_univCl_eq_univCl' (φ : Proposition L) : (φ.univCl : Proposition L) = φ.univCl' := by simp [univCl] -@[simp] lemma univCl_coe_sentence (σ : Sentence L) : univCl (↑σ : SyntacticFormula L) = σ := by +@[simp] lemma univCl_coe_sentence (σ : Sentence L) : univCl (↑σ : Proposition L) = σ := by unfold univCl refine (Semiformula.coe_inj _ _).mp ?_ rw [emb_toEmpty] @@ -513,12 +513,12 @@ lemma lMap_rewrite (f : ξ₁ → Semiterm L₁ ξ₂ n) (φ : Semiformula L₁ lemma lMap_subst (w : Fin k → Semiterm L₁ ξ n) (φ : Semiformula L₁ ξ k) : lMap Φ (φ ⇜ w) = (lMap Φ φ)⇜(Semiterm.lMap Φ ∘ w) := lMap_bind _ _ _ -lemma lMap_shift (φ : SyntacticSemiformula L₁ n) : lMap Φ (@Rew.shift L₁ n ▹ φ) = @Rew.shift L₂ n ▹ lMap Φ φ := lMap_bind _ _ _ +lemma lMap_shift (φ : Semiproposition L₁ n) : lMap Φ (@Rew.shift L₁ n ▹ φ) = @Rew.shift L₂ n ▹ lMap Φ φ := lMap_bind _ _ _ -lemma lMap_free (φ : SyntacticSemiformula L₁ (n + 1)) : lMap Φ (@Rew.free L₁ n ▹ φ) = @Rew.free L₂ n ▹ lMap Φ φ := by +lemma lMap_free (φ : Semiproposition L₁ (n + 1)) : lMap Φ (@Rew.free L₁ n ▹ φ) = @Rew.free L₂ n ▹ lMap Φ φ := by simp [Rew.free, lMap_bind, Function.comp_def, Matrix.comp_vecConsLast] -lemma lMap_fix (φ : SyntacticSemiformula L₁ n) : lMap Φ (@Rew.fix L₁ n ▹ φ) = @Rew.fix L₂ n ▹ lMap Φ φ := by +lemma lMap_fix (φ : Semiproposition L₁ n) : lMap Φ (@Rew.fix L₁ n ▹ φ) = @Rew.fix L₂ n ▹ lMap Φ φ := by simp only [Rew.fix, lMap_bind, Function.comp_def, Semiterm.lMap_bvar] congr; { funext x; cases x <;> simp } diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean index c075e7d9f..01dacaf26 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean @@ -17,7 +17,7 @@ variable {L : Language} [L.Encodable] [L.LORDefinable] variable {T : Theory L} [T.Δ₁] -lemma derivable_quote {Γ : Finset (SyntacticFormula L)} (d : T ⟹₂ Γ) : T.Derivable (⌜Γ⌝ : V) := +lemma derivable_quote {Γ : Finset (Proposition L)} (d : T ⟹₂ Γ) : T.Derivable (⌜Γ⌝ : V) := ⟨⌜d⌝, by simpa [Semiformula.quote_def] using (⌜d⌝ : Theory.internalize V T ⊢!ᵈᵉʳ ⌜Γ⌝).derivationOf⟩ /-- Hilbert–Bernays provability condition D1 -/ diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean index 578823688..e75b86c66 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean @@ -18,7 +18,7 @@ variable {L : Language} [L.Encodable] [L.LORDefinable] variable (T : Theory L) [T.Δ₁] /-- Hilbert–Bernays provability condition D2 -/ -theorem modus_ponens {φ ψ : SyntacticFormula L} (hφψ : T.Provable (⌜φ ➝ ψ⌝ : V)) (hφ : T.Provable (⌜φ⌝ : V)) : +theorem modus_ponens {φ ψ : Proposition L} (hφψ : T.Provable (⌜φ ➝ ψ⌝ : V)) (hφ : T.Provable (⌜φ⌝ : V)) : T.Provable (⌜ψ⌝ : V) := by apply (tprovable_tquote_iff_provable_quote (L := L)).mp have hφψ : Theory.internalize V T ⊢ ⌜φ⌝ ➝ ⌜ψ⌝ := by simpa using (tprovable_tquote_iff_provable_quote (L := L)).mpr hφψ diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean index cc5bd6389..aa14634ac 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean @@ -49,7 +49,7 @@ namespace FirstOrder.Semiformula variable (V) {n : ℕ} -noncomputable def typedQuote {n} : SyntacticSemiformula L n → Bootstrapping.Semiformula V L n +noncomputable def typedQuote {n} : Semiproposition L n → Bootstrapping.Semiformula V L n | rel R v => Bootstrapping.Semiformula.rel R fun i ↦ ⌜v i⌝ | nrel R v => Bootstrapping.Semiformula.nrel R fun i ↦ ⌜v i⌝ | ⊤ => ⊤ @@ -61,7 +61,7 @@ noncomputable def typedQuote {n} : SyntacticSemiformula L n → Bootstrapping.Se variable {V} -lemma typedQuote_neg {n} (φ : SyntacticSemiformula L n) : (∼φ).typedQuote V = ∼(φ.typedQuote V) := by +lemma typedQuote_neg {n} (φ : Semiproposition L n) : (∼φ).typedQuote V = ∼(φ.typedQuote V) := by match φ with | rel R v => simp [typedQuote] | nrel R v => simp [typedQuote] @@ -72,7 +72,7 @@ lemma typedQuote_neg {n} (φ : SyntacticSemiformula L n) : (∼φ).typedQuote V | ∀⁰ φ => simp [typedQuote, typedQuote_neg φ] | ∃⁰ φ => simp [typedQuote, typedQuote_neg φ] -noncomputable instance : LCWQIsoGödelQuote (SyntacticSemiformula L) (Bootstrapping.Semiformula V L) where +noncomputable instance : LCWQIsoGödelQuote (Semiproposition L) (Bootstrapping.Semiformula V L) where gq _ := ⟨typedQuote V⟩ top := rfl bot := rfl @@ -89,7 +89,7 @@ noncomputable instance : LCWQIsoGödelQuote (SyntacticSemiformula L) (Bootstrapp @[simp] lemma typed_quote_nrel (R : L.Rel k) (v : Fin k → SyntacticSemiterm L n) : (⌜nrel R v⌝ : Bootstrapping.Semiformula V L n) = Bootstrapping.Semiformula.nrel R fun i ↦ ⌜v i⌝ := rfl -@[simp] lemma typed_quote_shift (φ : SyntacticSemiformula L n) : +@[simp] lemma typed_quote_shift (φ : Semiproposition L n) : (⌜Rewriting.shift φ⌝ : Bootstrapping.Semiformula V L n) = Bootstrapping.Semiformula.shift ⌜φ⌝ := by induction φ using Semiformula.rec' case hrel => simp [rew_rel, *]; rfl @@ -101,7 +101,7 @@ noncomputable instance : LCWQIsoGödelQuote (SyntacticSemiformula L) (Bootstrapp case hall φ ih => simp [*] case hexs φ ih => simp [*] -@[simp] lemma typed_quote_substs {n m} (w : Fin n → SyntacticSemiterm L m) (φ : SyntacticSemiformula L n) : +@[simp] lemma typed_quote_substs {n m} (w : Fin n → SyntacticSemiterm L m) (φ : Semiproposition L n) : (⌜φ ⇜ w⌝ : Bootstrapping.Semiformula V L m) = Bootstrapping.Semiformula.subst (fun i ↦ ⌜w i⌝) ⌜φ⌝ := by induction φ using Semiformula.rec' generalizing m case hrel => simp [rew_rel, *]; rfl @@ -115,7 +115,7 @@ noncomputable instance : LCWQIsoGödelQuote (SyntacticSemiformula L) (Bootstrapp case hexs φ ih => simp [*, Rew.q_subst, Matrix.comp_vecCons']; rfl -@[simp] lemma free_quote (φ : SyntacticSemiformula L 1) : +@[simp] lemma free_quote (φ : Semiproposition L 1) : (⌜Rewriting.free φ⌝ : Bootstrapping.Formula V L) = Bootstrapping.Semiformula.free ⌜φ⌝ := by rw [← LawfulSyntacticRewriting.app_subst_fbar_zero_comp_shift_eq_free, typed_quote_substs, typed_quote_shift] simp [Bootstrapping.Semiformula.free, Matrix.constant_eq_singleton] @@ -123,20 +123,20 @@ noncomputable instance : LCWQIsoGödelQuote (SyntacticSemiformula L) (Bootstrapp open Bootstrapping.Arithmetic @[simp] lemma typed_quote_eq (t u : SyntacticSemiterm ℒₒᵣ n) : - (⌜(“!!t = !!u” : SyntacticSemiformula ℒₒᵣ n)⌝ : Bootstrapping.Semiformula V ℒₒᵣ n) = (⌜t⌝ ≐ ⌜u⌝) := rfl + (⌜(“!!t = !!u” : Semiproposition ℒₒᵣ n)⌝ : Bootstrapping.Semiformula V ℒₒᵣ n) = (⌜t⌝ ≐ ⌜u⌝) := rfl @[simp] lemma typed_quote_ne (t u : SyntacticSemiterm ℒₒᵣ n) : - (⌜(“!!t ≠ !!u” : SyntacticSemiformula ℒₒᵣ n)⌝ : Bootstrapping.Semiformula V ℒₒᵣ n) = (⌜t⌝ ≉ ⌜u⌝) := rfl + (⌜(“!!t ≠ !!u” : Semiproposition ℒₒᵣ n)⌝ : Bootstrapping.Semiformula V ℒₒᵣ n) = (⌜t⌝ ≉ ⌜u⌝) := rfl @[simp] lemma typed_quote_lt (t u : SyntacticSemiterm ℒₒᵣ n) : - (⌜(“!!t < !!u” : SyntacticSemiformula ℒₒᵣ n)⌝ : Bootstrapping.Semiformula V ℒₒᵣ n) = (⌜t⌝ <' ⌜u⌝) := rfl + (⌜(“!!t < !!u” : Semiproposition ℒₒᵣ n)⌝ : Bootstrapping.Semiformula V ℒₒᵣ n) = (⌜t⌝ <' ⌜u⌝) := rfl @[simp] lemma typed_quote_nlt (t u : SyntacticSemiterm ℒₒᵣ n) : - (⌜(“!!t ≮ !!u” : SyntacticSemiformula ℒₒᵣ n)⌝ : Bootstrapping.Semiformula V ℒₒᵣ n) = (⌜t⌝ ≮' ⌜u⌝) := rfl + (⌜(“!!t ≮ !!u” : Semiproposition ℒₒᵣ n)⌝ : Bootstrapping.Semiformula V ℒₒᵣ n) = (⌜t⌝ ≮' ⌜u⌝) := rfl lemma ne_iff_val_ne (φ ψ : Bootstrapping.Semiformula V L n) : φ ≠ ψ ↔ φ.val ≠ ψ.val := Iff.ne Semiformula.ext_iff -lemma typed_quote_inj {n} {φ₁ φ₂ : SyntacticSemiformula L n} : (⌜φ₁⌝ : Bootstrapping.Semiformula V L n) = ⌜φ₂⌝ → φ₁ = φ₂ := +lemma typed_quote_inj {n} {φ₁ φ₂ : Semiproposition L n} : (⌜φ₁⌝ : Bootstrapping.Semiformula V L n) = ⌜φ₂⌝ → φ₁ = φ₂ := match φ₁, φ₂ with | rel R₁ v₁, rel R₂ v₂ => by simp only [typed_quote_rel, Bootstrapping.Semiformula.rel, Semiformula.mk.injEq, qqRel_inj, @@ -186,19 +186,19 @@ lemma typed_quote_inj {n} {φ₁ φ₂ : SyntacticSemiformula L n} : (⌜φ₁ | ∃⁰ _, rel _ _ | ∃⁰ _, nrel _ _ | ∃⁰ _, ⊤ | ∃⁰ _, ⊥ | ∃⁰ _, _ ⋏ _ | ∃⁰ _, _ ⋎ _ | ∃⁰ _, ∀⁰ _ => by simp [ne_iff_val_ne, qqRel, qqNRel, qqVerum, qqFalsum, qqAnd, qqOr, qqAll, qqExs] -@[simp] lemma typed_quote_inj_iff {φ₁ φ₂ : SyntacticSemiformula L n} : +@[simp] lemma typed_quote_inj_iff {φ₁ φ₂ : Semiproposition L n} : (⌜φ₁⌝ : Bootstrapping.Semiformula V L n) = ⌜φ₂⌝ ↔ φ₁ = φ₂ := ⟨typed_quote_inj, by rintro rfl; rfl⟩ -noncomputable instance : GödelQuote (SyntacticSemiformula L n) V where +noncomputable instance : GödelQuote (Semiproposition L n) V where quote φ := (⌜φ⌝ : Bootstrapping.Semiformula V L n).val -lemma quote_def (φ : SyntacticSemiformula L n) : (⌜φ⌝ : V) = (⌜φ⌝ : Bootstrapping.Semiformula V L n).val := rfl +lemma quote_def (φ : Semiproposition L n) : (⌜φ⌝ : V) = (⌜φ⌝ : Bootstrapping.Semiformula V L n).val := rfl -@[simp] lemma quote_isSemiformula (φ : SyntacticSemiformula L n) : IsSemiformula L ↑n (⌜φ⌝ : V) := by simp [quote_def] +@[simp] lemma quote_isSemiformula (φ : Semiproposition L n) : IsSemiformula L ↑n (⌜φ⌝ : V) := by simp [quote_def] -@[simp] lemma quote_isSemiformula₀ (φ : SyntacticFormula L) : IsSemiformula L 0 (⌜φ⌝ : V) := by simp [quote_def] +@[simp] lemma quote_isSemiformula₀ (φ : Proposition L) : IsSemiformula L 0 (⌜φ⌝ : V) := by simp [quote_def] -@[simp] lemma quote_isSemiformul₁ (φ : SyntacticSemiformula L 1) : IsSemiformula L 1 (⌜φ⌝ : V) := by simp [quote_def] +@[simp] lemma quote_isSemiformul₁ (φ : Semiproposition L 1) : IsSemiformula L 1 (⌜φ⌝ : V) := by simp [quote_def] @[simp] lemma quote_rel (R : L.Rel k) (v : Fin k → SyntacticSemiterm L n) : (⌜rel R v⌝ : V) = ^rel ↑k ⌜R⌝ (SemitermVec.val fun i ↦ (⌜v i⌝ : Bootstrapping.Semiterm V L n)) := rfl @@ -206,22 +206,22 @@ lemma quote_def (φ : SyntacticSemiformula L n) : (⌜φ⌝ : V) = (⌜φ⌝ : B @[simp] lemma quote_nrel (R : L.Rel k) (v : Fin k → SyntacticSemiterm L n) : (⌜nrel R v⌝ : V) = ^nrel ↑k ⌜R⌝ (SemitermVec.val fun i ↦ (⌜v i⌝ : Bootstrapping.Semiterm V L n)) := rfl -@[simp] lemma quote_verum : (⌜(⊤ : SyntacticSemiformula L n)⌝ : V) = ^⊤ := rfl +@[simp] lemma quote_verum : (⌜(⊤ : Semiproposition L n)⌝ : V) = ^⊤ := rfl -@[simp] lemma quote_falsum : (⌜(⊥ : SyntacticSemiformula L n)⌝ : V) = ^⊥ := rfl +@[simp] lemma quote_falsum : (⌜(⊥ : Semiproposition L n)⌝ : V) = ^⊥ := rfl -@[simp] lemma quote_and (φ ψ : SyntacticSemiformula L n) : (⌜φ ⋏ ψ⌝ : V) = ⌜φ⌝ ^⋏ ⌜ψ⌝ := rfl +@[simp] lemma quote_and (φ ψ : Semiproposition L n) : (⌜φ ⋏ ψ⌝ : V) = ⌜φ⌝ ^⋏ ⌜ψ⌝ := rfl -@[simp] lemma quote_or (φ ψ : SyntacticSemiformula L n) : (⌜φ ⋎ ψ⌝ : V) = ⌜φ⌝ ^⋎ ⌜ψ⌝ := rfl +@[simp] lemma quote_or (φ ψ : Semiproposition L n) : (⌜φ ⋎ ψ⌝ : V) = ⌜φ⌝ ^⋎ ⌜ψ⌝ := rfl -@[simp] lemma quote_all (φ : SyntacticSemiformula L (n + 1)) : (⌜∀⁰ φ⌝ : V) = ^∀ ⌜φ⌝ := rfl +@[simp] lemma quote_all (φ : Semiproposition L (n + 1)) : (⌜∀⁰ φ⌝ : V) = ^∀ ⌜φ⌝ := rfl -@[simp] lemma quote_ex (φ : SyntacticSemiformula L (n + 1)) : (⌜∃⁰ φ⌝ : V) = ^∃ ⌜φ⌝ := rfl +@[simp] lemma quote_ex (φ : Semiproposition L (n + 1)) : (⌜∃⁰ φ⌝ : V) = ^∃ ⌜φ⌝ := rfl -lemma quote_shift (φ : SyntacticSemiformula L n) : +lemma quote_shift (φ : Semiproposition L n) : (⌜Rewriting.shift φ⌝ : V) = Bootstrapping.shift L ⌜φ⌝ := by simp [quote_def] -lemma quote_eq_encode (φ : SyntacticSemiformula L n) : (⌜φ⌝ : V) = ↑(encode φ) := by +lemma quote_eq_encode (φ : Semiproposition L n) : (⌜φ⌝ : V) = ↑(encode φ) := by suffices (⌜φ⌝ : Bootstrapping.Semiformula V L n).val = ↑(encode φ) from this induction φ using rec' case hrel => simp [encode_rel, qqRel, coe_pair_eq_pair_coe, Semiterm.quote_eq_encode']; rfl @@ -233,18 +233,18 @@ lemma quote_eq_encode (φ : SyntacticSemiformula L n) : (⌜φ⌝ : V) = ↑(enc case hall => simp [encode_all, qqAll, coe_pair_eq_pair_coe, *]; simp [encode_eq_toNat] case hexs => simp [encode_ex, qqExs, coe_pair_eq_pair_coe, *]; simp [encode_eq_toNat] -lemma coe_quote_eq_quote (φ : SyntacticSemiformula L n) : (↑(⌜φ⌝ : ℕ) : V) = ⌜φ⌝ := by +lemma coe_quote_eq_quote (φ : Semiproposition L n) : (↑(⌜φ⌝ : ℕ) : V) = ⌜φ⌝ := by simp [quote_eq_encode] -lemma coe_quote_eq_quote' (φ : SyntacticSemiformula L n) : +lemma coe_quote_eq_quote' (φ : Semiproposition L n) : (↑(⌜φ⌝ : Bootstrapping.Semiformula ℕ L n).val : V) = (⌜φ⌝ : Bootstrapping.Semiformula V L n).val := coe_quote_eq_quote φ -@[simp] lemma quote_inj_iff {φ₁ φ₂ : SyntacticSemiformula L n} : +@[simp] lemma quote_inj_iff {φ₁ φ₂ : Semiproposition L n} : (⌜φ₁⌝ : V) = ⌜φ₂⌝ ↔ φ₁ = φ₂ := by simp [quote_eq_encode] noncomputable instance : LCWQIsoGödelQuote (Semisentence L) (Bootstrapping.Semiformula V L) where - gq n := ⟨fun σ ↦ (⌜(Rewriting.emb σ : SyntacticSemiformula L n)⌝)⟩ + gq n := ⟨fun σ ↦ (⌜(Rewriting.emb σ : Semiproposition L n)⌝)⟩ top := by simp bot := by simp and _ _ := by simp @@ -254,10 +254,10 @@ noncomputable instance : LCWQIsoGödelQuote (Semisentence L) (Bootstrapping.Semi all _ := by simp exs _ := by simp -@[simp] lemma coe_quote {ξ n} (φ : SyntacticSemiformula L n) : ↑(⌜φ⌝ : ℕ) = (⌜φ⌝ : Semiterm ℒₒᵣ ξ m) := by +@[simp] lemma coe_quote {ξ n} (φ : Semiproposition L n) : ↑(⌜φ⌝ : ℕ) = (⌜φ⌝ : Semiterm ℒₒᵣ ξ m) := by simp [gödelNumber'_def, Semiformula.quote_eq_encode] -@[simp] lemma quote_quote_eq_numeral (φ : SyntacticSemiformula L n) : +@[simp] lemma quote_quote_eq_numeral (φ : Semiproposition L n) : (⌜(⌜φ⌝ : Semiterm ℒₒᵣ ℕ m)⌝ : Bootstrapping.Semiterm V ℒₒᵣ m) = Bootstrapping.Arithmetic.typedNumeral ⌜φ⌝ := by simp [←coe_quote, coe_quote_eq_quote] @@ -266,7 +266,7 @@ end Semiformula namespace Sentence def typed_quote_def (σ : Semisentence L n) : - (⌜σ⌝ : Bootstrapping.Semiformula V L n) = ⌜(Rewriting.emb σ : SyntacticSemiformula L n)⌝ := rfl + (⌜σ⌝ : Bootstrapping.Semiformula V L n) = ⌜(Rewriting.emb σ : Semiproposition L n)⌝ := rfl @[simp] lemma typed_quote_eq (t u : ClosedSemiterm ℒₒᵣ n) : (⌜(“!!t = !!u” : Semisentence ℒₒᵣ n)⌝ : Bootstrapping.Semiformula V ℒₒᵣ n) = (⌜t⌝ ≐ ⌜u⌝) := rfl @@ -281,9 +281,9 @@ def typed_quote_def (σ : Semisentence L n) : (⌜(“!!t ≮ !!u” : Semisentence ℒₒᵣ n)⌝ : Bootstrapping.Semiformula V ℒₒᵣ n) = (⌜t⌝ ≮' ⌜u⌝) := rfl noncomputable instance : GödelQuote (Semisentence L n) V where - quote σ := ⌜(Rewriting.emb σ : SyntacticSemiformula L n)⌝ + quote σ := ⌜(Rewriting.emb σ : Semiproposition L n)⌝ -lemma quote_def (σ : Semisentence L n) : (⌜σ⌝ : V) = ⌜(Rewriting.emb σ : SyntacticSemiformula L n)⌝ := rfl +lemma quote_def (σ : Semisentence L n) : (⌜σ⌝ : V) = ⌜(Rewriting.emb σ : Semiproposition L n)⌝ := rfl def quote_eq (σ : Semisentence L n) : (⌜σ⌝ : V) = (⌜σ⌝ : Bootstrapping.Semiformula V L n).val := rfl @@ -320,7 +320,7 @@ namespace FirstOrder.Arithmetic.Bootstrapping open Encodable FirstOrder -lemma IsSemiformula.sound {n φ : ℕ} (h : IsSemiformula L n φ) : ∃ F : FirstOrder.SyntacticSemiformula L n, ⌜F⌝ = φ := by +lemma IsSemiformula.sound {n φ : ℕ} (h : IsSemiformula L n φ) : ∃ F : FirstOrder.Semiproposition L n, ⌜F⌝ = φ := by induction φ using Nat.strongRec generalizing n case ind φ ih => rcases IsSemiformula.case_iff.mp h with diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean index 9170132c4..50735646f 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean @@ -18,22 +18,22 @@ namespace Derivation2 variable (V) -def cast [L.DecidableEq] {T : Theory L} {Γ Δ : Finset (SyntacticFormula L)} (d : T ⟹₂ Γ) (h : Γ = Δ) : T ⟹₂ Δ := h ▸ d +def cast [L.DecidableEq] {T : Theory L} {Γ Δ : Finset (Proposition L)} (d : T ⟹₂ Γ) (h : Γ = Δ) : T ⟹₂ Δ := h ▸ d -noncomputable def Sequent.quote (Γ : Finset (SyntacticFormula L)) : V := ∑ φ ∈ Γ, Exp.exp (⌜φ⌝ : V) +noncomputable def Sequent.quote (Γ : Finset (Proposition L)) : V := ∑ φ ∈ Γ, Exp.exp (⌜φ⌝ : V) -noncomputable instance : GödelQuote (Finset (SyntacticFormula L)) V := ⟨Sequent.quote V⟩ +noncomputable instance : GödelQuote (Finset (Proposition L)) V := ⟨Sequent.quote V⟩ omit [L.DecidableEq] in -lemma Sequent.quote_def (Γ : Finset (SyntacticFormula L)) : ⌜Γ⌝ = ∑ φ ∈ Γ, Exp.exp (⌜φ⌝ : V) := rfl +lemma Sequent.quote_def (Γ : Finset (Proposition L)) : ⌜Γ⌝ = ∑ φ ∈ Γ, Exp.exp (⌜φ⌝ : V) := rfl variable {V} omit [L.DecidableEq] in -@[simp] lemma Sequent.quote_empty : (⌜(∅ : Finset (SyntacticFormula L))⌝ : V) = ∅ := by +@[simp] lemma Sequent.quote_empty : (⌜(∅ : Finset (Proposition L))⌝ : V) = ∅ := by simp [Sequent.quote_def, emptyset_def] -@[simp] lemma Sequent.mem_quote_iff {Γ : Finset (SyntacticFormula L)} {φ} : ⌜φ⌝ ∈ (⌜Γ⌝ : V) ↔ φ ∈ Γ := by +@[simp] lemma Sequent.mem_quote_iff {Γ : Finset (Proposition L)} {φ} : ⌜φ⌝ ∈ (⌜Γ⌝ : V) ↔ φ ∈ Γ := by induction Γ using Finset.induction generalizing φ case empty => simp [Sequent.quote_def] case insert a Γ ha ih => @@ -45,22 +45,22 @@ omit [L.DecidableEq] in rw [this] simp [←ih] -lemma Sequent.quote_inj {Γ Δ : Finset (SyntacticFormula L)} : (⌜Γ⌝ : V) = ⌜Δ⌝ → Γ = Δ := fun h ↦ by +lemma Sequent.quote_inj {Γ Δ : Finset (Proposition L)} : (⌜Γ⌝ : V) = ⌜Δ⌝ → Γ = Δ := fun h ↦ by ext φ; rw [←Sequent.mem_quote_iff (V := V), h]; simp omit [L.DecidableEq] in -@[simp] lemma Sequent.quote_singleton [L.DecidableEq] (φ : SyntacticFormula L) : - (⌜({φ} : Finset (SyntacticFormula L))⌝ : V) = {⌜φ⌝} := by simp [Sequent.quote_def]; rfl +@[simp] lemma Sequent.quote_singleton [L.DecidableEq] (φ : Proposition L) : + (⌜({φ} : Finset (Proposition L))⌝ : V) = {⌜φ⌝} := by simp [Sequent.quote_def]; rfl omit [L.DecidableEq] in -@[simp] lemma Sequent.quote_insert [L.DecidableEq] (Γ : Finset (SyntacticFormula L)) (φ) : (⌜(insert φ Γ)⌝ : V) = insert ⌜φ⌝ ⌜Γ⌝ := by +@[simp] lemma Sequent.quote_insert [L.DecidableEq] (Γ : Finset (Proposition L)) (φ) : (⌜(insert φ Γ)⌝ : V) = insert ⌜φ⌝ ⌜Γ⌝ := by by_cases hp : φ ∈ Γ · simp [Sequent.mem_quote_iff, hp, insert_eq_self_of_mem] · have : (⌜insert φ Γ⌝ : V) = Exp.exp ⌜φ⌝ + ⌜Γ⌝ := by simp [Sequent.quote_def, hp] simp [Sequent.mem_quote_iff, this, insert_eq, bitInsert, hp, add_comm] omit [L.DecidableEq] in -lemma Sequent.mem_quote [L.DecidableEq] {Γ : Finset (SyntacticFormula L)} (hx : x ∈ (⌜Γ⌝ : V)) : ∃ φ ∈ Γ, x = ⌜φ⌝ := by +lemma Sequent.mem_quote [L.DecidableEq] {Γ : Finset (Proposition L)} (hx : x ∈ (⌜Γ⌝ : V)) : ∃ φ ∈ Γ, x = ⌜φ⌝ := by induction Γ using Finset.induction case empty => simp at hx case insert a Γ _ ih => @@ -70,18 +70,18 @@ lemma Sequent.mem_quote [L.DecidableEq] {Γ : Finset (SyntacticFormula L)} (hx : · rcases ih hx with ⟨p, hx, rfl⟩ exact ⟨p, by simp [*]⟩ -lemma Sequent.mem_quote_iff' {Γ : Finset (SyntacticFormula L)} : x ∈ (⌜Γ⌝ : V) ↔ (∃ φ ∈ Γ, x = ⌜φ⌝) := by +lemma Sequent.mem_quote_iff' {Γ : Finset (Proposition L)} : x ∈ (⌜Γ⌝ : V) ↔ (∃ φ ∈ Γ, x = ⌜φ⌝) := by constructor · intro h; exact Sequent.mem_quote h · rintro ⟨p, hp, rfl⟩; simp [Sequent.mem_quote_iff, hp] -@[simp] lemma Sequent.quote_subset_quote {Γ Δ : Finset (SyntacticFormula L)} : +@[simp] lemma Sequent.quote_subset_quote {Γ Δ : Finset (Proposition L)} : (⌜Γ⌝ : V) ⊆ ⌜Δ⌝ ↔ Γ ⊆ Δ := ⟨fun h _ hp ↦ Sequent.mem_quote_iff.mp <| h <| Sequent.mem_quote_iff.mpr hp, fun h x hx ↦ by rcases Sequent.mem_quote hx with ⟨φ, hφ, rfl⟩; simp [h hφ]⟩ -lemma setShift_quote (Γ : Finset (SyntacticFormula L)) : +lemma setShift_quote (Γ : Finset (Proposition L)) : setShift L (⌜Γ⌝ : V) = ⌜Finset.image Rewriting.shift Γ⌝ := by apply mem_ext intro x; simp only [mem_setShift_iff] @@ -95,50 +95,50 @@ lemma setShift_quote (Γ : Finset (SyntacticFormula L)) : rcases by simpa using hp' with ⟨p, hp, rfl⟩ exact ⟨⌜p⌝, by simpa [Sequent.mem_quote_iff] using hp, by simp [Semiformula.quote_def]⟩ -@[simp] lemma formulaSet_quote_finset (Γ : Finset (SyntacticFormula L)) : IsFormulaSet L (⌜Γ⌝ : V) := by +@[simp] lemma formulaSet_quote_finset (Γ : Finset (Proposition L)) : IsFormulaSet L (⌜Γ⌝ : V) := by intro x hx rcases Derivation2.Sequent.mem_quote hx with ⟨p, _, rfl⟩; simp [Semiformula.quote_def] -noncomputable instance : GödelQuote (Finset (SyntacticFormula L)) (Bootstrapping.Sequent V L) := ⟨fun Γ ↦ ⟨⌜Γ⌝, by simp⟩⟩ +noncomputable instance : GödelQuote (Finset (Proposition L)) (Bootstrapping.Sequent V L) := ⟨fun Γ ↦ ⟨⌜Γ⌝, by simp⟩⟩ -@[simp] lemma Sequent.typed_quote_val (Γ : Finset (SyntacticFormula L)) : (⌜Γ⌝ : Bootstrapping.Sequent V L).val = ⌜Γ⌝ := rfl +@[simp] lemma Sequent.typed_quote_val (Γ : Finset (Proposition L)) : (⌜Γ⌝ : Bootstrapping.Sequent V L).val = ⌜Γ⌝ := rfl -@[simp] lemma Sequent.quote_mem_quote {φ : SyntacticFormula L} {Γ : Finset (SyntacticFormula L)} : +@[simp] lemma Sequent.quote_mem_quote {φ : Proposition L} {Γ : Finset (Proposition L)} : ⌜φ⌝ ∈ (⌜Γ⌝ : Bootstrapping.Sequent V L) ↔ φ ∈ Γ := by simp [Bootstrapping.Sequent.mem_iff, ←Semiformula.quote_def] -@[simp] lemma Sequent.typed_quote_insert (Γ : Finset (SyntacticFormula L)) (φ) : (⌜insert φ Γ⌝ : Bootstrapping.Sequent V L) = insert ⌜φ⌝ ⌜Γ⌝ := by +@[simp] lemma Sequent.typed_quote_insert (Γ : Finset (Proposition L)) (φ) : (⌜insert φ Γ⌝ : Bootstrapping.Sequent V L) = insert ⌜φ⌝ ⌜Γ⌝ := by ext; simp [Bootstrapping.Sequent.mem_iff, Semiformula.quote_def] -@[simp] lemma Sequent.typed_quote_empty : (⌜(∅ : Finset (SyntacticFormula L))⌝ : Bootstrapping.Sequent V L) = ∅ := rfl +@[simp] lemma Sequent.typed_quote_empty : (⌜(∅ : Finset (Proposition L))⌝ : Bootstrapping.Sequent V L) = ∅ := rfl -@[simp] lemma Sequent.typed_quote_singleton (φ : SyntacticFormula L) : - (⌜({φ} : Finset (SyntacticFormula L))⌝ : Bootstrapping.Sequent V L) = {⌜φ⌝} := by - rw [show ({φ} : Finset (SyntacticFormula L)) = insert φ ∅ by simp] +@[simp] lemma Sequent.typed_quote_singleton (φ : Proposition L) : + (⌜({φ} : Finset (Proposition L))⌝ : Bootstrapping.Sequent V L) = {⌜φ⌝} := by + rw [show ({φ} : Finset (Proposition L)) = insert φ ∅ by simp] rw [Sequent.typed_quote_insert]; simp [Sequent.insert_empty_eq_singleton] -@[simp] lemma setShift_typed_quote (Γ : Finset (SyntacticFormula L)) : +@[simp] lemma setShift_typed_quote (Γ : Finset (Proposition L)) : (⌜Finset.image Rewriting.shift Γ⌝ : Bootstrapping.Sequent V L) = (⌜Γ⌝ : Bootstrapping.Sequent V L).shift := by apply Sequent.ext' simp [←setShift_quote]; rfl -lemma Sequent.typed_quote_inj {Γ Δ : Finset (SyntacticFormula L)} : (⌜Γ⌝ : Bootstrapping.Sequent V L) = ⌜Δ⌝ → Γ = Δ := fun h ↦ by +lemma Sequent.typed_quote_inj {Γ Δ : Finset (Proposition L)} : (⌜Γ⌝ : Bootstrapping.Sequent V L) = ⌜Δ⌝ → Γ = Δ := fun h ↦ by have : (⌜Γ⌝ : V) = ⌜Δ⌝ := by simpa using congr_arg Sequent.val h exact quote_inj this -lemma Sequent.coe_eq (Γ : Finset (SyntacticFormula L)) : (↑(⌜Γ⌝ : ℕ) : V) = ⌜Γ⌝ := by +lemma Sequent.coe_eq (Γ : Finset (Proposition L)) : (↑(⌜Γ⌝ : ℕ) : V) = ⌜Γ⌝ := by induction Γ using Finset.induction · simp case insert φ s h ih => simp [insert_absolute, ih, Semiformula.coe_quote_eq_quote] -@[simp] lemma Sequent.typed_quote_subset_typed_quote {Γ Δ : Finset (SyntacticFormula L)} : +@[simp] lemma Sequent.typed_quote_subset_typed_quote {Γ Δ : Finset (Proposition L)} : (⌜Γ⌝ : Bootstrapping.Sequent V L) ⊆ ⌜Δ⌝ ↔ Γ ⊆ Δ := Sequent.quote_subset_quote -lemma isFormulaSet_sound {s : ℕ} : IsFormulaSet L s → ∃ S : Finset (SyntacticFormula L), ⌜S⌝ = s := by +lemma isFormulaSet_sound {s : ℕ} : IsFormulaSet L s → ∃ S : Finset (Proposition L), ⌜S⌝ = s := by intro h - have : ∀ x, ∃ φ : SyntacticFormula L, x ∈ s → ⌜φ⌝ = x := by + have : ∀ x, ∃ φ : Proposition L, x ∈ s → ⌜φ⌝ = x := by intro x; by_cases hx : x ∈ s · simpa [hx] using (h x hx).sound @@ -158,7 +158,7 @@ lemma isFormulaSet_sound {s : ℕ} : IsFormulaSet L s → ∃ S : Finset (Syntac variable (V) -noncomputable def typedQuote {Γ : Finset (SyntacticFormula L)} : T ⟹₂ Γ → T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝ +noncomputable def typedQuote {Γ : Finset (Proposition L)} : T ⟹₂ Γ → T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝ | closed Δ φ h hn => TDerivation.em ⌜φ⌝ (by simpa) (by simpa using Sequent.quote_mem_quote.mpr hn) | axm φ hT _ => TDerivation.byAxm ⌜φ⌝ (by have : ∃ σ ∈ T, ↑σ = φ := by simpa [Theory.toSchema] using hT @@ -179,9 +179,9 @@ noncomputable def typedQuote {Γ : Finset (SyntacticFormula L)} : T ⟹₂ Γ | cut (φ := φ) d dn => TDerivation.cut (φ := ⌜φ⌝) (d.typedQuote.cast (by simp)) (dn.typedQuote.cast (by simp)) -noncomputable instance (Γ : Finset (SyntacticFormula L)) : GödelQuote (T ⟹₂ Γ) (T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝) := ⟨typedQuote V⟩ +noncomputable instance (Γ : Finset (Proposition L)) : GödelQuote (T ⟹₂ Γ) (T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝) := ⟨typedQuote V⟩ -noncomputable instance (Γ : Finset (SyntacticFormula L)) : GödelQuote (T ⟹₂ Γ) V := ⟨fun d ↦ (⌜d⌝ : T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝).val⟩ +noncomputable instance (Γ : Finset (Proposition L)) : GödelQuote (T ⟹₂ Γ) V := ⟨fun d ↦ (⌜d⌝ : T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝).val⟩ lemma quote_def (d : (T : Schema L) ⟹₂ Γ) : (⌜d⌝ : V) = (⌜d⌝ : T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝).val := rfl @@ -321,7 +321,7 @@ lemma Derivation.sound {d : ℕ} (h : T.Derivation d) : ∃ Γ, ⌜Γ⌝ = fstId rcases this with ⟨σ, hσ, rfl⟩ refine ⟨Derivation2.axm σ (by simp [hσ]) hφ⟩ -lemma Provable.sound2 {φ : SyntacticFormula L} (h : T.Provable (⌜φ⌝ : ℕ)) : T ⊢!₂! φ := by +lemma Provable.sound2 {φ : Proposition L} (h : T.Provable (⌜φ⌝ : ℕ)) : T ⊢!₂! φ := by rcases h with ⟨d, hp, hd⟩ rcases hd.sound with ⟨Γ, e, b⟩ have : Γ = {φ} := Sequent.quote_inj (V := ℕ) <| by simp [e, hp] diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean index b866229d6..83f46808f 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean @@ -158,7 +158,7 @@ def proof_to_tDerivation {σ : Formula V L} : T ⊢! σ → T ⊢!ᵈᵉʳ inser lemma tprovable_iff_provable {T : Theory L} [T.Δ₁] {σ : Formula V L} : T.internalize V ⊢ σ ↔ T.Provable σ.val := TProvable.iff_provable -lemma tprovable_tquote_iff_provable_quote {T : Theory L} [T.Δ₁] {φ : SyntacticFormula L} : +lemma tprovable_tquote_iff_provable_quote {T : Theory L} [T.Δ₁] {φ : Proposition L} : T.internalize V ⊢ ⌜φ⌝ ↔ T.Provable (⌜φ⌝ : V) := TProvable.iff_provable lemma tprovable_tquote_iff_provable_quote_sentence {T : Theory L} [T.Δ₁] {σ : Sentence L} : diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean index 9c19f1172..4e1235fa1 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean @@ -12,7 +12,7 @@ variable {L : Language} [L.Encodable] [L.LORDefinable] /-- TODO: define predicate `VariableFree` and make `mem_iff` `∀ φ : Sentence, ℕ ⊧/![⌜φ⌝] ch.val ↔ φ ∈ T` -/ class _root_.LO.FirstOrder.Theory.Δ₁ (T : Theory L) where ch : 𝚫₁.Semisentence 1 - mem_iff : ∀ φ : SyntacticFormula L, ℕ ⊧/![⌜φ⌝] ch.val ↔ ∃ σ ∈ T, φ = σ + mem_iff : ∀ φ : Proposition L, ℕ ⊧/![⌜φ⌝] ch.val ↔ ∃ σ ∈ T, φ = σ isDelta1 : ch.ProvablyProperOn 𝗜𝚺₁ abbrev _root_.LO.FirstOrder.Theory.Δ₁ch (T : Theory L) [T.Δ₁] : 𝚫₁.Semisentence 1 := Theory.Δ₁.ch T @@ -35,7 +35,7 @@ instance Δ₁Class.definable : 𝚫₁-Predicate[V] (· ∈ T.Δ₁Class) := Δ @[simp] lemma Δ₁Class.proper : T.Δ₁ch.ProperOn V := (Theory.Δ₁.isDelta1 (T := T)).properOn V -@[simp] lemma Δ₁Class.mem_iff_s {φ : SyntacticFormula L} : (⌜φ⌝ : V) ∈ T.Δ₁Class ↔ ∃ σ ∈ T, φ = σ := +@[simp] lemma Δ₁Class.mem_iff_s {φ : Proposition L} : (⌜φ⌝ : V) ∈ T.Δ₁Class ↔ ∃ σ ∈ T, φ = σ := have : V ⊧/![⌜φ⌝] T.Δ₁ch.val ↔ ℕ ⊧/![⌜φ⌝] T.Δ₁ch.val := by simpa [Semiformula.coe_quote_eq_quote, Matrix.constant_eq_singleton] using FirstOrder.Arithmetic.models_iff_of_Delta1 (V := V) (σ := T.Δ₁ch) (by simp) (by simp) (e := ![⌜φ⌝]) @@ -46,7 +46,7 @@ instance Δ₁Class.definable : 𝚫₁-Predicate[V] (· ∈ T.Δ₁Class) := Δ @[simp] lemma Δ₁Class.mem_iff' {φ : Sentence L} : V ⊧/![⌜φ⌝] T.Δ₁ch.val ↔ φ ∈ T := Δ₁Class.mem_iff -@[simp] lemma Δ₁Class.mem_iff'_s {φ : SyntacticFormula L} : V ⊧/![⌜φ⌝] T.Δ₁ch.val ↔ ∃ σ ∈ T, φ = σ := Δ₁Class.mem_iff_s +@[simp] lemma Δ₁Class.mem_iff'_s {φ : Proposition L} : V ⊧/![⌜φ⌝] T.Δ₁ch.val ↔ ∃ σ ∈ T, φ = σ := Δ₁Class.mem_iff_s @[simp] lemma Δ₁Class.mem_iff'' {φ : Sentence L} : ((⌜φ⌝ : Bootstrapping.Formula V L).val : V) ∈ T.Δ₁Class ↔ φ ∈ T := Δ₁Class.mem_iff diff --git a/Foundation/FirstOrder/Completeness/Coding.lean b/Foundation/FirstOrder/Completeness/Coding.lean index 3a430037c..3aad7ff1a 100644 --- a/Foundation/FirstOrder/Completeness/Coding.lean +++ b/Foundation/FirstOrder/Completeness/Coding.lean @@ -16,20 +16,20 @@ namespace Entailment inductive Code (L : Language.{u}) | axL : {k : ℕ} → (r : L.Rel k) → (v : Fin k → SyntacticTerm L) → Code L | verum : Code L - | and : SyntacticFormula L → SyntacticFormula L → Code L - | or : SyntacticFormula L → SyntacticFormula L → Code L - | all : SyntacticSemiformula L 1 → Code L - | exs : SyntacticSemiformula L 1 → SyntacticTerm L → Code L + | and : Proposition L → Proposition L → Code L + | or : Proposition L → Proposition L → Code L + | all : Semiproposition L 1 → Code L + | exs : Semiproposition L 1 → SyntacticTerm L → Code L | id : Sentence L → Code L def Code.equiv (L : Language.{u}) : Code L ≃ ((k : ℕ) × (L.Rel k) × (Fin k → SyntacticTerm L)) ⊕ Unit ⊕ - (SyntacticFormula L × SyntacticFormula L) ⊕ - (SyntacticFormula L × SyntacticFormula L) ⊕ - (SyntacticSemiformula L 1) ⊕ - (SyntacticSemiformula L 1 × SyntacticTerm L) ⊕ + (Proposition L × Proposition L) ⊕ + (Proposition L × Proposition L) ⊕ + (Semiproposition L 1) ⊕ + (Semiproposition L 1 × SyntacticTerm L) ⊕ (Sentence L) where toFun := fun c => match c with diff --git a/Foundation/FirstOrder/Completeness/SearchTree.lean b/Foundation/FirstOrder/Completeness/SearchTree.lean index ba660b499..e61bac21f 100644 --- a/Foundation/FirstOrder/Completeness/SearchTree.lean +++ b/Foundation/FirstOrder/Completeness/SearchTree.lean @@ -18,16 +18,16 @@ inductive Redux (T : Theory L) : Code L → Sequent L → Sequent L → Prop | axLRefl {Γ : Sequent L} {k} (r : L.Rel k) (v) : Semiformula.rel r v ∉ Γ ∨ Semiformula.nrel r v ∉ Γ → Redux T (Code.axL r v) Γ Γ | verumRefl {Γ : Sequent L} : ⊤ ∉ Γ → Redux T Code.verum Γ Γ - | and₁ {Γ : Sequent L} {φ ψ : SyntacticFormula L} : φ ⋏ ψ ∈ Γ → Redux T (Code.and φ ψ) (φ :: Γ) Γ - | and₂ {Γ : Sequent L} {φ ψ : SyntacticFormula L} : φ ⋏ ψ ∈ Γ → Redux T (Code.and φ ψ) (ψ :: Γ) Γ - | andRefl {Γ : Sequent L} {φ ψ : SyntacticFormula L} : φ ⋏ ψ ∉ Γ → Redux T (Code.and φ ψ) Γ Γ - | or {Γ : Sequent L} {φ ψ : SyntacticFormula L} : φ ⋎ ψ ∈ Γ → Redux T (Code.or φ ψ) (φ :: ψ :: Γ) Γ - | orRefl {Γ : Sequent L} {φ ψ : SyntacticFormula L} : φ ⋎ ψ ∉ Γ → Redux T (Code.or φ ψ) Γ Γ - | all {Γ : Sequent L} {φ : SyntacticSemiformula L 1} : ∀⁰ φ ∈ Γ → Redux T (Code.all φ) (φ/[&(newVar Γ)] :: Γ) Γ - | allRefl {Γ : Sequent L} {φ : SyntacticSemiformula L 1} : ∀⁰ φ ∉ Γ → Redux T (Code.all φ) Γ Γ - | exs {Γ : Sequent L} {φ : SyntacticSemiformula L 1} {t : SyntacticTerm L} : + | and₁ {Γ : Sequent L} {φ ψ : Proposition L} : φ ⋏ ψ ∈ Γ → Redux T (Code.and φ ψ) (φ :: Γ) Γ + | and₂ {Γ : Sequent L} {φ ψ : Proposition L} : φ ⋏ ψ ∈ Γ → Redux T (Code.and φ ψ) (ψ :: Γ) Γ + | andRefl {Γ : Sequent L} {φ ψ : Proposition L} : φ ⋏ ψ ∉ Γ → Redux T (Code.and φ ψ) Γ Γ + | or {Γ : Sequent L} {φ ψ : Proposition L} : φ ⋎ ψ ∈ Γ → Redux T (Code.or φ ψ) (φ :: ψ :: Γ) Γ + | orRefl {Γ : Sequent L} {φ ψ : Proposition L} : φ ⋎ ψ ∉ Γ → Redux T (Code.or φ ψ) Γ Γ + | all {Γ : Sequent L} {φ : Semiproposition L 1} : ∀⁰ φ ∈ Γ → Redux T (Code.all φ) (φ/[&(newVar Γ)] :: Γ) Γ + | allRefl {Γ : Sequent L} {φ : Semiproposition L 1} : ∀⁰ φ ∉ Γ → Redux T (Code.all φ) Γ Γ + | exs {Γ : Sequent L} {φ : Semiproposition L 1} {t : SyntacticTerm L} : ∃⁰ φ ∈ Γ → Redux T (Code.exs φ t) (φ/[t] :: Γ) Γ - | exsRefl {Γ : Sequent L} {φ : SyntacticSemiformula L 1} {t : SyntacticTerm L} : + | exsRefl {Γ : Sequent L} {φ : Semiproposition L 1} {t : SyntacticTerm L} : ∃⁰ φ ∉ Γ → Redux T (Code.exs φ t) Γ Γ | id {Γ : Sequent L} {σ : Sentence L} (hσ : σ ∈ T) : Redux T (Code.id σ) ((∼σ) :: Γ) Γ | idRefl {Γ : Sequent L} {σ : Sentence L} (hσ : σ ∉ T) : Redux T (Code.id σ) Γ Γ @@ -148,7 +148,7 @@ noncomputable def chainU (T : Theory L) (Γ : Sequent L) : ℕ → SearchTree T noncomputable def chain (T : Theory L) (Γ : Sequent L) (s : ℕ) : Sequent L := (chainU T Γ s).seq -def chainSet (T : Theory L) (Γ : Sequent L) : Set (SyntacticFormula L) := ⋃ s, {x | x ∈ chain T Γ s} +def chainSet (T : Theory L) (Γ : Sequent L) : Set (Proposition L) := ⋃ s, {x | x ∈ chain T Γ s} local notation "⛓️[" s "]" => chain T Γ s @@ -216,7 +216,7 @@ lemma chainSet_axL (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {k} (r : L.Rel k) rcases this; assumption contradiction -lemma chainSet_and (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ ψ : SyntacticFormula L} (h : φ ⋏ ψ ∈ ⛓️) : +lemma chainSet_and (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ ψ : Proposition L} (h : φ ⋏ ψ ∈ ⛓️) : φ ∈ ⛓️ ∨ ψ ∈ ⛓️ := by have : ∃ s, φ ⋏ ψ ∈ ⛓️[s] := by simpa [chainSet] using h rcases this with ⟨s, hs⟩ @@ -231,7 +231,7 @@ lemma chainSet_and (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ ψ : Syntactic have : φ ⋏ ψ ∈ ⛓️[(encode $ Code.and φ ψ).pair s] := chain_monotone nwf (Nat.right_le_pair _ _) hs contradiction -lemma chainSet_or (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ ψ : SyntacticFormula L} (h : φ ⋎ ψ ∈ ⛓️) : +lemma chainSet_or (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ ψ : Proposition L} (h : φ ⋎ ψ ∈ ⛓️) : φ ∈ ⛓️ ∧ ψ ∈ ⛓️ := by have : ∃ s, φ ⋎ ψ ∈ ⛓️[s] := by simpa [chainSet] using h rcases this with ⟨s, hs⟩ @@ -243,7 +243,7 @@ lemma chainSet_or (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ ψ : SyntacticF · have : φ ⋎ ψ ∈ ⛓️[(encode $ Code.or φ ψ).pair s] := chain_monotone nwf (Nat.right_le_pair _ _) hs contradiction -lemma chainSet_all (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ : SyntacticSemiformula L 1} (h : ∀⁰ φ ∈ ⛓️) : +lemma chainSet_all (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ : Semiproposition L 1} (h : ∀⁰ φ ∈ ⛓️) : ∃ t, φ/[t] ∈ ⛓️ := by have : ∃ s, ∀⁰ φ ∈ ⛓️[s] := by simpa [chainSet] using h rcases this with ⟨s, hs⟩ @@ -254,7 +254,7 @@ lemma chainSet_all (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ : SyntacticSem · have : ∀⁰ φ ∈ ⛓️[(encode $ Code.all φ).pair s] := chain_monotone nwf (Nat.right_le_pair _ _) hs contradiction -lemma chainSet_ex (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ : SyntacticSemiformula L 1} (h : ∃⁰ φ ∈ ⛓️) : +lemma chainSet_ex (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ : Semiproposition L 1} (h : ∃⁰ φ ∈ ⛓️) : ∀ t, φ/[t] ∈ ⛓️ := fun t => by have : ∃ s, ∃⁰ φ ∈ ⛓️[s] := by simpa [chainSet] using h rcases this with ⟨s, hs⟩ @@ -292,7 +292,7 @@ instance Model.structure (T : Theory L) (Γ : Sequent L) : Structure L (Model T (Model.structure T Γ).rel r v ↔ nrel r v ∈ ⛓️ := of_eq rfl lemma semanticMainLemma_val (nwf : ¬WellFounded (SearchTree.Lt T Γ)) : - (φ : SyntacticFormula L) → φ ∈ ⛓️ → ¬Evalf (Model.structure T Γ) Semiterm.fvar φ + (φ : Proposition L) → φ ∈ ⛓️ → ¬Evalf (Model.structure T Γ) Semiterm.fvar φ | ⊤, h => by by_contra; exact chainSet_verum nwf h | ⊥, _ => by simp | rel r v, h => by rcases chainSet_axL nwf r v with (hr | hr); { contradiction }; { simpa [eval_rel] using hr } @@ -331,7 +331,7 @@ lemma Model.models (nwf : ¬WellFounded (SearchTree.Lt T Γ)) : Model T Γ ⊧ₘ* T := ⟨fun φ hφ ↦ by simpa [Semiformula.eval_univCl] using semanticMainLemma_val nwf _ (chainSet_id nwf hφ)⟩ -lemma semanticMainLemmaTop (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ : SyntacticFormula L} (h : φ ∈ Γ) : +lemma semanticMainLemmaTop (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ : Proposition L} (h : φ ∈ Γ) : ¬Evalf (Model.structure T Γ) Semiterm.fvar φ := semanticMainLemma_val nwf φ (Set.mem_iUnion.mpr ⟨0, by simp [chain, chainU, h]⟩) diff --git a/Foundation/FirstOrder/Hauptsatz.lean b/Foundation/FirstOrder/Hauptsatz.lean index f60dc8f0c..dcb77ddc1 100644 --- a/Foundation/FirstOrder/Hauptsatz.lean +++ b/Foundation/FirstOrder/Hauptsatz.lean @@ -65,7 +65,7 @@ variable {Γ Δ : Sequent L} @[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᵀ Γ} : IsCutFree (Derivation.map d f) ↔ IsCutFree d := isCutFree_rewrite_iff_isCutFree -@[simp] lemma IsCutFree.genelalizeByNewver_isCutFree {φ : SyntacticSemiformula L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) +@[simp] lemma IsCutFree.genelalizeByNewver_isCutFree {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) (d : ⊢ᵀ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] end Derivation @@ -151,13 +151,13 @@ def trans {r q p : ℙ} (srq : r ≼ q) (sqp : q ≼ p) : r ≼ p := ⟨sqp.val. def ofSubset {q p : ℙ} (h : q ⊇ p) : q ≼ p := ⟨.ofSubset <| List.map_subset _ h⟩ -def and {p : ℙ} (φ ψ : SyntacticFormula L) : φ ⋏ ψ :: p ≼ φ :: ψ :: p := ⟨.or .id⟩ +def and {p : ℙ} (φ ψ : Proposition L) : φ ⋏ ψ :: p ≼ φ :: ψ :: p := ⟨.or .id⟩ -def K_left {p : ℙ} (φ ψ : SyntacticFormula L) : φ ⋏ ψ :: p ≼ φ :: p := trans (and φ ψ) (ofSubset <| by simp) +def K_left {p : ℙ} (φ ψ : Proposition L) : φ ⋏ ψ :: p ≼ φ :: p := trans (and φ ψ) (ofSubset <| by simp) -def K_right {p : ℙ} (φ ψ : SyntacticFormula L) : φ ⋏ ψ :: p ≼ ψ :: p := trans (and φ ψ) (ofSubset <| by simp) +def K_right {p : ℙ} (φ ψ : Proposition L) : φ ⋏ ψ :: p ≼ ψ :: p := trans (and φ ψ) (ofSubset <| by simp) -def all {p : ℙ} (φ : SyntacticSemiformula L 1) (t) : (∀⁰ φ) :: p ≼ φ/[t] :: p := ⟨.exs t (by simpa [← Semiformula.neg_eq] using .id)⟩ +def all {p : ℙ} (φ : Semiproposition L 1) (t) : (∀⁰ φ) :: p ≼ φ/[t] :: p := ⟨.exs t (by simpa [← Semiformula.neg_eq] using .id)⟩ def minLeLeft (p q : ℙ) : p ⊓ q ≼ p := ofSubset (by simp [inf_def]) @@ -171,7 +171,7 @@ def leMinRightOfLe (s : q ≼ p) : q ≼ p ⊓ q := leMinOfle s (.refl q) end StrongerThan -def Forces (p : ℙ) : SyntacticFormulaᵢ L → Type u +def Forces (p : ℙ) : Propositionᵢ L → Type u | ⊥ => { b : ⊢ᵀ ∼p // Derivation.IsCutFree b } | .rel R v => { b : ⊢ᵀ .rel R v :: ∼p // Derivation.IsCutFree b } | φ ⋏ ψ => Forces p φ × Forces p ψ @@ -183,7 +183,7 @@ def Forces (p : ℙ) : SyntacticFormulaᵢ L → Type u scoped infix:45 " ⊩ " => Forces -abbrev allForces (φ : SyntacticFormulaᵢ L) := (p : ℙ) → p ⊩ φ +abbrev allForces (φ : Propositionᵢ L) := (p : ℙ) → p ⊩ φ scoped prefix:45 "⊩ " => allForces @@ -194,19 +194,19 @@ def falsumEquiv : p ⊩ ⊥ ≃ { b : ⊢ᵀ ∼p // Derivation.IsCutFree b} := def relEquiv {k} {R : L.Rel k} {v} : p ⊩ .rel R v ≃ { b : ⊢ᵀ .rel R v :: ∼p // Derivation.IsCutFree b } := by unfold Forces; exact .refl _ -def andEquiv {φ ψ : SyntacticFormulaᵢ L} : p ⊩ φ ⋏ ψ ≃ (p ⊩ φ) × (p ⊩ ψ) := by +def andEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ ⋏ ψ ≃ (p ⊩ φ) × (p ⊩ ψ) := by conv => lhs unfold Forces exact .refl _ -def orEquiv {φ ψ : SyntacticFormulaᵢ L} : p ⊩ φ ⋎ ψ ≃ (p ⊩ φ) ⊕ (p ⊩ ψ) := by +def orEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ ⋎ ψ ≃ (p ⊩ φ) ⊕ (p ⊩ ψ) := by conv => lhs unfold Forces exact .refl _ -def implyEquiv {φ ψ : SyntacticFormulaᵢ L} : p ⊩ φ ➝ ψ ≃ ((q : ℙ) → q ≼ p → q ⊩ φ → q ⊩ ψ) := by +def implyEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ ➝ ψ ≃ ((q : ℙ) → q ≼ p → q ⊩ φ → q ⊩ ψ) := by conv => lhs unfold Forces @@ -226,7 +226,7 @@ def exsEquiv {φ} : p ⊩ ∃⁰ φ ≃ ((t : SyntacticTerm L) × Forces p (φ/[ def cast {p : ℙ} (f : p ⊩ φ) (s : φ = ψ) : p ⊩ ψ := s ▸ f -def monotone {q p : ℙ} (s : q ≼ p) : {φ : SyntacticFormulaᵢ L} → p ⊩ φ → q ⊩ φ +def monotone {q p : ℙ} (s : q ≼ p) : {φ : Propositionᵢ L} → p ⊩ φ → q ⊩ φ | ⊥, b => let ⟨d, hd⟩ := b.falsumEquiv falsumEquiv.symm ⟨s.val.graft d, PositiveDerivationFrom.graft_isCutFree_of_isCutFree hd⟩ @@ -242,7 +242,7 @@ def monotone {q p : ℙ} (s : q ≼ p) : {φ : SyntacticFormulaᵢ L} → p ⊩ exsEquiv.symm ⟨t, d.monotone s⟩ termination_by φ => φ.complexity -def explosion {p : ℙ} (b : p ⊩ ⊥) : (φ : SyntacticFormulaᵢ L) → p ⊩ φ +def explosion {p : ℙ} (b : p ⊩ ⊥) : (φ : Propositionᵢ L) → p ⊩ φ | ⊥ => b | .rel R v => let ⟨d, hd⟩ := b.falsumEquiv @@ -254,19 +254,19 @@ def explosion {p : ℙ} (b : p ⊩ ⊥) : (φ : SyntacticFormulaᵢ L) → p ⊩ | ∃⁰ φ => exsEquiv.symm ⟨default, b.explosion (φ/[default])⟩ termination_by φ => φ.complexity -def efq (φ : SyntacticFormulaᵢ L) : ⊩ ⊥ ➝ φ := fun _ ↦ implyEquiv.symm fun _ _ d ↦ d.explosion φ +def efq (φ : Propositionᵢ L) : ⊩ ⊥ ➝ φ := fun _ ↦ implyEquiv.symm fun _ _ d ↦ d.explosion φ -def implyOf {φ ψ : SyntacticFormulaᵢ L} (b : (q : ℙ) → q ⊩ φ → p ⊓ q ⊩ ψ) : +def implyOf {φ ψ : Propositionᵢ L} (b : (q : ℙ) → q ⊩ φ → p ⊓ q ⊩ ψ) : p ⊩ φ ➝ ψ := implyEquiv.symm fun q sqp fφ ↦ let fψ : p ⊓ q ⊩ ψ := b q fφ fψ.monotone (StrongerThan.leMinRightOfLe sqp) open LawfulSyntacticRewriting -def modusPonens {φ ψ : SyntacticFormulaᵢ L} (f : p ⊩ φ ➝ ψ) (g : p ⊩ φ) : p ⊩ ψ := +def modusPonens {φ ψ : Propositionᵢ L} (f : p ⊩ φ ➝ ψ) (g : p ⊩ φ) : p ⊩ ψ := f.implyEquiv p (StrongerThan.refl p) g -def ofMinimalProof {φ : SyntacticFormulaᵢ L} : 𝗠𝗶𝗻¹ ⊢! φ → ⊩ φ +def ofMinimalProof {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢! φ → ⊩ φ | .mdp (φ := ψ) b d => fun p ↦ let b : p ⊩ ψ ➝ φ := ofMinimalProof b p let d : p ⊩ ψ := ofMinimalProof d p @@ -356,7 +356,7 @@ protected def refl.exs (d : ∀ x, [φ/[&x]] ⊩ (φ/[&x])ᴺ) : [∃⁰ φ] ⊩ (Derivation.cast b (by simp [inf_def])) falsumEquiv.symm ⟨ba, by simp [ba, hb]⟩ -protected def refl : (φ : SyntacticFormula L) → [φ] ⊩ φᴺ +protected def refl : (φ : Proposition L) → [φ] ⊩ φᴺ | ⊤ => implyEquiv.symm fun q sqp dφ ↦ dφ | ⊥ => falsumEquiv.symm ⟨Derivation.verum, by simp⟩ | .rel R v => implyOf fun q dq ↦ @@ -376,12 +376,12 @@ protected def refl : (φ : SyntacticFormula L) → [φ] ⊩ φᴺ | ∃⁰ φ => refl.exs fun x ↦ Forces.refl (φ/[&x]) termination_by φ => φ.complexity -def conj : {Γ : Sequentᵢ L} → (b : (φ : SyntacticFormulaᵢ L) → φ ∈ Γ → p ⊩ φ) → p ⊩ ⋀Γ +def conj : {Γ : Sequentᵢ L} → (b : (φ : Propositionᵢ L) → φ ∈ Γ → p ⊩ φ) → p ⊩ ⋀Γ | [], _ => implyEquiv.symm fun q sqp bφ ↦ bφ | [φ], b => b φ (by simp) | φ :: ψ :: Γ, b => andEquiv.symm ⟨b φ (by simp), conj (fun χ hχ ↦ b χ (List.mem_cons_of_mem φ hχ))⟩ -def conj' : {Γ : Sequent L} → (b : (φ : SyntacticFormula L) → φ ∈ Γ → p ⊩ φᴺ) → p ⊩ ⋀Γᴺ +def conj' : {Γ : Sequent L} → (b : (φ : Proposition L) → φ ∈ Γ → p ⊩ φᴺ) → p ⊩ ⋀Γᴺ | [], _ => implyEquiv.symm fun q sqp bφ ↦ bφ | [φ], b => b φ (by simp) | φ :: ψ :: Γ, b => andEquiv.symm ⟨b φ (by simp), conj' (fun χ hχ ↦ b χ (List.mem_cons_of_mem φ hχ))⟩ diff --git a/Foundation/FirstOrder/Incompleteness/RosserProvability.lean b/Foundation/FirstOrder/Incompleteness/RosserProvability.lean index a35e2de2f..5cb2ac82c 100644 --- a/Foundation/FirstOrder/Incompleteness/RosserProvability.lean +++ b/Foundation/FirstOrder/Incompleteness/RosserProvability.lean @@ -35,13 +35,13 @@ end variable {T} -lemma rosser_quote {φ : SyntacticFormula L} : T.RosserProvable (V := V) ⌜φ⌝ ↔ T.ProvabilityComparisonLE (V := V) ⌜φ⌝ ⌜∼φ⌝ := by +lemma rosser_quote {φ : Proposition L} : T.RosserProvable (V := V) ⌜φ⌝ ↔ T.ProvabilityComparisonLE (V := V) ⌜φ⌝ ⌜∼φ⌝ := by simp [Theory.RosserProvable, Semiformula.quote_def] lemma rosser_quote₀ {φ : Sentence L} : T.RosserProvable (V := V) ⌜φ⌝ ↔ T.ProvabilityComparisonLE (V := V) ⌜φ⌝ ⌜∼φ⌝ := by simpa [Sentence.quote_def] using rosser_quote -lemma rosser_quote_def {φ : SyntacticFormula L} : +lemma rosser_quote_def {φ : Proposition L} : T.RosserProvable (V := V) ⌜φ⌝ ↔ ∃ b : V, T.Proof b ⌜φ⌝ ∧ ∀ b' < b, ¬T.Proof b' ⌜∼φ⌝ := rosser_quote lemma rosser_quote_def₀ {φ : Sentence L} : diff --git a/Foundation/FirstOrder/Intuitionistic/Deduction.lean b/Foundation/FirstOrder/Intuitionistic/Deduction.lean index c9505d702..3086bb09e 100644 --- a/Foundation/FirstOrder/Intuitionistic/Deduction.lean +++ b/Foundation/FirstOrder/Intuitionistic/Deduction.lean @@ -8,23 +8,23 @@ public import Foundation.FirstOrder.Intuitionistic.Rew namespace LO.FirstOrder -abbrev Sequentᵢ (L : Language) := List (SyntacticFormulaᵢ L) +abbrev Sequentᵢ (L : Language) := List (Propositionᵢ L) open Semiformulaᵢ variable {L : Language.{u}} {T : Theory L} structure Hilbertᵢ (L : Language) where - axiomSet : Set (SyntacticFormulaᵢ L) - rewrite_closed {φ : SyntacticFormulaᵢ L} : φ ∈ axiomSet → ∀ f : ℕ → SyntacticTerm L, Rew.rewrite f ▹ φ ∈ axiomSet + axiomSet : Set (Propositionᵢ L) + rewrite_closed {φ : Propositionᵢ L} : φ ∈ axiomSet → ∀ f : ℕ → SyntacticTerm L, Rew.rewrite f ▹ φ ∈ axiomSet namespace Hilbertᵢ -instance : SetLike (Hilbertᵢ L) (SyntacticFormulaᵢ L) where +instance : SetLike (Hilbertᵢ L) (Propositionᵢ L) where coe := Hilbertᵢ.axiomSet coe_injective' := by rintro ⟨T, _⟩ ⟨U, _⟩; simp -@[simp] lemma mem_mk (s : Set (SyntacticFormulaᵢ L)) (h) : φ ∈ Hilbertᵢ.mk s h ↔ φ ∈ s := by rfl +@[simp] lemma mem_mk (s : Set (Propositionᵢ L)) (h) : φ ∈ Hilbertᵢ.mk s h ↔ φ ∈ s := by rfl def Minimal : Hilbertᵢ L := ⟨∅, by simp⟩ @@ -47,7 +47,7 @@ notation "𝗖𝗹¹" => Classical end Hilbertᵢ -inductive HilbertProofᵢ (Λ : Hilbertᵢ L) : SyntacticFormulaᵢ L → Type _ +inductive HilbertProofᵢ (Λ : Hilbertᵢ L) : Propositionᵢ L → Type _ | eaxm {φ} : φ ∈ Λ → HilbertProofᵢ Λ φ | mdp {φ ψ} : HilbertProofᵢ Λ (φ ➝ ψ) → HilbertProofᵢ Λ φ → HilbertProofᵢ Λ ψ | gen {φ} : HilbertProofᵢ Λ (Rewriting.free φ) → HilbertProofᵢ Λ (∀⁰ φ) @@ -65,7 +65,7 @@ inductive HilbertProofᵢ (Λ : Hilbertᵢ L) : SyntacticFormulaᵢ L → Type _ | ex₁ t φ : HilbertProofᵢ Λ <| φ/[t] ➝ ∃⁰ φ | ex₂ φ ψ : HilbertProofᵢ Λ <| ∀⁰ (φ ➝ ψ/[]) ➝ ∃⁰ φ ➝ ψ -instance : Entailment (Hilbertᵢ L) (SyntacticFormulaᵢ L) := ⟨HilbertProofᵢ⟩ +instance : Entailment (Hilbertᵢ L) (Propositionᵢ L) := ⟨HilbertProofᵢ⟩ namespace HilbertProofᵢ @@ -156,7 +156,7 @@ def allIffAllOfIff {φ ψ} (b : Λ ⊢! free φ ⭤ free ψ) : Λ ⊢! ∀⁰ φ (allImplyAllOfAllImply φ ψ ⨀ gen (Entailment.cast (by simp) (Entailment.K_left b))) (allImplyAllOfAllImply ψ φ ⨀ gen (Entailment.cast (by simp) (Entailment.K_right b))) -def dneOfNegative [L.DecidableEq] : {φ : SyntacticFormulaᵢ L} → φ.IsNegative → Λ ⊢! ∼∼φ ➝ φ +def dneOfNegative [L.DecidableEq] : {φ : Propositionᵢ L} → φ.IsNegative → Λ ⊢! ∼∼φ ➝ φ | ⊥, _ => Entailment.CNNOO | φ ⋏ ψ, h => have ihφ : Λ ⊢! ∼∼φ ➝ φ := dneOfNegative (by simp [by simpa using h]) @@ -181,13 +181,13 @@ def dneOfNegative [L.DecidableEq] : {φ : SyntacticFormulaᵢ L} → φ.IsNegati implyAll (Entailment.cast (by simp) (deduct' this)) termination_by φ _ => φ.complexity -def ofDNOfNegative [L.DecidableEq] {φ : SyntacticFormulaᵢ L} {Γ} (b : Γ ⊢[Λ]! ∼∼φ) (h : φ.IsNegative) : Γ ⊢[Λ]! φ := +def ofDNOfNegative [L.DecidableEq] {φ : Propositionᵢ L} {Γ} (b : Γ ⊢[Λ]! ∼∼φ) (h : φ.IsNegative) : Γ ⊢[Λ]! φ := Entailment.C_trans (toDef b) (dneOfNegative h) -def DN_of_isNegative [L.DecidableEq] {φ : SyntacticFormulaᵢ L} (h : φ.IsNegative) : Λ ⊢! ∼∼φ ⭤ φ := +def DN_of_isNegative [L.DecidableEq] {φ : Propositionᵢ L} (h : φ.IsNegative) : Λ ⊢! ∼∼φ ⭤ φ := Entailment.K_intro (dneOfNegative h) Entailment.dni -def efqOfNegative : {φ : SyntacticFormulaᵢ L} → φ.IsNegative → Λ ⊢! ⊥ ➝ φ +def efqOfNegative : {φ : Propositionᵢ L} → φ.IsNegative → Λ ⊢! ⊥ ➝ φ | ⊥, _ => Entailment.C_id | φ ⋏ ψ, h => have ihφ : Λ ⊢! ⊥ ➝ φ := efqOfNegative (by simp [by simpa using h]) @@ -201,7 +201,7 @@ def efqOfNegative : {φ : SyntacticFormulaᵢ L} → φ.IsNegative → Λ ⊢! implyAll <| Entailment.cast (by simp) ihφ termination_by φ _ => φ.complexity -def iffnegOfNegIff [L.DecidableEq] {φ ψ : SyntacticFormulaᵢ L} (h : φ.IsNegative) (b : Λ ⊢! ∼φ ⭤ ψ) : Λ ⊢! φ ⭤ ∼ψ := +def iffnegOfNegIff [L.DecidableEq] {φ ψ : Propositionᵢ L} (h : φ.IsNegative) (b : Λ ⊢! ∼φ ⭤ ψ) : Λ ⊢! φ ⭤ ∼ψ := Entailment.E_trans (Entailment.E_symm <| DN_of_isNegative h) (Entailment.ENN_of_E b) def rewrite (f : ℕ → SyntacticTerm L) : Λ ⊢! φ → Λ ⊢! Rew.rewrite f ▹ φ @@ -295,7 +295,7 @@ instance : AdjunctiveSet (Sentenceᵢ L) (Theoryᵢ L 𝓗) where @[simp] lemma adjoin_theory_def : (adjoin φ T).theory = insert φ T.theory := rfl def Proof (T : Theoryᵢ L 𝓗) (φ : Sentenceᵢ L) := - (Rewriting.emb '' T.theory) *⊢[𝓗]! (Rewriting.emb φ : SyntacticFormulaᵢ L) + (Rewriting.emb '' T.theory) *⊢[𝓗]! (Rewriting.emb φ : Propositionᵢ L) instance : Entailment (Theoryᵢ L 𝓗) (Sentenceᵢ L) := ⟨Theoryᵢ.Proof⟩ diff --git a/Foundation/FirstOrder/Intuitionistic/Formula.lean b/Foundation/FirstOrder/Intuitionistic/Formula.lean index 349790571..cf1c77e24 100644 --- a/Foundation/FirstOrder/Intuitionistic/Formula.lean +++ b/Foundation/FirstOrder/Intuitionistic/Formula.lean @@ -30,9 +30,9 @@ abbrev Sentenceᵢ (L : Language) := Formulaᵢ L Empty abbrev Semisentenceᵢ (L : Language) (n : ℕ) := Semiformulaᵢ L Empty n -abbrev SyntacticSemiformulaᵢ (L : Language) (n : ℕ) := Semiformulaᵢ L ℕ n +abbrev Semipropositionᵢ (L : Language) (n : ℕ) := Semiformulaᵢ L ℕ n -abbrev SyntacticFormulaᵢ (L : Language) := SyntacticSemiformulaᵢ L 0 +abbrev Propositionᵢ (L : Language) := Semipropositionᵢ L 0 variable {L : Language} diff --git a/Foundation/FirstOrder/Intuitionistic/Rew.lean b/Foundation/FirstOrder/Intuitionistic/Rew.lean index 146fb884a..0ce318de1 100644 --- a/Foundation/FirstOrder/Intuitionistic/Rew.lean +++ b/Foundation/FirstOrder/Intuitionistic/Rew.lean @@ -31,7 +31,7 @@ instance : Rewriting L ξ (Semiformulaᵢ L ξ) ζ (Semiformulaᵢ L ζ) where app_all (_ _) := rfl app_exs (_ _) := rfl -instance : Coe (Semisentenceᵢ L n) (SyntacticSemiformulaᵢ L n) := ⟨Rewriting.emb (ξ := ℕ)⟩ +instance : Coe (Semisentenceᵢ L n) (Semipropositionᵢ L n) := ⟨Rewriting.emb (ξ := ℕ)⟩ lemma rew_rel (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} (r : L.Rel k) (v : Fin k → Semiterm L ξ₁ n₁) : ω ▹ rel r v = rel r fun i ↦ ω (v i) := rfl @@ -76,7 +76,7 @@ instance : TransitiveRewriting L ξ₁ (Semiformulaᵢ L ξ₁) ξ₂ (Semiformu instance : InjMapRewriting L ξ (Semiformulaᵢ L ξ) ζ (Semiformulaᵢ L ζ) where smul_map_injective := map_inj -instance : LawfulSyntacticRewriting L (SyntacticSemiformulaᵢ L) where +instance : LawfulSyntacticRewriting L (Semipropositionᵢ L) where @[simp] lemma complexity_rew (ω : Rew L ξ₁ n₁ ξ₂ n₂) (φ : Semiformulaᵢ L ξ₁ n₁) : (ω ▹ φ).complexity = φ.complexity := by induction φ using rec' generalizing n₂ <;> simp [*, rew_rel] diff --git a/Foundation/FirstOrder/Kripke/Intuitionistic.lean b/Foundation/FirstOrder/Kripke/Intuitionistic.lean index a5efef924..162ca826e 100644 --- a/Foundation/FirstOrder/Kripke/Intuitionistic.lean +++ b/Foundation/FirstOrder/Kripke/Intuitionistic.lean @@ -98,7 +98,7 @@ lemma rew {bv : Fin n₂ → C} {fv : ξ₂ → C} {ω : Rew L ξ₁ n₁ ξ₂ funext i; cases i using Fin.cases <;> simp simp [ih, this] -@[simp] lemma free {v : W} {fv : ℕ → C} {φ : SyntacticSemiformulaᵢ L (n + 1)} : +@[simp] lemma free {v : W} {fv : ℕ → C} {φ : Semipropositionᵢ L (n + 1)} : v ⊩[bv|↑x :>ₙ fv] Rewriting.free φ ↔ v ⊩[bv <: x|fv] φ := by have : (fun i ↦ Semiterm.relationalVal (L := L) bv (x :>ₙ fv) (Rew.free #i)) = (bv <: x) := by ext i; cases i using Fin.lastCases <;> simp diff --git a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean index d10c820dd..39d22e553 100644 --- a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean +++ b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean @@ -92,7 +92,7 @@ variable {L : Language} [L.DecidableEq] {T : Theory L} {Λ : Hilbertᵢ L} open Rewriting LO.Entailment Entailment.FiniteContext HilbertProofᵢ -def negDoubleNegation : (φ : SyntacticFormula L) → Λ ⊢! ∼φᴺ ⭤ (∼φ)ᴺ +def negDoubleNegation : (φ : Proposition L) → Λ ⊢! ∼φᴺ ⭤ (∼φ)ᴺ | .rel r v => Entailment.tneIff (φ := Semiformulaᵢ.rel r v) | .nrel r v => Entailment.E_Id (φ := ∼∼(Semiformulaᵢ.rel r v)) | ⊤ => Entailment.ENNOO @@ -123,13 +123,13 @@ def negDoubleNegation : (φ : SyntacticFormula L) → Λ ⊢! ∼φᴺ ⭤ (∼ this termination_by φ => φ.complexity -lemma neg_doubleNegation (φ : SyntacticFormula L) : Λ ⊢ ∼φᴺ ⭤ (∼φ)ᴺ := ⟨negDoubleNegation φ⟩ +lemma neg_doubleNegation (φ : Proposition L) : Λ ⊢ ∼φᴺ ⭤ (∼φ)ᴺ := ⟨negDoubleNegation φ⟩ -lemma neg_doubleNegation' (φ : SyntacticFormula L) : Λ ⊢ ∼(∼φ)ᴺ ⭤ φᴺ := by simpa using neg_doubleNegation (∼φ) +lemma neg_doubleNegation' (φ : Proposition L) : Λ ⊢ ∼(∼φ)ᴺ ⭤ φᴺ := by simpa using neg_doubleNegation (∼φ) open FiniteContext -lemma imply_doubleNegation (φ ψ : SyntacticFormula L) : Λ ⊢ (φᴺ ➝ ψᴺ) ⭤ (φ ➝ ψ)ᴺ := by +lemma imply_doubleNegation (φ ψ : Proposition L) : Λ ⊢ (φᴺ ➝ ψᴺ) ⭤ (φ ➝ ψ)ᴺ := by suffices Λ ⊢ (φᴺ ➝ ψᴺ) ⭤ ∼(∼(∼φ)ᴺ ⋏ ∼ψᴺ) by simpa [Semiformula.doubleNegation_imply] have hφ₀ : Λ ⊢ ∼(∼φ)ᴺ ⭤ φᴺ := by simpa using neg_doubleNegation (∼φ) have hψ : Λ ⊢ ∼∼ψᴺ ⭤ ψᴺ := ⟨DN_of_isNegative (by simp)⟩ @@ -191,16 +191,16 @@ theorem gödel_gentzen {T : Theory L} {φ} : T ⊢ φ → T.ToTheoryᵢ Λ ⊢ intro h let ⟨⟨s, hs⟩, b⟩ := Theory.compact' h have h : (∅ : Schema L) ⊢ ↑s.conj ➝ ↑φ := by simpa using provable_def.mp b - let ψ : SyntacticFormula L := ↑s.conj ➝ ↑φ + let ψ : Proposition L := ↑s.conj ➝ ↑φ have h₁ : Λ ⊢ ∼(∼ψ)ᴺ := by simpa using Entailment.FiniteContext.provable_iff.mp ⟨Derivation.gödelGentzen h.get⟩ have h₂ : Λ ⊢ ∼(∼ψ)ᴺ ⭤ ψᴺ := by simpa using Derivation.neg_doubleNegation (∼ψ) have : Λ ⊢ ψᴺ := K!_left h₂ ⨀ h₁ - have H : Λ ⊢ (↑s.conj : SyntacticFormula L)ᴺ ➝ ↑φᴺ := + have H : Λ ⊢ (↑s.conj : Proposition L)ᴺ ➝ ↑φᴺ := by simpa [Semiformula.emb_doubleNegation] using (K!_right (Derivation.imply_doubleNegation _ _)) ⨀ this - let U : Set (SyntacticFormulaᵢ L) := (Rewriting.emb '' (T.ToTheoryᵢ Λ).theory) + let U : Set (Propositionᵢ L) := (Rewriting.emb '' (T.ToTheoryᵢ Λ).theory) suffices - U *⊢[Λ] ⋀ s.toList.map fun φ : Sentence L ↦ (↑φ : SyntacticFormula L)ᴺ by + U *⊢[Λ] ⋀ s.toList.map fun φ : Sentence L ↦ (↑φ : Proposition L)ᴺ by apply Theoryᵢ.provable_def.mpr apply Context.of! H ⨀ ?_ simpa [Finset.conj, List.map_conj₂, Function.comp_def] diff --git a/Foundation/FirstOrder/SetTheory/Basic/Axioms.lean b/Foundation/FirstOrder/SetTheory/Basic/Axioms.lean index 0b2f9f967..95ce1aec2 100644 --- a/Foundation/FirstOrder/SetTheory/Basic/Axioms.lean +++ b/Foundation/FirstOrder/SetTheory/Basic/Axioms.lean @@ -50,11 +50,11 @@ def infinity : Sentence ℒₛₑₜ := “∃ I, (∀ e, !isEmpty e → e ∈ I def foundation : Sentence ℒₛₑₜ := “∀ x, !isNonempty x → ∃ y ∈ x, ∀ z ∈ x, z ∉ y” /-- Axiom schema of separation (Aussonderungsaxiom). -/ -def separationSchema (φ : SyntacticSemiformula ℒₛₑₜ 1) : Sentence ℒₛₑₜ := +def separationSchema (φ : Semiproposition ℒₛₑₜ 1) : Sentence ℒₛₑₜ := .univCl “∀ x, ∃ y, ∀ z, z ∈ y ↔ z ∈ x ∧ !φ z” /-- Axiom schema of replacement. -/ -def replacementSchema (φ : SyntacticSemiformula ℒₛₑₜ 2) : Sentence ℒₛₑₜ := +def replacementSchema (φ : Semiproposition ℒₛₑₜ 2) : Sentence ℒₛₑₜ := .univCl “(∀ x, ∃! y, !φ x y) → ∀ X, ∃ Y, ∀ y, y ∈ Y ↔ ∃ x ∈ X, !φ x y” /-- Axiom of choice. -/ @@ -84,7 +84,7 @@ inductive Zermelo : Theory ℒₛₑₜ /-- Axiom of foundation. -/ | axiom_of_foundation : Zermelo Axiom.foundation /-- Axiom schema of separation. -/ - | axiom_of_separation (φ : SyntacticSemiformula ℒₛₑₜ 1) : Zermelo (Axiom.separationSchema φ) + | axiom_of_separation (φ : Semiproposition ℒₛₑₜ 1) : Zermelo (Axiom.separationSchema φ) notation "𝗭" => Zermelo @@ -111,9 +111,9 @@ inductive ZermeloFraenkel : Theory ℒₛₑₜ /-- Axiom of foundation. -/ | axiom_of_foundation : ZermeloFraenkel Axiom.foundation /-- Axiom schema of separation. -/ - | axiom_of_separation (φ : SyntacticSemiformula ℒₛₑₜ 1) : ZermeloFraenkel (Axiom.separationSchema φ) + | axiom_of_separation (φ : Semiproposition ℒₛₑₜ 1) : ZermeloFraenkel (Axiom.separationSchema φ) /-- Axiom schema of replacement. -/ - | axiom_of_replacement (φ : SyntacticSemiformula ℒₛₑₜ 2) : ZermeloFraenkel (Axiom.replacementSchema φ) + | axiom_of_replacement (φ : Semiproposition ℒₛₑₜ 2) : ZermeloFraenkel (Axiom.replacementSchema φ) notation "𝗭𝗙" => ZermeloFraenkel diff --git a/Foundation/LinearLogic/FirstOrder/ClassicalEmbedding.lean b/Foundation/LinearLogic/FirstOrder/ClassicalEmbedding.lean index 3d7d013e5..21bef703a 100644 --- a/Foundation/LinearLogic/FirstOrder/ClassicalEmbedding.lean +++ b/Foundation/LinearLogic/FirstOrder/ClassicalEmbedding.lean @@ -447,7 +447,7 @@ namespace Proof variable [L.DecidableEq] theorem girard {φ : Sentence L} : 𝐋𝐊 ⊢ φ → 𝐋𝐋 ⊢ φ.Girard := fun h ↦ ⟨by - have : 𝐋𝐊₀ ⊢ (φ : SyntacticFormula L) := by simpa using Proof.cast.mp h + have : 𝐋𝐊₀ ⊢ (φ : Proposition L) := by simpa using Proof.cast.mp h simpa using Derivation.toLL this.get⟩ theorem girard_faithful {φ : Sentence L} : 𝐋𝐋 ⊢ φ.Girard ↔ 𝐋𝐊 ⊢ φ := From 55b4981f61c55a3fd65dc27e06f884e7897b37b3 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Fri, 6 Mar 2026 20:29:57 +0900 Subject: [PATCH 04/61] Schema --- .../FirstOrder/Basic/Syntax/Schema.lean | 124 ++++++++++++++++++ .../FirstOrder/Basic/Syntax/Theory.lean | 77 ----------- Foundation/Syntax/Predicate/Rew.lean | 18 ++- 3 files changed, 141 insertions(+), 78 deletions(-) create mode 100644 Foundation/FirstOrder/Basic/Syntax/Schema.lean delete mode 100644 Foundation/FirstOrder/Basic/Syntax/Theory.lean diff --git a/Foundation/FirstOrder/Basic/Syntax/Schema.lean b/Foundation/FirstOrder/Basic/Syntax/Schema.lean new file mode 100644 index 000000000..d5a54d1f9 --- /dev/null +++ b/Foundation/FirstOrder/Basic/Syntax/Schema.lean @@ -0,0 +1,124 @@ +module + +public import Foundation.FirstOrder.Basic.Syntax.Rew + +@[expose] public section + +/-! +# Schema + +First-order schema `Schema L` is defined as a set of propositions, which may contains free variables. + +-/ + +namespace LO.FirstOrder + +structure Schema (L : Language) where + Mem : Proposition L → Prop + +namespace Schema + +variable {L : Language} + +instance : SetLike (Schema L) (Proposition L) where + coe 𝓢 := { φ | 𝓢.Mem φ } + coe_injective' := by + rintro ⟨⟩ ⟨⟩ _ + congr + +lemma mem_def (𝓢 : Schema L) (φ : Proposition L) : 𝓢.Mem φ ↔ φ ∈ 𝓢 := Iff.rfl + +@[simp] lemma mem_mk_iff (φ : Proposition L) (P : Proposition L → Prop) : φ ∈ Schema.mk P ↔ P φ := Iff.rfl + +lemma le_def (𝓢₁ 𝓢₂ : Schema L) : 𝓢₁ ≤ 𝓢₂ ↔ ∀ φ, φ ∈ 𝓢₁ → φ ∈ 𝓢₂ := Iff.rfl + +instance : CompleteLattice (Schema L) where + sup 𝓢₁ 𝓢₂ := ⟨fun φ ↦ φ ∈ 𝓢₁ ∨ φ ∈ 𝓢₂⟩ + le_sup_left _ _ := by simp [le_def]; grind + le_sup_right _ _ := by simp [le_def]; grind + sup_le _ _ _ := by simp [le_def]; grind + inf 𝓢₁ 𝓢₂ := ⟨fun φ ↦ φ ∈ 𝓢₁ ∧ φ ∈ 𝓢₂⟩ + inf_le_left _ _ := by simp [le_def]; grind + inf_le_right _ _ := by simp [le_def] + le_inf _ _ _ := by simp [le_def]; grind + sSup s := ⟨fun φ ↦ ∃ 𝓢 ∈ s, φ ∈ 𝓢⟩ + le_sSup _ _ := by simp [le_def]; grind + sSup_le _ _ := by simp [le_def]; grind + sInf s := ⟨fun φ ↦ ∀ 𝓢 ∈ s, φ ∈ 𝓢⟩ + sInf_le _ _ := by simp [le_def]; grind + le_sInf _ _ := by simp [le_def]; grind + top := ⟨fun _ ↦ True⟩ + le_top _ _ := by simp + bot := ⟨fun _ ↦ False⟩ + bot_le _ _ := by simp + +@[simp] lemma mem_sup_iff (𝓢₁ 𝓢₂ : Schema L) (φ : Proposition L) : φ ∈ 𝓢₁ ⊔ 𝓢₂ ↔ φ ∈ 𝓢₁ ∨ φ ∈ 𝓢₂ := Iff.rfl + +@[simp] lemma mem_inf_iff (𝓢₁ 𝓢₂ : Schema L) (φ : Proposition L) : φ ∈ 𝓢₁ ⊓ 𝓢₂ ↔ φ ∈ 𝓢₁ ∧ φ ∈ 𝓢₂ := Iff.rfl + +@[simp] lemma mem_sSup_iff (s : Set (Schema L)) (φ : Proposition L) : φ ∈ sSup s ↔ ∃ 𝓢 ∈ s, φ ∈ 𝓢 := Iff.rfl + +@[simp] lemma mem_sInf_iff (s : Set (Schema L)) (φ : Proposition L) : φ ∈ sInf s ↔ ∀ 𝓢 ∈ s, φ ∈ 𝓢 := Iff.rfl + +@[simp] lemma mem_top (φ : Proposition L) : φ ∈ (⊤ : Schema L) := by trivial + +@[simp] lemma not_mem_bot (φ : Proposition L) : φ ∉ (⊥ : Schema L) := by rintro ⟨⟩ + +instance : Coe (Proposition L) (Schema L) := ⟨fun φ ↦ ⟨(· = φ)⟩⟩ + +@[simp] lemma mem_coe (φ ψ : Proposition L) : ψ ∈ (φ : Schema L) ↔ ψ = φ := by simp + +instance : AdjunctiveSet (Proposition L) (Schema L) where + Subset 𝓢₁ 𝓢₂ := 𝓢₁ ≤ 𝓢₂ + emptyCollection := ⊥ + adjoin φ 𝓢 := φ ⊔ 𝓢 + subset_iff := by simp [le_def] + not_mem_empty _ := by simp + mem_cons_iff := by simp + +class IsClosed (𝓢 : Schema L) : Prop where + closed : ∀ ω : Rew L ℕ 0 ℕ 0, ∀ φ ∈ 𝓢, ω ▹ φ ∈ 𝓢 + +namespace IsClosed + +instance : IsClosed (⊤ : Schema L) where + closed _ _ _ := by trivial + +instance : IsClosed (⊥ : Schema L) where + closed _ _ := by rintro ⟨⟩ + +instance sup (𝓢₁ 𝓢₂ : Schema L) [IsClosed 𝓢₁] [IsClosed 𝓢₂] : IsClosed (𝓢₁ ⊔ 𝓢₂) where + closed ω φ h := by + have : φ ∈ 𝓢₁ ∨ φ ∈ 𝓢₂ := by simpa using h + rcases this with (h |h ) + · left; apply IsClosed.closed ω φ h + · right; apply IsClosed.closed ω φ h + +instance inf (𝓢₁ 𝓢₂ : Schema L) [IsClosed 𝓢₁] [IsClosed 𝓢₂] : IsClosed (𝓢₁ ⊓ 𝓢₂) where + closed ω φ h := by + have : φ ∈ 𝓢₁ ∧ φ ∈ 𝓢₂ := by simpa using h + rcases this with ⟨h₁, h₂⟩ + constructor + · apply IsClosed.closed ω φ h₁ + · apply IsClosed.closed ω φ h₂ + +lemma sSup (s : Set (Schema L)) (H : ∀ 𝓢 ∈ s, IsClosed 𝓢) : IsClosed (sSup s) where + closed ω φ h := by + have : ∃ 𝓢 ∈ s, φ ∈ 𝓢 := by simpa using h + rcases this with ⟨𝓢, hs, hφ⟩ + have : IsClosed 𝓢 := H 𝓢 hs + exact ⟨𝓢, hs, IsClosed.closed _ _ hφ⟩ + +instance (σ : Sentence L) : IsClosed (σ : Schema L) where + closed _ φ h := by + have : φ = σ := by simpa using h + rcases this + simp + +end IsClosed + +end Schema + +end LO.FirstOrder + +end diff --git a/Foundation/FirstOrder/Basic/Syntax/Theory.lean b/Foundation/FirstOrder/Basic/Syntax/Theory.lean deleted file mode 100644 index 252314b45..000000000 --- a/Foundation/FirstOrder/Basic/Syntax/Theory.lean +++ /dev/null @@ -1,77 +0,0 @@ -module - -public import Foundation.FirstOrder.Basic.Syntax.Rew - -@[expose] public section - -/-! -# Theory of first-order logic - -First-order theory `Theory L` is defined as a set of sentence. --/ - -namespace LO.FirstOrder - -abbrev Schema (L : Language) := Set (SyntacticFormula L) - -abbrev Theory (L : Language) := Set (Sentence L) - -instance : AdjunctiveSet (SyntacticFormula L) (Schema L) := inferInstance - -instance : AdjunctiveSet (Sentence L) (Theory L) := inferInstance - -namespace Theory - -variable (T U : Theory L) - -def lMap (Φ : L₁ →ᵥ L₂) (T : Theory L₁) : Theory L₂ := Semiformula.lMap Φ '' T - -variable {T U} - -instance {L : Language} : Add (Theory L) := ⟨(· ∪ ·)⟩ - -lemma add_def : T + U = T ∪ U := rfl - -@[coe] def toSchema (T : Theory L) : Schema L := Rewriting.emb '' T - -instance : Coe (Theory L) (Schema L) := ⟨toSchema⟩ - -@[simp] lemma coe_mem_coe {σ : Sentence L} {T : Theory L} : (σ : SyntacticFormula L) ∈ (T : Schema L) ↔ σ ∈ T := by - simp [toSchema] - -@[simp] lemma coe_empty_eq : ((∅ : Theory L) : Schema L) = ∅ := by simp [toSchema] - -@[simp] lemma coe_subset_coe : (T : Schema L) ⊆ (U : Schema L) ↔ T ⊆ U := by - constructor - · intro h σ hσ - simpa using h (Theory.coe_mem_coe.mpr hσ) - · simp only [toSchema, Set.image_subset_iff] - intro h σ hσ - refine Set.mem_preimage.mpr (Theory.coe_mem_coe.mpr (h hσ)) - -@[simp] lemma coe_insert (σ : Sentence L) (T : Theory L) : (insert σ T).toSchema = insert ↑σ ↑T := by - ext; simp [toSchema]; tauto - -end Theory - -namespace Schema - -def lMap (Φ : L₁ →ᵥ L₂) (𝓢 : Schema L₁) : Schema L₂ := Semiformula.lMap Φ '' 𝓢 - -@[coe] def toTheory (𝓢 : Schema L) : Theory L := Semiformula.univCl '' 𝓢 - -instance : CoeOut (Schema L) (Theory L) := ⟨toTheory⟩ - -end Schema - -@[simp] lemma Theory.coe_insert_eq (σ : Sentence L) (𝓢 : Schema L) : - ((insert ↑σ 𝓢 : Schema L) : Theory L) = insert σ ↑𝓢 := by - ext τ - simp [Schema.toTheory] - simp [Semiformula.univCl] - tauto - -abbrev ArithmeticAxiom := Theory ℒₒᵣ - -end LO.FirstOrder -end diff --git a/Foundation/Syntax/Predicate/Rew.lean b/Foundation/Syntax/Predicate/Rew.lean index 649b9204b..67448904d 100644 --- a/Foundation/Syntax/Predicate/Rew.lean +++ b/Foundation/Syntax/Predicate/Rew.lean @@ -572,6 +572,12 @@ lemma shift_comp_subst1 (t : SyntacticSemiterm L n₂) : · simp [comp_app] · exact IsEmpty.elim e x +@[simp] lemma comp_emb_eq_emb {o : Type v₁} [e : IsEmpty o] {ω : Rew L ξ₁ 0 ξ₂ 0} : + ω.comp emb = (emb : Rew L o 0 ξ₂ 0) := by + ext x + · exact Fin.elim0 x + · exact IsEmpty.elim e x + lemma rewrite_comp_free_eq_subst (t : SyntacticTerm L) : (rewrite (t :>ₙ Semiterm.fvar)).comp free = subst ![t] := by ext x <;> simp [comp_app] @@ -999,7 +1005,7 @@ end LawfulSyntacticRewriting namespace Rewriting -variable {ο ξ : Type*} [IsEmpty ο] {O F : ℕ → Type*} [LCWQ O] [LCWQ F] +variable {ο ξ : Type*} [IsEmpty ο] {O F F₁ F₂ : ℕ → Type*} [LCWQ O] [LCWQ F] [LCWQ F₁] [LCWQ F₂] open ReflectiveRewriting TransitiveRewriting InjMapRewriting Semiterm @@ -1009,6 +1015,16 @@ lemma emb_injective [Rewriting L ο O ξ F] [InjMapRewriting L ο O ξ F] : Func @[simp] lemma emb_allClosure [Rewriting L ο O ξ F] {σ : O n} : (emb (ξ := ξ) (∀⁰* σ)) = ∀⁰* (emb (ξ := ξ) σ) := by induction n <;> simp [*, allClosure_succ] +@[simp] lemma rew_emb_eq_emb + [Rewriting L ξ₁ F₁ ξ₂ F₂] [Rewriting L ο O ξ₁ F₁] [Rewriting L ο O ξ₂ F₂] + [TransitiveRewriting L ο O ξ₁ F₁ ξ₂ F₂] + (φ : O 0) (ω : Rew L ξ₁ 0 ξ₂ 0) : + ω ▹ (emb (ξ := ξ₁) φ) = emb (ξ := ξ₂) φ := by + unfold emb + rw [←comp_app] + congr 2 + simp + /-- `coe_subst_eq_subst_coe` -/ lemma emb_subst_eq_subst_emb [Rewriting L ο O ο O] [Rewriting L ο O ξ F] [Rewriting L ξ F ξ F] From 2681a6ee599cf8491c0cc027cfb54d6c1e9172eb Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 7 Mar 2026 03:56:35 +0900 Subject: [PATCH 05/61] int --- Foundation/FirstOrder/Basic/Syntax/Rew.lean | 70 +++++++++---------- Foundation/FirstOrder/Intuitionistic/Rew.lean | 2 +- Foundation/LinearLogic/FirstOrder/Rew.lean | 2 +- .../Propositional/Entailment/Cl/Basic.lean | 5 ++ Foundation/SecondOrder/Syntax/Rew.lean | 2 +- 5 files changed, 42 insertions(+), 39 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Syntax/Rew.lean b/Foundation/FirstOrder/Basic/Syntax/Rew.lean index 59de2020e..174b18911 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Rew.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Rew.lean @@ -81,37 +81,35 @@ lemma rew_rel (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} (r : L.Rel k) (v : Fin k lemma rew_nrel (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} (r : L.Rel k) (v : Fin k → Semiterm L ξ₁ n₁) : ω ▹ nrel r v = nrel r fun i ↦ ω (v i) := rfl -lemma rew_rel' (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} {r : L.Rel k} {v : Fin k → Semiterm L ξ₁ n₁} : +@[simp] lemma rew_rel_eq_comp (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} {r : L.Rel k} {v : Fin k → Semiterm L ξ₁ n₁} : ω ▹ rel r v = rel r (ω ∘ v) := rfl -lemma nrel' (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} {r : L.Rel k} {v : Fin k → Semiterm L ξ₁ n₁} : +@[simp] lemma rew_nrel_eq_comp (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} {r : L.Rel k} {v : Fin k → Semiterm L ξ₁ n₁} : ω ▹ nrel r v = nrel r (ω ∘ v) := rfl @[simp] lemma rew_rel0 (ω : Rew L ξ₁ n₁ ξ₂ n₂) {r : L.Rel 0} {v : Fin 0 → Semiterm L ξ₁ n₁} : - ω ▹ rel r v = rel r ![] := by simp [rew_rel, Matrix.empty_eq] + ω ▹ rel r v = rel r ![] := by simp [Matrix.empty_eq] @[simp] lemma rew_rel1 (ω : Rew L ξ₁ n₁ ξ₂ n₂) {r : L.Rel 1} {t : Semiterm L ξ₁ n₁} : - ω ▹ rel r ![t] = rel r ![ω t] := by simp [rew_rel, Matrix.constant_eq_singleton] + ω ▹ rel r ![t] = rel r ![ω t] := by simp @[simp] lemma rew_rel2 (ω : Rew L ξ₁ n₁ ξ₂ n₂) {r : L.Rel 2} {t₁ t₂ : Semiterm L ξ₁ n₁} : - ω ▹ rel r ![t₁, t₂] = rel r ![ω t₁, ω t₂] := by simp [rew_rel, Matrix.constant_eq_singleton, Matrix.comp_vecCons'] + ω ▹ rel r ![t₁, t₂] = rel r ![ω t₁, ω t₂] := by simp @[simp] lemma rew_rel3 (ω : Rew L ξ₁ n₁ ξ₂ n₂) {r : L.Rel 3} {t₁ t₂ t₃ : Semiterm L ξ₁ n₁} : - ω ▹ rel r ![t₁, t₂, t₃] = rel r ![ω t₁, ω t₂, ω t₃] := by - simp [rew_rel, Matrix.constant_eq_singleton, Matrix.comp_vecCons'] + ω ▹ rel r ![t₁, t₂, t₃] = rel r ![ω t₁, ω t₂, ω t₃] := by simp @[simp] lemma rew_nrel0 (ω : Rew L ξ₁ n₁ ξ₂ n₂) {r : L.Rel 0} {v : Fin 0 → Semiterm L ξ₁ n₁} : - ω ▹ nrel r v = nrel r ![] := by simp [rew_nrel, Matrix.empty_eq] + ω ▹ nrel r v = nrel r ![] := by simp [Matrix.empty_eq] @[simp] lemma rew_nrel1 (ω : Rew L ξ₁ n₁ ξ₂ n₂) {r : L.Rel 1} {t : Semiterm L ξ₁ n₁} : - ω ▹ nrel r ![t] = nrel r ![ω t] := by simp [rew_nrel, Matrix.constant_eq_singleton] + ω ▹ nrel r ![t] = nrel r ![ω t] := by simp @[simp] lemma rew_nrel2 (ω : Rew L ξ₁ n₁ ξ₂ n₂) {r : L.Rel 2} {t₁ t₂ : Semiterm L ξ₁ n₁} : - ω ▹ nrel r ![t₁, t₂] = nrel r ![ω t₁, ω t₂] := by simp [rew_nrel, Matrix.constant_eq_singleton, Matrix.comp_vecCons'] + ω ▹ nrel r ![t₁, t₂] = nrel r ![ω t₁, ω t₂] := by simp @[simp] lemma rew_nrel3 (ω : Rew L ξ₁ n₁ ξ₂ n₂) {r : L.Rel 3} {t₁ t₂ t₃ : Semiterm L ξ₁ n₁} : - ω ▹ nrel r ![t₁, t₂, t₃] = nrel r ![ω t₁, ω t₂, ω t₃] := by - simp [rew_nrel, Matrix.constant_eq_singleton, Matrix.comp_vecCons'] + ω ▹ nrel r ![t₁, t₂, t₃] = nrel r ![ω t₁, ω t₂, ω t₃] := by simp private lemma map_inj {b : Fin n₁ → Fin n₂} {f : ξ₁ → ξ₂} (hb : Function.Injective b) (hf : Function.Injective f) : @@ -122,49 +120,49 @@ private lemma map_inj {b : Fin n₁ → Fin n₂} {f : ξ₁ → ξ₂} simp only [rew_rel, rel.injEq, and_imp] rintro rfl; simp only [heq_eq_eq, true_and]; rintro rfl h; simp only [true_and] funext i; exact Rew.map_inj hb hf (congr_fun h i) - | nrel _ _ | ⊤ | ⊥ | _ ⋏ _ | _ ⋎ _ | ∀⁰ _ | ∃⁰ _ => by simp [rew_rel, rew_nrel] + | nrel _ _ | ⊤ | ⊥ | _ ⋏ _ | _ ⋎ _ | ∀⁰ _ | ∃⁰ _ => by simp | nrel r v => fun φ ↦ match φ with | nrel s w => by simp only [rew_nrel, nrel.injEq, and_imp] rintro rfl; simp only [heq_eq_eq, true_and]; rintro rfl h; simp only [true_and] funext i; exact Rew.map_inj hb hf (congr_fun h i) - | rel _ _ | ⊤ | ⊥ | _ ⋏ _ | _ ⋎ _ | ∀⁰ _ | ∃⁰ _ => by simp [rew_rel, rew_nrel] - | ⊤ => by intro φ; cases φ using cases' <;> simp [rew_rel, rew_nrel] - | ⊥ => by intro φ; cases φ using cases' <;> simp [rew_rel, rew_nrel] + | rel _ _ | ⊤ | ⊥ | _ ⋏ _ | _ ⋎ _ | ∀⁰ _ | ∃⁰ _ => by simp + | ⊤ => by intro φ; cases φ using cases' <;> simp + | ⊥ => by intro φ; cases φ using cases' <;> simp | φ ⋏ ψ => fun χ ↦ match χ with | _ ⋏ _ => by simp only [LogicalConnective.HomClass.map_and, and_inj, and_imp] intro hp hq; exact ⟨map_inj hb hf hp, map_inj hb hf hq⟩ - | rel _ _ | nrel _ _ | ⊤ | ⊥ | _ ⋎ _ | ∀⁰ _ | ∃⁰ _ => by simp [rew_rel, rew_nrel] + | rel _ _ | nrel _ _ | ⊤ | ⊥ | _ ⋎ _ | ∀⁰ _ | ∃⁰ _ => by simp | φ ⋎ ψ => fun χ ↦ match χ with | _ ⋎ _ => by simp only [LogicalConnective.HomClass.map_or, or_inj, and_imp] intro hp hq; exact ⟨map_inj hb hf hp, map_inj hb hf hq⟩ - | rel _ _ | nrel _ _ | ⊤ | ⊥ | _ ⋏ _ | ∀⁰ _ | ∃⁰ _ => by simp [rew_rel, rew_nrel] + | rel _ _ | nrel _ _ | ⊤ | ⊥ | _ ⋏ _ | ∀⁰ _ | ∃⁰ _ => by simp | ∀⁰ φ => fun ψ ↦ match ψ with | ∀⁰ _ => by simp only [Rewriting.app_all, Rew.q_map, Nat.succ_eq_add_one, all_inj] exact fun h ↦ map_inj (b := 0 :> Fin.succ ∘ b) (Matrix.injective_vecCons ((Fin.succ_injective _).comp hb) (fun _ ↦ (Fin.succ_ne_zero _).symm)) hf h - | rel _ _ | nrel _ _ | ⊤ | ⊥ | _ ⋏ _ | _ ⋎ _ | ∃⁰ _ => by simp [rew_rel, rew_nrel] + | rel _ _ | nrel _ _ | ⊤ | ⊥ | _ ⋏ _ | _ ⋎ _ | ∃⁰ _ => by simp | ∃⁰ φ => fun ψ ↦ match ψ with | ∃⁰ _ => by simp only [Rewriting.app_exs, Rew.q_map, Nat.succ_eq_add_one, exs_inj] exact fun h ↦ map_inj (b := 0 :> Fin.succ ∘ b) (Matrix.injective_vecCons ((Fin.succ_injective _).comp hb) (fun _ ↦ (Fin.succ_ne_zero _).symm)) hf h - | rel _ _ | nrel _ _ | ⊤ | ⊥ | _ ⋏ _ | _ ⋎ _ | ∀⁰ _ => by simp [rew_rel, rew_nrel] + | rel _ _ | nrel _ _ | ⊤ | ⊥ | _ ⋏ _ | _ ⋎ _ | ∀⁰ _ => by simp instance : ReflectiveRewriting L ξ (Semiformula L ξ) where - id_app (φ) := by induction φ using rec' <;> simp [rew_rel, rew_nrel, *] + id_app (φ) := by induction φ using rec' <;> simp [*, Function.comp_def] instance : TransitiveRewriting L ξ₁ (Semiformula L ξ₁) ξ₂ (Semiformula L ξ₂) ξ₃ (Semiformula L ξ₃) where comp_app {n₁ n₂ n₃ ω₁₂ ω₂₃ φ} := by - induction φ using rec' generalizing n₂ n₃ <;> simp [rew_rel, rew_nrel, Rew.comp_app, Rew.q_comp, *] + induction φ using rec' generalizing n₂ n₃ <;> simp [Rew.comp_app, Rew.q_comp, *, Function.comp_def] instance : InjMapRewriting L ξ (Semiformula L ξ) ζ (Semiformula L ζ) where smul_map_injective := map_inj @@ -172,17 +170,17 @@ instance : InjMapRewriting L ξ (Semiformula L ξ) ζ (Semiformula L ζ) where instance : LawfulSyntacticRewriting L (Semiproposition L) where @[simp] lemma complexity_rew (ω : Rew L ξ₁ n₁ ξ₂ n₂) (φ : Semiformula L ξ₁ n₁) : (ω ▹ φ).complexity = φ.complexity := by - induction φ using Semiformula.rec' generalizing n₂ <;> simp [*, rew_rel, rew_nrel] + induction φ using Semiformula.rec' generalizing n₂ <;> simp [*] section variable (ω : Rew L ξ₁ n₁ ξ₂ n₂) @[simp] lemma eq_top_iff {φ : Semiformula L ξ₁ n₁} : ω ▹ φ = (⊤ : Semiformula L ξ₂ n₂) ↔ φ = ⊤ := by - cases φ using Semiformula.rec' <;> simp [rew_rel, rew_nrel] + cases φ using Semiformula.rec' <;> simp @[simp] lemma eq_bot_iff {φ : Semiformula L ξ₁ n₁} : ω ▹ φ = (⊥ : Semiformula L ξ₂ n₂) ↔ φ = ⊥ := by - cases φ using Semiformula.rec' <;> simp [rew_rel, rew_nrel] + cases φ using Semiformula.rec' <;> simp lemma eq_rel_iff {φ : Semiformula L ξ₁ n₁} {k} {r : L.Rel k} {v} : ω ▹ φ = Semiformula.rel r v ↔ ∃ v', ω ∘ v' = v ∧ φ = Semiformula.rel r v' := by @@ -191,7 +189,7 @@ lemma eq_rel_iff {φ : Semiformula L ξ₁ n₁} {k} {r : L.Rel k} {v} : simp only [rew_rel, rel.injEq] by_cases hk : k' = k <;> simp [hk]; rcases hk with rfl; simp by_cases hr : r' = r <;> simp [hr, funext_iff] - | nrel _ _ | ⊤ | ⊥ | _ ⋏ _ | _ ⋎ _ | ∀⁰ _ | ∃⁰ _ => simp [rew_nrel] + | nrel _ _ | ⊤ | ⊥ | _ ⋏ _ | _ ⋎ _ | ∀⁰ _ | ∃⁰ _ => simp lemma eq_nrel_iff {φ : Semiformula L ξ₁ n₁} {k} {r : L.Rel k} {v} : ω ▹ φ = Semiformula.nrel r v ↔ ∃ v', ω ∘ v' = v ∧ φ = Semiformula.nrel r v' := by @@ -200,23 +198,23 @@ lemma eq_nrel_iff {φ : Semiformula L ξ₁ n₁} {k} {r : L.Rel k} {v} : simp only [rew_nrel] by_cases hk : k' = k <;> simp [hk]; rcases hk with rfl; simp by_cases hr : r' = r <;> simp [hr, funext_iff] - | rel _ _ | ⊤ | ⊥ | _ ⋏ _ | _ ⋎ _ | ∀⁰ _ | ∃⁰ _ => simp [rew_rel] + | rel _ _ | ⊤ | ⊥ | _ ⋏ _ | _ ⋎ _ | ∀⁰ _ | ∃⁰ _ => simp @[simp] lemma eq_and_iff {φ : Semiformula L ξ₁ n₁} {ψ₁ ψ₂ : Semiformula L ξ₂ n₂} : ω ▹ φ = ψ₁ ⋏ ψ₂ ↔ ∃ φ₁ φ₂ : Semiformula L ξ₁ n₁, ω ▹ φ₁ = ψ₁ ∧ ω ▹ φ₂ = ψ₂ ∧ φ = φ₁ ⋏ φ₂ := by - cases φ using Semiformula.rec' <;> simp [rew_rel, rew_nrel] + cases φ using Semiformula.rec' <;> simp @[simp] lemma eq_or_iff {φ : Semiformula L ξ₁ n₁} {ψ₁ ψ₂ : Semiformula L ξ₂ n₂} : ω ▹ φ = ψ₁ ⋎ ψ₂ ↔ ∃ φ₁ φ₂ : Semiformula L ξ₁ n₁, ω ▹ φ₁ = ψ₁ ∧ ω ▹ φ₂ = ψ₂ ∧ φ = φ₁ ⋎ φ₂ := by - cases φ using Semiformula.rec' <;> simp [rew_rel, rew_nrel] + cases φ using Semiformula.rec' <;> simp lemma eq_all_iff {φ : Semiformula L ξ₁ n₁} {ψ : Semiformula L ξ₂ (n₂ + 1)} : ω ▹ φ = ∀⁰ ψ ↔ ∃ φ' : Semiformula L ξ₁ (n₁ + 1), ω.q ▹ φ' = ψ ∧ φ = ∀⁰ φ' := by - cases φ using Semiformula.rec' <;> simp [rew_rel, rew_nrel] + cases φ using Semiformula.rec' <;> simp lemma eq_exs_iff {φ : Semiformula L ξ₁ n₁} {ψ : Semiformula L ξ₂ (n₂ + 1)} : ω ▹ φ = ∃⁰ ψ ↔ ∃ φ' : Semiformula L ξ₁ (n₁ + 1), ω.q ▹ φ' = ψ ∧ φ = ∃⁰ φ' := by - cases φ using Semiformula.rec' <;> simp [rew_rel, rew_nrel] + cases φ using Semiformula.rec' <;> simp @[simp] lemma eq_neg_iff {φ : Semiformula L ξ₁ n₁} {ψ₁ ψ₂ : Semiformula L ξ₂ n₂} : ω ▹ φ = ψ₁ ➝ ψ₂ ↔ ∃ φ₁ φ₂ : Semiformula L ξ₁ n₁, ω ▹ φ₁ = ψ₁ ∧ ω ▹ φ₂ = ψ₂ ∧ φ = φ₁ ➝ φ₂ := by @@ -390,7 +388,7 @@ lemma rew_eq_self_of [DecidableEq ξ] {ω : Rew L ξ n ξ n} {φ : Semiformula L section univCl @[simp] lemma fvSup_sentence (σ : Semisentence L n) : (Rewriting.emb σ).fvSup = 0 := by - induction σ using rec' <;> simp [fvSup] + induction σ using rec' <;> simp [fvSup, -rew_rel_eq_comp, -rew_nrel_eq_comp] private lemma not_fvar?_fixitr_fvSup (φ : Proposition L) : ¬(Rew.fixitr 0 φ.fvSup ▹ φ).FVar? x := by rw [Rew.eq_bind (Rew.fixitr 0 φ.fvSup)] @@ -455,10 +453,10 @@ def toEmpty [DecidableEq ξ] {n : ℕ} : (φ : Semiformula L ξ n) → φ.freeVa | ∃⁰ φ, h => ∃⁰ φ.toEmpty (by simpa using h) @[simp] lemma emb_toEmpty [DecidableEq ξ] (φ : Semiformula L ξ n) (hp : φ.freeVariables = ∅) : Rewriting.emb (φ.toEmpty hp) = φ := by - induction φ using rec' <;> simp [toEmpty, rew_rel, rew_nrel, *] + induction φ using rec' <;> simp [toEmpty, Function.comp_def, *] @[simp] lemma toEmpty_emb [DecidableEq ξ] (φ : Semisentence L n) : (Rewriting.emb φ : Semiformula L ξ n).toEmpty (by simp) = φ := by - induction φ using rec' <;> simp [toEmpty, rew_rel, rew_nrel, *] + induction φ using rec' <;> simp [toEmpty, *] @[simp] lemma toEmpty_verum [DecidableEq ξ] : (⊤ : Semiformula L ξ n).toEmpty (by simp) = ⊤ := rfl @@ -501,7 +499,7 @@ variable {L : Language.{u}} {L₁ : Language.{u₁}} {L₂ : Language.{u₂}} {L lemma lMap_bind (b : Fin n₁ → Semiterm L₁ ξ₂ n₂) (e : ξ₁ → Semiterm L₁ ξ₂ n₂) (φ : Semiformula L₁ ξ₁ n₁) : lMap Φ (Rew.bind b e ▹ φ) = Rew.bind (Semiterm.lMap Φ ∘ b) (Semiterm.lMap Φ ∘ e) ▹ (lMap Φ φ) := by induction φ using rec' generalizing ξ₂ n₂ <;> - simp [*, rew_rel, rew_nrel, lMap_rel, lMap_nrel, Semiterm.lMap_bind, Rew.q_bind, Matrix.comp_vecCons', Semiterm.lMap_bShift, Function.comp_def] + simp [*, lMap_rel, lMap_nrel, Semiterm.lMap_bind, Rew.q_bind, Matrix.comp_vecCons', Semiterm.lMap_bShift, Function.comp_def] lemma lMap_map (b : Fin n₁ → Fin n₂) (e : ξ₁ → ξ₂) (φ : Semiformula L₁ ξ₁ n₁) : lMap Φ (Rew.map (L := L₁) b e ▹ φ) = Rew.map (L := L₂) b e ▹ lMap Φ φ := lMap_bind _ _ _ @@ -537,7 +535,7 @@ lemma lMap_rewriteMap (φ : Semiformula L₁ ξ₁ n) (f : ξ₁ → ξ₂) : end lMap @[simp] lemma rew_open_iff {ω : Rew L ξ₁ n₁ ξ₂ n₂} {φ : Semiformula L ξ₁ n₁} : (ω ▹ φ).Open ↔ φ.Open := by - induction φ using Semiformula.rec' <;> simp [rew_rel, rew_nrel, *] + induction φ using Semiformula.rec' <;> simp [*] end Semiformula diff --git a/Foundation/FirstOrder/Intuitionistic/Rew.lean b/Foundation/FirstOrder/Intuitionistic/Rew.lean index 0ce318de1..0d16208d7 100644 --- a/Foundation/FirstOrder/Intuitionistic/Rew.lean +++ b/Foundation/FirstOrder/Intuitionistic/Rew.lean @@ -36,7 +36,7 @@ instance : Coe (Semisentenceᵢ L n) (Semipropositionᵢ L n) := ⟨Rewriting.em lemma rew_rel (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} (r : L.Rel k) (v : Fin k → Semiterm L ξ₁ n₁) : ω ▹ rel r v = rel r fun i ↦ ω (v i) := rfl -lemma rew_rel' (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} {r : L.Rel k} {v : Fin k → Semiterm L ξ₁ n₁} : +lemma rew_rel_eq_comp (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} {r : L.Rel k} {v : Fin k → Semiterm L ξ₁ n₁} : ω ▹ rel r v = rel r (ω ∘ v) := rfl set_option linter.flexible false in diff --git a/Foundation/LinearLogic/FirstOrder/Rew.lean b/Foundation/LinearLogic/FirstOrder/Rew.lean index 6f2ac984f..2566f8c2b 100644 --- a/Foundation/LinearLogic/FirstOrder/Rew.lean +++ b/Foundation/LinearLogic/FirstOrder/Rew.lean @@ -53,7 +53,7 @@ abbrev shift (φ : Semistatement L n) : Semistatement L n := Rewriting.shift φ lemma rew_rel (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} (r : L.Rel k) (v : Fin k → Semiterm L ξ₁ n₁) : ω ▹ rel r v = rel r fun i ↦ ω (v i) := rfl -lemma rew_rel' (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} {r : L.Rel k} {v : Fin k → Semiterm L ξ₁ n₁} : +lemma rew_rel_eq_comp (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} {r : L.Rel k} {v : Fin k → Semiterm L ξ₁ n₁} : ω ▹ rel r v = rel r (ω ∘ v) := rfl lemma rew_nrel (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} (r : L.Rel k) (v : Fin k → Semiterm L ξ₁ n₁) : diff --git a/Foundation/Propositional/Entailment/Cl/Basic.lean b/Foundation/Propositional/Entailment/Cl/Basic.lean index 87078ab11..a5010201f 100644 --- a/Foundation/Propositional/Entailment/Cl/Basic.lean +++ b/Foundation/Propositional/Entailment/Cl/Basic.lean @@ -190,6 +190,11 @@ instance : HasAxiomPeirce 𝓢 where . simp; . simp; +instance : HasAxiomEFQ 𝓢 where + efq := C_of_CNN (C_of_conseq NO) + +instance : Entailment.Int 𝓢 where + end section diff --git a/Foundation/SecondOrder/Syntax/Rew.lean b/Foundation/SecondOrder/Syntax/Rew.lean index 3212c3a3c..b149a5908 100644 --- a/Foundation/SecondOrder/Syntax/Rew.lean +++ b/Foundation/SecondOrder/Syntax/Rew.lean @@ -70,7 +70,7 @@ instance : Rewriting L ξ₁ (Semiformula L Ξ ξ₁ N) ξ₂ (Semiformula L Ξ lemma rew_rel (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} (r : L.Rel k) (v : Fin k → Semiterm L ξ₁ n₁) : ω ▹ (rel r v : Semiformula L Ξ ξ₁ N n₁) = rel r fun i ↦ ω (v i) := rfl -lemma rew_rel' (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} {r : L.Rel k} {v : Fin k → Semiterm L ξ₁ n₁} : +lemma rew_rel_eq_comp (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} {r : L.Rel k} {v : Fin k → Semiterm L ξ₁ n₁} : ω ▹ (rel r v : Semiformula L Ξ ξ₁ N n₁) = rel r (ω ∘ v) := rfl lemma rew_nrel (ω : Rew L ξ₁ n₁ ξ₂ n₂) {k} (r : L.Rel k) (v : Fin k → Semiterm L ξ₁ n₁) : From 947d25d45e69df0ee60c0bdda5335a67b6461c7f Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 7 Mar 2026 03:56:40 +0900 Subject: [PATCH 06/61] calculus --- Foundation.lean | 2 +- Foundation/FirstOrder/Basic/Calculus.lean | 736 +++++------------- .../FirstOrder/Basic/Syntax/Schema.lean | 8 +- Foundation/Logic/Calculus.lean | 16 +- .../Propositional/Entailment/Cl/Basic.lean | 5 +- 5 files changed, 207 insertions(+), 560 deletions(-) diff --git a/Foundation.lean b/Foundation.lean index b126ad5e7..0c6491076 100644 --- a/Foundation.lean +++ b/Foundation.lean @@ -52,7 +52,7 @@ public import Foundation.FirstOrder.Basic.Semantics.Semantics public import Foundation.FirstOrder.Basic.Soundness public import Foundation.FirstOrder.Basic.Syntax.Formula public import Foundation.FirstOrder.Basic.Syntax.Rew -public import Foundation.FirstOrder.Basic.Syntax.Theory +public import Foundation.FirstOrder.Basic.Syntax.Schema public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D1 public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D2 public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D3 diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index cecadcbdc..6e3f389de 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -1,7 +1,9 @@ module /- public import Foundation.Logic.Calculus -/ -public import Foundation.FirstOrder.Basic.Syntax.Theory +public import Foundation.Logic.Calculus +public import Foundation.Propositional.Entailment.AxiomEFQ +public import Foundation.FirstOrder.Basic.Syntax.Schema public import Mathlib.Data.List.MinMax /-! # One-sided sequent calculus for first-order classical logic -/ @@ -12,370 +14,146 @@ namespace LO namespace FirstOrder -abbrev Sequent (L : Language) := List (Proposition L) - -open Semiformula +variable {L : Language} -variable {L : Language} {𝓢 : Schema L} - -inductive Derivation (𝓢 : Schema L) : Sequent L → Type _ -| axm : φ ∈ 𝓢 → Derivation 𝓢 [φ] -| axL (r : L.Rel k) (v) : Derivation 𝓢 [rel r v, nrel r v] -| verum : Derivation 𝓢 [⊤] -| or : Derivation 𝓢 (φ :: ψ :: Γ) → Derivation 𝓢 (φ ⋎ ψ :: Γ) -| and : Derivation 𝓢 (φ :: Γ) → Derivation 𝓢 (ψ :: Γ) → Derivation 𝓢 (φ ⋏ ψ :: Γ) -| all : Derivation 𝓢 (φ.free :: Γ⁺) → Derivation 𝓢 ((∀⁰ φ) :: Γ) -| exs (t) : Derivation 𝓢 (φ/[t] :: Γ) → Derivation 𝓢 ((∃⁰ φ) :: Γ) -| wk : Derivation 𝓢 Δ → Δ ⊆ Γ → Derivation 𝓢 Γ -| cut : Derivation 𝓢 (φ :: Γ) → Derivation 𝓢 (∼φ :: Γ) → Derivation 𝓢 Γ +abbrev Sequent (L : Language) := List (Proposition L) -/--/ -instance : OneSided (Schema L) (Proposition L) := ⟨Derivation⟩ +namespace Sequent -abbrev Schema.pureLK : Schema L := ∅ +open Semiformula -notation "𝐋𝐊₀" => Schema.pureLK +def newVar (Γ : Sequent L) : ℕ := (Γ.map Semiformula.fvSup).foldr max 0 -abbrev Derivation₀ (Γ : Sequent L) : Type _ := 𝐋𝐊₀ ⟹ Γ +lemma not_fvar?_newVar {φ : Proposition L} {Γ : Sequent L} (h : φ ∈ Γ) : ¬FVar? φ Γ.newVar := + not_fvar?_of_lt_fvSup φ (by simpa [newVar] using List.le_max_of_le (List.mem_map_of_mem h) (by simp)) -abbrev Derivable₀ (Γ : Sequent L) : Prop := 𝐋𝐊₀ ⟹! Γ +end Sequent -prefix:45 "⊢ᵀ " => Derivation₀ +/-! ## Derivation for one-sided $\mathbf{LK}$ -/ -abbrev Theory.pureLK : Theory L := ∅ +/-- Derivation for one-sided $\mathbf{LK}$ -/ +inductive Derivation : Sequent L → Type _ +| protected id (r : L.Rel k) (v) : Derivation [.rel r v, .nrel r v] +| cut : Derivation (φ :: Γ) → Derivation (∼φ :: Δ) → Derivation (Γ ++ Δ) +| wk : Derivation Δ → Δ ⊆ Γ → Derivation Γ +| verum : Derivation [⊤] +| or : Derivation (φ :: ψ :: Γ) → Derivation (φ ⋎ ψ :: Γ) +| and : Derivation (φ :: Γ) → Derivation (ψ :: Γ) → Derivation (φ ⋏ ψ :: Γ) +| all : Derivation (φ.free :: Γ⁺) → Derivation ((∀⁰ φ) :: Γ) +| exs : Derivation (φ/[t] :: Γ) → Derivation ((∃⁰ φ) :: Γ) -notation "𝐋𝐊" => Theory.pureLK +scoped prefix:45 "⊢ᴷ " => Derivation namespace Derivation -variable {𝓢 U : Schema L} {Δ Δ₁ Δ₂ Γ : Sequent L} {φ ψ r : Proposition L} - open Rewriting LawfulSyntacticRewriting -def height {Δ : Sequent L} : 𝓢 ⟹ Δ → ℕ - | axL _ _ => 0 + + +def height {Δ : Sequent L} : ⊢ᴷ Δ → ℕ + | .id _ _ => 0 + | cut dp dn => (max (height dp) (height dn)).succ + | wk d _ => d.height.succ | verum => 0 | or d => d.height.succ | and dp dq => (max (height dp) (height dq)).succ | all d => d.height.succ - | exs _ d => d.height.succ - | wk d _ => d.height.succ - | cut dp dn => (max (height dp) (height dn)).succ - | axm _ => 0 + | exs d => d.height.succ section height -@[simp] lemma height_axL {k} {r : L.Rel k} {v} : - height (axL (𝓢 := 𝓢) r v) = 0 := rfl +@[simp] lemma height_id {k} {r : L.Rel k} {v} : + height (Derivation.id r v) = 0 := rfl -@[simp] lemma height_verum : height (verum : Derivation 𝓢 [⊤]) = 0 := rfl +@[simp] lemma height_cut {φ} (dp : ⊢ᴷ φ :: Δ) (dn : ⊢ᴷ (∼φ) :: Δ) : + height (cut dp dn) = (max (height dp) (height dn)).succ := rfl -@[simp] lemma height_and {φ ψ} (dp : 𝓢 ⟹ φ :: Δ) (dq : 𝓢 ⟹ ψ :: Δ) : - height (and dp dq) = (max (height dp) (height dq)).succ := rfl +@[simp] lemma height_wk (d : ⊢ᴷ Δ) (h : Δ ⊆ Γ) : height (wk d h) = d.height.succ := rfl -@[simp] lemma height_or {φ ψ} (d : 𝓢 ⟹ φ :: ψ :: Δ) : height (or d) = d.height.succ := rfl +@[simp] lemma height_verum : height (verum : ⊢ᴷ ([⊤] : Sequent L)) = 0 := rfl -@[simp] lemma height_all {φ} (d : 𝓢 ⟹ Rewriting.free φ :: Δ⁺) : height (all d) = d.height.succ := rfl +@[simp] lemma height_and {φ ψ} (dp : ⊢ᴷ φ :: Δ) (dq : ⊢ᴷ ψ :: Δ) : + height (and dp dq) = (max (height dp) (height dq)).succ := rfl -@[simp] lemma height_exs {t} {φ} (d : 𝓢 ⟹ φ/[t] :: Δ) : height (exs t d) = d.height.succ := rfl +@[simp] lemma height_or {φ ψ} (d : ⊢ᴷ φ :: ψ :: Δ) : height (or d) = d.height.succ := rfl -@[simp] lemma height_wk (d : 𝓢 ⟹ Δ) (h : Δ ⊆ Γ) : height (wk d h) = d.height.succ := rfl +@[simp] lemma height_all {φ : Semiproposition L 1} (d : ⊢ᴷ φ.free :: Δ⁺) : height (all d) = d.height.succ := rfl -@[simp] lemma height_cut {φ} (dp : 𝓢 ⟹ φ :: Δ) (dn : 𝓢 ⟹ (∼φ) :: Δ) : - height (cut dp dn) = (max (height dp) (height dn)).succ := rfl +@[simp] lemma height_exs {t} {φ} (d : ⊢ᴷ φ/[t] :: Δ) : height (exs d) = d.height.succ := rfl end height -section Repr -variable [∀ k, ToString (L.Func k)] [∀ k, ToString (L.Rel k)] - -protected unsafe def repr {Δ : Sequent L} : 𝓢 ⟹ Δ → String - | axL r v => - "\\AxiomC{}\n" ++ - "\\RightLabel{\\scriptsize(axL)}\n" ++ - "\\UnaryInfC{$" ++ reprStr [Semiformula.rel r v, Semiformula.nrel r v] ++ "$}\n\n" - | verum => - "\\AxiomC{}\n" ++ - "\\RightLabel{\\scriptsize($\\top$)}\n" ++ - "\\UnaryInfC{$" ++ reprStr Δ ++ "$}\n\n" - | or (Γ := Δ) (φ := φ) (ψ := ψ) d => - Derivation.repr d ++ - "\\RightLabel{\\scriptsize($\\lor$)}\n" ++ - "\\UnaryInfC{$" ++ reprStr ((φ ⋎ ψ) :: Δ) ++ "$}\n\n" - | and (Γ := Δ) (φ := φ) (ψ := ψ) dp dq => - Derivation.repr dp ++ - Derivation.repr dq ++ - "\\RightLabel{\\scriptsize($\\land$)}\n" ++ - "\\BinaryInfC{$" ++ reprStr ((φ ⋏ ψ) :: Δ) ++ "$}\n\n" - | all (Γ := Δ) (φ := φ) d => - Derivation.repr d ++ - "\\RightLabel{\\scriptsize($\\forall$)}\n" ++ - "\\UnaryInfC{$" ++ reprStr ((∀⁰ φ) :: Δ) ++ "$}\n\n" - | exs (Γ := Δ) (φ := φ) _ d => - Derivation.repr d ++ - "\\RightLabel{\\scriptsize($\\exists$)}\n" ++ - "\\UnaryInfC{$" ++ reprStr ((∃⁰ φ) :: Δ) ++ "$}\n\n" - | wk (𝓢 := 𝓢) (Γ := Γ) d _ => - Derivation.repr d ++ - "\\RightLabel{\\scriptsize(wk)}\n" ++ - "\\UnaryInfC{$" ++ reprStr Γ ++ "$}\n\n" - | @cut _ _ Δ _ dp dn => - Derivation.repr dp ++ - Derivation.repr dn ++ - "\\RightLabel{\\scriptsize(Cut)}\n" ++ - "\\BinaryInfC{$" ++ reprStr Δ ++ "$}\n\n" - | axm (φ := φ) _ => - "\\AxiomC{}\n" ++ - "\\RightLabel{\\scriptsize(ROOT)}\n" ++ - "\\UnaryInfC{$" ++ reprStr φ ++ ", " ++ reprStr (∼φ) ++ "$}\n\n" - -unsafe instance : Repr (𝓢 ⟹ Δ) where reprPrec d _ := Derivation.repr d - -end Repr - -protected abbrev cast (d : 𝓢 ⟹ Δ) (e : Δ = Γ) : 𝓢 ⟹ Γ := e ▸ d - -@[simp] lemma cast_eq (d : 𝓢 ⟹ Δ) (e : Δ = Δ) : Derivation.cast d e = d := rfl - -@[simp] lemma height_cast (d : 𝓢 ⟹ Δ) (e : Δ = Γ) : +protected abbrev cast (d : ⊢ᴷ Δ) (e : Δ = Γ := by simp) : ⊢ᴷ Γ := e ▸ d + +@[simp] lemma height_cast (d : ⊢ᴷ Δ) (e : Δ = Γ) : height (Derivation.cast d e) = height d := by rcases e with rfl; simp [Derivation.cast] -@[simp] lemma height_cast' (d : 𝓢 ⟹ Δ) (e : Δ = Γ) : - height (e ▸ d) = height d := by rcases e with rfl; simp - -alias weakening := wk - -def verum' (h : ⊤ ∈ Δ) : 𝓢 ⟹ Δ := verum.wk (by simp [h]) - -def axL' {k} (r : L.Rel k) (v) - (h : Semiformula.rel r v ∈ Δ) (hn : Semiformula.nrel r v ∈ Δ) : 𝓢 ⟹ Δ := (axL r v).wk (by simp [h, hn]) - -def all' {φ} (h : ∀⁰ φ ∈ Δ) (d : 𝓢 ⟹ Rewriting.free φ :: Δ⁺) : 𝓢 ⟹ Δ := d.all.wk (by simp [h]) - -def exs' {φ} (h : ∃⁰ φ ∈ Δ) (t) (d : 𝓢 ⟹ φ/[t] :: Δ) : 𝓢 ⟹ Δ := (d.exs t).wk (by simp [h]) - -@[simp] lemma ne_step_max (n m : ℕ) : n ≠ max n m + 1 := - ne_of_lt $ Nat.lt_succ_of_le $ by simp - -@[simp] lemma ne_step_max' (n m : ℕ) : n ≠ max m n + 1 := - ne_of_lt $ Nat.lt_succ_of_le $ by simp - -private lemma neg_ne_and {φ ψ : Proposition L} : ¬∼φ = φ ⋏ ψ := - ne_of_ne_complexity (by simp) - -def em {Δ : Sequent L} : {φ : Proposition L} → (hpos : φ ∈ Δ) → (hneg : ∼φ ∈ Δ) → 𝓢 ⟹ Δ - | ⊤, hpos, hneg => verum' hpos - | ⊥, hpos, hneg => verum' hneg - | .rel R v, hpos, hneg => axL' R v hpos hneg - | .nrel R v, hpos, hneg => axL' R v hneg hpos - | φ ⋏ ψ, hpos, hneg => - have ihp : 𝓢 ⟹ φ :: ∼φ :: ∼ψ :: Δ := em (φ := φ) (by simp) (by simp) - have ihq : 𝓢 ⟹ ψ :: ∼φ :: ∼ψ :: Δ := em (φ := ψ) (by simp) (by simp) - have : 𝓢 ⟹ ∼φ :: ∼ψ :: Δ := (ihp.and ihq).wk (by simp [hpos]) - this.or.wk (by simpa using hneg) - | φ ⋎ ψ, hpos, hneg => - have ihp : 𝓢 ⟹ ∼φ :: φ :: ψ :: Δ := em (φ := φ) (by simp) (by simp) - have ihq : 𝓢 ⟹ ∼ψ :: φ :: ψ :: Δ := em (φ := ψ) (by simp) (by simp) - have : 𝓢 ⟹ φ :: ψ :: Δ := (ihp.and ihq).wk (by simp [by simpa using hneg]) - this.or.wk (by simp [hpos]) - | ∀⁰ φ, hpos, hneg => - have : 𝓢 ⟹ ∼φ.free :: φ.free :: Δ⁺ := em (φ := φ.free) (by simp) (by simp) - have : 𝓢 ⟹ (∼φ.shift)/[&0] :: φ.free :: Δ⁺ := - Derivation.cast this (by simp [←TransitiveRewriting.comp_app]) - have : 𝓢 ⟹ φ.free :: Δ⁺ := (exs &0 this).wk - (List.cons_subset_of_subset_of_mem - (List.mem_cons_of_mem φ.free <| by simpa using mem_shifts_iff.mpr hneg) (by rfl)) - this.all.wk (by simp [hpos]) - | ∃⁰ φ, hpos, hneg => - have : 𝓢 ⟹ φ.free :: ∼φ.free :: Δ⁺ := em (φ := φ.free) (by simp) (by simp) - have : 𝓢 ⟹ (φ.shift)/[&0] :: ∼φ.free :: Δ⁺ := - Derivation.cast this (by simp [←TransitiveRewriting.comp_app]) - have : 𝓢 ⟹ (∼φ).free :: Δ⁺ := (exs &0 this).wk - (List.cons_subset_of_subset_of_mem - (List.mem_cons_of_mem (∼φ).free <| by simpa using mem_shifts_iff.mpr hpos) (by simp)) - this.all.wk (by simpa using hneg) +def weakening (d : ⊢ᴷ Δ) (h : Δ ⊆ Γ := by simp) : ⊢ᴷ Γ := wk d h + +def top (h : ⊤ ∈ Δ := by simp) : ⊢ᴷ Δ := verum.wk (by simp [h]) + +def id' (r : L.Rel k) (v) (hpos : Semiformula.rel r v ∈ Δ := by simp) (hneg : Semiformula.nrel r v ∈ Δ := by simp) : ⊢ᴷ Δ := + (Derivation.id r v).wk (by simp [hpos, hneg]) + +def tensor {φ ψ} (dφ : ⊢ᴷ φ :: Γ) (dψ : ⊢ᴷ ψ :: Δ) : ⊢ᴷ φ ⋏ ψ :: (Γ ++ Δ) := and dφ.weakening dψ.weakening + +def rotate (d : ⊢ᴷ φ :: Γ) : ⊢ᴷ Γ ++ [φ] := d.weakening + +def identity : (φ : Proposition L) → ⊢ᴷ [φ, ∼φ] + | .rel R v | .nrel R v => id' R v + | ⊤ | ⊥ => top + | φ ⋏ ψ => ((identity φ).tensor (identity ψ)).rotate.or.rotate + | φ ⋎ ψ => ((identity φ).rotate.tensor (identity ψ).rotate).rotate.or + | ∀⁰ φ => + have : ⊢ᴷ [(∼φ.shift)/[&0], φ.free] := (identity φ.free).rotate.cast + have : ⊢ᴷ φ.free :: [∃⁰ ∼φ]⁺ := this.exs.rotate.cast + this.all + | ∃⁰ φ => + have : ⊢ᴷ [(φ.shift)/[&0], (∼φ).free] := (identity φ.free).cast + have : ⊢ᴷ (∼φ).free :: [∃⁰ φ]⁺ := this.exs.rotate.cast + this.all.rotate termination_by φ => φ.complexity -instance : Tait (Proposition L) (Schema L) where - verum := fun _ Δ => verum' (by simp) - and := fun dp dq => dp.and dq - or := fun d => d.or - wk := fun d ss => d.wk ss - em := fun hp hn => em hp hn - -instance : Tait.Cut (Proposition L) (Schema L) where - cut {_ _ _ dp dn} := cut dp dn - -protected def id {φ} (hφ : φ ∈ 𝓢) : 𝓢 ⟹ ∼φ :: Δ → 𝓢 ⟹ Δ := fun b ↦ Tait.cut (Tait.wk (axm hφ) (by simp)) b - -def provableOfDerivable {φ} (b : 𝓢 ⟹. φ) : 𝓢 ⊢! φ := b - -def specialize {φ : Semiproposition L 1} (t : SyntacticTerm L) : - 𝓢 ⟹ (∀⁰ φ) :: Γ → 𝓢 ⟹ φ/[t] :: Γ := fun d ↦ - have : 𝓢 ⟹ ∼φ/[t] :: φ/[t] :: Γ := Tait.em (φ := φ/[t]) (by simp) (by simp) - have dn : 𝓢 ⟹ ∼(∀⁰ φ) :: φ/[t] :: Γ := by - simp only [neg_all, Nat.reduceAdd] - exact Derivation.exs t (by simpa using this) - have dp : 𝓢 ⟹ (∀⁰ φ) :: φ/[t] :: Γ := - Derivation.wk d (List.cons_subset_cons _ <| by simp) - Derivation.cut dp dn - -def specializes : {k : ℕ} → {φ : Semiproposition L k} → {Γ : Sequent L} → (v : Fin k → SyntacticTerm L) → - 𝓢 ⟹ (∀⁰* φ) :: Γ → 𝓢 ⟹ (φ ⇜ v) :: Γ - | 0, φ, Γ, _, b => Derivation.cast b (by simp) - | k + 1, φ, Γ, v, b => - have : 𝓢 ⟹ (∀⁰ (Rew.subst (v ·.succ)).q ▹ φ) :: Γ := by simpa using specializes (φ := ∀⁰ φ) (v ·.succ) b - Derivation.cast (specialize (v 0) this) (by - simp only [Nat.reduceAdd, ← TransitiveRewriting.comp_app, List.cons.injEq, and_true]; congr 2 - ext x <;> simp [Rew.comp_app] - cases x using Fin.cases <;> simp) - -def instances : {k : ℕ} → {φ : Semiproposition L k} → {Γ : Sequent L} → {v : Fin k → SyntacticTerm L} → - 𝓢 ⟹ (φ ⇜ v) :: Γ → 𝓢 ⟹ (∃⁰* φ) :: Γ - | 0, φ, Γ, _, b => Derivation.cast b (by simp) - | k + 1, φ, Γ, v, b => - have : 𝓢 ⟹ (∃⁰ (Rew.subst (v ·.succ)).q ▹ φ) :: Γ := - exs (v 0) <| Derivation.cast b <| by - unfold Rewriting.subst; rw [←TransitiveRewriting.comp_app]; congr 3 - ext x <;> simp [Rew.comp_app] - cases x using Fin.cases <;> simp - instances (k := k) (v := (v ·.succ)) (Derivation.cast this (by simp)) - -def allClosureFixitr {φ : Proposition L} (dp : 𝓢 ⊢! φ) : (m : ℕ) → 𝓢 ⊢! ∀⁰* Rew.fixitr 0 m ▹ φ - | 0 => by simpa - | m + 1 => by - simp only [allClosure_fixitr, Nat.reduceAdd] - apply all; simpa using allClosureFixitr dp m - -def toClose (b : 𝓢 ⊢! φ) : 𝓢 ⊢! φ.univCl' := allClosureFixitr b φ.fvSup - -def toClose! (b : 𝓢 ⊢ φ) : 𝓢 ⊢ φ.univCl' := ⟨toClose b.get⟩ - -def rewrite₁ (b : 𝓢 ⊢! φ) (f : ℕ → SyntacticTerm L) : 𝓢 ⊢! (Rew.rewrite f) ▹ φ := - Derivation.cast (specializes (fun x ↦ f x) (allClosureFixitr b φ.fvSup)) (by simp) - -def rewrite {Γ} : 𝓢 ⟹ Γ → ∀ (f : ℕ → SyntacticTerm L), 𝓢 ⟹ Γ.map fun φ ↦ Rew.rewrite f ▹ φ - | axL r v, f => - Derivation.cast (axL r (fun i ↦ Rew.rewrite f (v i))) (by simp [rew_rel, rew_nrel]) - | verum, f => Derivation.cast verum (by simp) - | or (Γ := Γ) (φ := φ) (ψ := ψ) d, f => - have : 𝓢 ⟹ Rew.rewrite f ▹ φ ⋎ Rew.rewrite f ▹ ψ :: Γ.map fun φ ↦ Rew.rewrite f ▹ φ := - or (Derivation.cast (rewrite d f) (by simp)) - Derivation.cast this (by simp) - | and (Γ := Γ) (φ := φ) (ψ := ψ) dp dq, f => - have : 𝓢 ⟹ Rew.rewrite f ▹ φ ⋏ Rew.rewrite f ▹ ψ :: Γ.map fun φ ↦ Rew.rewrite f ▹ φ := - and (Derivation.cast (rewrite dp f) (by simp)) (Derivation.cast (rewrite dq f) (by simp)) - Derivation.cast this (by simp) - | all (Γ := Γ) (φ := φ) d, f => - have : 𝓢 ⟹ ((Rewriting.free φ) :: Γ⁺).map fun φ ↦ Rew.rewrite (&0 :>ₙ fun x => Rew.shift (f x)) ▹ φ := - rewrite d (&0 :>ₙ fun x => Rew.shift (f x)) - have : 𝓢 ⟹ (∀⁰ Rew.rewrite (Rew.bShift ∘ f) ▹ φ) :: Γ.map fun φ ↦ Rew.rewrite f ▹ φ := - all (Derivation.cast this (by simp [free_rewrite_eq, Rewriting.shifts, shift_rewrite_eq, Function.comp_def])) +def close (φ : Proposition L) (hp : φ ∈ Δ := by simp) (hn : ∼φ ∈ Δ := by simp) : ⊢ᴷ Δ := + identity φ |>.weakening (by simp [hp, hn]) + +instance : OneSidedLK (Derivation (L := L)) where + verum := verum + and d₁ d₂ := d₁.and d₂ + or d := d.or + wk d ss := d.wk ss + identity φ := identity φ + +instance : OneSidedLK.Cut (Derivation (L := L)) where + cut dp dn := cut dp dn + +def rewrite {Γ} (f : ℕ → SyntacticTerm L) : ⊢ᴷ Γ → ⊢ᴷ Γ.map (Rew.rewrite f ▹ ·) + | .id R v => Derivation.id R (Rew.rewrite f ∘ v) + | cut (φ := φ) (Γ := Γ) (Δ := Δ) d₁ d₂ => + have d₁ : ⊢ᴷ Rew.rewrite f ▹ φ :: Γ.map (app (Rew.rewrite f)) := (d₁.rewrite f).cast + have d₂ : ⊢ᴷ ∼(Rew.rewrite f ▹ φ) :: Δ.map (app (Rew.rewrite f)) := (d₂.rewrite f).cast + d₁.cut d₂ |>.cast + | wk d ss => d.rewrite f |>.wk (List.map_subset _ ss) + | verum => verum + | or d => (d.rewrite f).or + | and d₁ d₂ => (d₁.rewrite f).and (d₂.rewrite f) + | all (φ := φ) (Γ := Γ) d => + let g : ℕ → SyntacticTerm L := &0 :>ₙ fun x ↦ Rew.shift (f x) + have : ⊢ᴷ (φ.free :: Γ⁺).map (Rew.rewrite g ▹ ·) := d.rewrite g + have : ⊢ᴷ (∀⁰ Rew.rewrite (Rew.bShift ∘ f) ▹ φ) :: Γ.map (Rew.rewrite f ▹ ·) := + all (Derivation.cast this (by simp [g, free_rewrite_eq, Rewriting.shifts, shift_rewrite_eq, Function.comp_def])) Derivation.cast this (by simp [Rew.q_rewrite]) - | exs (Γ := Γ) (φ := φ) (t := t) d, f => - have : 𝓢 ⟹ (φ/[t] :: Γ).map fun φ ↦ Rew.rewrite f ▹ φ := rewrite d f - have : 𝓢 ⟹ (∃⁰ Rew.rewrite (Rew.bShift ∘ f) ▹ φ) :: Γ.map fun φ ↦ Rew.rewrite f ▹ φ := - exs (Rew.rewrite f t) (Derivation.cast this (by simp [rewrite_subst_eq])) + | exs (φ := φ) (Γ := Γ) (t := t) d => + have : ⊢ᴷ (φ/[t] :: Γ).map (Rew.rewrite f ▹ ·) := d.rewrite f + have : ⊢ᴷ (∃⁰ Rew.rewrite (Rew.bShift ∘ f) ▹ φ) :: Γ.map (Rew.rewrite f ▹ ·) := + exs (t := Rew.rewrite f t) (Derivation.cast this (by simp [rewrite_subst_eq])) Derivation.cast this (by simp [Rew.q_rewrite]) - | wk (𝓢 := 𝓢) (Γ := Γ) d ss, f => (rewrite d f).wk (List.map_subset _ ss) - | cut (Γ := Γ) (φ := φ) d dn, f => - have dΓ : 𝓢 ⟹ (Rew.rewrite f ▹ φ) :: Γ.map fun φ ↦ Rew.rewrite f ▹ φ := Derivation.cast (rewrite d f) (by simp) - have dΔ : 𝓢 ⟹ ∼(Rew.rewrite f ▹ φ) :: Γ.map fun φ ↦ Rew.rewrite f ▹ φ := Derivation.cast (rewrite dn f) (by simp) - Derivation.cast (cut dΓ dΔ) (by simp) - | axm h, f => rewrite₁ (axm h) f - -protected def map {Δ : Sequent L} (d : 𝓢 ⟹ Δ) (f : ℕ → ℕ) : - 𝓢 ⟹ Δ.map fun φ ↦ @Rew.rewriteMap L ℕ ℕ 0 f ▹ φ := rewrite d (fun x ↦ &(f x)) - -protected def shift {Δ : Sequent L} (d : 𝓢 ⟹ Δ) : 𝓢 ⟹ Δ⁺ := - Derivation.cast (Derivation.map d Nat.succ) (by simp only [Rewriting.shifts, List.map_inj_left]; intro _ _; rfl) - -def trans (F : U ⊢!* 𝓢) {Γ : Sequent L} : 𝓢 ⟹ Γ → U ⟹ Γ - | axL r v => axL r v - | verum => verum - | and d₁ d₂ => and (trans F d₁) (trans F d₂) - | or d => or (trans F d) - | all d => all (trans F d) - | exs t d => exs t (trans F d) - | wk d ss => wk (trans F d) ss - | cut d₁ d₂ => cut (trans F d₁) (trans F d₂) - | axm h => F h - -instance : Tait.Axiomatized (Proposition L) (Schema L) where - axm {_ _ h} := axm h - trans {_ _ _ F d} := trans (fun h ↦ F _ h) d - -variable [L.DecidableEq] - -def not_close' (φ) : 𝓢 ⟹ [∼(φ.univCl'), φ] := - have : 𝓢 ⟹ [∃⁰* ∼(@Rew.fixitr L 0 (fvSup φ) ▹ φ), φ] := instances (v := fun x ↦ &x) (em (φ := φ) (by simp) (by simp)) - Derivation.cast this (by simp [univCl']) - -def invClose (b : 𝓢 ⊢! φ.univCl') : 𝓢 ⊢! φ := cut (wk b (by simp)) (not_close' φ) - -def invClose! (b : 𝓢 ⊢ φ.univCl') : 𝓢 ⊢ φ := ⟨invClose b.get⟩ - -def compact {Γ : Sequent L} : 𝓢 ⟹ Γ → (s : { s : Finset (Proposition L) // ↑s ⊆ 𝓢}) × (s : Schema L) ⟹ Γ - | axL r v => ⟨⟨∅, by simp⟩, axL r v⟩ - | verum => ⟨⟨∅, by simp⟩, verum⟩ - | and d₁ d₂ => - let ⟨s₁, d₁⟩ := compact d₁ - let ⟨s₂, d₂⟩ := compact d₂ - ⟨⟨(s₁ ∪ s₂ : Finset (Proposition L)), by simp [s₁.prop, s₂.prop]⟩, - and (Tait.ofAxiomSubset (by simp) d₁) (Tait.ofAxiomSubset (by simp) d₂)⟩ - | or d => - let ⟨s, d⟩ := compact d - ⟨s, or d⟩ - | wk d ss => - let ⟨s, d⟩ := compact d - ⟨s, wk d ss⟩ - | cut d₁ d₂ => - let ⟨s₁, d₁⟩ := compact d₁ - let ⟨s₂, d₂⟩ := compact d₂ - ⟨⟨(s₁ ∪ s₂ : Finset (Proposition L)), by simp [s₁.prop, s₂.prop]⟩, - cut (Tait.ofAxiomSubset (by simp) d₁) (Tait.ofAxiomSubset (by simp) d₂)⟩ - | axm (φ := φ) h => - ⟨⟨{φ}, by simp [h]⟩, axm (by simp)⟩ - | all d => - let ⟨s, d⟩ := compact d - ⟨s, all d⟩ - | exs t d => - let ⟨s, d⟩ := compact d - ⟨s, exs t d⟩ -instance : Entailment.Compact (Schema L) where - Γ b := (compact b).1 - ΓPrf b := (compact b).2 - Γ_subset b := by simpa using (compact b).1.prop - Γ_finite b := by simp - -def deductionAux {Γ : Sequent L} : 𝓢 ⟹ Γ → 𝓢 \ {φ} ⟹ ∼(φ.univCl') :: Γ - | axL r v => Tait.wkTail <| axL r v - | verum => Tait.wkTail <| verum - | and d₁ d₂ => Tait.rotate₁ <| and (Tait.rotate₁ (deductionAux d₁)) (Tait.rotate₁ (deductionAux d₂)) - | or d => Tait.rotate₁ <| or (Tait.rotate₂ (deductionAux d)) - | all d => Tait.rotate₁ <| all (Derivation.cast (Tait.rotate₁ (deductionAux d)) (by simp)) - | exs t d => Tait.rotate₁ <| exs t <| Tait.rotate₁ (deductionAux d) - | wk d ss => wk (deductionAux d) (by simp [List.subset_cons_of_subset _ ss]) - | cut d₁ d₂ => (Tait.rotate₁ <| deductionAux d₁).cut (Tait.rotate₁ <| deductionAux d₂) - | axm (φ := ψ) h => if hq : φ = ψ then Derivation.cast (not_close' φ) (by simp [hq]) else - have : 𝓢 \ {φ} ⟹. ψ := axm (by simp [h, Ne.symm hq]) - wk this (by simp) - -def deduction (d : insert φ 𝓢 ⟹ Γ) : 𝓢 ⟹ ∼(φ.univCl') :: Γ := Tait.ofAxiomSubset (by intro x; simp; tauto) (deductionAux d (φ := φ)) - -def provable_iff_inconsistent : 𝓢 ⊢ φ ↔ Entailment.Inconsistent (insert (∼φ.univCl') 𝓢) := by - constructor - · rintro b - exact Entailment.inconsistent_of_provable_of_unprovable - (Entailment.wk! (by simp) (toClose! b)) (Entailment.by_axm _ (by simp)) - · intro h - rcases Tait.inconsistent_iff_provable.mp h with ⟨d⟩ - have : 𝓢 ⊢! φ.univCl' := Derivation.cast (deduction d) (by rw [univCl'_eq_self_of (∼(φ.univCl')) (by simp)]; simp) - exact ⟨invClose this⟩ - -def unprovable_iff_consistent : 𝓢 ⊬ φ ↔ Entailment.Consistent (insert (∼φ.univCl') 𝓢) := by - simp [←Entailment.not_inconsistent_iff_consistent, ←provable_iff_inconsistent] +protected def map {Δ : Sequent L} (d : ⊢ᴷ Δ) (f : ℕ → ℕ) : + ⊢ᴷ Δ.map (Rew.rewriteMap f ▹ ·) := d.rewrite (fun x ↦ &(f x)) + +protected def shift {Δ : Sequent L} (d : ⊢ᴷ Δ) : ⊢ᴷ Δ⁺ := + Derivation.cast (Derivation.map d Nat.succ) (by rfl) section Hom @@ -385,42 +163,36 @@ lemma shifts_image (Φ : L₁ →ᵥ L₂) {Δ : List (Proposition L₁)} : (Δ.map <| Semiformula.lMap Φ)⁺ = (Δ⁺.map <| Semiformula.lMap Φ) := by simp [Rewriting.shifts, Function.comp_def, Semiformula.lMap_shift] -def lMap (Φ : L₁ →ᵥ L₂) {Γ} : 𝓢₁ ⟹ Γ → 𝓢₁.lMap Φ ⟹ Γ.map (.lMap Φ) - | axL r v => - .cast (axL (Φ.rel r) (fun i ↦ .lMap Φ (v i))) +def lMap (Φ : L₁ →ᵥ L₂) {Γ} : ⊢ᴷ Γ → ⊢ᴷ Γ.map (.lMap Φ) + | .id r v => + .cast (Derivation.id (Φ.rel r) (fun i ↦ .lMap Φ (v i))) (by simp [Semiformula.lMap_rel, Semiformula.lMap_nrel]) + | cut (Γ := Γ) (Δ := Δ) (φ := φ) d dn => + have : ⊢ᴷ (Γ.map (.lMap Φ) ++ Δ.map (.lMap Φ) : Sequent L₂) := + cut (φ := .lMap Φ φ) (Derivation.cast (lMap Φ d) (by simp)) (Derivation.cast (lMap Φ dn) (by simp)) + Derivation.cast this (by simp) + | wk (Δ := Δ) (Γ := Γ) d ss => (lMap Φ d).wk (List.map_subset _ ss) | verum => by simpa using verum | or (Γ := Γ) (φ := φ) (ψ := ψ) d => by - have : 𝓢₁.lMap Φ ⟹ (.lMap Φ φ ⋎ .lMap Φ ψ :: Γ.map (.lMap Φ) : Sequent L₂) := + have : ⊢ᴷ (.lMap Φ φ ⋎ .lMap Φ ψ :: Γ.map (.lMap Φ) : Sequent L₂) := or (by simpa using lMap Φ d) exact Derivation.cast this (by simp) | and (Γ := Γ) (φ := φ) (ψ := ψ) dp dq => - have : 𝓢₁.lMap Φ ⟹ (.lMap Φ φ ⋏ .lMap Φ ψ :: (Γ.map (.lMap Φ)) : Sequent L₂) := + have : ⊢ᴷ (.lMap Φ φ ⋏ .lMap Φ ψ :: (Γ.map (.lMap Φ)) : Sequent L₂) := and (Derivation.cast (lMap Φ dp) (by simp)) (Derivation.cast (lMap Φ dq) (by simp)) Derivation.cast this (by simp) | all (Γ := Γ) (φ := φ) d => - have : 𝓢₁.lMap Φ ⟹ ((∀⁰ .lMap Φ φ) :: (Γ.map (.lMap Φ)) : Sequent L₂) := + have : ⊢ᴷ ((∀⁰ .lMap Φ φ) :: (Γ.map (.lMap Φ)) : Sequent L₂) := all (Derivation.cast (lMap Φ d) (by simp [←Semiformula.lMap_free, shifts_image])) Derivation.cast this (by simp) | exs (Γ := Γ) (φ := φ) (t := t) d => - have : 𝓢₁.lMap Φ ⟹ ((∃⁰ .lMap Φ φ) :: (Γ.map (.lMap Φ)) : Sequent L₂) := - exs (Semiterm.lMap Φ t) - (Derivation.cast (lMap Φ d) (by simp [Semiformula.lMap_subst])) + have : ⊢ᴷ ((∃⁰ .lMap Φ φ) :: (Γ.map (.lMap Φ)) : Sequent L₂) := + exs (t := Semiterm.lMap Φ t) + (.cast (lMap Φ d) (by simp [Semiformula.lMap_subst])) Derivation.cast this (by simp) - | wk (Δ := Δ) (Γ := Γ) d ss => (lMap Φ d).wk (List.map_subset _ ss) - | cut (Γ := Γ) (φ := φ) d dn => - have : 𝓢₁.lMap Φ ⟹ (Γ.map (.lMap Φ) : Sequent L₂) := - cut (φ := .lMap Φ φ) (Derivation.cast (lMap Φ d) (by simp)) (Derivation.cast (lMap Φ dn) (by simp)) - Derivation.cast this (by simp) - | axm h => axm (Set.mem_image_of_mem _ h) - -lemma inconsistent'_lMap (Φ : L₁ →ᵥ L₂) : Entailment.Inconsistent 𝓢₁ → Entailment.Inconsistent (𝓢₁.lMap Φ) := by - simp only [Entailment.inconsistent_iff_provable_bot]; intro ⟨b⟩; exact ⟨by simpa using lMap Φ b⟩ end Hom -omit [L.DecidableEq] - private lemma map_subst_eq_free (φ : Semiproposition L 1) (h : ¬φ.FVar? m) : (@Rew.rewriteMap L ℕ ℕ 0 (fun x ↦ if x = m then 0 else x + 1)) ▹ (φ/[&m] : Proposition L) = Rewriting.free φ := by simp only [← TransitiveRewriting.comp_app] @@ -430,251 +202,121 @@ private lemma map_subst_eq_free (φ : Semiproposition L 1) (h : ¬φ.FVar? m) : private lemma map_rewriteMap_eq_shifts (Δ : Sequent L) (h : ∀ φ ∈ Δ, ¬φ.FVar? m) : Δ.map (fun φ ↦ @Rew.rewriteMap L ℕ ℕ 0 (fun x ↦ if x = m then 0 else x + 1) ▹ φ) = Δ⁺ := by apply List.map_congr_left - intro φ hp; exact rew_eq_of_funEqOn₀ + intro φ hp; exact Semiformula.rew_eq_of_funEqOn₀ (by intro x hx; simp [ne_of_mem_of_not_mem hx (h φ hp)]) def genelalizeByNewver {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) - (d : 𝓢 ⟹ φ/[&m] :: Δ) : 𝓢 ⟹ (∀⁰ φ) :: Δ := by - have : 𝓢 ⟹ (Rewriting.free φ) :: Δ⁺ := - Derivation.cast (Derivation.map d (fun x => if x = m then 0 else x + 1)) + (d : ⊢ᴷ φ/[&m] :: Δ) : ⊢ᴷ (∀⁰ φ) :: Δ := by + have : ⊢ᴷ φ.free :: Δ⁺ := + Derivation.cast (Derivation.map d (fun x ↦ if x = m then 0 else x + 1)) (by simp [map_subst_eq_free φ hp, map_rewriteMap_eq_shifts Δ hΔ]) exact all this def exOfInstances (v : List (SyntacticTerm L)) (φ : Semiproposition L 1) - (h : 𝓢 ⟹ v.map (φ/[·]) ++ Γ) : 𝓢 ⟹ (∃⁰ φ) :: Γ := by + (h : ⊢ᴷ v.map (φ/[·]) ++ Γ) : ⊢ᴷ (∃⁰ φ) :: Γ := by induction' v with t v ih generalizing Γ · exact weakening h (List.subset_cons_self _ _) - · exact (ih (Γ := (∃⁰ φ) :: Γ) ((exs t h).wk (by simp))).wk (by simp) + · exact (ih (Γ := (∃⁰ φ) :: Γ) ((exs h).wk (by simp))).wk (by simp) def exOfInstances' (v : List (SyntacticTerm L)) (φ : Semiproposition L 1) - (h : 𝓢 ⟹ (∃⁰ φ) :: v.map (φ/[·]) ++ Γ) : 𝓢 ⟹ (∃⁰ φ) :: Γ := + (h : ⊢ᴷ (∃⁰ φ) :: v.map (φ/[·]) ++ Γ) : ⊢ᴷ (∃⁰ φ) :: Γ := (exOfInstances (Γ := (∃⁰ φ) :: Γ) v φ (h.wk <| by simp)).wk (by simp) -end Derivation - -def newVar (Γ : Sequent L) : ℕ := (Γ.map Semiformula.fvSup).foldr max 0 - -lemma not_fvar?_newVar {φ : Proposition L} {Γ : Sequent L} (h : φ ∈ Γ) : ¬FVar? φ (newVar Γ) := - not_fvar?_of_lt_fvSup φ (by simpa [newVar] using List.le_max_of_le (List.mem_map_of_mem h) (by simp)) - -namespace Derivation - -open Semiformula -variable {P : Proposition L → Prop} {𝓢 : Schema L} {Δ : Sequent L} - -def allNvar {φ} (h : ∀⁰ φ ∈ Δ) : 𝓢 ⟹ φ/[&(newVar Δ)] :: Δ → 𝓢 ⟹ Δ := fun b ↦ - let b : 𝓢 ⟹ (∀⁰ φ) :: Δ := - genelalizeByNewver (by simpa [FVar?] using not_fvar?_newVar h) (fun _ ↦ not_fvar?_newVar) b - Tait.wk b (by simp [h]) - -def id_allClosure {φ} (hp : φ ∈ 𝓢) : 𝓢 ⟹ ∼φ.univCl' :: Δ → 𝓢 ⟹ Δ := fun b ↦ Tait.cut (Tait.wk (toClose (axm hp)) (by simp)) b +def allNvar {Δ : Sequent L} {φ} (h : ∀⁰ φ ∈ Δ) : ⊢ᴷ φ/[&Δ.newVar] :: Δ → ⊢ᴷ Δ := fun b ↦ + let b : ⊢ᴷ (∀⁰ φ) :: Δ := + b.genelalizeByNewver (by simpa [Semiformula.FVar?] using Sequent.not_fvar?_newVar h) (fun _ ↦ Sequent.not_fvar?_newVar) + b.wk (by simp [h]) end Derivation -namespace Schema - -instance {𝓢 U : Schema L} : 𝓢 ⪯ 𝓢 ∪ U := Entailment.Axiomatized.weakerThanOfSubset (by simp) +/-! ## Classical proof system -/ -instance {𝓢 U : Schema L} : U ⪯ 𝓢 ∪ U := Entailment.Axiomatized.weakerThanOfSubset (by simp) +inductive Proof.Symbol (L : Language) + | symbol -def deduction [L.DecidableEq] {𝓢 : Schema L} {φ ψ} (b : insert φ 𝓢 ⊢! ψ) : 𝓢 ⊢! φ.univCl' ➝ ψ := - have : 𝓢 ⟹ [∼φ.univCl', ψ] := Derivation.deduction b - (Tait.or this).cast (by simp; rfl) +notation "𝐋𝐊¹" => Proof.Symbol.symbol -theorem deduction! [L.DecidableEq] {𝓢 : Schema L} {φ ψ} (b : insert φ 𝓢 ⊢ ψ) : 𝓢 ⊢ φ.univCl' ➝ ψ := - ⟨deduction b.get⟩ +abbrev Proof (φ : Proposition L) := ⊢ᴷ [φ] -lemma close!_iff [L.DecidableEq] {𝓢 : Schema L} {φ} : 𝓢 ⊢ φ.univCl' ↔ 𝓢 ⊢ φ := by - constructor - · intro h - apply deduction! (Entailment.Axiomatized.adjoin! _ _) ⨀ h - · intro h - exact Derivation.toClose! h +instance : Entailment (Proof.Symbol L) (Proposition L) where + Prf _ := Proof -end Schema +lemma Proof.def (φ : Proposition L) : (𝐋𝐊¹ ⊢! φ) = (⊢ᴷ [φ]) := rfl -/-! - ### Theory (T set of sentences) --/ - -instance : Entailment (Theory L) (Sentence L) := ⟨fun T σ ↦ (T : Schema L) ⊢! ↑σ⟩ - -instance (T : Theory L) : Entailment.Cl T := Entailment.Cl.ofEquiv (T : Schema L) T (Rewriting.app Rew.emb) (fun _ ↦ .refl _) - -def toSyntacticProof {T : Theory L} {σ} : T ⊢! σ → (T : Schema L) ⊢! ↑σ := fun b ↦ b - -def ofSyntacticProof {T : Theory L} {σ} : (T : Schema L) ⊢! ↑σ → T ⊢! σ := fun b ↦ b - -lemma provable_def {T : Theory L} {σ} : T ⊢ σ ↔ (T : Schema L) ⊢ ↑σ := by rfl - -def Proof.cast {T : Theory L} {σ} : T ⊢ σ ↔ (T : Schema L) ⊢ ↑σ := by rfl +structure Schema.Proof (𝓢 : Schema L) (φ : Proposition L) where + axioms : List (Proposition L) + axioms_mem : ∀ ψ ∈ axioms, ψ ∈ 𝓢 + derivation : ⊢ᴷ φ :: ∼axioms -namespace Theory +namespace Schema.Proof -open Entailment - -instance : Axiomatized (Theory L) where - prfAxm {T} σ h := ofSyntacticProof <| Axiomatized.prfAxm (by simpa using h) - weakening {σ T B} h b := ofSyntacticProof <| Axiomatized.weakening (by simpa using h) b - -def deduction [L.DecidableEq] {T : Theory L} {σ τ} (b : insert σ T ⊢! τ) : T ⊢! σ ➝ τ := - have : insert ↑σ T.toSchema ⊢! ↑τ := by simpa using toSyntacticProof b - (Schema.deduction this).cast (by simp) - -instance [L.DecidableEq] : Entailment.Deduction (Theory L) where - ofInsert := Theory.deduction - inv {σ τ T} b := - have : adjoin σ T ⊢! σ ➝ τ := Axiomatized.weakening (by simp) b - this ⨀ (Axiomatized.adjoin _ _) - -def compact! [L.DecidableEq] {T : Theory L} {φ : Sentence L} : - T ⊢! φ → (s : { s : Finset (Sentence L) // ↑s ⊆ T}) × (s : Theory L) ⊢! φ := - fun b ↦ - let ⟨s, b⟩ := Derivation.compact b - ⟨⟨s.val.image Semiformula.toEmpty', fun φ ↦ by - suffices ∀ φ' ∈ s.val, φ'.toEmpty' = φ → φ ∈ T by simpa - intro φ hφ e - have : ∃ σ ∈ T, ↑σ = φ := by - simpa [Theory.toSchema] using s.prop hφ - rcases this with ⟨σ, hσ, rfl⟩ - have : σ = φ := by simpa [Semiformula.toEmpty'] using e - simp_all⟩, ofSyntacticProof <| - Axiomatized.weakening (by - simp only [Finset.coe_image] - intro φ hφ - have : ∃ σ ∈ T, ↑σ = φ := by - simpa [Theory.toSchema] using s.prop hφ - rcases this with ⟨σ, _, rfl⟩ - simpa using ⟨σ, hφ, by simp⟩) b⟩ - -instance [L.DecidableEq] : Entailment.Compact (Theory L) where - Γ b := (compact! b).1 - ΓPrf b := (compact! b).2 - Γ_subset b := by simpa using (compact! b).1.prop - Γ_finite b := by simp - -theorem compact [L.DecidableEq] {T : Theory L} {φ : Sentence L} (b : T ⊢ φ) : - ∃ (s : { s : Finset (Sentence L) // ↑s ⊆ T}), (s : Theory L) ⊢ φ := - let ⟨s, b⟩ := compact! b.get - ⟨s, ⟨b⟩⟩ - -instance : Entailment.StrongCut (Theory L) (Theory L) where - cut {T U φ} b d := - Tait.Axiomatized.trans (𝓛 := (↑T : Schema L)) (𝓚 := (↑U : Schema L)) - (fun ψ hψ ↦ - let b := @b ψ.toEmpty' (by - have : ∃ ψ₀ ∈ U, ↑ψ₀ = ψ := by simpa [toSchema] using hψ - rcases this with ⟨ψ₀, hψ₀U, rfl⟩ - simpa using hψ) - (toSyntacticProof b).cast <| by - have : ∃ ψ₀ ∈ U, ↑ψ₀ = ψ := by simpa [toSchema] using hψ - rcases this with⟨_, _, rfl⟩ - simp) - (toSyntacticProof d) - -lemma compact' [L.DecidableEq] {T : Theory L} {φ : Sentence L} - (b : T ⊢ φ) : ∃ (s : { s : Finset (Sentence L) // ↑s ⊆ T}), (∅ : Theory L) ⊢ s.val.conj ➝ φ := by - let ⟨s, b⟩ := compact b - let bc : ({s.val.conj} : Theory L) ⊢ s.val.conj := Axiomatized.provable_refl _ (by simp) - have : {s.val.conj} ⊢ φ := StrongCut.cut! (fun {ψ} hψ ↦ Entailment.left_Fconj!_intro (by simpa) ⨀ bc) b - have : (insert s.val.conj ∅ : Theory L) ⊢ φ := by simpa using this - exact ⟨s, ⟨deduction this.get⟩⟩ - -instance (T : Theory L) : Entailment.Cl T := Entailment.Cl.ofEquiv (T : Schema L) T (Rewriting.app Rew.emb) (fun _ ↦ .refl _) - -instance : DeductiveExplosion (Theory L) where - dexp b _ := ofSyntacticProof <| DeductiveExplosion.dexp (toSyntacticProof b) _ - -lemma inconsistent_iff {T : Theory L} : - Inconsistent T ↔ Inconsistent (T : Schema L) := calc - Inconsistent T ↔ T ⊢ ⊥ := inconsistent_iff_provable_bot - _ ↔ (T : Schema L) ⊢ ⊥ := by simp [provable_def] - _ ↔ Inconsistent (T : Schema L) := inconsistent_iff_provable_bot.symm - -lemma inconsistent_lMap {T : Theory L₁} (Φ : L₁ →ᵥ L₂) : - Entailment.Inconsistent T → Entailment.Inconsistent (T.lMap Φ) := by - intro h - have : Schema.lMap Φ ↑T ⊢ ⊥ := ⟨Derivation.lMap Φ (provable_def.mp <| inconsistent_iff_provable_bot.mp h).get⟩ - refine inconsistent_iff_provable_bot.mpr <| provable_def.mpr ?_ - suffices ↑(lMap Φ T) ⊢ ⊥ by simpa - apply Axiomatized.weakening! ?_ this - simp only [Schema.lMap, toSchema, Set.image_subset_iff] - intro φ hφ - simpa using ⟨(Semiformula.lMap Φ) φ, Set.mem_image_of_mem _ hφ, Eq.symm (lMap_emb φ)⟩ - -instance {T U : Theory L} : T ⪯ T + U := Entailment.Axiomatized.weakerThanOfSubset (by simp [add_def]) - -instance {T U : Theory L} : U ⪯ T + U := Entailment.Axiomatized.weakerThanOfSubset (by simp [add_def]) +instance : Entailment (Schema L) (Proposition L) where + Prf := Schema.Proof -end Theory +variable {𝓢 : Schema L} -namespace Schema +attribute [simp] axioms_mem -open Entailment +def equiv (𝓢 : Schema L) (φ) : + (𝓢 ⊢! φ) ≃ (Γ : {Γ : Sequent L // ∀ ψ ∈ Γ, ψ ∈ 𝓢}) × ⊢ᴷ φ :: ∼Γ where + toFun b := ⟨⟨b.axioms, b.axioms_mem⟩, b.derivation⟩ + invFun := fun ⟨⟨Γ, hΓ⟩, d⟩ ↦ ⟨Γ, hΓ, d⟩ -variable [L.DecidableEq] {𝓢 : Schema L} +lemma provable_iff : + 𝓢 ⊢ φ ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ φ :: ∼Γ) := by + simpa using (equiv 𝓢 φ).nonempty_congr -def coe_provable_iff_provable_coe {σ : Sentence L} : - (𝓢 : Theory L) ⊢ σ ↔ 𝓢 ⊢ ↑σ := by - constructor - · intro b - have : 𝓢.toTheory.toSchema ⊢ ↑σ := b - apply Entailment.StrongCut.cut! ?_ this - intro τ hτ - have : ∃ τ' ∈ 𝓢, τ'.univCl' = τ := by simpa [Schema.toTheory, Theory.toSchema] using hτ - rcases this with ⟨τ, h, rfl⟩ - exact Derivation.toClose! <| by_axm _ <| by simpa - · intro b - apply provable_def.mpr - apply Entailment.StrongCut.cut! ?_ b - intro φ hφ - have : 𝓢.toTheory.toSchema ⊢ φ.univCl' := - by_axm _ <| by simpa [Schema.toTheory, Theory.toSchema] using ⟨φ, by simpa, rfl⟩ - exact Schema.close!_iff.mp this +instance : Entailment.Compact (Schema L) where + core b := ⟨fun φ ↦ φ ∈ b.axioms⟩ + corePrf b := ⟨b.axioms, by simp, b.derivation⟩ + core_finite b := by simp [AdjunctiveSet.Finite, AdjunctiveSet.set] + core_subset b := by simpa [AdjunctiveSet.subset_iff] using b.axioms_mem -def coe_unprovable_iff_unprovable_coe {σ} : - (𝓢 : Theory L) ⊬ σ ↔ 𝓢 ⊬ ↑σ := coe_provable_iff_provable_coe.not +instance : OneSidedLK.Entailment (Derivation (L := L)) (Schema L) where + equiv {𝓢 φ} := equiv 𝓢 φ -def provable_univCl_iff {φ : Proposition L} : - (𝓢 : Theory L) ⊢ φ.univCl ↔ 𝓢 ⊢ φ := Iff.trans coe_provable_iff_provable_coe (by simp [Schema.close!_iff]) +instance : Entailment.Cl 𝓢 := inferInstance -def unprovable_univCl_iff {φ : Proposition L} : - (𝓢 : Theory L) ⊬ φ.univCl ↔ 𝓢 ⊬ φ := provable_univCl_iff.not +lemma weakerThan_of_le {𝓢 𝓤 : Schema L} (h : 𝓢 ≤ 𝓤) : 𝓢 ⪯ 𝓤 := Entailment.Axiomatized.weakerThanOfSubset h -instance (𝓢 𝓣 : Schema L) [𝓢 ⪯ 𝓣] : 𝓢.toTheory ⪯ 𝓣.toTheory := - ⟨fun _ b ↦ coe_provable_iff_provable_coe.mpr <| (inferInstanceAs (𝓢 ⪯ 𝓣)).pbl (coe_provable_iff_provable_coe.mp b)⟩ +instance (𝓢 𝓤 : Schema L) : 𝓢 ⪯ 𝓢 ⊔ 𝓤 := weakerThan_of_le (by simp) -@[simp] lemma coe_consistent_iff : - Consistent (𝓢 : Theory L) ↔ Consistent 𝓢 := calc - Consistent (𝓢 : Theory L) ↔ (𝓢 : Theory L) ⊬ ⊥ := consistent_iff_unprovable_bot - _ ↔ 𝓢 ⊬ ⊥ := by simp [coe_unprovable_iff_unprovable_coe] - _ ↔ Consistent 𝓢 := consistent_iff_unprovable_bot.symm +instance (𝓢 𝓤 : Schema L) : 𝓤 ⪯ 𝓢 ⊔ 𝓤 := weakerThan_of_le (by simp) -instance [Consistent 𝓢] : Consistent (𝓢 : Theory L) := by simp_all +lemma inconsistent_iff : + Entailment.Inconsistent 𝓢 ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ ∼Γ) := calc + _ ↔ 𝓢 ⊢ ⊥ := Entailment.inconsistent_iff_provable_bot + _ ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ ⊥ :: ∼Γ) := by simp [provable_iff] + _ ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ ∼Γ) := by + constructor + · rintro ⟨Γ, hΓ, ⟨d⟩⟩ + have : ⊢ᴷ [(∼⊥ : Proposition L)] := Derivation.verum.cast + exact ⟨Γ, hΓ, ⟨(Derivation.cut d this).cast⟩⟩ + · rintro ⟨Γ, hΓ, ⟨d⟩⟩ + exact ⟨Γ, hΓ, ⟨d.weakening⟩⟩ -end Schema +end Schema.Proof -namespace Schema -variable {𝓢 : Schema L} +/-! + ### Theory of schemata +-/ -def specialize! (φ : Semiproposition L 1) (t : SyntacticTerm L) : 𝓢 ⊢! ∀⁰ φ ➝ φ/[t] := - have : 𝓢 ⟹ [(∼φ)/[t], φ/[t]] := Derivation.em (φ := φ/[t]) (by simp) (by simp) - have : 𝓢 ⟹ [∃⁰ ∼φ, φ/[t]] := this.exs t - this.or.cast (by simp [Semiformula.imp_eq]) +abbrev Theory (L : Language) := Set (Sentence L) -lemma specialize (φ : Semiproposition L 1) (t : SyntacticTerm L) : 𝓢 ⊢ ∀⁰ φ ➝ φ/[t] := ⟨specialize! φ t⟩ +def Schema.theory (𝓢 : Schema L) : Theory L := {σ | 𝓢 ⊢ ↑σ} -end Schema +@[simp] lemma Schema.mem_theory {𝓢 : Schema L} {σ : Sentence L} : + σ ∈ 𝓢.theory ↔ 𝓢 ⊢ ↑σ := by simp [Schema.theory] namespace Theory -variable {T : Theory L} - -def specialize! (φ : Semisentence L 1) (t) : T ⊢! ∀⁰ φ ➝ φ/[t] := ofSyntacticProof <| by - simpa [Semiformula.coe_subst_eq_subst_coe₁] using (Schema.specialize! (𝓢 := T) φ (t : SyntacticTerm L)) +instance : Entailment (Theory L) (Sentence L) where + Prf T σ := PLift (σ ∈ T) -lemma specialize (φ : Semisentence L 1) (t) : T ⊢ ∀⁰ φ ➝ φ/[t] := ⟨specialize! φ t⟩ +@[simp] lemma provable_iff (σ : Sentence L) (T : Theory L) : + T ⊢ σ ↔ σ ∈ T := + ⟨fun h ↦ PLift.down h.some, fun h ↦ ⟨⟨h⟩⟩⟩ end Theory diff --git a/Foundation/FirstOrder/Basic/Syntax/Schema.lean b/Foundation/FirstOrder/Basic/Syntax/Schema.lean index d5a54d1f9..dbc6df6b6 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Schema.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Schema.lean @@ -64,9 +64,11 @@ instance : CompleteLattice (Schema L) where @[simp] lemma not_mem_bot (φ : Proposition L) : φ ∉ (⊥ : Schema L) := by rintro ⟨⟩ -instance : Coe (Proposition L) (Schema L) := ⟨fun φ ↦ ⟨(· = φ)⟩⟩ +@[coe] def ofProposition (φ : Proposition L) : Schema L := ⟨(· = φ)⟩ -@[simp] lemma mem_coe (φ ψ : Proposition L) : ψ ∈ (φ : Schema L) ↔ ψ = φ := by simp +instance : Coe (Proposition L) (Schema L) := ⟨fun φ ↦ ofProposition φ⟩ + +@[simp] lemma mem_coe (φ ψ : Proposition L) : ψ ∈ (φ : Schema L) ↔ ψ = φ := by rfl instance : AdjunctiveSet (Proposition L) (Schema L) where Subset 𝓢₁ 𝓢₂ := 𝓢₁ ≤ 𝓢₂ @@ -109,7 +111,7 @@ lemma sSup (s : Set (Schema L)) (H : ∀ 𝓢 ∈ s, IsClosed 𝓢) : IsClosed ( have : IsClosed 𝓢 := H 𝓢 hs exact ⟨𝓢, hs, IsClosed.closed _ _ hφ⟩ -instance (σ : Sentence L) : IsClosed (σ : Schema L) where +instance sentence (σ : Sentence L) : IsClosed (σ : Schema L) where closed _ φ h := by have : φ = σ := by simpa using h rcases this diff --git a/Foundation/Logic/Calculus.lean b/Foundation/Logic/Calculus.lean index 9acb53d4b..8c681d40f 100644 --- a/Foundation/Logic/Calculus.lean +++ b/Foundation/Logic/Calculus.lean @@ -42,12 +42,6 @@ def verum' (h : ⊤ ∈ Γ := by simp) : 𝔇 Γ := wk verum (by simp [h]) def tensor {φ ψ : F} (dφ : 𝔇 (φ :: Γ)) (dψ : 𝔇 (ψ :: Δ)) : 𝔇 (φ ⋏ ψ :: Γ ++ Δ) := and (wk dφ (by simp)) (wk dψ (by simp)) -def wkTail (d : 𝔇 Γ) : 𝔇 (φ :: Γ) := wk d (by simp) - -def wkAppendLeft (d : 𝔇 Δ) : 𝔇 (Δ ++ Γ) := wk d (by simp) - -def wkAppendRight (d : 𝔇 Γ) : 𝔇 (Δ ++ Γ) := wk d (by simp) - def rotate₁ (d : 𝔇 (φ₂ :: φ₁ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: Γ) := wk d (by simp) def rotate₂ (d : 𝔇 (φ₃ :: φ₁ :: φ₂ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: φ₃ :: Γ) := @@ -60,7 +54,7 @@ def rotate₃ (d : 𝔇 (φ₄ :: φ₁ :: φ₂ :: φ₃ :: Γ)) : 𝔇 (φ₁ alias cut := OneSidedLK.Cut.cut protected class Entailment (𝔇 : outParam (List F → Type*)) (S : Type*) [Entailment S F] [AdjunctiveSet F S] where - equiv {𝓢 : S} : 𝓢 ⊢! φ ≃ (l : {l : List F // ∀ φ ∈ l, φ ∈ 𝓢}) × 𝔇 (φ :: ∼l) + equiv {𝓢 : S} {φ} : 𝓢 ⊢! φ ≃ (l : {l : List F // ∀ φ ∈ l, φ ∈ 𝓢}) × 𝔇 (φ :: ∼l) open Entailment @@ -105,6 +99,14 @@ instance : Entailment.StrongCut S S where have ⟨l, hl⟩ := OneSidedLK.Entailment.equiv b bl l l.prop φ hl +instance : Entailment.DeductiveExplosion S where + dexp b φ := + have ⟨Γ, b⟩ := OneSidedLK.Entailment.equiv b + OneSidedLK.Entailment.equiv.symm + ⟨ Γ, + have : 𝔇 [∼⊥] := cast verum (by simp) + wk (cut b this) (by simp) ⟩ + instance (𝓢 : S) : Entailment.Cl 𝓢 where negEquiv {φ} := Entailment.cast (show 𝓢 ⊢! (φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ) from diff --git a/Foundation/Propositional/Entailment/Cl/Basic.lean b/Foundation/Propositional/Entailment/Cl/Basic.lean index a5010201f..7a8630baf 100644 --- a/Foundation/Propositional/Entailment/Cl/Basic.lean +++ b/Foundation/Propositional/Entailment/Cl/Basic.lean @@ -167,6 +167,8 @@ lemma provable_iff_inconsistent_adjoin {φ : F} : have : 𝓢 ⊢ ∼φ ➝ ⊥ := Deduction.of_insert! (h _) refine of_NN! <| N!_iff_CO!.mpr this +instance deductiveExplosion : Entailment.DeductiveExplosion S := inferInstance + end consistency @@ -190,8 +192,7 @@ instance : HasAxiomPeirce 𝓢 where . simp; . simp; -instance : HasAxiomEFQ 𝓢 where - efq := C_of_CNN (C_of_conseq NO) +instance : HasAxiomEFQ 𝓢 := inferInstance instance : Entailment.Int 𝓢 where From f21f1d8f834fc4706f326ba7e184e1ea1a38357b Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 7 Mar 2026 17:55:10 +0900 Subject: [PATCH 07/61] iff_context --- Foundation/FirstOrder/Basic/Calculus.lean | 102 ++++++++++++++---- .../FirstOrder/Basic/Syntax/Schema.lean | 8 ++ Foundation/Logic/Calculus.lean | 19 +++- Foundation/Logic/LogicSymbol.lean | 47 +++++++- 4 files changed, 155 insertions(+), 21 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index 6e3f389de..fa3e25d03 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -27,6 +27,9 @@ def newVar (Γ : Sequent L) : ℕ := (Γ.map Semiformula.fvSup).foldr max 0 lemma not_fvar?_newVar {φ : Proposition L} {Γ : Sequent L} (h : φ ∈ Γ) : ¬FVar? φ Γ.newVar := not_fvar?_of_lt_fvSup φ (by simpa [newVar] using List.le_max_of_le (List.mem_map_of_mem h) (by simp)) +@[simp] lemma rew_neg_comm {Γ : Sequent L} (ω : Rew L ℕ 0 ℕ 0) : + (∼Γ).map (ω ▹ ·) = ∼Γ.map (ω ▹ ·) := by simp [List.tilde_def] + end Sequent /-! ## Derivation for one-sided $\mathbf{LK}$ -/ @@ -48,8 +51,6 @@ namespace Derivation open Rewriting LawfulSyntacticRewriting - - def height {Δ : Sequent L} : ⊢ᴷ Δ → ℕ | .id _ _ => 0 | cut dp dn => (max (height dp) (height dn)).succ @@ -262,10 +263,6 @@ def equiv (𝓢 : Schema L) (φ) : toFun b := ⟨⟨b.axioms, b.axioms_mem⟩, b.derivation⟩ invFun := fun ⟨⟨Γ, hΓ⟩, d⟩ ↦ ⟨Γ, hΓ, d⟩ -lemma provable_iff : - 𝓢 ⊢ φ ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ φ :: ∼Γ) := by - simpa using (equiv 𝓢 φ).nonempty_congr - instance : Entailment.Compact (Schema L) where core b := ⟨fun φ ↦ φ ∈ b.axioms⟩ corePrf b := ⟨b.axioms, by simp, b.derivation⟩ @@ -284,29 +281,96 @@ instance (𝓢 𝓤 : Schema L) : 𝓢 ⪯ 𝓢 ⊔ 𝓤 := weakerThan_of_le (by instance (𝓢 𝓤 : Schema L) : 𝓤 ⪯ 𝓢 ⊔ 𝓤 := weakerThan_of_le (by simp) lemma inconsistent_iff : - Entailment.Inconsistent 𝓢 ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ ∼Γ) := calc - _ ↔ 𝓢 ⊢ ⊥ := Entailment.inconsistent_iff_provable_bot - _ ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ ⊥ :: ∼Γ) := by simp [provable_iff] - _ ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ ∼Γ) := by - constructor - · rintro ⟨Γ, hΓ, ⟨d⟩⟩ - have : ⊢ᴷ [(∼⊥ : Proposition L)] := Derivation.verum.cast - exact ⟨Γ, hΓ, ⟨(Derivation.cut d this).cast⟩⟩ - · rintro ⟨Γ, hΓ, ⟨d⟩⟩ - exact ⟨Γ, hΓ, ⟨d.weakening⟩⟩ + Entailment.Inconsistent 𝓢 ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ ∼Γ) := + OneSidedLK.inconsistent_iff + +def rewrite [𝓢.IsClosed] (b : 𝓢 ⊢! φ) (f : ℕ → SyntacticTerm L) : + 𝓢 ⊢! Rew.rewrite f ▹ φ where + axioms := b.axioms.map (Rew.rewrite f ▹ ·) + axioms_mem := by + suffices ∀ ψ ∈ b.axioms, Rew.rewrite f ▹ ψ ∈ 𝓢 by simpa + intro ψ hψ + exact Schema.IsClosed.closed (Rew.rewrite f) _ (b.axioms_mem ψ hψ) + derivation := b.derivation.rewrite f |>.cast end Schema.Proof +namespace Derivation + +open Entailment + +variable {Γ Δ : Sequent L} + +def eCut (d₁ : ⊢ᴷ φ :: Γ) (d₂ : ⊢ᴷ ψ :: Δ) (e : ∼φ = ψ := by simp) : ⊢ᴷ Γ ++ Δ := cut d₁ (d₂.cast (by simp [e])) + +def disj₂ {Γ Δ : Sequent L} : ⊢ᴷ (Γ ++ Δ) → ⊢ᴷ ⋁Γ :: Δ := fun d ↦ + match Γ with + | [] => d.weakening + | [φ] => d + | [φ, ψ] => d.or + | φ :: ψ :: χ :: Γ => + let Φ := ⋁(χ :: Γ) + have : ⊢ᴷ (φ ⋎ ψ :: χ :: Γ) ++ Δ := d.or + have d₁ : ⊢ᴷ (φ ⋎ ψ) ⋎ Φ :: Δ := this.disj₂ + have d₂ : ⊢ᴷ [(∼φ ⋏ ∼ψ) ⋏ ∼Φ, φ ⋎ ψ ⋎ Φ] := + have : ⊢ᴷ [φ, ψ ⋎ Φ, (∼φ ⋏ ∼ψ) ⋏ ∼Φ] := + ((identity φ).rotate.tensor (identity ψ).rotate).tensor + (identity Φ).rotate |>.rotate.rotate.or.weakening + this.or.rotate + d₂.eCut d₁ + termination_by _ => Γ.length + +def conj₂ {Γ Δ : Sequent L} (d : (φ : Proposition L) → φ ∈ Γ → ⊢ᴷ φ :: Δ) : ⊢ᴷ ⋀Γ :: Δ := + match Γ with + | [] => verum.weakening + | [φ] => d φ (by simp) + | φ :: ψ :: Γ => + have : ⊢ᴷ ⋀(ψ :: Γ) :: Δ := conj₂ (Γ := ψ :: Γ) (fun χ h ↦ d χ (by simp_all)) + (d φ (by simp)).and this + +def disjClosure : ⊢ᴷ Γ → 𝐋𝐊¹ ⊢! ⋁Γ := fun d ↦ + have : ⊢ᴷ Γ ++ [] := d.cast + this.disj₂ + +def disjClosureInv : 𝐋𝐊¹ ⊢! ⋁Γ → ⊢ᴷ Γ := fun d ↦ + have d₁ : ⊢ᴷ [⋁Γ] := d + have d₂ : ⊢ᴷ ⋀(∼Γ) :: Γ := conj₂ fun φ h ↦ close φ (by simp) (by simp_all) + d₁.eCut d₂ + +lemma nonempty_iff_provable_disj : Nonempty (⊢ᴷ Γ) ↔ 𝐋𝐊¹ ⊢ ⋁Γ := + ⟨by rintro ⟨d⟩; exact ⟨d.disjClosure⟩, by rintro ⟨d⟩; exact ⟨d.disjClosureInv⟩⟩ + +end Derivation + +namespace Schema.Proof + +variable {𝓢 : Schema L} + +open Derivation + +lemma iff_context : 𝓢 ⊢ φ ↔ 𝓢 *⊢[𝐋𝐊¹] φ := by + constructor + · rintro ⟨d⟩ + have : 𝐋𝐊¹ ⊢! ⋀d.axioms ➝ φ := + have : ⊢ᴷ ∼d.axioms ++ [φ] := d.derivation.weakening + this.disj₂.or.cast <| by simp [Semiformula.imp_eq] + refine ⟨⟨d.axioms, by simpa using d.axioms_mem, this⟩⟩ + · rintro ⟨Γ, h, d⟩ + have d : ⊢ᴷ [⋁(∼Γ) ⋎ φ] := d.cast (by simp [Semiformula.imp_eq]) + have : ⊢ᴷ ⋀Γ ⋏ ∼φ :: φ :: ∼Γ := + have : ⊢ᴷ ⋀Γ :: ∼Γ := Derivation.conj₂ fun φ h ↦ close φ (by simp) (by simp [h]) + this.tensor (identity φ).rotate |>.weakening + refine ⟨⟨Γ, h, (d.eCut this).cast⟩⟩ + +end Schema.Proof /-! ### Theory of schemata -/ -abbrev Theory (L : Language) := Set (Sentence L) - def Schema.theory (𝓢 : Schema L) : Theory L := {σ | 𝓢 ⊢ ↑σ} -@[simp] lemma Schema.mem_theory {𝓢 : Schema L} {σ : Sentence L} : +@[simp] lemma Schema.mem_theory {𝓢 : Schema L} : σ ∈ 𝓢.theory ↔ 𝓢 ⊢ ↑σ := by simp [Schema.theory] namespace Theory diff --git a/Foundation/FirstOrder/Basic/Syntax/Schema.lean b/Foundation/FirstOrder/Basic/Syntax/Schema.lean index dbc6df6b6..5c1f2160e 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Schema.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Schema.lean @@ -16,6 +16,7 @@ namespace LO.FirstOrder structure Schema (L : Language) where Mem : Proposition L → Prop +abbrev Theory (L : Language) := Set (Sentence L) namespace Schema variable {L : Language} @@ -119,6 +120,13 @@ instance sentence (σ : Sentence L) : IsClosed (σ : Schema L) where end IsClosed +def uniClosure (𝓢 : Schema L) : Theory L := Set.image Semiformula.univCl {φ | φ ∈ 𝓢} + +variable {𝓢 : Schema L} + +@[simp] lemma mem_uniClosure : + σ ∈ 𝓢.uniClosure ↔ ∃ φ ∈ 𝓢, Semiformula.univCl φ = σ := by simp [uniClosure] + end Schema end LO.FirstOrder diff --git a/Foundation/Logic/Calculus.lean b/Foundation/Logic/Calculus.lean index 8c681d40f..31b219b14 100644 --- a/Foundation/Logic/Calculus.lean +++ b/Foundation/Logic/Calculus.lean @@ -60,6 +60,11 @@ open Entailment variable {S : Type*} [Entailment S F] [AdjunctiveSet F S] [OneSidedLK.Entailment 𝔇 S] +omit [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] in +lemma provable_iff {𝓢 : S} : + 𝓢 ⊢ φ ↔ ∃ Γ : List F, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (𝔇 (φ :: ∼Γ)) := by + simpa using OneSidedLK.Entailment.equiv.nonempty_congr + def toProof (𝓢 : S) (d : 𝔇 [φ]) : 𝓢 ⊢! φ := OneSidedLK.Entailment.equiv.symm ⟨⟨[], by simp⟩, d⟩ def ofAxiom {𝓢 : S} (h : φ ∈ 𝓢) : 𝓢 ⊢! φ := @@ -74,7 +79,7 @@ instance : Entailment.Axiomatized S where prfAxm h := ofAxiom h weakening h d := ofAxiomSubset d h -variable [OneSidedLK.Cut 𝔇] [OneSidedLK.Entailment 𝔇 S] +variable [OneSidedLK.Cut 𝔇] instance (𝓢 : S) : Entailment.ModusPonens 𝓢 where mdp {φ ψ} b₁ b₂ := @@ -107,6 +112,18 @@ instance : Entailment.DeductiveExplosion S where have : 𝔇 [∼⊥] := cast verum (by simp) wk (cut b this) (by simp) ⟩ +lemma inconsistent_iff {𝓢 : S} : + Entailment.Inconsistent 𝓢 ↔ ∃ Γ : List F, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (𝔇 (∼Γ)) := calc + _ ↔ 𝓢 ⊢ ⊥ := Entailment.inconsistent_iff_provable_bot + _ ↔ ∃ Γ : List F, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (𝔇 (⊥ :: ∼Γ)) := by simp [provable_iff] + _ ↔ ∃ Γ : List F, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (𝔇 (∼Γ)) := by + constructor + · rintro ⟨Γ, hΓ, ⟨d⟩⟩ + have : 𝔇 [(∼⊥ : F)] := cast verum + exact ⟨Γ, hΓ, ⟨cast (cut d this)⟩⟩ + · rintro ⟨Γ, hΓ, ⟨d⟩⟩ + exact ⟨Γ, hΓ, ⟨wk d (by simp)⟩⟩ + instance (𝓢 : S) : Entailment.Cl 𝓢 where negEquiv {φ} := Entailment.cast (show 𝓢 ⊢! (φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ) from diff --git a/Foundation/Logic/LogicSymbol.lean b/Foundation/Logic/LogicSymbol.lean index 04b4f4404..6ac11cfa4 100644 --- a/Foundation/Logic/LogicSymbol.lean +++ b/Foundation/Logic/LogicSymbol.lean @@ -344,15 +344,32 @@ variable [Tilde α] instance : Tilde (List α) := ⟨fun l ↦ l.map (∼·)⟩ +lemma tilde_def (l : List α) : ∼l = l.map (∼·) := rfl + @[simp] lemma tilde_nil : ∼([] : List α) = [] := rfl @[simp] lemma tilde_cons (a : α) (l : List α) : ∼(a :: l) = ∼a :: ∼l := rfl @[simp] lemma tilde_append (l k : List α) : ∼(l ++ k) = ∼l ++ ∼k := by induction l with - | nil => simp [*] + | nil => simp [*] | cons a as ih => simp [*, List.cons_append] +@[simp] lemma mem_tilde_iff [NegInvolutive α] {a : α} {l : List α} : a ∈ ∼l ↔ ∼a ∈ l := by + induction l with + | nil => simp [*] + | cons b bs ih => + suffices a = ∼b ↔ ∼a = b by + simp [ih, this] + constructor <;> {rintro rfl; simp} + +instance [NegInvolutive α] : NegInvolutive (List α) where + neg_involutive l := by + induction l with + | nil => simp [*] + | cons a as ih => + simp [ih, NegInvolutive.neg_involutive a] + end tilde section conjunction @@ -437,6 +454,34 @@ def disj' (f : ι → α) (l : List ι) : α := (l.map f).disj₂ end disjunction +section tilde + +variable [LogicalConnective α] [DeMorgan α] + +@[simp] lemma tilde_conj (l : List α) : ∼l.disj = (∼l).conj := by + match l with + | [] => simp + | a :: l => simp [tilde_conj l] + +@[simp] lemma tilde_disj (l : List α) : ∼l.conj = (∼l).disj := by + match l with + | [] => simp + | a :: l => simp [tilde_disj l] + +@[simp] lemma tilde_conj₂ (l : List α) : ∼⋁l = ⋀(∼l) := by + match l with + | [] => simp + | [a] => simp + | a :: b :: l => simp [tilde_conj₂ (b :: l)] + +@[simp] lemma tilde_disj₂ (l : List α) : ∼⋀l = ⋁(∼l) := by + match l with + | [] => simp + | [a] => simp + | a :: b :: l => simp [tilde_disj₂ (b :: l)] + +end tilde + section variable [LogicalConnective α] [LogicalConnective β] [FunLike G α β] [LogicalConnective.HomClass G α β] From 5baf6f0ad2b787dc2a7bad9a86b825ed95ee59e8 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 7 Mar 2026 18:54:00 +0900 Subject: [PATCH 08/61] add --- Foundation/FirstOrder/Basic/Calculus.lean | 38 ++++++-- Foundation/Logic/Calculus.lean | 111 +++++++++++++++++++--- 2 files changed, 128 insertions(+), 21 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index fa3e25d03..1ea367254 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -242,7 +242,16 @@ abbrev Proof (φ : Proposition L) := ⊢ᴷ [φ] instance : Entailment (Proof.Symbol L) (Proposition L) where Prf _ := Proof -lemma Proof.def (φ : Proposition L) : (𝐋𝐊¹ ⊢! φ) = (⊢ᴷ [φ]) := rfl +namespace Proof + +lemma def_eq (φ : Proposition L) : (𝐋𝐊¹ ⊢! φ) = (⊢ᴷ [φ]) := rfl + +instance : OneSidedLK.EmptyEntailment (Derivation (L := L)) (𝐋𝐊¹ : Proof.Symbol L) where + equiv := Equiv.refl _ + +instance classical : Entailment.Cl (𝐋𝐊¹ : Proof.Symbol L) := inferInstance + +end Proof structure Schema.Proof (𝓢 : Schema L) (φ : Proposition L) where axioms : List (Proposition L) @@ -282,7 +291,7 @@ instance (𝓢 𝓤 : Schema L) : 𝓤 ⪯ 𝓢 ⊔ 𝓤 := weakerThan_of_le (by lemma inconsistent_iff : Entailment.Inconsistent 𝓢 ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ ∼Γ) := - OneSidedLK.inconsistent_iff + OneSidedLK.Entailment.inconsistent_iff def rewrite [𝓢.IsClosed] (b : 𝓢 ⊢! φ) (f : ℕ → SyntacticTerm L) : 𝓢 ⊢! Rew.rewrite f ▹ φ where @@ -293,6 +302,10 @@ def rewrite [𝓢.IsClosed] (b : 𝓢 ⊢! φ) (f : ℕ → SyntacticTerm L) : exact Schema.IsClosed.closed (Rew.rewrite f) _ (b.axioms_mem ψ hψ) derivation := b.derivation.rewrite f |>.cast +@[simp] lemma empty_provable_iff_eprovable : + (⊥ : Schema L) ⊢ φ ↔ 𝐋𝐊¹ ⊢ φ := + OneSidedLK.Entailment.empty_provable_iff_eprovable 𝐋𝐊¹ + end Schema.Proof namespace Derivation @@ -303,7 +316,7 @@ variable {Γ Δ : Sequent L} def eCut (d₁ : ⊢ᴷ φ :: Γ) (d₂ : ⊢ᴷ ψ :: Δ) (e : ∼φ = ψ := by simp) : ⊢ᴷ Γ ++ Δ := cut d₁ (d₂.cast (by simp [e])) -def disj₂ {Γ Δ : Sequent L} : ⊢ᴷ (Γ ++ Δ) → ⊢ᴷ ⋁Γ :: Δ := fun d ↦ +def disj₂ {Γ Δ : Sequent L} : ⊢ᴷ Γ ++ Δ → ⊢ᴷ ⋁Γ :: Δ := fun d ↦ match Γ with | [] => d.weakening | [φ] => d @@ -344,11 +357,9 @@ end Derivation namespace Schema.Proof -variable {𝓢 : Schema L} - -open Derivation +open Entailment Derivation -lemma iff_context : 𝓢 ⊢ φ ↔ 𝓢 *⊢[𝐋𝐊¹] φ := by +lemma iff_context {𝓢 : Schema L} : 𝓢 ⊢ φ ↔ 𝓢 *⊢[𝐋𝐊¹] φ := by constructor · rintro ⟨d⟩ have : 𝐋𝐊¹ ⊢! ⋀d.axioms ➝ φ := @@ -362,10 +373,21 @@ lemma iff_context : 𝓢 ⊢ φ ↔ 𝓢 *⊢[𝐋𝐊¹] φ := by this.tensor (identity φ).rotate |>.weakening refine ⟨⟨Γ, h, (d.eCut this).cast⟩⟩ +open Classical in + +noncomputable instance : Entailment.Deduction (Schema L) where + ofInsert {φ ψ 𝓢 b} := + have : insert φ ↑𝓢 *⊢[𝐋𝐊¹] ψ := iff_context.mp ⟨b⟩ + have : ↑𝓢 *⊢[𝐋𝐊¹] φ ➝ ψ := Context.deduct! this + (iff_context.mpr this).get + inv {φ ψ 𝓢 b} := + have : ↑(adjoin φ 𝓢) *⊢[𝐋𝐊¹] ψ := Context.deductInv! (iff_context.mp ⟨b⟩) + (iff_context.mpr this).get + end Schema.Proof /-! - ### Theory of schemata + ### Theory -/ def Schema.theory (𝓢 : Schema L) : Theory L := {σ | 𝓢 ⊢ ↑σ} diff --git a/Foundation/Logic/Calculus.lean b/Foundation/Logic/Calculus.lean index 31b219b14..160243b49 100644 --- a/Foundation/Logic/Calculus.lean +++ b/Foundation/Logic/Calculus.lean @@ -53,26 +53,93 @@ def rotate₃ (d : 𝔇 (φ₄ :: φ₁ :: φ₂ :: φ₃ :: Γ)) : 𝔇 (φ₁ alias cut := OneSidedLK.Cut.cut +open Entailment + +class EmptyEntailment (𝔇 : outParam (List F → Type*)) {E : Type*} [Entailment E F] (𝓔 : E) where + equiv {φ} : 𝓔 ⊢! φ ≃ 𝔇 [φ] + +namespace EmptyEntailment + +variable {E : Type*} [Entailment E F] (𝓔 : E) [EmptyEntailment 𝔇 𝓔] + +omit [LogicalConnective F] [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] in +lemma provable_iff : + 𝓔 ⊢ φ ↔ Nonempty (𝔇 [φ]) := by + simpa using OneSidedLK.EmptyEntailment.equiv.nonempty_congr + +variable [OneSidedLK.Cut 𝔇] + +instance : Entailment.ModusPonens 𝓔 where + mdp {φ ψ} b₁ b₂ := + let b₁ := equiv b₁ + let b₂ := equiv b₂ + have : 𝔇 [∼(φ ➝ ψ), ∼φ, ψ] := cast (tensor (𝔇 := 𝔇) (identity φ) (identity (∼ψ))) (by simp [DeMorgan.imply]) + have : 𝔇 [∼φ, ψ] := wk (cut b₁ this) (by simp) + have : 𝔇 [ψ] := wk (cut b₂ this) (by simp) + equiv.symm <| cast this + +instance : Entailment.Cl 𝓔 where + negEquiv {φ} := Entailment.cast + (show 𝓔 ⊢! (φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ) from + equiv.symm <| and (or <| rotate₁ <| or <| close φ) (or <| and (identity φ) verum')) + (by simp [Axioms.NegEquiv, DeMorgan.imply, LogicalConnective.iff]) + verum := equiv.symm <| verum + implyK {φ ψ} := + have : 𝓔 ⊢! ∼φ ⋎ ∼ψ ⋎ φ := equiv.symm <| or <| rotate₁ <| or <| close φ + Entailment.cast this (by simp [DeMorgan.imply]) + implyS {φ ψ χ} := + have : 𝓔 ⊢! φ ⋏ ψ ⋏ ∼χ ⋎ φ ⋏ ∼ψ ⋎ ∼φ ⋎ χ := + equiv.symm <| or <| rotate₁ <| or <| rotate₁ <| or <| rotate₃ <| and + (close φ) + (and (rotate₃ <| and (close φ) (close ψ)) (close χ)) + Entailment.cast this (by simp [DeMorgan.imply]) + and₁ {φ ψ} := + have : 𝓔 ⊢! (∼φ ⋎ ∼ψ) ⋎ φ := equiv.symm <|or <| or <| close φ + Entailment.cast this (by simp [DeMorgan.imply]) + and₂ {φ ψ} := + have : 𝓔 ⊢! (∼φ ⋎ ∼ψ) ⋎ ψ := equiv.symm <| or <| or <| close ψ + Entailment.cast this (by simp [DeMorgan.imply]) + and₃ {φ ψ} := + have : 𝓔 ⊢! ∼φ ⋎ ∼ψ ⋎ φ ⋏ ψ := equiv.symm <| or <| rotate₁ <| or <| rotate₁ <| and (close φ) (close ψ) + Entailment.cast this (by simp [DeMorgan.imply]) + or₁ {φ ψ} := + have : 𝓔 ⊢! ∼φ ⋎ φ ⋎ ψ := equiv.symm <| or <| rotate₁ <| or <| close φ + Entailment.cast this (by simp [DeMorgan.imply]) + or₂ {φ ψ} := + have : 𝓔 ⊢! ∼ψ ⋎ φ ⋎ ψ := equiv.symm <| or <| rotate₁ <| or <| close ψ + Entailment.cast this (by simp [DeMorgan.imply]) + or₃ {φ ψ χ} := + have : 𝓔 ⊢! φ ⋏ ∼χ ⋎ ψ ⋏ ∼ χ ⋎ ∼φ ⋏ ∼ψ ⋎ χ := + equiv.symm <| or <| rotate₁ <| or <| rotate₁ <| or <| and + (rotate₃ <| and (close φ) (close χ)) + (rotate₂ <| and (close ψ) (close χ)) + Entailment.cast this (by simp [DeMorgan.imply]) + dne {φ} := + have : 𝓔 ⊢! ∼φ ⋎ φ := equiv.symm <| or <| close φ + Entailment.cast this (by simp [DeMorgan.imply]) + +end EmptyEntailment + protected class Entailment (𝔇 : outParam (List F → Type*)) (S : Type*) [Entailment S F] [AdjunctiveSet F S] where equiv {𝓢 : S} {φ} : 𝓢 ⊢! φ ≃ (l : {l : List F // ∀ φ ∈ l, φ ∈ 𝓢}) × 𝔇 (φ :: ∼l) -open Entailment +namespace Entailment variable {S : Type*} [Entailment S F] [AdjunctiveSet F S] [OneSidedLK.Entailment 𝔇 S] omit [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] in lemma provable_iff {𝓢 : S} : 𝓢 ⊢ φ ↔ ∃ Γ : List F, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (𝔇 (φ :: ∼Γ)) := by - simpa using OneSidedLK.Entailment.equiv.nonempty_congr + simpa using equiv.nonempty_congr -def toProof (𝓢 : S) (d : 𝔇 [φ]) : 𝓢 ⊢! φ := OneSidedLK.Entailment.equiv.symm ⟨⟨[], by simp⟩, d⟩ +def toProof (𝓢 : S) (d : 𝔇 [φ]) : 𝓢 ⊢! φ := equiv.symm ⟨⟨[], by simp⟩, d⟩ def ofAxiom {𝓢 : S} (h : φ ∈ 𝓢) : 𝓢 ⊢! φ := - OneSidedLK.Entailment.equiv.symm ⟨⟨[φ], by simp_all⟩, identity φ⟩ + equiv.symm ⟨⟨[φ], by simp_all⟩, identity φ⟩ def ofAxiomSubset {𝓢 𝓤 : S} : 𝓢 ⊢! φ → 𝓢 ⊆ 𝓤 → 𝓤 ⊢! φ := fun b h ↦ - have ⟨l, d⟩ := OneSidedLK.Entailment.equiv b - OneSidedLK.Entailment.equiv.symm + have ⟨l, d⟩ := equiv b + equiv.symm ⟨⟨l, fun φ hφ ↦ AdjunctiveSet.subset_iff.mp h _ (l.prop φ hφ)⟩, d⟩ instance : Entailment.Axiomatized S where @@ -83,31 +150,31 @@ variable [OneSidedLK.Cut 𝔇] instance (𝓢 : S) : Entailment.ModusPonens 𝓢 where mdp {φ ψ} b₁ b₂ := - let ⟨Γ₁, b₁⟩ := OneSidedLK.Entailment.equiv b₁ - let ⟨Γ₂, b₂⟩ := OneSidedLK.Entailment.equiv b₂ + let ⟨Γ₁, b₁⟩ := equiv b₁ + let ⟨Γ₂, b₂⟩ := equiv b₂ have : 𝔇 [∼(φ ➝ ψ), ∼φ, ψ] := cast (tensor (𝔇 := 𝔇) (identity φ) (identity (∼ψ))) (by simp [DeMorgan.imply]) have : 𝔇 (∼φ :: ψ :: ∼↑Γ₁) := wk (cut b₁ this) (by simp) have : 𝔇 (ψ :: ∼↑Γ₁ ++ ∼↑Γ₂) := wk (cut b₂ this) (by simp) - OneSidedLK.Entailment.equiv.symm ⟨⟨Γ₁ ++ Γ₂, by simp; grind⟩, cast this⟩ + equiv.symm ⟨⟨Γ₁ ++ Γ₂, by simp; grind⟩, cast this⟩ instance : Entailment.StrongCut S S where cut {T U φ bs b} := let rec bl (l : List F) (hl : ∀ ψ ∈ l, ψ ∈ U) (χ) (d : 𝔇 (χ :: ∼l)) : T ⊢! χ := match l with - | [] => OneSidedLK.Entailment.equiv.symm ⟨⟨[], by simp⟩, d⟩ + | [] => equiv.symm ⟨⟨[], by simp⟩, d⟩ | ψ :: l => have bχ : T ⊢! ψ ➝ χ := Entailment.cast (bl l (by simp at hl; grind) (∼ψ ⋎ χ) (OneSidedLK.or <| OneSidedLK.rotate₁ d)) (by simp [DeMorgan.imply]) have bψ : T ⊢! ψ := bs (show ψ ∈ U by simp at hl; grind) Entailment.mdp bχ bψ - have ⟨l, hl⟩ := OneSidedLK.Entailment.equiv b + have ⟨l, hl⟩ := equiv b bl l l.prop φ hl instance : Entailment.DeductiveExplosion S where dexp b φ := - have ⟨Γ, b⟩ := OneSidedLK.Entailment.equiv b - OneSidedLK.Entailment.equiv.symm + have ⟨Γ, b⟩ := equiv b + equiv.symm ⟨ Γ, have : 𝔇 [∼⊥] := cast verum (by simp) wk (cut b this) (by simp) ⟩ @@ -164,6 +231,24 @@ instance (𝓢 : S) : Entailment.Cl 𝓢 where have : 𝓢 ⊢! ∼φ ⋎ φ := toProof _ <| or <| close φ Entailment.cast this (by simp [DeMorgan.imply]) +variable {E : Type*} [Entailment E F] + +omit [DeMorgan F] [OneSidedLK 𝔇] [Cut 𝔇] in +lemma empty_provable_iff_eprovable (𝓔 : E) [EmptyEntailment 𝔇 𝓔] : + (∅ : S) ⊢ φ ↔ 𝓔 ⊢ φ := by + constructor + · rintro ⟨d⟩ + let ⟨l, d⟩ := equiv d + have : 𝓔 ⊢! φ := EmptyEntailment.equiv.symm <| cast d <| by + have : ∀ φ, φ ∉ (l : List F) := by simpa using l.prop + simp [List.eq_nil_iff_forall_not_mem]; grind + exact ⟨this⟩ + · rintro ⟨b⟩ + have : 𝔇 [φ] := EmptyEntailment.equiv b + exact ⟨equiv.symm ⟨⟨[], by simp⟩, this⟩⟩ + +end Entailment + end OneSidedLK end LO From 67d1f60188f139481e294ccea73b66037c54b029 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 7 Mar 2026 19:22:19 +0900 Subject: [PATCH 09/61] fix --- Foundation/FirstOrder/Basic/Calculus.lean | 52 ++--- .../ClassicalSemantics/Tait.lean | 4 + Foundation/Propositional/Tait/Calculus.lean | 202 ++++++------------ 3 files changed, 98 insertions(+), 160 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index 1ea367254..e91769130 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -36,7 +36,7 @@ end Sequent /-- Derivation for one-sided $\mathbf{LK}$ -/ inductive Derivation : Sequent L → Type _ -| protected id (r : L.Rel k) (v) : Derivation [.rel r v, .nrel r v] +| identity (r : L.Rel k) (v) : Derivation [.rel r v, .nrel r v] | cut : Derivation (φ :: Γ) → Derivation (∼φ :: Δ) → Derivation (Γ ++ Δ) | wk : Derivation Δ → Δ ⊆ Γ → Derivation Γ | verum : Derivation [⊤] @@ -52,19 +52,19 @@ namespace Derivation open Rewriting LawfulSyntacticRewriting def height {Δ : Sequent L} : ⊢ᴷ Δ → ℕ - | .id _ _ => 0 - | cut dp dn => (max (height dp) (height dn)).succ - | wk d _ => d.height.succ - | verum => 0 - | or d => d.height.succ - | and dp dq => (max (height dp) (height dq)).succ - | all d => d.height.succ - | exs d => d.height.succ + | identity _ _ => 0 + | cut dp dn => max dp.height dn.height + 1 + | wk d _ => d.height + 1 + | verum => 0 + | or d => d.height + 1 + | and dp dq => max (height dp) (height dq) + 1 + | all d => d.height + 1 + | exs d => d.height + 1 section height @[simp] lemma height_id {k} {r : L.Rel k} {v} : - height (Derivation.id r v) = 0 := rfl + height (identity r v) = 0 := rfl @[simp] lemma height_cut {φ} (dp : ⊢ᴷ φ :: Δ) (dn : ⊢ᴷ (∼φ) :: Δ) : height (cut dp dn) = (max (height dp) (height dn)).succ := rfl @@ -93,43 +93,43 @@ def weakening (d : ⊢ᴷ Δ) (h : Δ ⊆ Γ := by simp) : ⊢ᴷ Γ := wk d h def top (h : ⊤ ∈ Δ := by simp) : ⊢ᴷ Δ := verum.wk (by simp [h]) -def id' (r : L.Rel k) (v) (hpos : Semiformula.rel r v ∈ Δ := by simp) (hneg : Semiformula.nrel r v ∈ Δ := by simp) : ⊢ᴷ Δ := - (Derivation.id r v).wk (by simp [hpos, hneg]) +def identity' (r : L.Rel k) (v) (hpos : Semiformula.rel r v ∈ Δ := by simp) (hneg : Semiformula.nrel r v ∈ Δ := by simp) : ⊢ᴷ Δ := + (identity r v).wk (by simp [hpos, hneg]) def tensor {φ ψ} (dφ : ⊢ᴷ φ :: Γ) (dψ : ⊢ᴷ ψ :: Δ) : ⊢ᴷ φ ⋏ ψ :: (Γ ++ Δ) := and dφ.weakening dψ.weakening def rotate (d : ⊢ᴷ φ :: Γ) : ⊢ᴷ Γ ++ [φ] := d.weakening -def identity : (φ : Proposition L) → ⊢ᴷ [φ, ∼φ] - | .rel R v | .nrel R v => id' R v +def eta : (φ : Proposition L) → ⊢ᴷ [φ, ∼φ] + | .rel R v | .nrel R v => identity' R v | ⊤ | ⊥ => top - | φ ⋏ ψ => ((identity φ).tensor (identity ψ)).rotate.or.rotate - | φ ⋎ ψ => ((identity φ).rotate.tensor (identity ψ).rotate).rotate.or + | φ ⋏ ψ => ((eta φ).tensor (eta ψ)).rotate.or.rotate + | φ ⋎ ψ => ((eta φ).rotate.tensor (eta ψ).rotate).rotate.or | ∀⁰ φ => - have : ⊢ᴷ [(∼φ.shift)/[&0], φ.free] := (identity φ.free).rotate.cast + have : ⊢ᴷ [(∼φ.shift)/[&0], φ.free] := (eta φ.free).rotate.cast have : ⊢ᴷ φ.free :: [∃⁰ ∼φ]⁺ := this.exs.rotate.cast this.all | ∃⁰ φ => - have : ⊢ᴷ [(φ.shift)/[&0], (∼φ).free] := (identity φ.free).cast + have : ⊢ᴷ [(φ.shift)/[&0], (∼φ).free] := (eta φ.free).cast have : ⊢ᴷ (∼φ).free :: [∃⁰ φ]⁺ := this.exs.rotate.cast this.all.rotate termination_by φ => φ.complexity def close (φ : Proposition L) (hp : φ ∈ Δ := by simp) (hn : ∼φ ∈ Δ := by simp) : ⊢ᴷ Δ := - identity φ |>.weakening (by simp [hp, hn]) + eta φ |>.weakening (by simp [hp, hn]) instance : OneSidedLK (Derivation (L := L)) where verum := verum and d₁ d₂ := d₁.and d₂ or d := d.or wk d ss := d.wk ss - identity φ := identity φ + identity φ := eta φ instance : OneSidedLK.Cut (Derivation (L := L)) where cut dp dn := cut dp dn def rewrite {Γ} (f : ℕ → SyntacticTerm L) : ⊢ᴷ Γ → ⊢ᴷ Γ.map (Rew.rewrite f ▹ ·) - | .id R v => Derivation.id R (Rew.rewrite f ∘ v) + | identity R v => identity R (Rew.rewrite f ∘ v) | cut (φ := φ) (Γ := Γ) (Δ := Δ) d₁ d₂ => have d₁ : ⊢ᴷ Rew.rewrite f ▹ φ :: Γ.map (app (Rew.rewrite f)) := (d₁.rewrite f).cast have d₂ : ⊢ᴷ ∼(Rew.rewrite f ▹ φ) :: Δ.map (app (Rew.rewrite f)) := (d₂.rewrite f).cast @@ -165,8 +165,8 @@ lemma shifts_image (Φ : L₁ →ᵥ L₂) {Δ : List (Proposition L₁)} : simp [Rewriting.shifts, Function.comp_def, Semiformula.lMap_shift] def lMap (Φ : L₁ →ᵥ L₂) {Γ} : ⊢ᴷ Γ → ⊢ᴷ Γ.map (.lMap Φ) - | .id r v => - .cast (Derivation.id (Φ.rel r) (fun i ↦ .lMap Φ (v i))) + | identity r v => + .cast (identity (Φ.rel r) (fun i ↦ .lMap Φ (v i))) (by simp [Semiformula.lMap_rel, Semiformula.lMap_nrel]) | cut (Γ := Γ) (Δ := Δ) (φ := φ) d dn => have : ⊢ᴷ (Γ.map (.lMap Φ) ++ Δ.map (.lMap Φ) : Sequent L₂) := @@ -327,8 +327,8 @@ def disj₂ {Γ Δ : Sequent L} : ⊢ᴷ Γ ++ Δ → ⊢ᴷ ⋁Γ :: Δ := fun have d₁ : ⊢ᴷ (φ ⋎ ψ) ⋎ Φ :: Δ := this.disj₂ have d₂ : ⊢ᴷ [(∼φ ⋏ ∼ψ) ⋏ ∼Φ, φ ⋎ ψ ⋎ Φ] := have : ⊢ᴷ [φ, ψ ⋎ Φ, (∼φ ⋏ ∼ψ) ⋏ ∼Φ] := - ((identity φ).rotate.tensor (identity ψ).rotate).tensor - (identity Φ).rotate |>.rotate.rotate.or.weakening + ((eta φ).rotate.tensor (eta ψ).rotate).tensor + (eta Φ).rotate |>.rotate.rotate.or.weakening this.or.rotate d₂.eCut d₁ termination_by _ => Γ.length @@ -370,7 +370,7 @@ lemma iff_context {𝓢 : Schema L} : 𝓢 ⊢ φ ↔ 𝓢 *⊢[𝐋𝐊¹] φ : have d : ⊢ᴷ [⋁(∼Γ) ⋎ φ] := d.cast (by simp [Semiformula.imp_eq]) have : ⊢ᴷ ⋀Γ ⋏ ∼φ :: φ :: ∼Γ := have : ⊢ᴷ ⋀Γ :: ∼Γ := Derivation.conj₂ fun φ h ↦ close φ (by simp) (by simp [h]) - this.tensor (identity φ).rotate |>.weakening + this.tensor (eta φ).rotate |>.weakening refine ⟨⟨Γ, h, (d.eCut this).cast⟩⟩ open Classical in diff --git a/Foundation/Propositional/ClassicalSemantics/Tait.lean b/Foundation/Propositional/ClassicalSemantics/Tait.lean index b17e49a1f..4bbbc7d3d 100644 --- a/Foundation/Propositional/ClassicalSemantics/Tait.lean +++ b/Foundation/Propositional/ClassicalSemantics/Tait.lean @@ -8,7 +8,9 @@ public import Foundation.Vorspiel.Set.Basic namespace LO.Propositional +/- +TODO: fix variable {α : Type*} {T : Theory α} {Γ : Sequent α} @@ -219,3 +221,5 @@ end Propositional end LO end + +-/ diff --git a/Foundation/Propositional/Tait/Calculus.lean b/Foundation/Propositional/Tait/Calculus.lean index f45985c97..eda8ba5fc 100644 --- a/Foundation/Propositional/Tait/Calculus.lean +++ b/Foundation/Propositional/Tait/Calculus.lean @@ -7,158 +7,92 @@ public import Foundation.Logic.Calculus namespace LO.Propositional -variable {α : Type*} - abbrev Sequent (α : Type*) := List (NNFormula α) -inductive Derivation (T : Theory α) : Sequent α → Type _ -| axL (Δ a) : Derivation T (NNFormula.atom a :: NNFormula.natom a :: Δ) -| verum (Δ) : Derivation T (⊤ :: Δ) -| or {Δ φ ψ} : Derivation T (φ :: ψ :: Δ) → Derivation T (φ ⋎ ψ :: Δ) -| and {Δ φ ψ} : Derivation T (φ :: Δ) → Derivation T (ψ :: Δ) → Derivation T (φ ⋏ ψ :: Δ) -| wk {Δ Γ} : Derivation T Δ → Δ ⊆ Γ → Derivation T Γ -| cut {Δ φ} : Derivation T (φ :: Δ) → Derivation T (∼φ :: Δ) → Derivation T Δ -| axm {φ} : φ ∈ T → Derivation T [φ] +inductive Derivation : Sequent α → Type _ +| identity (a : α) : Derivation [NNFormula.atom a, NNFormula.natom a] +| cut : Derivation (φ :: Γ) → Derivation (∼φ :: Δ) → Derivation (Γ ++ Δ) +| wk : Derivation Δ → Δ ⊆ Γ → Derivation Γ +| verum : Derivation [⊤] +| or : Derivation (φ :: ψ :: Γ) → Derivation (φ ⋎ ψ :: Γ) +| and : Derivation (φ :: Γ) → Derivation (ψ :: Γ) → Derivation (φ ⋏ ψ :: Γ) -instance : OneSided (Theory α) (NNFormula α) := ⟨Derivation⟩ +scoped prefix:45 "⊢ᴷ " => Derivation namespace Derivation variable {T U : Theory α} {Δ Δ₁ Δ₂ Γ : Sequent α} -def length {Δ : Sequent α} : T ⟹ Δ → ℕ - | axL _ _ => 0 - | verum _ => 0 - | or d => d.length.succ - | and dp dq => (max (length dp) (length dq)).succ - | wk d _ => d.length.succ - | cut dp dn => (max (length dp) (length dn)).succ - | axm _ => 0 +def height {Δ : Sequent α} : ⊢ᴷ Δ → ℕ + |identity _ => 0 + | cut dp dn => max dp.height dn.height + 1 + | wk d _ => d.height + 1 + | verum => 0 + | or d => d.height + 1 + | and dp dq => max (height dp) (height dq) + 1 -protected def cast (d : T ⟹ Δ) (e : Δ = Γ) : T ⟹ Γ := cast (by simp [e]) d +protected def cast (d : ⊢ᴷ Δ) (e : Δ = Γ) : ⊢ᴷ Γ := cast (by simp [e]) d -@[simp] lemma length_cast (d : T ⟹ Δ) (e : Δ = Γ) : length (Derivation.cast d e) = length d := by +@[simp] lemma height_cast (d : ⊢ᴷ Δ) (e : Δ = Γ) : height (Derivation.cast d e) = height d := by rcases e with rfl; simp [Derivation.cast] -def verum' (h : ⊤ ∈ Δ) : T ⟹ Δ := (verum Δ).wk (by simp [h]) - -def axL' (a : α) - (h : NNFormula.atom a ∈ Δ) (hn : NNFormula.natom a ∈ Δ) : T ⟹ Δ := (axL Δ a).wk (by simp [h, hn]) - -def em {φ : NNFormula α} {Δ : Sequent α} (hpos : φ ∈ Δ) (hneg : ∼φ ∈ Δ) : T ⟹ Δ := by - induction φ using NNFormula.rec' generalizing Δ <;> simp at hneg - case hverum => exact verum' hpos - case hfalsum => exact verum' hneg - case hatom a => exact axL' a hpos hneg - case hnatom a => exact axL' a hneg hpos - case hand φ ψ ihp ihq => - have ihp : T ⟹ φ :: ∼φ :: ∼ψ :: Δ := ihp (by simp) (by simp) - have ihq : T ⟹ ψ :: ∼φ :: ∼ψ :: Δ := ihq (by simp) (by simp) - have : T ⟹ ∼φ :: ∼ψ :: Δ := (ihp.and ihq).wk (by simp [hpos]) - exact this.or.wk (by simp [hneg]) - case hor φ ψ ihp ihq => - have ihp : T ⟹ ∼φ :: φ :: ψ :: Δ := ihp (by simp) (by simp) - have ihq : T ⟹ ∼ψ :: φ :: ψ :: Δ := ihq (by simp) (by simp) - have : T ⟹ φ :: ψ :: Δ := (ihp.and ihq).wk (by simp [hneg]) - exact this.or.wk (by simp [hpos]) - -instance : Tait (NNFormula α) (Theory α) where - verum := fun _ Δ => Derivation.verum Δ - and := fun dp dq => Derivation.cast (dp.and dq) (by simp) - or := fun d => Derivation.cast d.or (by simp) - wk := fun d ss => d.wk ss - em := fun hp hn => Derivation.em hp hn - -instance : Tait.Cut (NNFormula α) (Theory α) := ⟨Derivation.cut⟩ - -def trans (F : U ⊢!* T) {Γ : Sequent α} : T ⟹ Γ → U ⟹ Γ - | axL Γ φ => axL Γ φ - | verum Γ => verum Γ - | and d₁ d₂ => and (trans F d₁) (trans F d₂) - | or d => or (trans F d) - | wk d ss => wk (trans F d) ss - | cut d₁ d₂ => cut (trans F d₁) (trans F d₂) - | axm h => F h - -instance : Tait.Axiomatized (NNFormula α) (Theory α) where - axm {_ _ h} := axm h - trans {_ _ _ F d} := trans (fun h ↦ F _ h) d - -variable [DecidableEq α] - -def compact {Γ : Sequent α} : T ⟹ Γ → (s : { s : Finset (NNFormula α) // ↑s ⊆ T}) × (s : Theory α) ⟹ Γ - | axL Γ φ => ⟨⟨∅, by simp⟩, axL Γ φ⟩ - | verum Γ => ⟨⟨∅, by simp⟩, verum Γ⟩ - | and d₁ d₂ => - let ⟨s₁, d₁⟩ := compact d₁ - let ⟨s₂, d₂⟩ := compact d₂ - ⟨⟨(s₁ ∪ s₂ : Finset (NNFormula α)), by simp [s₁.prop, s₂.prop]⟩, - and (Tait.ofAxiomSubset (by simp) d₁) (Tait.ofAxiomSubset (by simp) d₂)⟩ - | or d => - let ⟨s, d⟩ := compact d - ⟨s, or d⟩ - | wk d ss => - let ⟨s, d⟩ := compact d - ⟨s, wk d ss⟩ - | cut d₁ d₂ => - let ⟨s₁, d₁⟩ := compact d₁ - let ⟨s₂, d₂⟩ := compact d₂ - ⟨⟨(s₁ ∪ s₂ : Finset (NNFormula α)), by simp [s₁.prop, s₂.prop]⟩, - cut (Tait.ofAxiomSubset (by simp) d₁) (Tait.ofAxiomSubset (by simp) d₂)⟩ - | axm (φ := φ) h => - ⟨⟨{φ}, by simp [h]⟩, axm (by simp)⟩ - -instance : Entailment.Compact (Theory α) where - Γ b := (compact b).1 - ΓPrf b := (compact b).2 - Γ_subset b := by simpa using (compact b).1.prop - Γ_finite b := by simp - -def deductionAux {Γ : Sequent α} {φ} : T ⟹ Γ → T \ {φ} ⟹ ∼φ :: Γ - | axL Γ φ => wk (axL Γ φ) (by simp) - | verum Γ => wk (verum Γ) (by simp) - | and d₁ d₂ => - Tait.rotate₁ <| and (Tait.rotate₁ <| deductionAux d₁) (Tait.rotate₁ <| deductionAux d₂) - | or d => Tait.rotate₁ <| Tait.or <| Tait.wk (deductionAux d) (by intro x; simp; tauto) - | wk d ss => wk (deductionAux d) <| List.cons_subset_cons (∼φ) ss - | cut d₁ d₂ => cut (Tait.rotate₁ <| deductionAux d₁) (Tait.rotate₁ <| deductionAux d₂) - | axm (φ := ψ) h => - if hq : φ = ψ then em (φ := φ) (by simp [hq]) (by simp) else - Tait.wk (show T \ {φ} ⟹ [ψ] from Tait.axm (by simp [h, Ne.symm hq])) (by simp) - -def deduction {Γ : Sequent α} {φ} (d : insert φ T ⟹ Γ) : T ⟹ ∼φ :: Γ := Tait.ofAxiomSubset (by simp) (deductionAux d) - -lemma inconsistent_iff_provable : - Entailment.Inconsistent (insert φ T) ↔ T ⊢ ∼φ := by - constructor - · intro h; exact ⟨deduction (Tait.inconsistent_iff_provable.mp h).get⟩ - · rintro b - exact Entailment.inconsistent_of_provable_of_unprovable (φ := φ) (Entailment.by_axm _ <| by simp) (Entailment.wk! (by simp) b) - -lemma consistent_iff_unprovable : - Entailment.Consistent (insert φ T) ↔ T ⊬ ∼φ := by simp [←Entailment.not_inconsistent_iff_consistent, inconsistent_iff_provable] - -omit [DecidableEq α] -@[simp] lemma inconsistent_theory_iff : - Entailment.Inconsistent (Entailment.theory T) ↔ Entailment.Inconsistent T := by - constructor - · intro h - exact Entailment.inconsistent_iff_provable_bot.mpr - <| Entailment.StrongCut.cut! (by simp) <| Entailment.inconsistent_iff_provable_bot.mp h - · intro h; exact h.of_supset (by simpa using Entailment.Axiomatized.axm_subset T) - -@[simp] lemma consistent_theory_iff : - Entailment.Consistent (Entailment.theory T) ↔ Entailment.Consistent T := by simp [←Entailment.not_inconsistent_iff_consistent, inconsistent_theory_iff] +def weakening (d : ⊢ᴷ Δ) (h : Δ ⊆ Γ := by simp) : ⊢ᴷ Γ := wk d h + +def top (h : ⊤ ∈ Δ := by simp) : ⊢ᴷ Δ := verum.wk (by simp [h]) + +def identity' (a : α) (hpos : .atom a ∈ Δ := by simp) (hneg : .natom a ∈ Δ := by simp) : ⊢ᴷ Δ := + (identity a).wk (by simp [hpos, hneg]) + +def tensor {φ ψ} (dφ : ⊢ᴷ φ :: Γ) (dψ : ⊢ᴷ ψ :: Δ) : ⊢ᴷ φ ⋏ ψ :: (Γ ++ Δ) := and dφ.weakening dψ.weakening + +def rotate (d : ⊢ᴷ φ :: Γ) : ⊢ᴷ Γ ++ [φ] := d.weakening + +def eta : (φ : NNFormula α) → ⊢ᴷ [φ, ∼φ] + | .atom a | .natom a => identity' a + | ⊤ | ⊥ => top + | φ ⋏ ψ => ((eta φ).tensor (eta ψ)).rotate.or.rotate + | φ ⋎ ψ => ((eta φ).rotate.tensor (eta ψ).rotate).rotate.or + +def close (φ : NNFormula α) (hp : φ ∈ Δ := by simp) (hn : ∼φ ∈ Δ := by simp) : ⊢ᴷ Δ := + eta φ |>.weakening (by simp [hp, hn]) + +instance : OneSidedLK (Derivation (α := α)) where + verum := verum + and d₁ d₂ := d₁.and d₂ + or d := d.or + wk d ss := d.wk ss + identity φ := eta φ + +instance : OneSidedLK.Cut (Derivation (α := α)) where + cut dp dn := cut dp dn end Derivation -abbrev Sequent.Tautology (Γ : Sequent α) := (∅ : Theory α) ⟹ Γ +/-! ## Classical proof system -/ -abbrev Sequent.IsTautology (Γ : Sequent α) := (∅ : Theory α) ⟹! Γ +inductive Proof.Symbol (α : Type*) : Type + | symbol -abbrev NNFormula.Tautology (φ : NNFormula α) := Sequent.Tautology [φ] +notation "𝐋𝐊⁰" => Proof.Symbol.symbol -abbrev NNFormula.IsTautology (φ : NNFormula α) := Sequent.IsTautology [φ] +abbrev Proof (φ : NNFormula α) := ⊢ᴷ [φ] + +instance : Entailment (Proof.Symbol α) (NNFormula α) where + Prf _ := Proof + +namespace Proof + +lemma def_eq (φ : NNFormula α) : (𝐋𝐊⁰ ⊢! φ) = (⊢ᴷ [φ]) := rfl + +instance : OneSidedLK.EmptyEntailment (Derivation (α := α)) (𝐋𝐊⁰ : Proof.Symbol α) where + equiv := Equiv.refl _ + +instance classical : Entailment.Cl (𝐋𝐊⁰ : Proof.Symbol α) := inferInstance + +end Proof + +abbrev NNFormula.IsTautology (φ : NNFormula α) : Prop := 𝐋𝐊⁰ ⊢ φ end LO.Propositional + end From ea7642c58bbf02505e3cfbca6cd6040c6d748d78 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sun, 15 Mar 2026 14:19:08 +0900 Subject: [PATCH 10/61] wip --- .../FirstOrder/Basic/Semantics/Semantics.lean | 421 ++++++++---------- Foundation/FirstOrder/Basic/Syntax/Rew.lean | 5 - .../FirstOrder/Basic/Syntax/Schema.lean | 18 +- Foundation/Logic/Calculus.lean | 55 ++- Foundation/Syntax/Predicate/Rew.lean | 55 +-- Foundation/Syntax/Predicate/Term.lean | 7 +- 6 files changed, 233 insertions(+), 328 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index a55fc1bd1..72095f407 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -1,6 +1,6 @@ module -public import Foundation.FirstOrder.Basic.Syntax.Theory +public import Foundation.FirstOrder.Basic.Syntax.Schema public import Foundation.Vorspiel.IsEmpty public import Foundation.Vorspiel.Empty @@ -35,7 +35,7 @@ namespace Structure instance [n : Nonempty M] : Nonempty (Structure L M) := by rcases n with ⟨x⟩ - exact ⟨{ func := fun _ _ _ => x, rel := fun _ _ _ => True }⟩ + exact ⟨{ func := fun _ _ _ ↦ x, rel := fun _ _ _ ↦ True }⟩ protected def lMap (φ : L₁ →ᵥ L₂) {M : Type w} (S : Structure L₂ M) : Structure L₁ M where func := fun _ f => S.func (φ.func f) @@ -48,8 +48,8 @@ variable (φ : L₁ →ᵥ L₂) {M : Type w} (s₂ : Structure L₂ M) @[simp] lemma lMap_rel {k} {r : L₁.Rel k} {v : Fin k → M} : (s₂.lMap φ).rel r v ↔ s₂.rel (φ.rel r) v := of_eq rfl def ofEquiv {M : Type w} [Structure L M] {N : Type w'} (Θ : M ≃ N) : Structure L N where - func := fun _ f v => Θ (func f (Θ.symm ∘ v)) - rel := fun _ r v => rel r (Θ.symm ∘ v) + func := fun _ f v ↦ Θ (func f (Θ.symm ∘ v)) + rel := fun _ r v ↦ rel r (Θ.symm ∘ v) protected abbrev Decidable (L : Language.{u}) (M : Type w) [s : Structure L M] := {k : ℕ} → (r : L.Rel k) → (v : Fin k → M) → Decidable (s.rel r v) @@ -75,88 +75,66 @@ variable {e : Fin n → M} {e₁ : Fin n₁ → M} {e₂ : Fin n₂ → M} {ε : ξ → M} {ε₁ : μ₁ → M} {ε₂ : μ₂ → M} -def val (s : Structure L M) (e : Fin n → M) (ε : ξ → M) : Semiterm L ξ n → M - | #x => e x - | &x => ε x - | func f v => s.func f (fun i => (v i).val s e ε) +def val [s : Structure L M] (e : Fin n → M) (ε : ξ → M) : Semiterm L ξ n → M + | #x => e x + | &x => ε x + | func f v => s.func f fun i ↦ (v i).val e ε -abbrev valb (s : Structure L M) (e : Fin n → M) (t : ClosedSemiterm L n) : M := t.val s e Empty.elim +abbrev valb (M : Type w) [s : Structure L M] (e : Fin n → M) (t : ClosedSemiterm L n) : M := t.val e Empty.elim -abbrev valm (M : Type w) [s : Structure L M] {n} (e : Fin n → M) (ε : ξ → M) : Semiterm L ξ n → M := val s e ε +abbrev valf [s : Structure L M] {n} (e : Fin n → M) : Semiterm L Empty n → M := val e Empty.elim -abbrev valbm (M : Type w) [s : Structure L M] {n} (e : Fin n → M) : ClosedSemiterm L n → M := valb s e +@[simp] lemma val_bvar (x) : val e ε (#x : Semiterm L ξ n) = e x := rfl -abbrev models (s : Structure L M) (t : Term L M) : M := t.val s ![] id +@[simp] lemma val_fvar (x) : val e ε (&x : Semiterm L ξ n) = ε x := rfl -@[simp] lemma val_bvar (x) : val s e ε (#x : Semiterm L ξ n) = e x := rfl +@[simp] lemma val_func {k} (f : L.Func k) (v) : + (func f v).val e ε = s.func f (Semiterm.val e ε ∘ v) := rfl -@[simp] lemma val_fvar (x) : val s e ε (&x : Semiterm L ξ n) = ε x := rfl - -lemma val_func {k} (f : L.Func k) (v) : - val s e ε (func f v) = s.func f (fun i ↦ (v i).val s e ε) := rfl - -@[simp] lemma val_func₀ (f : L.Func 0) (v) : - val s e ε (func f v) = s.func f ![] := by simp [val_func, Matrix.empty_eq] - -@[simp] lemma val_func₁ (f : L.Func 1) (t) : - val s e ε (func f ![t]) = s.func f ![t.val s e ε] := by - simp only [val_func] - congr; funext i; cases' i using Fin.cases with i <;> simp - -@[simp] lemma val_func₂ (f : L.Func 2) (t u) : - val s e ε (func f ![t, u]) = s.func f ![t.val s e ε, u.val s e ε] := by - simp only [val_func] - congr; funext i; cases' i using Fin.cases with i <;> simp +lemma val_func' {k} (f : L.Func k) (v) : + (func f v).val e ε = s.func f fun i ↦ Semiterm.val e ε (v i) := rfl lemma val_rew (ω : Rew L μ₁ n₁ μ₂ n₂) (t : Semiterm L μ₁ n₁) : - (ω t).val s e₂ ε₂ = t.val s (val s e₂ ε₂ ∘ ω ∘ bvar) (val s e₂ ε₂ ∘ ω ∘ fvar) := - by induction t <;> simp [*, Rew.func, val_func] + (ω t).val e₂ ε₂ = t.val (val e₂ ε₂ ∘ ω ∘ bvar) (val e₂ ε₂ ∘ ω ∘ fvar) := by + induction t <;> simp [*, -val_func, val_func'] lemma val_rewrite (f : μ₁ → Semiterm L μ₂ n) (t : Semiterm L μ₁ n) : - (Rew.rewrite f t).val s e ε₂ = t.val s e (fun x => (f x).val s e ε₂) := - by simp [val_rew]; congr + (Rew.rewrite f t).val e ε₂ = t.val e (val e ε₂ ∘ f) := by + simp [val_rew]; congr lemma val_rewriteMap (f : μ₁ → μ₂) (t : Semiterm L μ₁ n) : - (Rew.rewriteMap f t).val s e ε₂ = t.val s e (fun x => ε₂ (f x)) := - by simp [val_rew]; congr + (Rew.rewriteMap f t).val e ε₂ = t.val e (ε₂ ∘ f) := by + simp [val_rew]; congr lemma val_substs (w : Fin n₁ → Semiterm L ξ n₂) (t : Semiterm L ξ n₁) : - (Rew.subst w t).val s e₂ ε = t.val s (fun x => (w x).val s e₂ ε) ε := - by simp [val_rew]; congr + (Rew.subst w t).val e₂ ε = t.val (val e₂ ε ∘ w) ε := by + simp [val_rew]; congr @[simp] lemma val_bShift (a : M) (t : Semiterm L ξ n) : - (Rew.bShift t).val s (a :> e) ε = t.val s e ε := by simp [val_rew, Function.comp_def] + (Rew.bShift t).val (a :> e) ε = t.val e ε := by simp [val_rew, Function.comp_def] lemma val_bShift' (e : Fin (n + 1) → M) (t : Semiterm L ξ n) : - (Rew.bShift t).val s e ε = t.val s (e ·.succ) ε := by simp [val_rew, Function.comp_def] + (Rew.bShift t).val e ε = t.val (e ·.succ) ε := by simp [val_rew, Function.comp_def] @[simp] lemma val_emb {o : Type v'} [i : IsEmpty o] (t : Semiterm L o n) : - (Rew.emb t : Semiterm L ξ n).val s e ε = t.val s e i.elim := by + (Rew.emb t : Semiterm L ξ n).val e ε = t.val e i.elim := by simp only [val_rew]; congr; funext x; exact i.elim' x @[simp] lemma val_castLE (h : n₁ ≤ n₂) (t : Semiterm L ξ n₁) : - (Rew.castLE h t).val s e₂ ε = t.val s (fun x => e₂ (x.castLE h)) ε := by + (Rew.castLE h t).val e₂ ε = t.val (fun x ↦ e₂ (x.castLE h)) ε := by simp [val_rew]; congr lemma val_embSubsts (w : Fin k → Semiterm L ξ n) (t : Semiterm L Empty k) : - (Rew.embSubsts w t).val s e ε = t.valb s (fun x ↦ (w x).val s e ε) := by + (Rew.embSubsts w t).val e ε = t.valb M (val e ε ∘ w) := by simp [val_rew, Empty.eq_elim]; congr -@[simp] lemma val_toS {e : Fin n → M} (t : Semiterm L (Fin n) 0) : - valb s e (Rew.toS t) = val s ![] e t := by - simp [val_rew, Matrix.empty_eq]; congr - -@[simp] lemma val_toF {e : Fin n → M} (t : ClosedSemiterm L n) : - val s ![] e (Rew.toF t) = valb s e t := by - simp only [val_rew]; congr; funext i; contradiction - section Language variable (φ : L₁ →ᵥ L₂) (e : Fin n → M) (ε : ξ → M) lemma val_lMap (φ : L₁ →ᵥ L₂) (s₂ : Structure L₂ M) (e : Fin n → M) (ε : ξ → M) {t : Semiterm L₁ ξ n} : - (t.lMap φ).val s₂ e ε = t.val (s₂.lMap φ) e ε := - by induction t <;> simp [*, val_func, Semiterm.lMap_func] + (t.lMap φ).val (s := s₂) e ε = t.val (s := s₂.lMap φ) e ε := by + induction t <;> simp [*, val_func, Semiterm.lMap_func, Function.comp_def] end Language @@ -165,15 +143,15 @@ section Syntactic variable (ε : ℕ → M) lemma val_shift (t : SyntacticSemiterm L n) : - (Rew.shift t).val s e ε = t.val s e (ε ∘ Nat.succ) := by simp [val_rew]; congr + (Rew.shift t).val e ε = t.val e (ε ∘ Nat.succ) := by simp [val_rew]; congr lemma val_free (a : M) (t : SyntacticSemiterm L (n + 1)) : - (Rew.free t).val s e (a :>ₙ ε) = t.val s (e <: a) ε := by + (Rew.free t).val e (a :>ₙ ε) = t.val (e <: a) ε := by simp only [val_rew] congr; exact funext <| Fin.lastCases (by simp) (by simp) lemma val_fix (a : M) (t : SyntacticSemiterm L n) : - (Rew.fix t).val s (e <: a) ε = t.val s e (a :>ₙ ε) := by + (Rew.fix t).val (e <: a) ε = t.val e (a :>ₙ ε) := by simp only [val_rew]; congr · simp [Function.comp_def] · simpa [Function.comp_def] using funext (Nat.cases (by simp) (by simp)) @@ -181,15 +159,16 @@ lemma val_fix (a : M) (t : SyntacticSemiterm L n) : end Syntactic lemma val_eq_of_funEqOn [DecidableEq ξ] (t : Semiterm L ξ n) (h : Function.funEqOn t.FVar? ε ε') : - val s e ε t = val s e ε' t := by + t.val e ε = t.val e ε' := by induction t case bvar => simp - case fvar x => exact h x (by simp [FVar?]) + case fvar x => + exact h x (by simp [FVar?]) case func k f v ih => - simp only [val_func] + simp only [val_func, Function.comp_def] congr; funext i; exact ih i (by intro x hx; exact h x (by simpa using ⟨i, hx⟩)) -lemma val_toEmpty [DecidableEq ξ] (t : Semiterm L ξ n) (h : t.freeVariables = ∅) : val s e ε t = valb s e (t.toEmpty h) := by +lemma val_toEmpty [DecidableEq ξ] (t : Semiterm L ξ n) (h : t.freeVariables = ∅) : t.val e ε = (t.toEmpty h).valb M e := by induction t case bvar => simp [Semiterm.toEmpty] case fvar => simp at h @@ -212,7 +191,7 @@ lemma ofEquiv_func (f : L.Func k) (v : Fin k → N) : (ofEquiv Θ).func f v = Θ (func f (Θ.symm ∘ v)) := rfl lemma ofEquiv_val (e : Fin n → N) (ε : ξ → N) (t : Semiterm L ξ n) : - t.val (ofEquiv Θ) e ε = Θ (t.val s (Θ.symm ∘ e) (Θ.symm ∘ ε)) := by + t.val (s := ofEquiv Θ) e ε = Θ (t.val (Θ.symm ∘ e) (Θ.symm ∘ ε)) := by induction t <;> simp [*, Semiterm.val_func, ofEquiv_func Θ, Function.comp_def] end @@ -224,21 +203,22 @@ namespace Semiformula variable {M : Type w} {s : Structure L M} variable {n : ℕ} {e : Fin n → M} {e₂ : Fin n₂ → M} {ε : ξ → M} {ε₂ : μ₂ → M} -def EvalAux (s : Structure L M) (ε : ξ → M) : ∀ {n}, (Fin n → M) → Semiformula L ξ n → Prop - | _, _, ⊤ => True - | _, _, ⊥ => False - | _, e, rel φ v => s.rel φ (fun i => Semiterm.val s e ε (v i)) - | _, e, nrel φ v => ¬s.rel φ (fun i => Semiterm.val s e ε (v i)) - | _, e, φ ⋏ ψ => φ.EvalAux s ε e ∧ ψ.EvalAux s ε e - | _, e, φ ⋎ ψ => φ.EvalAux s ε e ∨ ψ.EvalAux s ε e - | _, e, ∀⁰ φ => ∀ x : M, (φ.EvalAux s ε (x :> e)) - | _, e, ∃⁰ φ => ∃ x : M, (φ.EvalAux s ε (x :> e)) +def EvalAux (s : Structure L M) (ε : ξ → M) {n} (e : Fin n → M) : Semiformula L ξ n → Prop + | rel φ v => s.rel φ (fun i ↦ Semiterm.val e ε (v i)) + | nrel φ v => ¬s.rel φ (fun i ↦ Semiterm.val e ε (v i)) + | ⊤ => True + | ⊥ => False + | φ ⋏ ψ => φ.EvalAux s ε e ∧ ψ.EvalAux s ε e + | φ ⋎ ψ => φ.EvalAux s ε e ∨ ψ.EvalAux s ε e + | ∀⁰ φ => ∀ x : M, (φ.EvalAux s ε (x :> e)) + | ∃⁰ φ => ∃ x : M, (φ.EvalAux s ε (x :> e)) @[simp] lemma EvalAux_neg (φ : Semiformula L ξ n) : EvalAux s ε e (∼φ) = ¬EvalAux s ε e φ := by induction φ using rec' <;> simp [*, EvalAux, or_iff_not_imp_left] -def Eval (s : Structure L M) (e : Fin n → M) (ε : ξ → M) : Semiformula L ξ n →ˡᶜ Prop where +/-- Evaluation of semiformula with variation of free-variables `ε` and bounded-variables `e` -/ +def Eval [s : Structure L M] (e : Fin n → M) (ε : ξ → M) : Semiformula L ξ n →ˡᶜ Prop where toTr := EvalAux s ε e map_top' := rfl map_bot' := rfl @@ -247,91 +227,64 @@ def Eval (s : Structure L M) (e : Fin n → M) (ε : ξ → M) : Semiformula L map_neg' := by simp [EvalAux_neg] map_imply' := by simp [EvalAux_neg, ←neg_eq, EvalAux, imp_iff_not_or] -abbrev Evalm (M : Type w) [s : Structure L M] {n} (e : Fin n → M) (ε : ξ → M) : - Semiformula L ξ n →ˡᶜ Prop := Eval s e ε +abbrev Evalf [s : Structure L M] (ε : ξ → M) : Formula L ξ →ˡᶜ Prop := Eval (s := s) ![] ε -abbrev Evalf (s : Structure L M) (ε : ξ → M) : Formula L ξ →ˡᶜ Prop := Eval s ![] ε +abbrev Evalb (M : Type w) [s : Structure L M] (e : Fin n → M) : + Semiformula L Empty n →ˡᶜ Prop := Eval e Empty.elim -abbrev Evalb (s : Structure L M) (e : Fin n → M) : Semisentence L n →ˡᶜ Prop := Eval s e Empty.elim +notation:max M:90 " ⊧/" e:max => Evalb M e -abbrev Evalfm (M : Type w) [s : Structure L M] (ε : ξ → M) : - Formula L ξ →ˡᶜ Prop := Evalf s ε +abbrev Models (s : Structure L M) : Formula L M →ˡᶜ Prop := Eval ![] id -abbrev Evalbm (M : Type w) [s : Structure L M] (e : Fin n → M) : - Semiformula L Empty n →ˡᶜ Prop := Evalb s e +lemma Eval.of_eq {e e' : Fin n → M} {ε ε' : ξ → M} + {φ : Semiformula L ξ n} (h : Eval e ε φ) (he : e = e') (hε : ε = ε') : Eval e' ε' φ := he ▸ hε ▸ h -notation:max M:90 " ⊧/" e:max => Evalbm M e +@[simp] lemma eval_rel {r : L.Rel k} {v} : + Eval e ε (rel r v) ↔ s.rel r (Semiterm.val e ε ∘ v) := of_eq rfl -abbrev Models (s : Structure L M) : Formula L M →ˡᶜ Prop := Eval s ![] id +lemma eval_rel' {r : L.Rel k} {v} : + Eval e ε (rel r v) ↔ s.rel r fun i ↦ (v i).val e ε := of_eq rfl -lemma eval_rel {k} {r : L.Rel k} {v} : - Eval s e ε (rel r v) ↔ s.rel r (fun i => Semiterm.val s e ε (v i)) := of_eq rfl +@[simp] lemma eval_nrel {r : L.Rel k} {v} : + Eval e ε (nrel r v) ↔ ¬s.rel r (Semiterm.val e ε ∘ v) := of_eq rfl -lemma Eval.of_eq {e e' : Fin n → M} {ε ε' : ξ → M} {φ} (h : Eval s e ε φ) (he : e = e') (hε : ε = ε') : Eval s e' ε' φ := he ▸ hε ▸ h - -@[simp] lemma eval_rel₀ {r : L.Rel 0} : - Eval s e ε (rel r ![]) ↔ s.rel r ![] := by simp [eval_rel, Matrix.empty_eq] - -@[simp] lemma eval_rel₁ {r : L.Rel 1} (t : Semiterm L ξ n) : - Eval s e ε (rel r ![t]) ↔ s.rel r ![t.val s e ε] := by - simp only [eval_rel]; apply of_eq; congr - funext i; cases' i using Fin.cases with i <;> simp - -@[simp] lemma eval_rel₂ {r : L.Rel 2} (t₁ t₂ : Semiterm L ξ n) : - Eval s e ε (rel r ![t₁, t₂]) ↔ s.rel r ![t₁.val s e ε, t₂.val s e ε] := by - simp only [eval_rel]; apply of_eq; congr - funext i; cases' i using Fin.cases with i <;> simp - -lemma eval_nrel {k} {r : L.Rel k} {v} : - Eval s e ε (nrel r v) ↔ ¬s.rel r (fun i => Semiterm.val s e ε (v i)) := of_eq rfl - -@[simp] lemma eval_nrel₀ {r : L.Rel 0} : - Eval s e ε (nrel r ![]) ↔ ¬s.rel r ![] := by simp [eval_nrel, Matrix.empty_eq] - -@[simp] lemma eval_nrel₁ {r : L.Rel 1} (t : Semiterm L ξ n) : - Eval s e ε (nrel r ![t]) ↔ ¬s.rel r ![t.val s e ε] := by - simp only [eval_nrel]; apply of_eq; congr - funext i; cases' i using Fin.cases with i <;> simp - -@[simp] lemma eval_nrel₂ {r : L.Rel 2} (t₁ t₂ : Semiterm L ξ n) : - Eval s e ε (nrel r ![t₁, t₂]) ↔ ¬s.rel r ![t₁.val s e ε, t₂.val s e ε] := by - simp only [eval_nrel]; apply of_eq; congr - funext i; cases' i using Fin.cases with i <;> simp +lemma eval_nrel' {r : L.Rel k} {v} : + Eval e ε (nrel r v) ↔ ¬s.rel r fun i ↦ (v i).val e ε := of_eq rfl @[simp] lemma eval_all {φ : Semiformula L ξ (n + 1)} : - Eval s e ε (∀⁰ φ) ↔ ∀ x : M, Eval s (x :> e) ε φ := of_eq rfl + Eval e ε (∀⁰ φ) ↔ ∀ x : M, Eval (x :> e) ε φ := of_eq rfl @[simp] lemma eval_ex {φ : Semiformula L ξ (n + 1)} : - Eval s e ε (∃⁰ φ) ↔ ∃ x : M, Eval s (x :> e) ε φ := of_eq rfl + Eval e ε (∃⁰ φ) ↔ ∃ x : M, Eval (x :> e) ε φ := of_eq rfl @[simp] lemma eval_ball {φ ψ : Semiformula L ξ (n + 1)} : - Eval s e ε (∀⁰[φ] ψ) ↔ ∀ x : M, Eval s (x :> e) ε φ → Eval s (x :> e) ε ψ := by + Eval e ε (∀⁰[φ] ψ) ↔ ∀ x : M, Eval (x :> e) ε φ → Eval (x :> e) ε ψ := by simp [ball] @[simp] lemma eval_bexs {φ ψ : Semiformula L ξ (n + 1)} : - Eval s e ε (∃⁰[φ] ψ) ↔ ∃ x : M, Eval s (x :> e) ε φ ⋏ Eval s (x :> e) ε ψ := by + Eval e ε (∃⁰[φ] ψ) ↔ ∃ x : M, Eval (x :> e) ε φ ⋏ Eval (x :> e) ε ψ := by simp [bexs] @[simp] lemma eval_allClosure {e} {φ : Semiformula L ξ k} : - Eval s e ε (∀⁰* φ) ↔ ∀ e', Eval s e' ε φ := + Eval e ε (∀⁰* φ) ↔ ∀ e', Eval e' ε φ := match k with | 0 => by simp [eq_finZeroElim] | k + 1 => by simpa [allClosure_succ, eval_allClosure (k := k), Matrix.forall_iff] using forall_comm @[simp] lemma eval_exsClosure {e} {φ : Semiformula L ξ k} : - Eval s e ε (∃⁰* φ) ↔ ∃ e', Eval s e' ε φ := + Eval e ε (∃⁰* φ) ↔ ∃ e', Eval e' ε φ := match k with | 0 => by simp [eq_finZeroElim] | k + 1 => by simpa [exsClosure_succ, eval_exsClosure (k := k), Matrix.exists_iff] using exists_comm @[simp] lemma eval_allItr {e} {φ : Semiformula L ξ (n + k)} : - Eval s e ε (∀⁰^[k] φ) ↔ ∀ e', Eval s (Matrix.appendr e' e) ε φ := + Eval e ε (∀⁰^[k] φ) ↔ ∀ e', Eval (Matrix.appendr e' e) ε φ := match k with | 0 => by simp [Matrix.empty_eq] | k + 1 => by simpa [allItr_succ, eval_allItr (k := k), Matrix.forall_iff] using forall_comm @[simp] lemma eval_exsItr {e} {φ : Semiformula L ξ (n + k)} : - Eval s e ε (∃⁰^[k] φ) ↔ ∃ e', Eval s (Matrix.appendr e' e) ε φ := + Eval e ε (∃⁰^[k] φ) ↔ ∃ e', Eval (Matrix.appendr e' e) ε φ := match k with | 0 => by simp [Matrix.empty_eq] | k + 1 => by simpa [exsItr_succ, eval_exsItr (k := k), Matrix.exists_iff] using exists_comm @@ -341,72 +294,70 @@ section rew variable {ε : ξ → M} {ε₂ : ξ₂ → M} lemma eval_rew {n₁ n₂ e₂ ε₂} (ω : Rew L ξ₁ n₁ ξ₂ n₂) (φ : Semiformula L ξ₁ n₁) : - Eval s e₂ ε₂ (ω ▹ φ) ↔ Eval s (Semiterm.val s e₂ ε₂ ∘ ω ∘ Semiterm.bvar) (Semiterm.val s e₂ ε₂ ∘ ω ∘ Semiterm.fvar) φ := by + Eval e₂ ε₂ (ω ▹ φ) ↔ Eval (Semiterm.val (s := s) e₂ ε₂ ∘ ω ∘ Semiterm.bvar) (Semiterm.val (s := s) e₂ ε₂ ∘ ω ∘ Semiterm.fvar) φ := by match φ with - | .rel r v => simp [Semiterm.val_rew, eval_rel, rew_rel] - | .nrel r v => simp [Semiterm.val_rew, eval_nrel, rew_nrel] - | ⊤ => simp - | ⊥ => simp - | φ ⋏ ψ => simp [eval_rew ω φ, eval_rew ω ψ] - | φ ⋎ ψ => simp [eval_rew ω φ, eval_rew ω ψ] - | ∀⁰ φ => - simpa [Function.comp_def, eval_rew ω.q φ] using iff_of_eq <| forall_congr fun x ↦ by congr; funext i; cases i using Fin.cases <;> simp - | ∃⁰ φ => - simpa [Function.comp_def, eval_rew ω.q φ] using exists_congr fun x ↦ iff_of_eq $ by congr; funext i; cases i using Fin.cases <;> simp + | .rel r v | .nrel r v => + simp only [rew_rel_eq_comp, eval_rel, eval_nrel]; apply iff_of_eq + congr; funext i + simp [Semiterm.val_rew] + | ⊤ | ⊥ => simp + | φ ⋏ ψ | φ ⋎ ψ => simp [eval_rew ω φ, eval_rew ω ψ] + | ∀⁰ φ => + simpa [Function.comp_def, eval_rew ω.q φ] using + iff_of_eq <| forall_congr fun x ↦ by congr; funext i; cases i using Fin.cases <;> simp + | ∃⁰ φ => + simpa [Function.comp_def, eval_rew ω.q φ] using + exists_congr fun x ↦ iff_of_eq $ by congr; funext i; cases i using Fin.cases <;> simp lemma eval_rew_q {ε₂ : ξ₂ → M} (ω : Rew L ξ₁ n₁ ξ₂ n₂) (φ : Semiformula L ξ₁ (n₁ + 1)) : - Eval s (x :> e₂) ε₂ (ω.q ▹ φ) ↔ - Eval s - (x :> Semiterm.val s e₂ ε₂ ∘ ω ∘ Semiterm.bvar) - (Semiterm.val s e₂ ε₂ ∘ ω ∘ Semiterm.fvar) φ := by + Eval (x :> e₂) ε₂ (ω.q ▹ φ) ↔ + Eval + (x :> Semiterm.val e₂ ε₂ ∘ ω ∘ Semiterm.bvar) + (Semiterm.val e₂ ε₂ ∘ ω ∘ Semiterm.fvar) φ := by simp only [Nat.succ_eq_add_one, eval_rew, Function.comp_def, Rew.q_fvar, Semiterm.val_bShift] apply iff_of_eq; congr 2 · funext x cases x using Fin.cases <;> simp lemma eval_map (b : Fin n₁ → Fin n₂) (f : ξ₁ → ξ₂) (e : Fin n₂ → M) (ε : ξ₂ → M) (φ : Semiformula L ξ₁ n₁) : - Eval s e ε ((Rew.map (L := L) b f) ▹ φ) ↔ Eval s (e ∘ b) (ε ∘ f) φ := by + Eval e ε ((Rew.map (L := L) b f) ▹ φ) ↔ Eval (e ∘ b) (ε ∘ f) φ := by simp [eval_rew, Function.comp_def] lemma eval_rewrite (f : ξ₁ → Semiterm L ξ₂ n) (φ : Semiformula L ξ₁ n) : - Eval s e ε₂ (Rew.rewrite f ▹ φ) ↔ Eval s e (fun x ↦ (f x).val s e ε₂) φ := by + Eval e ε₂ (Rew.rewrite f ▹ φ) ↔ Eval e (fun x ↦ (f x).val e ε₂) φ := by simp [eval_rew, Function.comp_def] lemma eval_rewriteMap (f : ξ₁ → ξ₂) (φ : Semiformula L ξ₁ n) : - Eval s e ε₂ (Rew.rewriteMap (L := L) (n := n) f ▹ φ) ↔ Eval s e (fun x ↦ ε₂ (f x)) φ := by + Eval e ε₂ (Rew.rewriteMap (L := L) (n := n) f ▹ φ) ↔ Eval e (fun x ↦ ε₂ (f x)) φ := by simp [eval_rew, Function.comp_def] @[simp] lemma eval_castLE (h : n₁ ≤ n₂) (φ : Semiformula L ξ n₁) : - Eval s e₂ ε (@Rew.castLE L ξ _ _ h ▹ φ) ↔ Eval s (fun x ↦ e₂ (x.castLE h)) ε φ := by + Eval e₂ ε (@Rew.castLE L ξ _ _ h ▹ φ) ↔ Eval (fun x ↦ e₂ (x.castLE h)) ε φ := by simp [eval_rew, Function.comp_def] @[simp] lemma eval_bShift (φ : Semiformula L ξ n) : - Eval s (x :> e) ε (@Rew.bShift L ξ n ▹ φ) ↔ Eval s e ε φ := by + Eval (x :> e) ε (@Rew.bShift L ξ n ▹ φ) ↔ Eval e ε φ := by simp [eval_rew, Function.comp_def] lemma eval_bShift' (φ : Semiformula L ξ n) : - Eval s e' ε (@Rew.bShift L ξ n ▹ φ) ↔ Eval s (e' ·.succ) ε φ := by + Eval e' ε (@Rew.bShift L ξ n ▹ φ) ↔ Eval (e' ·.succ) ε φ := by simp [eval_rew, Function.comp_def] @[simp] lemma eval_substs {k} (w : Fin k → Semiterm L ξ n) (φ : Semiformula L ξ k) : - Eval s e ε (φ ⇜ w) ↔ Eval s (fun i ↦ (w i).val s e ε) ε φ := by + Eval e ε (φ ⇜ w) ↔ Eval (fun i ↦ (w i).val e ε) ε φ := by simp [eval_rew, Function.comp_def] @[simp] lemma eval_emb {ε : ξ → M} (φ : Semiformula L Empty n) : - Eval s e ε (Rewriting.emb (ξ := ξ) φ : Semiformula L ξ n) ↔ Eval s e Empty.elim φ := by + Eval e ε (Rewriting.emb (ξ := ξ) φ : Semiformula L ξ n) ↔ Eval e Empty.elim φ := by simp [eval_rew, Function.comp_def, Empty.eq_elim] @[simp] lemma eval_empty [h : IsEmpty o] (φ : Formula L o) : - Eval s e ε (@Rew.empty L o _ ξ n ▹ φ) ↔ Eval s ![] h.elim φ := by + Eval e ε (@Rew.empty L o _ ξ n ▹ φ) ↔ Eval (s := s) ![] h.elim φ := by simp [eval_rew, Function.comp_def, Matrix.empty_eq] simp [IsEmpty.eq_elim] -@[simp] lemma eval_toS {e : Fin n → M} {ε} (φ : Formula L (Fin n)) : - Eval s e ε (@Rew.toS L n ▹ φ) ↔ Eval s ![] e φ := by - simp [Rew.toS, eval_rew, Function.comp_def, Matrix.empty_eq] - @[simp] lemma eval_embSubsts {ξ} {ε : ξ → M} {k} (w : Fin k → Semiterm L ξ n) (σ : Semisentence L k) : - Eval s e ε ((@Rew.embSubsts L ξ n k w) ▹ σ) ↔ Evalb s (fun x ↦ (w x).val s e ε) σ := by + Eval e ε ((@Rew.embSubsts L ξ n k w) ▹ σ) ↔ σ.Evalb M (fun x ↦ (w x).val e ε) := by simp [eval_rew, Function.comp_def, Empty.eq_elim] section Syntactic @@ -414,77 +365,71 @@ section Syntactic variable (ε : ℕ → M) @[simp] lemma eval_free (φ : Semiproposition L (n + 1)) : - Eval s e (a :>ₙ ε) (@Rew.free L n ▹ φ) ↔ Eval s (e <: a) ε φ := by + Eval e (a :>ₙ ε) (@Rew.free L n ▹ φ) ↔ Eval (e <: a) ε φ := by simp only [eval_rew, Function.comp_def, Rew.free_fvar, Semiterm.val_fvar, Nat.cases_succ, Nat.succ_eq_add_one] apply iff_of_eq; congr; funext x; cases x using Fin.lastCases <;> simp @[simp] lemma eval_shift (φ : Semiproposition L n) : - Eval s e (a :>ₙ ε) (@Rew.shift L n ▹ φ) ↔ Eval s e ε φ := by + Eval e (a :>ₙ ε) (@Rew.shift L n ▹ φ) ↔ Eval e ε φ := by simp [eval_rew, Function.comp_def] end Syntactic lemma eval_iff_of_funEqOn [DecidableEq ξ] {n e} (φ : Semiformula L ξ n) (h : Function.funEqOn φ.FVar? ε ε') : - Eval s e ε φ ↔ Eval s e ε' φ := by + Eval e ε φ ↔ Eval e ε' φ := by match φ with | .rel r v => - simp only [eval_rel]; apply iff_of_eq; congr + simp only [eval_rel]; apply iff_of_eq; congr 1 funext i exact Semiterm.val_eq_of_funEqOn (v i) (fun x hx ↦ h x (fvar?_rel.mpr ⟨i, hx⟩)) | .nrel r v => - simp only [eval_nrel]; apply iff_of_eq; congr + simp only [eval_nrel]; apply iff_of_eq; congr 2 funext i exact Semiterm.val_eq_of_funEqOn (v i) (fun x hx ↦ h x (fvar?_nrel.mpr ⟨i, hx⟩)) - | ⊤ => simp - | ⊥ => simp + | ⊤ | ⊥ => simp | φ ⋏ ψ => - suffices Eval s e ε φ ∧ Eval s e ε ψ ↔ Eval s e ε' φ ∧ Eval s e ε' ψ by simpa + suffices Eval e ε φ ∧ Eval e ε ψ ↔ Eval e ε' φ ∧ Eval e ε' ψ by simpa apply and_congr · exact eval_iff_of_funEqOn φ fun x hx ↦ h x (by simp [hx]) · exact eval_iff_of_funEqOn ψ fun x hx ↦ h x (by simp [hx]) | φ ⋎ ψ => - suffices Eval s e ε φ ∨ Eval s e ε ψ ↔ Eval s e ε' φ ∨ Eval s e ε' ψ by simpa + suffices Eval e ε φ ∨ Eval e ε ψ ↔ Eval e ε' φ ∨ Eval e ε' ψ by simpa apply or_congr · exact eval_iff_of_funEqOn φ fun x hx ↦ h x (by simp [hx]) · exact eval_iff_of_funEqOn ψ fun x hx ↦ h x (by simp [hx]) | ∀⁰ φ => - suffices (∀ x, Eval s (x :> e) ε φ) ↔ (∀ x, Eval s (x :> e) ε' φ) by simpa + suffices (∀ x, Eval (x :> e) ε φ) ↔ (∀ x, Eval (x :> e) ε' φ) by simpa apply forall_congr'; intro x exact eval_iff_of_funEqOn φ fun x hx ↦ h _ (by simpa [FVar?]) | ∃⁰ φ => - suffices (∃ x, Eval s (x :> e) ε φ) ↔ (∃ x, Eval s (x :> e) ε' φ) by simpa + suffices (∃ x, Eval (x :> e) ε φ) ↔ (∃ x, Eval (x :> e) ε' φ) by simpa apply exists_congr; intro x exact eval_iff_of_funEqOn φ fun x hx ↦ h _ (by simpa [FVar?]) -lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeVariables = ∅) {e} : Eval s e f φ ↔ Evalb s e (φ.toEmpty hp) := by +lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeVariables = ∅) {e} : Eval e f φ ↔ Evalb M e (φ.toEmpty hp) := by match φ with | .rel r v => - simp only [eval_rel, toEmpty] - apply iff_of_eq; congr; funext i - rw [Semiterm.val_toEmpty] + simp only [eval_rel] + apply iff_of_eq; congr 2; funext i + simpa [Semiterm.val_toEmpty] using Semiterm.val_toEmpty _ ?_ | .nrel r v => - simp only [toEmpty] apply iff_of_eq; congr; funext i rw [Semiterm.val_toEmpty] - | ⊤ => simp - | ⊥ => simp - | φ ⋏ ψ => - simp [eval_toEmpty (φ := φ) (by simp [by simpa [Finset.union_eq_empty] using hp]), - eval_toEmpty (φ := ψ) (by simp [by simpa [Finset.union_eq_empty] using hp])] - | φ ⋎ ψ => + | ⊤ | ⊥ => simp + | φ ⋏ ψ | φ ⋎ ψ => simp [eval_toEmpty (φ := φ) (by simp [by simpa [Finset.union_eq_empty] using hp]), eval_toEmpty (φ := ψ) (by simp [by simpa [Finset.union_eq_empty] using hp])] - | ∀⁰ φ => - have : ∀ x, Eval s (x :> e) f φ ↔ Evalb s (x :> e) (φ.toEmpty hp) := + | ∀⁰ φ => + have : ∀ x, Eval (x :> e) f φ ↔ Evalb M (x :> e) (φ.toEmpty hp) := fun x ↦ eval_toEmpty (φ := φ) (e := (x :> e)) (by simpa using hp) simp [this] - | ∃⁰ φ => - have : ∀ x, Eval s (x :> e) f φ ↔ Evalb s (x :> e) (φ.toEmpty hp) := + | ∃⁰ φ => + have : ∀ x, Eval (x :> e) f φ ↔ Evalb M (x :> e) (φ.toEmpty hp) := fun x ↦ eval_toEmpty (φ := φ) (e := (x :> e)) (by simpa using hp) simp [this] -@[simp] lemma eval_univCl' {ε} (φ : Proposition L) : - Evalf s ε φ.univCl' ↔ ∀ f, Evalf s f φ := by +@[simp] lemma eval_univCl' {ε : ℕ → M} (φ : Proposition L) : + Evalf ε φ.univCl' ↔ ∀ f : ℕ → M, Evalf f φ := by simp only [univCl', eval_allClosure, eval_rew, Matrix.empty_eq, Function.comp_def] constructor · intro h f @@ -495,12 +440,12 @@ lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeV intro x hx; simp [Rew.fixitr_fvar, lt_fvSup_of_fvar? hx] @[simp] lemma eval_univCl [Nonempty M] (φ : Proposition L) : - Evalb s ![] φ.univCl ↔ ∀ f, Evalf s f φ := by + Evalb M ![] φ.univCl ↔ ∀ f : ℕ → M, Evalf f φ := by haveI : Inhabited M := Classical.inhabited_of_nonempty inferInstance simp [Semiformula.univCl, ←eval_toEmpty (f := default)] @[simp] lemma eval_enumarateFVar_idxOfFVar_eq_id [DecidableEq M] [Inhabited M] (φ : Semiformula L M n) (v) : - Semiformula.Evalm M v (fun x ↦ φ.enumarateFVar (φ.idxOfFVar x)) φ ↔ Semiformula.Evalm M v id φ := + Semiformula.Eval v (fun x ↦ φ.enumarateFVar (φ.idxOfFVar x)) φ ↔ Semiformula.Eval v id φ := Semiformula.eval_iff_of_funEqOn _ <| by intro x hx; simp [Semiformula.enumarateFVar_idxOfFVar (Semiformula.mem_fvarList_iff_fvar?.mpr hx)] @@ -519,30 +464,27 @@ lemma ofEquiv_rel (r : L.Rel k) (v : Fin k → N) : (Structure.ofEquiv Θ).rel r v ↔ Structure.rel r (Θ.symm ∘ v) := iff_of_eq rfl lemma eval_ofEquiv_iff {e : Fin n → N} {ε : ξ → N} {φ : Semiformula L ξ n} : - Eval (ofEquiv Θ) e ε φ ↔ Eval s (Θ.symm ∘ e) (Θ.symm ∘ ε) φ := + Eval (s := ofEquiv Θ) e ε φ ↔ Eval (Θ.symm ∘ e) (Θ.symm ∘ ε) φ := match φ with - | ⊤ => by simp - | ⊥ => by simp - | .rel r v => by simp [Function.comp_def, eval_rel, ofEquiv_rel Θ, Structure.ofEquiv_val Θ] - | .nrel r v => by simp [Function.comp_def, eval_nrel, ofEquiv_rel Θ, Structure.ofEquiv_val Θ] - | φ ⋏ ψ => by simp [eval_ofEquiv_iff (φ := φ), eval_ofEquiv_iff (φ := ψ)] - | φ ⋎ ψ => by simp [eval_ofEquiv_iff (φ := φ), eval_ofEquiv_iff (φ := ψ)] - | ∀⁰ φ => + | .rel r v | .nrel r v => by simp [Function.comp_def, ofEquiv_rel Θ, Structure.ofEquiv_val Θ] + | ⊤ | ⊥ => by simp + | φ ⋏ ψ | φ ⋎ ψ => by simp [eval_ofEquiv_iff (φ := φ), eval_ofEquiv_iff (φ := ψ)] + | ∀⁰ φ => ⟨fun h x ↦ by simpa [Matrix.comp_vecCons''] using eval_ofEquiv_iff.mp (h (Θ x)), fun h x ↦ eval_ofEquiv_iff.mpr (by simpa [Matrix.comp_vecCons''] using h (Θ.symm x))⟩ - | ∃⁰ φ => + | ∃⁰ φ => ⟨by rintro ⟨x, h⟩; exists Θ.symm x; simpa [Matrix.comp_vecCons''] using eval_ofEquiv_iff.mp h, by rintro ⟨x, h⟩; exists Θ x; apply eval_ofEquiv_iff.mpr; simpa [Matrix.comp_vecCons''] using h⟩ lemma evalf_ofEquiv_iff {ε : ξ → N} {φ : Formula L ξ} : - Evalf (ofEquiv Θ) ε φ ↔ Evalf s (Θ.symm ∘ ε) φ := by simpa using eval_ofEquiv_iff (Θ := Θ) (ε := ε) (φ := φ) (e := ![]) + Evalf (s := ofEquiv Θ) ε φ ↔ Evalf (s := s) (Θ.symm ∘ ε) φ := by simpa using eval_ofEquiv_iff (Θ := Θ) (ε := ε) (φ := φ) (e := ![]) end end Structure instance : Semantics (Struc L) (Sentence L) where - Models := fun str ↦ Semiformula.Evalb str.struc ![] + Models := fun str ↦ Semiformula.Evalb str.Dom ![] instance : Semantics.Tarski (Struc L) where models_verum := by simp [Semantics.Models] @@ -556,62 +498,63 @@ section variable (M : Type*) [Nonempty M] [s : Structure L M] {T U : Theory L} -abbrev Models : Sentence L → Prop := Semantics.Models s.toStruc - -/-- Models a sentence -/ -infix:45 " ⊧ₘ " => Models +/-- Standard structure inferred from a given domain -/ +abbrev Language.str (M : Type*) [Nonempty M] (L : Language) [s : Structure L M] : Struc L := s.toStruc -abbrev ModelsTheory (T : Theory L) : Prop := Semantics.ModelsSet s.toStruc T - -/-- Models a set of sentences -/ -infix:45 " ⊧ₘ* " => ModelsTheory +notation: max M "↓[" L "]" => Language.str M L abbrev Consequence (T : Theory L) (σ : Sentence L) : Prop := T ⊨[SmallStruc L] σ /-- Semantic entailment, also known as logical consequence. -/ -infix:45 " ⊨ " => Consequence +scoped infix:45 " ⊨ " => Consequence abbrev Satisfiable (T : Theory L) : Prop := Semantics.Satisfiable (SmallStruc L) T variable {M} -def modelsTheory_iff_modelsTheory_s : M ⊧ₘ* T ↔ s.toStruc ⊧* T := by rfl +lemma models_iff : M↓[L] ⊧ σ ↔ M ⊧/![] σ := by rfl + +lemma models_iff_proposition {φ : Proposition L} : M↓[L] ⊧ φ.univCl ↔ ∀ f : ℕ → M, φ.Evalf f := by + simp [models_iff] + +lemma models_theory_iff : M↓[L] ⊧* T ↔ (∀ {φ}, φ ∈ T → M↓[L] ⊧ φ) := Semantics.modelsSet_iff -lemma models_iff : M ⊧ₘ σ ↔ Semiformula.Evalbm (s := s) M ![] σ := by rfl +lemma models_schema_iff {𝓢 : Schema L} : M↓[L] ⊧* 𝓢 ↔ (∀ {φ : Proposition L}, φ ∈ 𝓢 → ∀ f : ℕ → M, φ.Evalf f) := by + simp [models_theory_iff, models_iff] -lemma modelsTheory_iff : M ⊧ₘ* T ↔ (∀ {φ}, φ ∈ T → M ⊧ₘ φ) := Semantics.modelsSet_iff +lemma models_of_mem {T : Theory L} [M↓[L] ⊧* T] {φ} (h : φ ∈ T) : M↓[L] ⊧ φ := Semantics.ModelsSet.models _ h variable (M T) -lemma Theory.models [M ⊧ₘ* T] {σ} (hσ : σ ∈ T) : M ⊧ₘ σ := Semantics.modelsSet_iff.mp inferInstance hσ +lemma Theory.models [M↓[L] ⊧* T] {σ} (hσ : σ ∈ T) : M↓[L] ⊧ σ := Semantics.modelsSet_iff.mp inferInstance hσ variable {M T} lemma models_iff_models {φ} : - M ⊧ₘ φ ↔ s.toStruc ⊧ φ := of_eq rfl + M↓[L] ⊧ φ ↔ s.toStruc ⊧ φ := of_eq rfl lemma consequence_iff {φ} : - T ⊨[Struc.{v, u} L] φ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M], M ⊧ₘ* T → M ⊧ₘ φ) := + T ⊨[Struc.{v, u} L] φ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M], M↓[L] ⊧* T → M↓[L] ⊧ φ) := ⟨fun h _ _ _ hT ↦ h hT, fun h s hT ↦ h s.Dom hT⟩ lemma consequence_iff' {φ} : - T ⊨[Struc.{v, u} L] φ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [M ⊧ₘ* T], M ⊧ₘ φ) := - ⟨fun h _ _ s _ => Semantics.consequence_iff'.mp h s.toStruc, - fun h s hs => @h s.Dom s.nonempty s.struc hs⟩ + T ⊨[Struc.{v, u} L] φ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [M↓[L] ⊧* T], M↓[L] ⊧ φ) := + ⟨fun h _ _ s _ ↦ Semantics.consequence_iff'.mp h s.toStruc, + fun h s hs ↦ @h s.Dom s.nonempty s.struc hs⟩ lemma valid_iff {φ} : - Semantics.Valid (Struc.{v, u} L) φ ↔ ∀ (M : Type v) [Nonempty M] [Structure L M], M ⊧ₘ φ := + Semantics.Valid (Struc.{v, u} L) φ ↔ ∀ (M : Type v) [Nonempty M] [Structure L M], M↓[L] ⊧ φ := ⟨fun hσ _ _ s ↦ @hσ s.toStruc, fun h s ↦ h s.Dom⟩ lemma satisfiable_iff : - Semantics.Satisfiable (Struc.{v, u} L) T ↔ ∃ (M : Type v) (_ : Nonempty M) (_ : Structure L M), M ⊧ₘ* T := + Semantics.Satisfiable (Struc.{v, u} L) T ↔ ∃ (M : Type v) (_ : Nonempty M) (_ : Structure L M), M↓[L] ⊧* T := ⟨by rintro ⟨s, hs⟩; exact ⟨s.Dom, s.nonempty, s.struc, hs⟩, by rintro ⟨M, i, s, hT⟩; exact ⟨s.toStruc, hT⟩⟩ lemma unsatisfiable_iff : - ¬Semantics.Satisfiable (Struc.{v, u} L) T ↔ ∀ (M : Type v) (_ : Nonempty M) (_ : Structure L M), ¬M ⊧ₘ* T := by + ¬Semantics.Satisfiable (Struc.{v, u} L) T ↔ ∀ (M : Type v) (_ : Nonempty M) (_ : Structure L M), ¬M↓[L] ⊧* T := by simpa using satisfiable_iff.not -lemma satisfiable_intro (M : Type v) [Nonempty M] [s : Structure L M] (h : M ⊧ₘ* T) : +lemma satisfiable_intro (M : Type v) [Nonempty M] [s : Structure L M] (h : M↓[L] ⊧* T) : Semantics.Satisfiable (Struc.{v, u} L) T := ⟨s.toStruc, h⟩ noncomputable def ModelOfSat (h : Semantics.Satisfiable (Struc.{v, u} L) T) : Type v := @@ -622,14 +565,14 @@ noncomputable instance nonemptyModelOfSat (h : Semantics.Satisfiable (Struc.{v, choose i _ _ using Classical.choose_spec (satisfiable_iff.mp h); exact i noncomputable def StructureModelOfSatAux (h : Semantics.Satisfiable (Struc.{v, u} L) T) : - { _s : Structure L (ModelOfSat h) // ModelOfSat h ⊧ₘ* T } := by + { _s : Structure L (ModelOfSat h) // (ModelOfSat h)↓[L] ⊧* T } := by choose _ s h using Classical.choose_spec (satisfiable_iff.mp h) exact ⟨s, h⟩ noncomputable instance StructureModelOfSat (h : Semantics.Satisfiable (Struc.{v, u} L) T) : Structure L (ModelOfSat h) := StructureModelOfSatAux h -lemma ModelOfSat.models (h : Semantics.Satisfiable (Struc.{v, u} L) T) : ModelOfSat h ⊧ₘ* T := (StructureModelOfSatAux h).prop +lemma ModelOfSat.models (h : Semantics.Satisfiable (Struc.{v, u} L) T) : (ModelOfSat h)↓[L] ⊧* T := (StructureModelOfSatAux h).prop lemma consequence_iff_unsatisfiable {σ : Sentence L} : T ⊨[Struc.{v, u} L] σ ↔ ¬Semantics.Satisfiable (Struc.{v, u} L) (insert (∼σ) T) := by @@ -640,7 +583,7 @@ lemma consequence_iff_unsatisfiable {σ : Sentence L} : intro hT; simpa using models_iff.mp (h hT) · intro h; apply consequence_iff.mpr intro M _ s hT - have : (Semiformula.Evalb s ![]) σ := by + have : σ.Evalb M ![] := by have := by simpa only [Semantics.ModelsSet.insert_iff, not_and', models_iff] using unsatisfiable_iff.mp h M inferInstance s simpa using this hT apply models_iff.mpr (by simpa using this) @@ -655,9 +598,9 @@ section lMap variable {M : Type u} {s₂ : Structure L₂ M} {n} {e : Fin n → M} {ε : ξ → M} lemma eval_lMap [Nonempty M] {φ : Semiformula L₁ ξ n} : - Eval s₂ e ε (lMap Φ φ) ↔ Eval (s₂.lMap Φ) e ε φ := by + Eval (s := s₂) e ε (lMap Φ φ) ↔ Eval (s := s₂.lMap Φ) e ε φ := by induction φ using rec' <;> - simp [*, Semiterm.val_lMap, lMap_rel, lMap_nrel, eval_rel, eval_nrel] + simp [*, Semiterm.val_lMap, lMap_rel, lMap_nrel, eval_rel, eval_nrel, Function.comp_def] lemma models_lMap [Nonempty M] {σ : Sentence L₁} : s₂.toStruc ⊧ lMap Φ σ ↔ (s₂.lMap Φ).toStruc ⊧ σ := by @@ -667,43 +610,27 @@ end lMap end Semiformula -lemma lMap_models_lMap {L₁ L₂ : Language.{u}} {Φ : L₁ →ᵥ L₂} {T : Theory L₁} {σ : Sentence L₁} (h : T ⊨[Struc.{v, u} L₁] σ) : - T.lMap Φ ⊨[Struc.{v, u} L₂] Semiformula.lMap Φ σ := by - intro s hM - have : (s.struc.lMap Φ).toStruc ⊧ σ := - h ⟨fun _ hq => Semiformula.models_lMap.mp <| hM.models _ (Set.mem_image_of_mem _ hq)⟩ - exact Semiformula.models_lMap.mpr this - -namespace ModelsTheory +section schema variable (M) [Nonempty M] [Structure L M] -lemma models {T : Theory L} [M ⊧ₘ* T] {φ} (h : φ ∈ T) : M ⊧ₘ φ := Semantics.ModelsSet.models _ h - variable {M} -lemma of_ss {T U : Theory L} (h : M ⊧ₘ* U) (ss : T ⊆ U) : M ⊧ₘ* T := +lemma of_ss {T U : Theory L} (h : M↓[L] ⊧* U) (ss : T ⊆ U) : M↓[L] ⊧* T := Semantics.ModelsSet.of_subset h ss -@[simp] lemma add_iff {T U : Theory L} : - M ⊧ₘ* T + U ↔ M ⊧ₘ* T ∧ M ⊧ₘ* U := by simp [Theory.add_def] +variable {𝓢 : Schema L} -instance add (T U : Theory L) [M ⊧ₘ* T] [M ⊧ₘ* U] : M ⊧ₘ* T + U := - ModelsTheory.add_iff.mpr ⟨inferInstance, inferInstance⟩ +@[simp] lemma schema_sup_iff {𝓢₁ 𝓢₂ : Schema L} : + M↓[L] ⊧* 𝓢₁ ∪ 𝓢₂ ↔ M↓[L] ⊧* 𝓢₁ ∧ M↓[L] ⊧* ↑𝓢₂ := by simp [] -end ModelsTheory - -namespace Theory - -variable {L₁ L₂ : Language.{u}} {Φ : L₁ →ᵥ L₂} - -variable {M : Type u} [Nonempty M] [s₂ : Structure L₂ M] - -lemma modelsTheory_onTheory₁ {T₁ : Theory L₁} : - ModelsTheory (s := s₂) M (T₁.lMap Φ) ↔ ModelsTheory (s := s₂.lMap Φ) M T₁ := - by simp [Semiformula.models_lMap, Theory.lMap, @modelsTheory_iff (T := T₁)] +instance models_schema_sup (𝓢₁ 𝓢₂ : Schema L) [M↓[L] ⊧* 𝓢₁] [M↓[L] ⊧* 𝓢₂] : M↓[L] ⊧* 𝓢₁ ⊔ 𝓢₂ := by + simp only [Set.sup_eq_union, Semantics.ModelsSet.union_iff] + constructor + · infer_instance + · infer_instance -end Theory +end schema namespace Structure @@ -713,9 +640,9 @@ abbrev theory (M : Type*) [Nonempty M] [s : Structure L M] : Theory L := Semanti variable {L} {M : Type v} [Nonempty M] [s : Structure L M] -@[simp] lemma mem_theory_iff {σ} : σ ∈ theory L M ↔ M ⊧ₘ σ := by rfl +@[simp] lemma mem_theory_iff {σ} : σ ∈ theory L M ↔ M↓[L] ⊧ σ := by rfl -lemma subset_of_models : T ⊆ theory L M ↔ M ⊧ₘ* T := ⟨fun h ↦ ⟨fun _ hσ ↦ h hσ⟩, fun h _ hσ ↦ h.models_set hσ⟩ +lemma subset_of_models : T ⊆ theory L M ↔ M↓[L] ⊧* T := ⟨fun h ↦ ⟨fun _ hσ ↦ h hσ⟩, fun h _ hσ ↦ h.models_set hσ⟩ lemma theory_satisfiable : Semantics.Satisfiable (Struc.{v} L) (theory L M) := ⟨s.toStruc, by simp⟩ diff --git a/Foundation/FirstOrder/Basic/Syntax/Rew.lean b/Foundation/FirstOrder/Basic/Syntax/Rew.lean index 174b18911..0c84b6166 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Rew.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Rew.lean @@ -523,11 +523,6 @@ lemma lMap_fix (φ : Semiproposition L₁ n) : lMap Φ (@Rew.fix L₁ n ▹ φ) lemma lMap_emb {ο : Type _} [IsEmpty ο] (φ : Semiformula L₁ ο n) : (lMap Φ (Rewriting.emb φ : Semiformula L₁ ξ n)) = Rewriting.emb (lMap Φ φ) := lMap_bind _ _ _ -lemma lMap_toS (φ : Semiformula L₁ (Fin n) 0) : - lMap Φ (@Rew.toS L₁ n ▹ φ) = @Rew.toS L₂ n ▹ lMap Φ φ := by - rw [Rew.eq_bind Rew.toS, lMap_bind] - simp [Function.comp_def, Matrix.empty_eq]; congr - lemma lMap_rewriteMap (φ : Semiformula L₁ ξ₁ n) (f : ξ₁ → ξ₂) : lMap Φ (Rew.rewriteMap (L := L₁) (n := n) f ▹ φ) = (Rew.rewriteMap (L := L₂) (n := n) f) ▹ (lMap Φ φ) := by simp [Rew.rewriteMap, lMap_rewrite, Function.comp_def] diff --git a/Foundation/FirstOrder/Basic/Syntax/Schema.lean b/Foundation/FirstOrder/Basic/Syntax/Schema.lean index 5c1f2160e..40d0a68c8 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Schema.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Schema.lean @@ -120,12 +120,26 @@ instance sentence (σ : Sentence L) : IsClosed (σ : Schema L) where end IsClosed -def uniClosure (𝓢 : Schema L) : Theory L := Set.image Semiformula.univCl {φ | φ ∈ 𝓢} +@[coe] def uniClosure (𝓢 : Schema L) : Theory L := Set.image Semiformula.univCl {φ | φ ∈ 𝓢} + +instance : Coe (Schema L) (Theory L) := ⟨uniClosure⟩ variable {𝓢 : Schema L} @[simp] lemma mem_uniClosure : - σ ∈ 𝓢.uniClosure ↔ ∃ φ ∈ 𝓢, Semiformula.univCl φ = σ := by simp [uniClosure] + σ ∈ (𝓢 : Theory L) ↔ ∃ φ ∈ 𝓢, Semiformula.univCl φ = σ := by simp [uniClosure] + +@[simp] lemma coe_sup (𝓢₁ 𝓢₂ : Schema L) : ((𝓢₁ ⊔ 𝓢₂ : Schema L) : Theory L) = (𝓢₁ : Theory L) ∪ (𝓢₂ : Theory L) := by + ext σ; simp [uniClosure]; grind + +@[simp] lemma coe_sSup (s : Set (Schema L)) : ((sSup s : Schema L) : Theory L) = ⋃ 𝓢 ∈ s, (𝓢 : Theory L) := by + ext σ; simp [uniClosure, sSup]; grind + +@[simp] lemma coe_coe_proposition (φ : Proposition L) : ((φ : Schema L) : Theory L) = {φ.univCl} := by + ext σ; simp [uniClosure] + +@[grind <-] lemma coe_subset_coe_iff_le {𝓢₁ 𝓢₂ : Schema L} (h : 𝓢₁ ≤ 𝓢₂) : (𝓢₁ : Theory L) ⊆ (𝓢₂ : Theory L) := + Set.image_mono h end Schema diff --git a/Foundation/Logic/Calculus.lean b/Foundation/Logic/Calculus.lean index 160243b49..8ef2b25b8 100644 --- a/Foundation/Logic/Calculus.lean +++ b/Foundation/Logic/Calculus.lean @@ -37,19 +37,18 @@ def cast (b : 𝔇 Γ) (h : Γ = Δ := by simp) : 𝔇 Δ := h ▸ b def close (φ : F) (hp : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : 𝔇 Γ := wk (identity φ) (by simp_all) -def verum' (h : ⊤ ∈ Γ := by simp) : 𝔇 Γ := wk verum (by simp [h]) +def top (h : ⊤ ∈ Γ := by simp) : 𝔇 Γ := wk verum (by simp [h]) def tensor {φ ψ : F} (dφ : 𝔇 (φ :: Γ)) (dψ : 𝔇 (ψ :: Δ)) : 𝔇 (φ ⋏ ψ :: Γ ++ Δ) := and (wk dφ (by simp)) (wk dψ (by simp)) -def rotate₁ (d : 𝔇 (φ₂ :: φ₁ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: Γ) := wk d (by simp) +def swap₁ (d : 𝔇 (φ₂ :: φ₁ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: Γ) := wk d (by simp) -def rotate₂ (d : 𝔇 (φ₃ :: φ₁ :: φ₂ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: φ₃ :: Γ) := - wk d (by simpa using List.subset_cons_of_subset _ (List.subset_cons_of_subset _ <| by simp)) +def swap₂ (d : 𝔇 (φ₃ :: φ₁ :: φ₂ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: φ₃ :: Γ) := + wk d (by grind) -def rotate₃ (d : 𝔇 (φ₄ :: φ₁ :: φ₂ :: φ₃ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: φ₃ :: φ₄ :: Γ) := - wk d (by simpa using - List.subset_cons_of_subset _ (List.subset_cons_of_subset _ <| List.subset_cons_of_subset _ <| by simp)) +def swap₃ (d : 𝔇 (φ₄ :: φ₁ :: φ₂ :: φ₃ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: φ₃ :: φ₄ :: Γ) := + wk d (by grind) alias cut := OneSidedLK.Cut.cut @@ -81,17 +80,17 @@ instance : Entailment.ModusPonens 𝓔 where instance : Entailment.Cl 𝓔 where negEquiv {φ} := Entailment.cast (show 𝓔 ⊢! (φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ) from - equiv.symm <| and (or <| rotate₁ <| or <| close φ) (or <| and (identity φ) verum')) + equiv.symm <| and (or <| swap₁ <| or <| close φ) (or <| and (identity φ) top)) (by simp [Axioms.NegEquiv, DeMorgan.imply, LogicalConnective.iff]) verum := equiv.symm <| verum implyK {φ ψ} := - have : 𝓔 ⊢! ∼φ ⋎ ∼ψ ⋎ φ := equiv.symm <| or <| rotate₁ <| or <| close φ + have : 𝓔 ⊢! ∼φ ⋎ ∼ψ ⋎ φ := equiv.symm <| or <| swap₁ <| or <| close φ Entailment.cast this (by simp [DeMorgan.imply]) implyS {φ ψ χ} := have : 𝓔 ⊢! φ ⋏ ψ ⋏ ∼χ ⋎ φ ⋏ ∼ψ ⋎ ∼φ ⋎ χ := - equiv.symm <| or <| rotate₁ <| or <| rotate₁ <| or <| rotate₃ <| and + equiv.symm <| or <| swap₁ <| or <| swap₁ <| or <| swap₃ <| and (close φ) - (and (rotate₃ <| and (close φ) (close ψ)) (close χ)) + (and (swap₃ <| and (close φ) (close ψ)) (close χ)) Entailment.cast this (by simp [DeMorgan.imply]) and₁ {φ ψ} := have : 𝓔 ⊢! (∼φ ⋎ ∼ψ) ⋎ φ := equiv.symm <|or <| or <| close φ @@ -100,19 +99,19 @@ instance : Entailment.Cl 𝓔 where have : 𝓔 ⊢! (∼φ ⋎ ∼ψ) ⋎ ψ := equiv.symm <| or <| or <| close ψ Entailment.cast this (by simp [DeMorgan.imply]) and₃ {φ ψ} := - have : 𝓔 ⊢! ∼φ ⋎ ∼ψ ⋎ φ ⋏ ψ := equiv.symm <| or <| rotate₁ <| or <| rotate₁ <| and (close φ) (close ψ) + have : 𝓔 ⊢! ∼φ ⋎ ∼ψ ⋎ φ ⋏ ψ := equiv.symm <| or <| swap₁ <| or <| swap₁ <| and (close φ) (close ψ) Entailment.cast this (by simp [DeMorgan.imply]) or₁ {φ ψ} := - have : 𝓔 ⊢! ∼φ ⋎ φ ⋎ ψ := equiv.symm <| or <| rotate₁ <| or <| close φ + have : 𝓔 ⊢! ∼φ ⋎ φ ⋎ ψ := equiv.symm <| or <| swap₁ <| or <| close φ Entailment.cast this (by simp [DeMorgan.imply]) or₂ {φ ψ} := - have : 𝓔 ⊢! ∼ψ ⋎ φ ⋎ ψ := equiv.symm <| or <| rotate₁ <| or <| close ψ + have : 𝓔 ⊢! ∼ψ ⋎ φ ⋎ ψ := equiv.symm <| or <| swap₁ <| or <| close ψ Entailment.cast this (by simp [DeMorgan.imply]) or₃ {φ ψ χ} := have : 𝓔 ⊢! φ ⋏ ∼χ ⋎ ψ ⋏ ∼ χ ⋎ ∼φ ⋏ ∼ψ ⋎ χ := - equiv.symm <| or <| rotate₁ <| or <| rotate₁ <| or <| and - (rotate₃ <| and (close φ) (close χ)) - (rotate₂ <| and (close ψ) (close χ)) + equiv.symm <| or <| swap₁ <| or <| swap₁ <| or <| and + (swap₃ <| and (close φ) (close χ)) + (swap₂ <| and (close ψ) (close χ)) Entailment.cast this (by simp [DeMorgan.imply]) dne {φ} := have : 𝓔 ⊢! ∼φ ⋎ φ := equiv.symm <| or <| close φ @@ -164,7 +163,7 @@ instance : Entailment.StrongCut S S where | [] => equiv.symm ⟨⟨[], by simp⟩, d⟩ | ψ :: l => have bχ : T ⊢! ψ ➝ χ := - Entailment.cast (bl l (by simp at hl; grind) (∼ψ ⋎ χ) (OneSidedLK.or <| OneSidedLK.rotate₁ d)) + Entailment.cast (bl l (by simp at hl; grind) (∼ψ ⋎ χ) (OneSidedLK.or <| OneSidedLK.swap₁ d)) (by simp [DeMorgan.imply]) have bψ : T ⊢! ψ := bs (show ψ ∈ U by simp at hl; grind) Entailment.mdp bχ bψ @@ -194,17 +193,17 @@ lemma inconsistent_iff {𝓢 : S} : instance (𝓢 : S) : Entailment.Cl 𝓢 where negEquiv {φ} := Entailment.cast (show 𝓢 ⊢! (φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ) from - toProof _ <| and (or <| rotate₁ <| or <| close φ) (or <| and (identity φ) verum')) + toProof _ <| and (or <| swap₁ <| or <| close φ) (or <| and (identity φ) top)) (by simp [Axioms.NegEquiv, DeMorgan.imply, LogicalConnective.iff]) verum := toProof _ <| verum implyK {φ ψ} := - have : 𝓢 ⊢! ∼φ ⋎ ∼ψ ⋎ φ := toProof _ <| or <| rotate₁ <| or <| close φ + have : 𝓢 ⊢! ∼φ ⋎ ∼ψ ⋎ φ := toProof _ <| or <| swap₁ <| or <| close φ Entailment.cast this (by simp [DeMorgan.imply]) implyS {φ ψ χ} := have : 𝓢 ⊢! φ ⋏ ψ ⋏ ∼χ ⋎ φ ⋏ ∼ψ ⋎ ∼φ ⋎ χ := - toProof _ <| or <| rotate₁ <| or <| rotate₁ <| or <| rotate₃ <| and + toProof _ <| or <| swap₁ <| or <| swap₁ <| or <| swap₃ <| and (close φ) - (and (rotate₃ <| and (close φ) (close ψ)) (close χ)) + (and (swap₃ <| and (close φ) (close ψ)) (close χ)) Entailment.cast this (by simp [DeMorgan.imply]) and₁ {φ ψ} := have : 𝓢 ⊢! (∼φ ⋎ ∼ψ) ⋎ φ := toProof _ <|or <| or <| close φ @@ -213,19 +212,19 @@ instance (𝓢 : S) : Entailment.Cl 𝓢 where have : 𝓢 ⊢! (∼φ ⋎ ∼ψ) ⋎ ψ := toProof _ <| or <| or <| close ψ Entailment.cast this (by simp [DeMorgan.imply]) and₃ {φ ψ} := - have : 𝓢 ⊢! ∼φ ⋎ ∼ψ ⋎ φ ⋏ ψ := toProof _ <| or <| rotate₁ <| or <| rotate₁ <| and (close φ) (close ψ) + have : 𝓢 ⊢! ∼φ ⋎ ∼ψ ⋎ φ ⋏ ψ := toProof _ <| or <| swap₁ <| or <| swap₁ <| and (close φ) (close ψ) Entailment.cast this (by simp [DeMorgan.imply]) or₁ {φ ψ} := - have : 𝓢 ⊢! ∼φ ⋎ φ ⋎ ψ := toProof _ <| or <| rotate₁ <| or <| close φ + have : 𝓢 ⊢! ∼φ ⋎ φ ⋎ ψ := toProof _ <| or <| swap₁ <| or <| close φ Entailment.cast this (by simp [DeMorgan.imply]) or₂ {φ ψ} := - have : 𝓢 ⊢! ∼ψ ⋎ φ ⋎ ψ := toProof _ <| or <| rotate₁ <| or <| close ψ + have : 𝓢 ⊢! ∼ψ ⋎ φ ⋎ ψ := toProof _ <| or <| swap₁ <| or <| close ψ Entailment.cast this (by simp [DeMorgan.imply]) or₃ {φ ψ χ} := have : 𝓢 ⊢! φ ⋏ ∼χ ⋎ ψ ⋏ ∼ χ ⋎ ∼φ ⋏ ∼ψ ⋎ χ := - toProof _ <| or <| rotate₁ <| or <| rotate₁ <| or <| and - (rotate₃ <| and (close φ) (close χ)) - (rotate₂ <| and (close ψ) (close χ)) + toProof _ <| or <| swap₁ <| or <| swap₁ <| or <| and + (swap₃ <| and (close φ) (close χ)) + (swap₂ <| and (close ψ) (close χ)) Entailment.cast this (by simp [DeMorgan.imply]) dne {φ} := have : 𝓢 ⊢! ∼φ ⋎ φ := toProof _ <| or <| close φ diff --git a/Foundation/Syntax/Predicate/Rew.lean b/Foundation/Syntax/Predicate/Rew.lean index 67448904d..0ee33c7ec 100644 --- a/Foundation/Syntax/Predicate/Rew.lean +++ b/Foundation/Syntax/Predicate/Rew.lean @@ -26,7 +26,7 @@ namespace FirstOrder structure Rew (L : Language) (ξ₁ : Type*) (n₁ : ℕ) (ξ₂ : Type*) (n₂ : ℕ) where toFun : Semiterm L ξ₁ n₁ → Semiterm L ξ₂ n₂ - func' : ∀ {k} (f : L.Func k) (v : Fin k → Semiterm L ξ₁ n₁), toFun (Semiterm.func f v) = Semiterm.func f (fun i => toFun (v i)) + func'' (f : L.Func k) (v : Fin k → Semiterm L ξ₁ n₁) : toFun (Semiterm.func f v) = Semiterm.func f fun i ↦ toFun (v i) abbrev SyntacticRew (L : Language) (n₁ n₂ : ℕ) := Rew L ℕ n₁ ℕ n₂ @@ -42,46 +42,27 @@ instance : FunLike (Rew L ξ₁ n₁ ξ₂ n₂) (Semiterm L ξ₁ n₁) (Semite instance : CoeFun (Rew L ξ₁ n₁ ξ₂ n₂) (fun _ => Semiterm L ξ₁ n₁ → Semiterm L ξ₂ n₂) := DFunLike.hasCoeToFun -protected lemma func {k} (f : L.Func k) (v : Fin k → Semiterm L ξ₁ n₁) : - ω (func f v) = func f (fun i => ω (v i)) := ω.func' f v +@[simp] protected lemma func {k} (f : L.Func k) (v : Fin k → Semiterm L ξ₁ n₁) : + ω (func f v) = func f (ω ∘ v) := ω.func'' f v -lemma func'' {k} (f : L.Func k) (v : Fin k → Semiterm L ξ₁ n₁) : - ω (func f v) = func f (ω ∘ v) := ω.func' f v - -@[simp] lemma func0 (f : L.Func 0) (v : Fin 0 → Semiterm L ξ₁ n₁) : - ω (func f v) = func f ![] := by simp [Rew.func, Matrix.empty_eq] - -@[simp] lemma func1 (f : L.Func 1) (t : Semiterm L ξ₁ n₁) : - ω (func f ![t]) = func f ![ω t] := by simp [Matrix.constant_eq_singleton, Rew.func] - -@[simp] lemma func2 (f : L.Func 2) (t₁ t₂ : Semiterm L ξ₁ n₁) : - ω (func f ![t₁, t₂]) = func f ![ω t₁, ω t₂] := by - simp only [Rew.func, func.injEq, heq_eq_eq, true_and] - funext i - induction i using Fin.induction <;> simp - -@[simp] lemma func3 (f : L.Func 3) (t₁ t₂ t₃ : Semiterm L ξ₁ n₁) : - ω (func f ![t₁, t₂, t₃]) = func f ![ω t₁, ω t₂, ω t₃] := by - simp only [Rew.func, func.injEq, heq_eq_eq, true_and] - funext i; induction' i using Fin.induction with i - · simp - · induction' i using Fin.induction with i <;> simp +lemma func' {k} (f : L.Func k) (v : Fin k → Semiterm L ξ₁ n₁) : + ω (func f v) = func f fun i ↦ ω (v i) := ω.func'' f v @[ext] lemma ext (ω₁ ω₂ : Rew L ξ₁ n₁ ξ₂ n₂) (hb : ∀ x, ω₁ #x = ω₂ #x) (hf : ∀ x, ω₁ &x = ω₂ &x) : ω₁ = ω₂ := by apply DFunLike.ext ω₁ ω₂; intro t - induction t <;> simp [*, ω₁.func, ω₂.func] + induction t <;> simp [*, ω₁.func, ω₂.func, Function.comp_def] lemma ext' {ω₁ ω₂ : Rew L ξ₁ n₁ ξ₂ n₂} (h : ω₁ = ω₂) (t) : ω₁ t = ω₂ t := by simp [h] protected def id : Rew L ξ n ξ n where toFun := id - func' := fun _ _ => rfl + func'' := fun _ _ => rfl @[simp] lemma id_app (t : Semiterm L ξ n) : Rew.id t = t := rfl protected def comp (ω₂ : Rew L ξ₂ n₂ ξ₃ n₃) (ω₁ : Rew L ξ₁ n₁ ξ₂ n₂) : Rew L ξ₁ n₁ ξ₃ n₃ where toFun := fun t => ω₂ (ω₁ t) - func' := fun f v => by simp [func'']; rfl + func'' := fun f v => by simp; rfl lemma comp_app (ω₂ : Rew L ξ₂ n₂ ξ₃ n₃) (ω₁ : Rew L ξ₁ n₁ ξ₂ n₂) (t : Semiterm L ξ₁ n₁) : (ω₂.comp ω₁) t = ω₂ (ω₁ t) := rfl @@ -97,7 +78,7 @@ def bindAux (b : Fin n₁ → Semiterm L ξ₂ n₂) (e : ξ₁ → Semiterm L def bind (b : Fin n₁ → Semiterm L ξ₂ n₂) (e : ξ₁ → Semiterm L ξ₂ n₂) : Rew L ξ₁ n₁ ξ₂ n₂ where toFun := bindAux b e - func' := fun _ _ => rfl + func'' := fun _ _ => rfl def rewrite (f : ξ₁ → Semiterm L ξ₂ n) : Rew L ξ₁ n ξ₂ n := bind Semiterm.bvar f @@ -127,10 +108,6 @@ def cast {n n' : ℕ} (h : n = n') : Rew L ξ n ξ n' := def castLE {n n' : ℕ} (h : n ≤ n') : Rew L ξ n ξ n' := map (Fin.castLE h) id -def toS : Rew L (Fin n) 0 Empty n := Rew.bind ![] (#·) - -def toF : Rew L Empty n (Fin n) 0 := Rew.bind (&·) Empty.elim - def embSubsts (v : Fin k → Semiterm L ξ n) : Rew L Empty k ξ n := Rew.bind v Empty.elim protected def q (ω : Rew L ξ₁ n₁ ξ₂ n₂) : Rew L ξ₁ (n₁ + 1) ξ₂ (n₂ + 1) := @@ -339,12 +316,6 @@ section castLE end castLE -section toS - -@[simp] lemma toS_fvar {n} (x : Fin n) : toS (&x : Term L (Fin n)) = #x := rfl - -end toS - section embSubsts variable {k} (w : Fin k → Semiterm L ξ n) @@ -457,10 +428,6 @@ lemma q_rewrite (f : ξ₁ → Semiterm L ξ₂ n) : (castLE h : Rew L ξ n ξ n').q = castLE (Nat.add_le_add_right h 1) := by ext x <;> simp; cases x using Fin.cases <;> simp -lemma q_toS : - (toS : Rew L (Fin n) 0 Empty n).q = bind ![#0] (#·.succ) := by - ext x <;> simp - @[simp] lemma qpow_castLE {n n'} (h : n ≤ n') : (castLE h : Rew L ξ n ξ n').qpow k = castLE (Nat.add_le_add_right h k) := by induction k <;> simp [*] @@ -748,7 +715,7 @@ open Rew lemma lMap_bind (b : Fin n₁ → Semiterm L₁ ξ₂ n₂) (e : ξ₁ → Semiterm L₁ ξ₂ n₂) (t) : lMap Φ (bind b e t) = bind (lMap Φ ∘ b) (lMap Φ ∘ e) (t.lMap Φ) := by - induction t <;> simp [*, lMap_func, Rew.func] + induction t <;> simp [*, -lMap_func, lMap_func', -Rew.func, Rew.func'] lemma lMap_map (b : Fin n₁ → Fin n₂) (e : ξ₁ → ξ₂) (t) : (map b e t).lMap Φ = map b e (t.lMap Φ) := by @@ -801,7 +768,7 @@ def toEmpty [DecidableEq ξ] {n : ℕ} : (t : Semiterm L ξ n) → t.freeVariabl func f fun i ↦ toEmpty (v i) (this i) @[simp] lemma emb_toEmpty [DecidableEq ξ] (t : Semiterm L ξ n) (ht : t.freeVariables = ∅) : Rew.emb (t.toEmpty ht) = t := by - induction t <;> try simp [toEmpty, Rew.func, *] + induction t <;> try simp [toEmpty, Rew.func, *, Function.comp_def] case fvar => simp at ht @[simp] lemma toEmpty_emb [DecidableEq ξ] (t : ClosedSemiterm L n) : diff --git a/Foundation/Syntax/Predicate/Term.lean b/Foundation/Syntax/Predicate/Term.lean index 092868584..5d66c565d 100644 --- a/Foundation/Syntax/Predicate/Term.lean +++ b/Foundation/Syntax/Predicate/Term.lean @@ -191,8 +191,11 @@ def lMap (Φ : L₁ →ᵥ L₂) : Semiterm L₁ ξ n → Semiterm L₂ ξ n @[simp] lemma lMap_fvar (x : ξ) : (&x : Semiterm L₁ ξ n).lMap Φ = &x := rfl -lemma lMap_func {k} (f : L₁.Func k) (v : Fin k → Semiterm L₁ ξ n) : - (func f v).lMap Φ = func (Φ.func f) (fun i ↦ lMap Φ (v i)) := rfl +@[simp] lemma lMap_func {k} (f : L₁.Func k) (v : Fin k → Semiterm L₁ ξ n) : + (func f v).lMap Φ = func (Φ.func f) (lMap Φ ∘ v) := rfl + +lemma lMap_func' {k} (f : L₁.Func k) (v : Fin k → Semiterm L₁ ξ n) : + (func f v).lMap Φ = func (Φ.func f) fun i ↦ lMap Φ (v i) := rfl @[simp] lemma lMap_positive (t : Semiterm L₁ ξ (n + 1)) : (t.lMap Φ).Positive ↔ t.Positive := by induction t <;> simp [lMap_func, *] From a1254ab06ae8f30de2dd373f95569a13a1728046 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sun, 15 Mar 2026 14:26:44 +0900 Subject: [PATCH 11/61] semantics --- .../FirstOrder/Basic/Semantics/Semantics.lean | 15 ++++++++------- Foundation/FirstOrder/Basic/Syntax/Schema.lean | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index 72095f407..df972639b 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -18,10 +18,12 @@ namespace FirstOrder variable {L : Language.{u}} +/-- A first-order `L`-structure associates domain `M` with interpretations of function and relation symbols. -/ @[ext] class Structure (L : Language.{u}) (M : Type w) where func : ⦃k : ℕ⦄ → L.Func k → (Fin k → M) → M rel : ⦃k : ℕ⦄ → L.Rel k → (Fin k → M) → Prop +/-- An auxiliary structure that corresponds to a first-order `L`-structure with a nonempty domain. -/ structure Struc (L : Language) where Dom : Type* nonempty : Nonempty Dom @@ -38,8 +40,8 @@ instance [n : Nonempty M] : Nonempty (Structure L M) := by exact ⟨{ func := fun _ _ _ ↦ x, rel := fun _ _ _ ↦ True }⟩ protected def lMap (φ : L₁ →ᵥ L₂) {M : Type w} (S : Structure L₂ M) : Structure L₁ M where - func := fun _ f => S.func (φ.func f) - rel := fun _ r => S.rel (φ.rel r) + func _ f := S.func (φ.func f) + rel _ r := S.rel (φ.rel r) variable (φ : L₁ →ᵥ L₂) {M : Type w} (s₂ : Structure L₂ M) @@ -616,13 +618,11 @@ variable (M) [Nonempty M] [Structure L M] variable {M} -lemma of_ss {T U : Theory L} (h : M↓[L] ⊧* U) (ss : T ⊆ U) : M↓[L] ⊧* T := +lemma models_of_ss {T U : Theory L} (h : M↓[L] ⊧* U) (ss : T ⊆ U) : M↓[L] ⊧* T := Semantics.ModelsSet.of_subset h ss -variable {𝓢 : Schema L} - -@[simp] lemma schema_sup_iff {𝓢₁ 𝓢₂ : Schema L} : - M↓[L] ⊧* 𝓢₁ ∪ 𝓢₂ ↔ M↓[L] ⊧* 𝓢₁ ∧ M↓[L] ⊧* ↑𝓢₂ := by simp [] +lemma models_of_le {𝓢₁ 𝓢₂ : Schema L} (h : M↓[L] ⊧* 𝓢₂) (le : 𝓢₁ ≤ 𝓢₂) : M↓[L] ⊧* 𝓢₁ := + Semantics.ModelsSet.of_subset h (Schema.coe_subset_coe_of_le le) instance models_schema_sup (𝓢₁ 𝓢₂ : Schema L) [M↓[L] ⊧* 𝓢₁] [M↓[L] ⊧* 𝓢₂] : M↓[L] ⊧* 𝓢₁ ⊔ 𝓢₂ := by simp only [Set.sup_eq_union, Semantics.ModelsSet.union_iff] @@ -651,4 +651,5 @@ end Structure end FirstOrder end LO + end diff --git a/Foundation/FirstOrder/Basic/Syntax/Schema.lean b/Foundation/FirstOrder/Basic/Syntax/Schema.lean index 40d0a68c8..2e7e60af6 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Schema.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Schema.lean @@ -138,7 +138,7 @@ variable {𝓢 : Schema L} @[simp] lemma coe_coe_proposition (φ : Proposition L) : ((φ : Schema L) : Theory L) = {φ.univCl} := by ext σ; simp [uniClosure] -@[grind <-] lemma coe_subset_coe_iff_le {𝓢₁ 𝓢₂ : Schema L} (h : 𝓢₁ ≤ 𝓢₂) : (𝓢₁ : Theory L) ⊆ (𝓢₂ : Theory L) := +@[grind <-] lemma coe_subset_coe_of_le {𝓢₁ 𝓢₂ : Schema L} (h : 𝓢₁ ≤ 𝓢₂) : (𝓢₁ : Theory L) ⊆ (𝓢₂ : Theory L) := Set.image_mono h end Schema From cd9461b7e20698a483efb53738683612d7e9127d Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sun, 15 Mar 2026 16:08:57 +0900 Subject: [PATCH 12/61] sound --- Foundation/FirstOrder/Basic/Calculus.lean | 62 ++++++++-------- .../Basic/Semantics/Elementary.lean | 55 +++++++------- .../FirstOrder/Basic/Semantics/Semantics.lean | 2 + Foundation/FirstOrder/Basic/Soundness.lean | 72 +++++++++++-------- 4 files changed, 103 insertions(+), 88 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index e91769130..84e8f1854 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -158,7 +158,7 @@ protected def shift {Δ : Sequent L} (d : ⊢ᴷ Δ) : ⊢ᴷ Δ⁺ := section Hom -variable {L₁ : Language} {L₂ : Language} {𝓢₁ : Schema L₁} {Δ₁ : Sequent L₁} +variable {L₁ : Language} {L₂ : Language} {𝔖₁ : Schema L₁} {Δ₁ : Sequent L₁} lemma shifts_image (Φ : L₁ →ᵥ L₂) {Δ : List (Proposition L₁)} : (Δ.map <| Semiformula.lMap Φ)⁺ = (Δ⁺.map <| Semiformula.lMap Φ) := by @@ -253,22 +253,22 @@ instance classical : Entailment.Cl (𝐋𝐊¹ : Proof.Symbol L) := inferInstanc end Proof -structure Schema.Proof (𝓢 : Schema L) (φ : Proposition L) where +structure Schema.Proof (𝔖 : Schema L) (φ : Proposition L) where axioms : List (Proposition L) - axioms_mem : ∀ ψ ∈ axioms, ψ ∈ 𝓢 + axioms_mem : ∀ ψ ∈ axioms, ψ ∈ 𝔖 derivation : ⊢ᴷ φ :: ∼axioms -namespace Schema.Proof +namespace Schema instance : Entailment (Schema L) (Proposition L) where Prf := Schema.Proof -variable {𝓢 : Schema L} +variable {𝔖 : Schema L} -attribute [simp] axioms_mem +attribute [simp] Proof.axioms_mem -def equiv (𝓢 : Schema L) (φ) : - (𝓢 ⊢! φ) ≃ (Γ : {Γ : Sequent L // ∀ ψ ∈ Γ, ψ ∈ 𝓢}) × ⊢ᴷ φ :: ∼Γ where +def equiv (𝔖 : Schema L) (φ) : + (𝔖 ⊢! φ) ≃ (Γ : {Γ : Sequent L // ∀ ψ ∈ Γ, ψ ∈ 𝔖}) × ⊢ᴷ φ :: ∼Γ where toFun b := ⟨⟨b.axioms, b.axioms_mem⟩, b.derivation⟩ invFun := fun ⟨⟨Γ, hΓ⟩, d⟩ ↦ ⟨Γ, hΓ, d⟩ @@ -279,25 +279,29 @@ instance : Entailment.Compact (Schema L) where core_subset b := by simpa [AdjunctiveSet.subset_iff] using b.axioms_mem instance : OneSidedLK.Entailment (Derivation (L := L)) (Schema L) where - equiv {𝓢 φ} := equiv 𝓢 φ + equiv {𝔖 φ} := equiv 𝔖 φ -instance : Entailment.Cl 𝓢 := inferInstance +instance : Entailment.Cl 𝔖 := inferInstance -lemma weakerThan_of_le {𝓢 𝓤 : Schema L} (h : 𝓢 ≤ 𝓤) : 𝓢 ⪯ 𝓤 := Entailment.Axiomatized.weakerThanOfSubset h +lemma weakerThan_of_le {𝔖 𝔘 : Schema L} (h : 𝔖 ≤ 𝔘) : 𝔖 ⪯ 𝔘 := Entailment.Axiomatized.weakerThanOfSubset h -instance (𝓢 𝓤 : Schema L) : 𝓢 ⪯ 𝓢 ⊔ 𝓤 := weakerThan_of_le (by simp) +instance (𝔖 𝔘 : Schema L) : 𝔖 ⪯ 𝔖 ⊔ 𝔘 := weakerThan_of_le (by simp) -instance (𝓢 𝓤 : Schema L) : 𝓤 ⪯ 𝓢 ⊔ 𝓤 := weakerThan_of_le (by simp) +instance (𝔖 𝔘 : Schema L) : 𝔘 ⪯ 𝔖 ⊔ 𝔘 := weakerThan_of_le (by simp) + +lemma provable_iff : + 𝔖 ⊢ φ ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝔖) ∧ Nonempty (⊢ᴷ φ :: ∼Γ) := + OneSidedLK.Entailment.provable_iff lemma inconsistent_iff : - Entailment.Inconsistent 𝓢 ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ ∼Γ) := + Entailment.Inconsistent 𝔖 ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝔖) ∧ Nonempty (⊢ᴷ ∼Γ) := OneSidedLK.Entailment.inconsistent_iff -def rewrite [𝓢.IsClosed] (b : 𝓢 ⊢! φ) (f : ℕ → SyntacticTerm L) : - 𝓢 ⊢! Rew.rewrite f ▹ φ where +def rewrite [𝔖.IsClosed] (b : 𝔖 ⊢! φ) (f : ℕ → SyntacticTerm L) : + 𝔖 ⊢! Rew.rewrite f ▹ φ where axioms := b.axioms.map (Rew.rewrite f ▹ ·) axioms_mem := by - suffices ∀ ψ ∈ b.axioms, Rew.rewrite f ▹ ψ ∈ 𝓢 by simpa + suffices ∀ ψ ∈ b.axioms, Rew.rewrite f ▹ ψ ∈ 𝔖 by simpa intro ψ hψ exact Schema.IsClosed.closed (Rew.rewrite f) _ (b.axioms_mem ψ hψ) derivation := b.derivation.rewrite f |>.cast @@ -306,7 +310,7 @@ def rewrite [𝓢.IsClosed] (b : 𝓢 ⊢! φ) (f : ℕ → SyntacticTerm L) : (⊥ : Schema L) ⊢ φ ↔ 𝐋𝐊¹ ⊢ φ := OneSidedLK.Entailment.empty_provable_iff_eprovable 𝐋𝐊¹ -end Schema.Proof +end Schema namespace Derivation @@ -355,11 +359,11 @@ lemma nonempty_iff_provable_disj : Nonempty (⊢ᴷ Γ) ↔ 𝐋𝐊¹ ⊢ ⋁Γ end Derivation -namespace Schema.Proof +namespace Schema open Entailment Derivation -lemma iff_context {𝓢 : Schema L} : 𝓢 ⊢ φ ↔ 𝓢 *⊢[𝐋𝐊¹] φ := by +lemma iff_context {𝔖 : Schema L} : 𝔖 ⊢ φ ↔ 𝔖 *⊢[𝐋𝐊¹] φ := by constructor · rintro ⟨d⟩ have : 𝐋𝐊¹ ⊢! ⋀d.axioms ➝ φ := @@ -376,24 +380,24 @@ lemma iff_context {𝓢 : Schema L} : 𝓢 ⊢ φ ↔ 𝓢 *⊢[𝐋𝐊¹] φ : open Classical in noncomputable instance : Entailment.Deduction (Schema L) where - ofInsert {φ ψ 𝓢 b} := - have : insert φ ↑𝓢 *⊢[𝐋𝐊¹] ψ := iff_context.mp ⟨b⟩ - have : ↑𝓢 *⊢[𝐋𝐊¹] φ ➝ ψ := Context.deduct! this + ofInsert {φ ψ 𝔖 b} := + have : insert φ ↑𝔖 *⊢[𝐋𝐊¹] ψ := iff_context.mp ⟨b⟩ + have : ↑𝔖 *⊢[𝐋𝐊¹] φ ➝ ψ := Context.deduct! this (iff_context.mpr this).get - inv {φ ψ 𝓢 b} := - have : ↑(adjoin φ 𝓢) *⊢[𝐋𝐊¹] ψ := Context.deductInv! (iff_context.mp ⟨b⟩) + inv {φ ψ 𝔖 b} := + have : ↑(adjoin φ 𝔖) *⊢[𝐋𝐊¹] ψ := Context.deductInv! (iff_context.mp ⟨b⟩) (iff_context.mpr this).get -end Schema.Proof +end Schema /-! ### Theory -/ -def Schema.theory (𝓢 : Schema L) : Theory L := {σ | 𝓢 ⊢ ↑σ} +def Schema.theory (𝔖 : Schema L) : Theory L := {σ | 𝔖 ⊢ ↑σ} -@[simp] lemma Schema.mem_theory {𝓢 : Schema L} : - σ ∈ 𝓢.theory ↔ 𝓢 ⊢ ↑σ := by simp [Schema.theory] +@[simp] lemma Schema.mem_theory {𝔖 : Schema L} : + σ ∈ 𝔖.theory ↔ 𝔖 ⊢ ↑σ := by simp [Schema.theory] namespace Theory diff --git a/Foundation/FirstOrder/Basic/Semantics/Elementary.lean b/Foundation/FirstOrder/Basic/Semantics/Elementary.lean index a2d46ee4f..4d60fa1fe 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Elementary.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Elementary.lean @@ -84,8 +84,8 @@ protected lemma rel {k} (r : L.Rel k) (v : Fin k → M₁) : s₁.rel r v → s₂.rel r (φ ∘ v) := map_rel φ r v lemma val_term (e : Fin n → M₁) (ε : ξ → M₁) (t : Semiterm L ξ n) : - φ (t.val s₁ e ε) = t.val s₂ (φ ∘ e) (φ ∘ ε) := by - induction t <;> simp [*, Semiterm.val_func, HomClass.func, Function.comp_def] + φ (t.val e ε) = t.val (φ ∘ e) (φ ∘ ε) := by + induction t <;> simp [*, HomClass.func, Function.comp_def] end HomClass @@ -170,18 +170,17 @@ open Structure variable {F : Type*} [FunLike F M₁ M₂] [EmbeddingClass F L M₁ M₂] (Θ : F) variable {e₁ : Fin n → M₁} {ε₁ : ξ → M₁} + omit [Nonempty M₁] [Nonempty M₂] -lemma eval_hom_iff_of_open {n} {e₁ : Fin n → M₁} {ε₁ : ξ → M₁} : {φ : Semiformula L ξ n} → φ.Open → - (Eval s₁ e₁ ε₁ φ ↔ Eval s₂ (Θ ∘ e₁) (Θ ∘ ε₁) φ) - | ⊤, _ => by simp - | ⊥, _ => by simp - | rel r v, _ => by simp [Function.comp_def, eval_rel, ←EmbeddingClass.rel Θ, HomClass.val_term] - | nrel r v, _ => by simp [Function.comp_def, eval_nrel, ←EmbeddingClass.rel Θ, HomClass.val_term] - | φ ⋏ ψ, h => by simp at h ⊢; simp [eval_hom_iff_of_open h.1, eval_hom_iff_of_open h.2] - | φ ⋎ ψ, h => by simp at h ⊢; simp [eval_hom_iff_of_open h.1, eval_hom_iff_of_open h.2] +lemma eval_hom_iff_of_open {n} {e₁ : Fin n → M₁} {ε₁ : ξ → M₁} {φ : Semiformula L ξ n} (h : φ.Open) : + φ.Eval e₁ ε₁ ↔ φ.Eval (Θ ∘ e₁) (Θ ∘ ε₁) := + match φ with + | rel r v | nrel r v => by simp [Function.comp_def, ←EmbeddingClass.rel Θ, HomClass.val_term] + | ⊤ | ⊥ => by simp + | φ ⋏ ψ | φ ⋎ ψ => by simp at h ⊢; simp [eval_hom_iff_of_open h.1, eval_hom_iff_of_open h.2] lemma eval_hom_allClosure {n} {ε₁ : ξ → M₁} {φ : Semiformula L ξ n} (hp : φ.Open) : - Evalf s₂ (Θ ∘ ε₁) (∀⁰* φ) → Evalf s₁ ε₁ (∀⁰* φ) := by + (∀⁰* φ).Evalf (Θ ∘ ε₁) → (∀⁰* φ).Evalf ε₁ := by simp only [eval_allClosure] intro h e₁; exact (eval_hom_iff_of_open Θ hp).mpr (h (Θ ∘ e₁)) @@ -200,7 +199,7 @@ namespace Structure variable (L M₁ M₂) class ElementaryEquiv : Prop where - models {φ : Sentence L} : M₁ ⊧ₘ φ ↔ M₂ ⊧ₘ φ + models {φ : Sentence L} : M₁↓[L] ⊧ φ ↔ M₂↓[L] ⊧ φ notation:50 M₁ " ≡ₑ[" L "] " M₂ => ElementaryEquiv L M₁ M₂ @@ -216,12 +215,12 @@ namespace ElementaryEquiv fun h₁ h₂ ↦ ⟨Iff.trans h₁.models h₂.models⟩ lemma modelsTheory [h : M₁ ≡ₑ[L] M₂] {T : Theory L} : - M₁ ⊧ₘ* T ↔ M₂ ⊧ₘ* T := by simp [modelsTheory_iff, h.models] + M₁↓[L] ⊧* T ↔ M₂↓[L] ⊧* T := by simp [models_theory_iff, h.models] variable (M₁ M₂) -lemma modelsTheory' [M₁ ≡ₑ[L] M₂] (T : Theory L) [M₂ ⊧ₘ* T] : - M₁ ⊧ₘ* T := modelsTheory.mpr (inferInstanceAs (M₂ ⊧ₘ* T)) +lemma modelsTheory' [M₁ ≡ₑ[L] M₂] (T : Theory L) [M₂↓[L] ⊧* T] : + M₁↓[L] ⊧* T := modelsTheory.mpr (inferInstanceAs (M₂↓[L] ⊧* T)) variable {M₁ M₂} @@ -237,14 +236,14 @@ lemma val_eq_of_equiv {f₁ f₂ b₁ b₂} (hf : ∀ x, I (f₁ x) = f₂ x) (hb : ∀ x, I (b₁ x) = b₂ x) (hfunc : ∀ {k} (f : L.Func k) {v₁ : Fin k → M₁} {v₂ : Fin k → M₂}, (∀ i, I (v₁ i) = v₂ i) → I (s₁.func f v₁) = s₂.func f v₂) (t : Semiterm L ξ n) : - I (t.val s₁ b₁ f₁) = t.val s₂ b₂ f₂ := + I (t.val b₁ f₁) = t.val b₂ f₂ := match t with | #x => by simp [hb] | &x => by simp [hf] | .func f v => by - have ih : ∀ i, I (Semiterm.val s₁ b₁ f₁ (v i)) = Semiterm.val s₂ b₂ f₂ (v i) := fun i ↦ + have ih : ∀ i, I ((v i).val b₁ f₁) = (v i).val b₂ f₂ := fun i ↦ val_eq_of_equiv I hf hb hfunc (v i) - simp [Semiterm.val_func, hfunc, ih] + simp [hfunc, ih, Function.comp_def] omit [Nonempty M₁] [Nonempty M₂] in lemma eval_iff_of_equiv {f₁ f₂ b₁ b₂} @@ -253,14 +252,12 @@ lemma eval_iff_of_equiv {f₁ f₂ b₁ b₂} (hrel : ∀ {k} (R : L.Rel k) {v₁ : Fin k → M₁} {v₂ : Fin k → M₂}, (∀ i, I (v₁ i) = v₂ i) → (s₁.rel R v₁ ↔ s₂.rel R v₂)) (hfunc : ∀ {k} (f : L.Func k) {v₁ : Fin k → M₁} {v₂ : Fin k → M₂}, (∀ i, I (v₁ i) = v₂ i) → I (s₁.func f v₁) = s₂.func f v₂) (φ : Semiformula L ξ n) : - Semiformula.Eval s₁ b₁ f₁ φ ↔ Semiformula.Eval s₂ b₂ f₂ φ := + φ.Eval b₁ f₁ ↔ φ.Eval b₂ f₂ := match φ with | .rel R v => by - simpa [Semiformula.eval_rel] - using hrel R fun i ↦ val_eq_of_equiv I hf hb hfunc (v i) + simpa using hrel R fun i ↦ val_eq_of_equiv I hf hb hfunc (v i) | .nrel R v => by - simpa [Semiformula.eval_nrel] - using not_congr <| hrel R fun i ↦ val_eq_of_equiv I hf hb hfunc (v i) + simpa using not_congr <| hrel R fun i ↦ val_eq_of_equiv I hf hb hfunc (v i) | ⊤ => by simp | ⊥ => by simp | φ ⋏ ψ => by @@ -269,32 +266,32 @@ lemma eval_iff_of_equiv {f₁ f₂ b₁ b₂} simp [eval_iff_of_equiv I hf hb hrel hfunc φ, eval_iff_of_equiv I hf hb hrel hfunc ψ] | ∀⁰ φ => by suffices - (∀ x₁ : M₁, φ.Eval s₁ (x₁ :> b₁) f₁) ↔ (∀ x₂ : M₂, φ.Eval s₂ (x₂ :> b₂) f₂) by simpa + (∀ x₁ : M₁, φ.Eval (x₁ :> b₁) f₁) ↔ (∀ x₂ : M₂, φ.Eval (x₂ :> b₂) f₂) by simpa constructor · intro h x₂ - have : φ.Eval s₁ (I.symm x₂ :> b₁) f₁ ↔ φ.Eval s₂ (x₂ :> b₂) f₂ := + have : φ.Eval (I.symm x₂ :> b₁) f₁ ↔ φ.Eval (x₂ :> b₂) f₂ := eval_iff_of_equiv I (b₁ := I.symm x₂ :> b₁) (b₂ := x₂ :> b₂) hf (by intro i; cases i using Fin.cases <;> simp [hb]) hrel hfunc φ exact this.mp (h (I.symm x₂)) · intro h x₁ - have : φ.Eval s₁ (x₁ :> b₁) f₁ ↔ φ.Eval s₂ (I x₁ :> b₂) f₂ := + have : φ.Eval (x₁ :> b₁) f₁ ↔ φ.Eval (I x₁ :> b₂) f₂ := eval_iff_of_equiv I (b₁ := x₁ :> b₁) (b₂ := I x₁ :> b₂) hf (by intro i; cases i using Fin.cases <;> simp [hb]) hrel hfunc φ exact this.mpr (h _) | ∃⁰ φ => by suffices - (∃ x₁, φ.Eval s₁ (x₁ :> b₁) f₁) ↔ (∃ x₂, φ.Eval s₂ (x₂ :> b₂) f₂) by simpa + (∃ x₁, φ.Eval (x₁ :> b₁) f₁) ↔ (∃ x₂, φ.Eval (x₂ :> b₂) f₂) by simpa constructor · rintro ⟨x₁, h⟩ - have : φ.Eval s₁ (x₁ :> b₁) f₁ ↔ φ.Eval s₂ (I x₁ :> b₂) f₂ := + have : φ.Eval (x₁ :> b₁) f₁ ↔ φ.Eval (I x₁ :> b₂) f₂ := eval_iff_of_equiv I (b₁ := x₁ :> b₁) (b₂ := I x₁ :> b₂) hf (by intro i; cases i using Fin.cases <;> simp [hb]) hrel hfunc φ exact ⟨I x₁, this.mp h⟩ · rintro ⟨x₂, h⟩ - have : φ.Eval s₁ (I.symm x₂ :> b₁) f₁ ↔ φ.Eval s₂ (x₂ :> b₂) f₂ := + have : φ.Eval (I.symm x₂ :> b₁) f₁ ↔ φ.Eval (x₂ :> b₂) f₂ := eval_iff_of_equiv I (b₁ := I.symm x₂ :> b₁) (b₂ := x₂ :> b₂) hf (by intro i; cases i using Fin.cases <;> simp [hb]) hrel hfunc φ diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index df972639b..a89bc3894 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -514,6 +514,8 @@ abbrev Satisfiable (T : Theory L) : Prop := Semantics.Satisfiable (SmallStruc L) variable {M} +lemma struc_models_iff_models {s : Struc L} : s ⊧ σ ↔ s.Dom↓[L] ⊧ σ := by rfl + lemma models_iff : M↓[L] ⊧ σ ↔ M ⊧/![] σ := by rfl lemma models_iff_proposition {φ : Proposition L} : M↓[L] ⊧ φ.univCl ↔ ∀ f : ℕ → M, φ.Evalf f := by diff --git a/Foundation/FirstOrder/Basic/Soundness.lean b/Foundation/FirstOrder/Basic/Soundness.lean index b9ad881c5..60fdf825a 100644 --- a/Foundation/FirstOrder/Basic/Soundness.lean +++ b/Foundation/FirstOrder/Basic/Soundness.lean @@ -12,55 +12,51 @@ namespace FirstOrder section sound open Semiformula -variable {L : Language} {T : Theory L} +variable {L : Language} namespace Derivation -lemma sound (M : Type*) [s : Structure L M] [Nonempty M] [M ⊧ₘ* T] (ε : ℕ → M) {Γ : Sequent L} : - (T : Schema L) ⟹ Γ → ∃ φ ∈ Γ, Evalfm M ε φ - | axm (φ := φ) h => ⟨φ, by simp, by - have : ∃ σ ∈ T, ↑σ = φ := by simpa [Theory.toSchema] using h - rcases this with ⟨σ, hσ, rfl⟩ - simpa using Theory.models M T hσ⟩ - | axL r v => by - by_cases h : s.rel r (Semiterm.valm M ![] ε ∘ v) +lemma sound {M : Type*} [s : Structure L M] [Nonempty M] (f : ℕ → M) {Γ : Sequent L} : + ⊢ᴷ Γ → ∃ φ ∈ Γ, φ.Evalf f + | identity r v => by + by_cases h : s.rel r (Semiterm.val ![] f ∘ v) · exact ⟨rel r v, by simp, h⟩ · exact ⟨nrel r v, by simp, h⟩ | verum => ⟨⊤, by simp⟩ | or (Γ := Γ) (φ := φ) (ψ := ψ) d => by - have : Evalfm M ε φ ∨ Evalfm M ε ψ ∨ ∃ ψ ∈ Γ, Evalfm M ε ψ := by simpa using sound M ε d + have : Evalf f φ ∨ Evalf f ψ ∨ ∃ ψ ∈ Γ, Evalf f ψ := by simpa using sound f d rcases this with (hp | hq | ⟨r, hr, hhr⟩) · exact ⟨φ ⋎ ψ, by simp, by simp [hp]⟩ · exact ⟨φ ⋎ ψ, by simp, by simp [hq]⟩ · exact ⟨r, by simp [hr], hhr⟩ | and (Γ := Γ) (φ := φ) (ψ := ψ) dp dq => by - have : Evalfm M ε φ ∨ ∃ r ∈ Γ, Evalfm M ε r := by simpa using sound M ε dp + have : Evalf f φ ∨ ∃ r ∈ Γ, Evalf f r := by simpa using sound f dp rcases this with (hp | ⟨r, hr, hhr⟩) - · have : Evalfm M ε ψ ∨ ∃ r ∈ Γ, Evalfm M ε r := by simpa using sound M ε dq + · have : Evalf f ψ ∨ ∃ r ∈ Γ, Evalf f r := by simpa using sound f dq rcases this with (hq | ⟨r, hr, hhr⟩) · exact ⟨φ ⋏ ψ, by simp, by simp [hp, hq]⟩ · exact ⟨r, by simp [hr], hhr⟩ · exact ⟨r, by simp [hr], hhr⟩ | all (Γ := Γ) (φ := φ) d => by - have : (∀ a : M, Evalm M ![a] ε φ) ∨ ∃ ψ ∈ Γ, Evalfm M ε ψ := by + have : (∀ a : M, Eval ![a] f φ) ∨ ∃ ψ ∈ Γ, Evalf f ψ := by simpa [Rewriting.shifts, Matrix.vecConsLast_vecEmpty, forall_or_right] - using fun a : M => sound M (a :>ₙ ε) d + using fun a : M => sound (a :>ₙ f) d rcases this with (hp | ⟨ψ, hq, hhq⟩) · exact ⟨∀⁰ φ, by simp, hp⟩ · exact ⟨ψ, by simp [hq], hhq⟩ - | exs (Γ := Γ) (φ := φ) t d => by - have : Evalm M ![t.valm M ![] ε] ε φ ∨ ∃ φ ∈ Γ, Evalfm M ε φ := by - simpa [eval_substs, Matrix.constant_eq_singleton] using sound M ε d + | exs (Γ := Γ) (φ := φ) (t := t) d => by + have : Eval ![t.val ![] f] f φ ∨ ∃ φ ∈ Γ, Evalf f φ := by + simpa [eval_substs, Matrix.constant_eq_singleton] using sound f d rcases this with (hp | ⟨ψ, hq, hhq⟩) - · exact ⟨∃⁰ φ, by simp, t.valm M ![] ε, hp⟩ + · exact ⟨∃⁰ φ, by simp, t.val ![] f, hp⟩ · exact ⟨ψ, by simp [hq], hhq⟩ | wk (Δ := Δ) (Γ := Γ) d ss => by - have : ∃ φ ∈ Δ, Evalfm M ε φ := sound M ε d + have : ∃ φ ∈ Δ, Evalf f φ := sound f d rcases this with ⟨φ, hp, h⟩ exact ⟨φ, ss hp, h⟩ - | cut (Γ := Γ) (φ := φ) d dn => by - have h : Evalfm M ε φ ∨ ∃ ψ ∈ Γ, Evalfm M ε ψ := by simpa using sound M ε d - have hn : ¬Evalfm M ε φ ∨ ∃ ψ ∈ Γ, Evalfm M ε ψ := by simpa using sound M ε dn + | cut (Γ := Γ) (Δ := Δ) (φ := φ) d dn => by + have h : Evalf f φ ∨ ∃ ψ ∈ Γ, Evalf f ψ := by simpa using sound f d + have hn : ¬Evalf f φ ∨ ∃ ψ ∈ Δ, Evalf f ψ := by simpa using sound f dn rcases h with (h | ⟨ψ, h, hq⟩) · rcases hn with (hn | ⟨ψ, hn, hq⟩) · contradiction @@ -69,16 +65,32 @@ lemma sound (M : Type*) [s : Structure L M] [Nonempty M] [M ⊧ₘ* T] (ε : ℕ end Derivation -theorem sound : T ⊢! σ → T ⊨[Struc.{v, u} L] σ := fun b s hT ↦ by - have : s.Dom ⊧ₘ* T := hT - have : Inhabited s.Dom := Classical.inhabited_of_nonempty s.nonempty - simpa using Derivation.sound s.Dom default b +theorem Provable.sound {M : Type*} [s : Structure L M] [Nonempty M] {φ : Proposition L} (f : ℕ → M) : + 𝐋𝐊¹ ⊢ φ → φ.Evalf f := fun b ↦ by simpa using Derivation.sound f b.get -theorem sound! : T ⊢ σ → T ⊨[Struc.{v, u} L] σ := fun ⟨b⟩ ↦ sound b +variable {𝔖 : Schema L} -theorem smallSound : T ⊢! σ → T ⊨ σ := sound +theorem Schema.sound_proposition {M : Type*} [s : Structure L M] [Nonempty M] : + 𝔖 ⊢ φ → M↓[L] ⊧* 𝔖 → ∀ f : ℕ → M, φ.Evalf f := fun b H f ↦ by + rcases Schema.provable_iff.mp b with ⟨Γ, hΓ, ⟨b⟩⟩ + have : φ.Evalf f ∨ ∃ ψ, ∼ψ ∈ Γ ∧ ψ.Evalf f := by simpa using b.sound f + rcases this with (h | ⟨ψ, hψ, h⟩) + · assumption + · have : ¬ψ.Evalf f := by + have := by simpa [models_iff] using H.models _ (φ := (∼ψ).univCl) (by grind only [Schema.mem_uniClosure]) + exact this f + contradiction -theorem smallSound! : T ⊢ σ → T ⊨ σ := sound! +theorem Schema.sound_proposition' : + 𝔖 ⊢ φ → (𝔖 : Theory L) ⊨[Struc.{v, u} L] φ.univCl := fun b s hS ↦ by + simpa [struc_models_iff_models (s := s), models_iff] + using Schema.sound_proposition b hS + +theorem Schema.sound_sentence {σ : Sentence L} : + 𝔖 ⊢ ↑σ → (𝔖 : Theory L) ⊨[Struc.{v, u} L] σ := fun b ↦ by + simpa using Schema.sound_proposition' b + +theorem Schema.smallSound_sentence (σ : Sentence L) : 𝔖 ⊢ ↑σ → (𝔖 : Theory L) ⊨ σ := Schema.sound_sentence instance (T : Theory L) : Sound T (Semantics.models (Struc.{v, u} L) T) := ⟨sound!⟩ @@ -95,7 +107,7 @@ lemma consistent_of_model (T : Theory L) (M : Type*) [s : Structure L M] [Nonemp lemma unprovable_of_countermodel {M : Type*} [s : Structure L M] [Nonempty M] [hM : M ⊧ₘ* T] {σ} (c : ¬M ⊧ₘ σ) : T ⊬ σ := by - apply Sound.not_provable_of_countermodel (𝓜 := Semantics.models (Struc L) T) (𝓢 := T) + apply Sound.not_provable_of_countermodel (𝓜 := Semantics.models (Struc L) T) (𝔖 := T) intro h exact c (h hM) From 7c5be668d3db7a70a52d87e2a75323a573de79f0 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 19 Mar 2026 07:49:39 +0900 Subject: [PATCH 13/61] pullback --- Foundation/Logic/Entailment.lean | 41 +++++++++++++++++++++++++++++++ Foundation/Logic/LogicSymbol.lean | 2 +- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/Foundation/Logic/Entailment.lean b/Foundation/Logic/Entailment.lean index 31d9c9e9f..da9363873 100644 --- a/Foundation/Logic/Entailment.lean +++ b/Foundation/Logic/Entailment.lean @@ -587,6 +587,47 @@ end Complete end +namespace Entailment + +variable (S : Type*) {F : Type*} [Entailment S F] + +structure Pullback (f : G → F) : Type _ where + forget : S + +variable {S} + +abbrev pullback (𝓢 : S) (f : G → F) : Pullback S f := ⟨𝓢⟩ + +instance (f : G → F) : Entailment (Pullback S f) G where + Prf := fun 𝓢 φ ↦ 𝓢.forget ⊢! f φ + +namespace Pullback + +section basics + +variable {f : G → F} + +omit [Entailment S F] in +@[simp] lemma pullback_forget (𝓢 : S) : (pullback 𝓢 f).forget = 𝓢 := rfl + +@[simp] lemma provable_iff {𝓢 : S} {φ : G} : pullback 𝓢 f ⊢ φ ↔ 𝓢 ⊢ f φ := by rfl + +@[simp] lemma unprovable_iff {𝓢 : S} {φ : G} : pullback 𝓢 f ⊬ φ ↔ 𝓢 ⊬ f φ := by rfl + +@[simp] lemma provableSet_iff {𝓢 : S} {s : Set G} : pullback 𝓢 f ⊢* s ↔ 𝓢 ⊢* f '' s := by + simp [ProvableSet] + +@[simp] lemma theory_eq (𝓢 : S) : theory (pullback 𝓢 f) = f ⁻¹' theory 𝓢 := rfl + +lemma weakerThan (𝓢 𝓣 : S) (h : 𝓢 ⪯ 𝓣) : pullback 𝓢 f ⪯ pullback 𝓣 f := by + simp_all [Entailment.weakerThan_iff, provable_iff] + +end basics + +end Pullback + +end Entailment + end LO end diff --git a/Foundation/Logic/LogicSymbol.lean b/Foundation/Logic/LogicSymbol.lean index 6ac11cfa4..f5d6075f2 100644 --- a/Foundation/Logic/LogicSymbol.lean +++ b/Foundation/Logic/LogicSymbol.lean @@ -98,7 +98,7 @@ instance : NegInvolutive Prop where class HomClass (F : Type*) (α β : outParam Type*) [LogicalConnective α] [LogicalConnective β] [FunLike F α β] where map_top : ∀ (f : F), f ⊤ = ⊤ map_bot : ∀ (f : F), f ⊥ = ⊥ - map_neg : ∀ (f : F) (φ : α), f (∼ φ) = ∼f φ + map_neg : ∀ (f : F) (φ : α), f (∼φ) = ∼f φ map_imply : ∀ (f : F) (φ ψ : α), f (φ ➝ ψ) = f φ ➝ f ψ map_and : ∀ (f : F) (φ ψ : α), f (φ ⋏ ψ) = f φ ⋏ f ψ map_or : ∀ (f : F) (φ ψ : α), f (φ ⋎ ψ) = f φ ⋎ f ψ From a37b17c1bdb9132ad612136fbdb3405b2a149e62 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 19 Mar 2026 09:26:35 +0900 Subject: [PATCH 14/61] soundness --- Foundation/FirstOrder/Basic/Soundness.lean | 35 ++++++++++--------- .../FirstOrder/Basic/Syntax/Schema.lean | 1 + Foundation/Logic/Entailment.lean | 12 +++++-- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Soundness.lean b/Foundation/FirstOrder/Basic/Soundness.lean index 60fdf825a..7edff4384 100644 --- a/Foundation/FirstOrder/Basic/Soundness.lean +++ b/Foundation/FirstOrder/Basic/Soundness.lean @@ -90,29 +90,30 @@ theorem Schema.sound_sentence {σ : Sentence L} : 𝔖 ⊢ ↑σ → (𝔖 : Theory L) ⊨[Struc.{v, u} L] σ := fun b ↦ by simpa using Schema.sound_proposition' b -theorem Schema.smallSound_sentence (σ : Sentence L) : 𝔖 ⊢ ↑σ → (𝔖 : Theory L) ⊨ σ := Schema.sound_sentence +theorem Schema.smallSound_sentence {σ : Sentence L} : 𝔖 ⊢ ↑σ → (𝔖 : Theory L) ⊨ σ := Schema.sound_sentence -instance (T : Theory L) : Sound T (Semantics.models (Struc.{v, u} L) T) := ⟨sound!⟩ +instance sound (𝔖 : Schema L) : + Sound (Entailment.pullback 𝔖 ((↑·) : Sentence L → Proposition L)) (Semantics.models (Struc.{v, u} L) 𝔖) := + ⟨Schema.sound_sentence⟩ -lemma models_of_subtheory {T U : Theory L} [U ⪯ T] {M : Type*} [Structure L M] [Nonempty M] (hM : M ⊧ₘ* T) : M ⊧ₘ* U := - ⟨ fun {φ} hp ↦ by - have : T ⊢ φ := (inferInstanceAs (U ⪯ T)).pbl (Entailment.by_axm _ hp) - exact sound! this hM ⟩ +lemma models_of_subtheory {𝔖 𝔗 : Schema L} [𝔖 ⪯ 𝔗] {M : Type*} [Structure L M] [Nonempty M] : M↓[L] ⊧* 𝔗 → M↓[L] ⊧* 𝔖 := + fun hM ↦ ⟨ fun {σ} hσ ↦ by + rcases show ∃ φ ∈ 𝔖, univCl φ = σ by simpa using hσ with ⟨φ, hφ, rfl⟩ + have : 𝔗 ⊢ φ := (inferInstanceAs (𝔖 ⪯ 𝔗)).pbl (Entailment.by_axm hφ) + exact Schema.sound_proposition' this hM ⟩ -lemma consistent_of_satisfiable (h : Semantics.Satisfiable (Struc.{v, u} L) T) : Entailment.Consistent T := - Sound.consistent_of_satisfiable h +lemma consistent_of_satisfiable (h : Semantics.Satisfiable (Struc.{v, u} L) 𝔖) : Entailment.Consistent 𝔖 := + Entailment.Pullback.consistent <| Sound.consistent_of_satisfiable (𝓢 := Entailment.pullback 𝔖 ((↑·) : Sentence L → Proposition L)) h -lemma consistent_of_model (T : Theory L) (M : Type*) [s : Structure L M] [Nonempty M] [hM : M ⊧ₘ* T] : - Entailment.Consistent T := consistent_of_satisfiable ⟨s.toStruc, hM⟩ +lemma consistent_of_model (𝔖 : Schema L) (M : Type*) [Structure L M] [Nonempty M] [hM : M↓[L] ⊧* 𝔖] : + Entailment.Consistent 𝔖 := consistent_of_satisfiable ⟨M↓[L], hM⟩ -lemma unprovable_of_countermodel {M : Type*} [s : Structure L M] [Nonempty M] [hM : M ⊧ₘ* T] - {σ} (c : ¬M ⊧ₘ σ) : T ⊬ σ := by - apply Sound.not_provable_of_countermodel (𝓜 := Semantics.models (Struc L) T) (𝔖 := T) - intro h - exact c (h hM) +lemma unprovable_of_countermodel {M : Type*} [Structure L M] [Nonempty M] [hM : M↓[L] ⊧* 𝔖] {σ} : M↓[L] ⊭ σ → 𝔖 ⊬ ↑σ := by + contrapose!; intro h + exact Schema.sound_sentence h hM -lemma models_of_provable {M : Type*} [Nonempty M] [Structure L M] (hT : M ⊧ₘ* T) (h : T ⊢ σ) : - M ⊧ₘ σ := consequence_iff.mp (sound! h) M inferInstance +lemma models_of_provable {M : Type*} [Nonempty M] [Structure L M] (hT : M↓[L] ⊧* 𝔖) {σ : Sentence L} (h : 𝔖 ⊢ ↑σ) : + M↓[L] ⊧ σ := consequence_iff.mp (Schema.sound_sentence h) M inferInstance end sound diff --git a/Foundation/FirstOrder/Basic/Syntax/Schema.lean b/Foundation/FirstOrder/Basic/Syntax/Schema.lean index 2e7e60af6..92c423c60 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Schema.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Schema.lean @@ -17,6 +17,7 @@ structure Schema (L : Language) where Mem : Proposition L → Prop abbrev Theory (L : Language) := Set (Sentence L) + namespace Schema variable {L : Language} diff --git a/Foundation/Logic/Entailment.lean b/Foundation/Logic/Entailment.lean index da9363873..7a177bb11 100644 --- a/Foundation/Logic/Entailment.lean +++ b/Foundation/Logic/Entailment.lean @@ -241,13 +241,13 @@ lemma inconsistent_iff_theory_eq {𝓢 : S} : Inconsistent 𝓢 ↔ theory 𝓢 = Set.univ := by simp [Inconsistent, Set.ext_iff, theory] -lemma not_inconsistent_iff_consistent {𝓢 : S} : +@[simp] lemma not_inconsistent_iff_consistent {𝓢 : S} : ¬Inconsistent 𝓢 ↔ Consistent 𝓢 := ⟨fun h ↦ ⟨h⟩, by rintro ⟨h⟩; exact h⟩ alias ⟨_, Consistent.not_inc⟩ := not_inconsistent_iff_consistent -lemma not_consistent_iff_inconsistent {𝓢 : S} : +@[simp] lemma not_consistent_iff_inconsistent {𝓢 : S} : ¬Consistent 𝓢 ↔ Inconsistent 𝓢 := by simp [←not_inconsistent_iff_consistent] alias ⟨_, Inconsistent.not_con⟩ := not_consistent_iff_inconsistent @@ -620,7 +620,13 @@ omit [Entailment S F] in @[simp] lemma theory_eq (𝓢 : S) : theory (pullback 𝓢 f) = f ⁻¹' theory 𝓢 := rfl lemma weakerThan (𝓢 𝓣 : S) (h : 𝓢 ⪯ 𝓣) : pullback 𝓢 f ⪯ pullback 𝓣 f := by - simp_all [Entailment.weakerThan_iff, provable_iff] + simp_all [Entailment.weakerThan_iff] + +lemma inconsistent {𝓢 : S} : Inconsistent 𝓢 → Inconsistent (pullback 𝓢 f) := by + simp_all [Inconsistent] + +lemma consistent {𝓢 : S} : Consistent (pullback 𝓢 f) → Consistent 𝓢 := by + contrapose; simpa using inconsistent end basics From 05bb81b9503046ae7e2ce11a531e40a5baf11aca Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 28 Mar 2026 01:36:45 +0900 Subject: [PATCH 15/61] add --- .../FirstOrder/Basic/BinderNotation.lean | 110 +++---- Foundation/FirstOrder/Basic/Calculus.lean | 13 +- Foundation/FirstOrder/Basic/Coding.lean | 3 +- Foundation/FirstOrder/Basic/Eq.lean | 277 ++++++++---------- Foundation/FirstOrder/Basic/Model.lean | 74 +++-- Foundation/FirstOrder/Basic/Operator.lean | 153 ++++------ .../FirstOrder/Basic/Semantics/Semantics.lean | 241 +++++++-------- Foundation/FirstOrder/Basic/Soundness.lean | 4 +- .../FirstOrder/Basic/Syntax/Formula.lean | 28 +- Foundation/FirstOrder/Basic/Syntax/Rew.lean | 15 +- Foundation/Logic/LogicSymbol.lean | 4 +- Foundation/Vorspiel/Finset/Basic.lean | 9 + Foundation/Vorspiel/Matrix.lean | 33 ++- 13 files changed, 440 insertions(+), 524 deletions(-) diff --git a/Foundation/FirstOrder/Basic/BinderNotation.lean b/Foundation/FirstOrder/Basic/BinderNotation.lean index aa8141fca..7c7b87fd5 100644 --- a/Foundation/FirstOrder/Basic/BinderNotation.lean +++ b/Foundation/FirstOrder/Basic/BinderNotation.lean @@ -33,107 +33,107 @@ def nestFormulaeFunc (φ : Semiformula L ξ (n + 1)) (Ψ : Fin n → Semiformula Rewriting.subst φ (#((0 : Fin (m + 1)).addNat n) :> fun i ↦ #(i.addCast m.succ)) ∀⁰^[n] σ -variable {M : Type*} [s : Structure L M] +variable {M : Type*} [s : Structure L M] {f : ξ → M} lemma eval_nestFormulae {φ : Semiformula L ξ n} {Ψ : Fin n → Semiformula L ξ (m + 1)} : - Eval s e ε (φ.nestFormulae Ψ) ↔ ∀ v : Fin n → M, (∀ i, Eval s (v i :> e) ε (Ψ i)) → Eval s v ε φ := by - simp [nestFormulae, Matrix.comp_vecCons'] + Eval e f (φ.nestFormulae Ψ) ↔ ∀ v : Fin n → M, (∀ i, Eval (v i :> e) f (Ψ i)) → Eval v f φ := by + simp [nestFormulae, Matrix.comp_vecCons', Function.comp_def] @[simp] lemma eval_nestFormulae₀ {φ : Semiformula L ξ 0} : - Eval s e ε (φ.nestFormulae ![]) ↔ Eval s ![] ε φ := by + Eval e f (φ.nestFormulae ![]) ↔ Eval ![] f φ := by simp [eval_nestFormulae, Matrix.empty_eq] @[simp] lemma eval_nestFormulae₁ {φ : Semiformula L ξ 1} {ψ : Semiformula L ξ (m + 1)} : - Eval s e ε (φ.nestFormulae ![ψ]) ↔ ∀ x : M, Eval s (x :> e) ε ψ → Eval s ![x] ε φ := by + Eval e f (φ.nestFormulae ![ψ]) ↔ ∀ x : M, Eval (x :> e) f ψ → Eval ![x] f φ := by simp [eval_nestFormulae, Matrix.forall_iff, Matrix.empty_eq] @[simp] lemma eval_nestFormulae₂ {φ : Semiformula L ξ 2} {ψ₁ ψ₂ : Semiformula L ξ (m + 1)} : - Eval s e ε (φ.nestFormulae ![ψ₁, ψ₂]) ↔ ∀ x₁, Eval s (x₁ :> e) ε ψ₁ → ∀ x₂, Eval s (x₂ :> e) ε ψ₂ → Eval s ![x₁, x₂] ε φ := by + Eval e f (φ.nestFormulae ![ψ₁, ψ₂]) ↔ ∀ x₁, Eval (x₁ :> e) f ψ₁ → ∀ x₂, Eval (x₂ :> e) f ψ₂ → Eval ![x₁, x₂] f φ := by suffices - (∀ x₁ x₂, Eval s (x₁ :> e) ε ψ₁ → Eval s (x₂ :> e) ε ψ₂ → Eval s ![x₁, x₂] ε φ) ↔ - ∀ x₁, Eval s (x₁ :> e) ε ψ₁ → ∀ x₂, Eval s (x₂ :> e) ε ψ₂ → Eval s ![x₁, x₂] ε φ by + (∀ x₁ x₂, Eval (x₁ :> e) f ψ₁ → Eval (x₂ :> e) f ψ₂ → Eval ![x₁, x₂] f φ) ↔ + ∀ x₁, Eval (x₁ :> e) f ψ₁ → ∀ x₂, Eval (x₂ :> e) f ψ₂ → Eval ![x₁, x₂] f φ by simpa [eval_nestFormulae, Matrix.forall_iff, Matrix.empty_eq, Fin.forall_fin_two] grind @[simp] lemma eval_nestFormulae₃ {φ : Semiformula L ξ 3} {ψ₁ ψ₂ ψ₃ : Semiformula L ξ (m + 1)} : - Eval s e ε (φ.nestFormulae ![ψ₁, ψ₂, ψ₃]) ↔ - ∀ x₁, Eval s (x₁ :> e) ε ψ₁ → ∀ x₂, Eval s (x₂ :> e) ε ψ₂ → ∀ x₃, Eval s (x₃ :> e) ε ψ₃ → Eval s ![x₁, x₂, x₃] ε φ := by + Eval e f (φ.nestFormulae ![ψ₁, ψ₂, ψ₃]) ↔ + ∀ x₁, Eval (x₁ :> e) f ψ₁ → ∀ x₂, Eval (x₂ :> e) f ψ₂ → ∀ x₃, Eval (x₃ :> e) f ψ₃ → Eval ![x₁, x₂, x₃] f φ := by suffices - (∀ x₁ x₂ x₃, Eval s (x₁ :> e) ε ψ₁ → Eval s (x₂ :> e) ε ψ₂ → Eval s (x₃ :> e) ε ψ₃ → Eval s ![x₁, x₂, x₃] ε φ) ↔ - ∀ x₁, Eval s (x₁ :> e) ε ψ₁ → ∀ x₂, Eval s (x₂ :> e) ε ψ₂ → ∀ x₃, Eval s (x₃ :> e) ε ψ₃ → Eval s ![x₁, x₂, x₃] ε φ by + (∀ x₁ x₂ x₃, Eval (x₁ :> e) f ψ₁ → Eval (x₂ :> e) f ψ₂ → Eval (x₃ :> e) f ψ₃ → Eval ![x₁, x₂, x₃] f φ) ↔ + ∀ x₁, Eval (x₁ :> e) f ψ₁ → ∀ x₂, Eval (x₂ :> e) f ψ₂ → ∀ x₃, Eval (x₃ :> e) f ψ₃ → Eval ![x₁, x₂, x₃] f φ by simpa [eval_nestFormulae, Matrix.forall_iff, Matrix.empty_eq, Fin.forall_fin_succ] grind @[simp] lemma eval_nestFormulae₄ {φ : Semiformula L ξ 4} {ψ₁ ψ₂ ψ₃ ψ₄ : Semiformula L ξ (m + 1)} : - Eval s e ε (φ.nestFormulae ![ψ₁, ψ₂, ψ₃, ψ₄]) ↔ - ∀ x₁, Eval s (x₁ :> e) ε ψ₁ → - ∀ x₂, Eval s (x₂ :> e) ε ψ₂ → - ∀ x₃, Eval s (x₃ :> e) ε ψ₃ → - ∀ x₄, Eval s (x₄ :> e) ε ψ₄ → - Eval s ![x₁, x₂, x₃, x₄] ε φ := by + Eval e f (φ.nestFormulae ![ψ₁, ψ₂, ψ₃, ψ₄]) ↔ + ∀ x₁, Eval (x₁ :> e) f ψ₁ → + ∀ x₂, Eval (x₂ :> e) f ψ₂ → + ∀ x₃, Eval (x₃ :> e) f ψ₃ → + ∀ x₄, Eval (x₄ :> e) f ψ₄ → + Eval ![x₁, x₂, x₃, x₄] f φ := by suffices (∀ x₁ x₂ x₃ x₄, - Eval s (x₁ :> e) ε ψ₁ → - Eval s (x₂ :> e) ε ψ₂ → - Eval s (x₃ :> e) ε ψ₃ → - Eval s (x₄ :> e) ε ψ₄ → - Eval s ![x₁, x₂, x₃, x₄] ε φ) ↔ - ( ∀ x₁, Eval s (x₁ :> e) ε ψ₁ → - ∀ x₂, Eval s (x₂ :> e) ε ψ₂ → - ∀ x₃, Eval s (x₃ :> e) ε ψ₃ → - ∀ x₄, Eval s (x₄ :> e) ε ψ₄ → - Eval s ![x₁, x₂, x₃, x₄] ε φ) by + Eval (x₁ :> e) f ψ₁ → + Eval (x₂ :> e) f ψ₂ → + Eval (x₃ :> e) f ψ₃ → + Eval (x₄ :> e) f ψ₄ → + Eval ![x₁, x₂, x₃, x₄] f φ) ↔ + ( ∀ x₁, Eval (x₁ :> e) f ψ₁ → + ∀ x₂, Eval (x₂ :> e) f ψ₂ → + ∀ x₃, Eval (x₃ :> e) f ψ₃ → + ∀ x₄, Eval (x₄ :> e) f ψ₄ → + Eval ![x₁, x₂, x₃, x₄] f φ) by simpa [eval_nestFormulae, Matrix.forall_iff, Matrix.empty_eq, Fin.forall_fin_succ] grind lemma eval_nestFormulaeFunc {φ : Semiformula L ξ (n + 1)} {Ψ : Fin n → Semiformula L ξ (m + 1)} : - Eval s (z :> e) ε (φ.nestFormulaeFunc Ψ) ↔ ∀ v : Fin n → M, (∀ i, Eval s (v i :> e) ε (Ψ i)) → Eval s (z :> v) ε φ := by - simp [nestFormulaeFunc, Matrix.comp_vecCons'] + Eval (z :> e) f (φ.nestFormulaeFunc Ψ) ↔ ∀ v : Fin n → M, (∀ i, Eval (v i :> e) f (Ψ i)) → Eval (z :> v) f φ := by + simp [nestFormulaeFunc, Matrix.comp_vecCons', Function.comp_def] @[simp] lemma eval_nestFormulaeFunc₀ {φ : Semiformula L ξ 1} : - Eval s (z :> e) ε (φ.nestFormulaeFunc ![]) ↔ Eval s ![z] ε φ := by + Eval (z :> e) f (φ.nestFormulaeFunc ![]) ↔ Eval ![z] f φ := by simp [eval_nestFormulaeFunc, Matrix.empty_eq] @[simp] lemma eval_nestFormulaeFunc₁ {φ : Semiformula L ξ 2} {ψ : Semiformula L ξ (m + 1)} : - Eval s (z :> e) ε (φ.nestFormulaeFunc ![ψ]) ↔ ∀ x, Eval s (x :> e) ε ψ → Eval s ![z, x] ε φ := by + Eval (z :> e) f (φ.nestFormulaeFunc ![ψ]) ↔ ∀ x, Eval (x :> e) f ψ → Eval ![z, x] f φ := by simp [eval_nestFormulaeFunc, Matrix.forall_iff, Matrix.empty_eq] @[simp] lemma eval_nestFormulaeFunc₂ {φ : Semiformula L ξ 3} {ψ₁ ψ₂ : Semiformula L ξ (m + 1)} : - Eval s (z :> e) ε (φ.nestFormulaeFunc ![ψ₁, ψ₂]) ↔ ∀ x₁, Eval s (x₁ :> e) ε ψ₁ → ∀ x₂, Eval s (x₂ :> e) ε ψ₂ → Eval s ![z, x₁, x₂] ε φ := by + Eval (z :> e) f (φ.nestFormulaeFunc ![ψ₁, ψ₂]) ↔ ∀ x₁, Eval (x₁ :> e) f ψ₁ → ∀ x₂, Eval (x₂ :> e) f ψ₂ → Eval ![z, x₁, x₂] f φ := by suffices - (∀ x₁ x₂, Eval s (x₁ :> e) ε ψ₁ → Eval s (x₂ :> e) ε ψ₂ → Eval s ![z, x₁, x₂] ε φ) ↔ - ∀ x₁, Eval s (x₁ :> e) ε ψ₁ → ∀ x₂, Eval s (x₂ :> e) ε ψ₂ → Eval s ![z, x₁, x₂] ε φ by + (∀ x₁ x₂, Eval (x₁ :> e) f ψ₁ → Eval (x₂ :> e) f ψ₂ → Eval ![z, x₁, x₂] f φ) ↔ + ∀ x₁, Eval (x₁ :> e) f ψ₁ → ∀ x₂, Eval (x₂ :> e) f ψ₂ → Eval ![z, x₁, x₂] f φ by simpa [eval_nestFormulaeFunc, Matrix.forall_iff, Matrix.empty_eq, Fin.forall_fin_two] grind @[simp] lemma eval_nestFormulaeFunc₃ {φ : Semiformula L ξ 4} {ψ₁ ψ₂ ψ₃ : Semiformula L ξ (m + 1)} : - Eval s (z :> e) ε (φ.nestFormulaeFunc ![ψ₁, ψ₂, ψ₃]) ↔ - ∀ x₁, Eval s (x₁ :> e) ε ψ₁ → ∀ x₂, Eval s (x₂ :> e) ε ψ₂ → ∀ x₃, Eval s (x₃ :> e) ε ψ₃ → Eval s ![z, x₁, x₂, x₃] ε φ := by + Eval (z :> e) f (φ.nestFormulaeFunc ![ψ₁, ψ₂, ψ₃]) ↔ + ∀ x₁, Eval (x₁ :> e) f ψ₁ → ∀ x₂, Eval (x₂ :> e) f ψ₂ → ∀ x₃, Eval (x₃ :> e) f ψ₃ → Eval ![z, x₁, x₂, x₃] f φ := by suffices - (∀ x₁ x₂ x₃, Eval s (x₁ :> e) ε ψ₁ → Eval s (x₂ :> e) ε ψ₂ → Eval s (x₃ :> e) ε ψ₃ → Eval s ![z, x₁, x₂, x₃] ε φ) ↔ - ∀ x₁, Eval s (x₁ :> e) ε ψ₁ → ∀ x₂, Eval s (x₂ :> e) ε ψ₂ → ∀ x₃, Eval s (x₃ :> e) ε ψ₃ → Eval s ![z, x₁, x₂, x₃] ε φ by + (∀ x₁ x₂ x₃, Eval (x₁ :> e) f ψ₁ → Eval (x₂ :> e) f ψ₂ → Eval (x₃ :> e) f ψ₃ → Eval ![z, x₁, x₂, x₃] f φ) ↔ + ∀ x₁, Eval (x₁ :> e) f ψ₁ → ∀ x₂, Eval (x₂ :> e) f ψ₂ → ∀ x₃, Eval (x₃ :> e) f ψ₃ → Eval ![z, x₁, x₂, x₃] f φ by simpa [eval_nestFormulaeFunc, Matrix.forall_iff, Matrix.empty_eq, Fin.forall_fin_succ] grind @[simp] lemma eval_nestFormulaeFunc₄ {φ : Semiformula L ξ 5} {ψ₁ ψ₂ ψ₃ ψ₄ : Semiformula L ξ (m + 1)} : - Eval s (z :> e) ε (φ.nestFormulaeFunc ![ψ₁, ψ₂, ψ₃, ψ₄]) ↔ - ∀ x₁, Eval s (x₁ :> e) ε ψ₁ → - ∀ x₂, Eval s (x₂ :> e) ε ψ₂ → - ∀ x₃, Eval s (x₃ :> e) ε ψ₃ → - ∀ x₄, Eval s (x₄ :> e) ε ψ₄ → - Eval s ![z, x₁, x₂, x₃, x₄] ε φ := by + Eval (z :> e) f (φ.nestFormulaeFunc ![ψ₁, ψ₂, ψ₃, ψ₄]) ↔ + ∀ x₁, Eval (x₁ :> e) f ψ₁ → + ∀ x₂, Eval (x₂ :> e) f ψ₂ → + ∀ x₃, Eval (x₃ :> e) f ψ₃ → + ∀ x₄, Eval (x₄ :> e) f ψ₄ → + Eval ![z, x₁, x₂, x₃, x₄] f φ := by suffices (∀ x₁ x₂ x₃ x₄, - Eval s (x₁ :> e) ε ψ₁ → - Eval s (x₂ :> e) ε ψ₂ → - Eval s (x₃ :> e) ε ψ₃ → - Eval s (x₄ :> e) ε ψ₄ → - Eval s ![z, x₁, x₂, x₃, x₄] ε φ) ↔ - ( ∀ x₁, Eval s (x₁ :> e) ε ψ₁ → - ∀ x₂, Eval s (x₂ :> e) ε ψ₂ → - ∀ x₃, Eval s (x₃ :> e) ε ψ₃ → - ∀ x₄, Eval s (x₄ :> e) ε ψ₄ → - Eval s ![z, x₁, x₂, x₃, x₄] ε φ) by + Eval (x₁ :> e) f ψ₁ → + Eval (x₂ :> e) f ψ₂ → + Eval (x₃ :> e) f ψ₃ → + Eval (x₄ :> e) f ψ₄ → + Eval ![z, x₁, x₂, x₃, x₄] f φ) ↔ + ( ∀ x₁, Eval (x₁ :> e) f ψ₁ → + ∀ x₂, Eval (x₂ :> e) f ψ₂ → + ∀ x₃, Eval (x₃ :> e) f ψ₃ → + ∀ x₄, Eval (x₄ :> e) f ψ₄ → + Eval ![z, x₁, x₂, x₃, x₄] f φ) by simpa [eval_nestFormulaeFunc, Matrix.forall_iff, Matrix.empty_eq, Fin.forall_fin_succ] grind diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index 84e8f1854..f993151c8 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -167,7 +167,7 @@ lemma shifts_image (Φ : L₁ →ᵥ L₂) {Δ : List (Proposition L₁)} : def lMap (Φ : L₁ →ᵥ L₂) {Γ} : ⊢ᴷ Γ → ⊢ᴷ Γ.map (.lMap Φ) | identity r v => .cast (identity (Φ.rel r) (fun i ↦ .lMap Φ (v i))) - (by simp [Semiformula.lMap_rel, Semiformula.lMap_nrel]) + (by simp [Function.comp_def]) | cut (Γ := Γ) (Δ := Δ) (φ := φ) d dn => have : ⊢ᴷ (Γ.map (.lMap Φ) ++ Δ.map (.lMap Φ) : Sequent L₂) := cut (φ := .lMap Φ φ) (Derivation.cast (lMap Φ d) (by simp)) (Derivation.cast (lMap Φ dn) (by simp)) @@ -399,17 +399,6 @@ def Schema.theory (𝔖 : Schema L) : Theory L := {σ | 𝔖 ⊢ ↑σ} @[simp] lemma Schema.mem_theory {𝔖 : Schema L} : σ ∈ 𝔖.theory ↔ 𝔖 ⊢ ↑σ := by simp [Schema.theory] -namespace Theory - -instance : Entailment (Theory L) (Sentence L) where - Prf T σ := PLift (σ ∈ T) - -@[simp] lemma provable_iff (σ : Sentence L) (T : Theory L) : - T ⊢ σ ↔ σ ∈ T := - ⟨fun h ↦ PLift.down h.some, fun h ↦ ⟨⟨h⟩⟩⟩ - -end Theory - end FirstOrder end LO diff --git a/Foundation/FirstOrder/Basic/Coding.lean b/Foundation/FirstOrder/Basic/Coding.lean index d37b86af4..65f1ab62a 100644 --- a/Foundation/FirstOrder/Basic/Coding.lean +++ b/Foundation/FirstOrder/Basic/Coding.lean @@ -189,8 +189,7 @@ lemma encode_ex (φ : Semiformula L ξ (n + 1)) : encode (∃⁰ φ) = (Nat.pair @[simp] lemma encode_emb (σ : Semisentence L n) : encode (Rewriting.emb σ : Semiformula L ξ n) = encode σ := by induction σ using rec' <;> - simp [coe_rel, coe_nrel, - encode_rel, encode_nrel, encode_verum, encode_falsum, encode_and, encode_or, encode_all, encode_ex, + simp [encode_rel, encode_nrel, encode_verum, encode_falsum, encode_and, encode_or, encode_all, encode_ex, ← encode_eq_toNat, *] @[simp] lemma encode_inj_sentence {σ : Semisentence L n} {φ : Semiformula L ξ n} : diff --git a/Foundation/FirstOrder/Basic/Eq.lean b/Foundation/FirstOrder/Basic/Eq.lean index d304a3f0f..76577f521 100644 --- a/Foundation/FirstOrder/Basic/Eq.lean +++ b/Foundation/FirstOrder/Basic/Eq.lean @@ -19,137 +19,121 @@ namespace LO namespace FirstOrder -variable {L : Language} {μ : Type*} [Semiformula.Operator.Eq L] +variable {L : Language} {ξ : Type*} [Semiformula.Operator.Eq L] -namespace Theory +namespace Eq -section Eq +protected abbrev refl (t : Term L ℕ) : Proposition L := op(=).operator ![t, t] -variable (L) +protected abbrev symm (t u : Term L ℕ) : Proposition L := op(=).operator ![t, u] ➝ op(=).operator ![u, t] -abbrev Eq.refl : Sentence L := “∀ x, x = x” +protected abbrev trans (t u v : Term L ℕ) : Proposition L := op(=).operator ![t, u] ➝ op(=).operator ![u, v] ➝ op(=).operator ![t, v] -abbrev Eq.symm : Sentence L := “∀ x y, x = y → y = x” +def funcExt {k} (f : L.Func k) (v w : Fin k → Term L ℕ) : Proposition L := + (Matrix.conj fun i ↦ op(=).operator ![v i, w i]) ➝ op(=).operator ![Semiterm.func f v, Semiterm.func f w] -abbrev Eq.trans : Sentence L := “∀ x y z, x = y → y = z → x = z” +@[simp] lemma rew_funcExt (ω : Rew L ℕ 0 ℕ 0) {k} (f : L.Func k) (v w : Fin k → Term L ℕ) : + ω ▹ funcExt f v w = funcExt f (ω ∘ v) (ω ∘ w) := by + simp [funcExt, Function.comp_def] -variable {L} +def relExt {k} (r : L.Rel k) (v w : Fin k → Term L ℕ) : Proposition L := + (Matrix.conj fun i ↦ op(=).operator ![v i, w i]) ➝ Semiformula.rel r v ➝ Semiformula.rel r w -abbrev Eq.funcExt {k} (f : L.Func k) : Sentence L := - let σ : Semisentence L (k + k) := - (Matrix.conj fun i : Fin k ↦ “#(i.addCast k) = #(i.addNat k)”) ➝ - op(=).operator ![Semiterm.func f (fun i ↦ #(i.addCast k)), Semiterm.func f (fun i ↦ #(i.addNat k))] - ∀⁰* σ - -abbrev Eq.relExt {k} (r : L.Rel k) : Sentence L := - let σ : Semisentence L (k + k) := - (Matrix.conj fun i : Fin k ↦ “#(i.addCast k) = #(i.addNat k)”) ➝ - Semiformula.rel r (fun i ↦ #(i.addCast k)) ➝ Semiformula.rel r (fun i ↦ #(i.addNat k)) - ∀⁰* σ - -inductive eqAxiom : Theory L - | refl : eqAxiom (Eq.refl L) - | symm : eqAxiom (Eq.symm L) - | trans : eqAxiom (Eq.trans L) - | funcExt {k} (f : L.Func k) : eqAxiom (Eq.funcExt f) - | relExt {k} (r : L.Rel k) : eqAxiom (Eq.relExt r) - -notation "𝗘𝗤" => eqAxiom - -lemma Eq.defeq : - 𝗘𝗤 = {Eq.refl L, Eq.symm L, Eq.trans L} - ∪ Set.range (fun f : (k : ℕ) × L.Func k ↦ Eq.funcExt f.2) - ∪ Set.range (fun f : (k : ℕ) × L.Rel k ↦ Eq.relExt f.2) := by - ext φ; constructor - · rintro ⟨⟩ - case refl => simp - case symm => simp - case trans => simp - case funcExt k f => - left; right; exact ⟨⟨k, f⟩, rfl⟩ - case relExt k r => - right; exact ⟨⟨k, r⟩, rfl⟩ - · rintro (((rfl | rfl | rfl) | ⟨f, rfl⟩) | ⟨r, rfl⟩) - · exact eqAxiom.refl - · exact eqAxiom.symm - · exact eqAxiom.trans - · exact eqAxiom.funcExt _ - · exact eqAxiom.relExt _ - -@[simp] lemma EqAxiom.finite [L.Finite] : Set.Finite (𝗘𝗤 : Theory L) := by - haveI : Fintype ((k : ℕ) × L.Func k) := Language.Finite.func - haveI : Fintype ((k : ℕ) × L.Rel k) := Language.Finite.rel - rw [Eq.defeq] - simp [Set.finite_range] +@[simp] lemma rew_relExt (ω : Rew L ℕ 0 ℕ 0) {k} (r : L.Rel k) (v w : Fin k → Term L ℕ) : + ω ▹ relExt r v w = relExt r (ω ∘ v) (ω ∘ w) := by + simp [relExt, Function.comp_def] -end Eq +inductive EqSchema : Proposition L → Prop + | refl (t : Term L ℕ) : EqSchema (Eq.refl t) + | symm (t u : Term L ℕ) : EqSchema (Eq.symm t u) + | trans (t u v : Term L ℕ) : EqSchema (Eq.trans t u v) + | funcExt {k} (f : L.Func k) (v w : Fin k → Term L ℕ) : EqSchema (funcExt f v w) + | relExt {k} (r : L.Rel k) (v w : Fin k → Term L ℕ) : EqSchema (relExt r v w) + +attribute [simp] EqSchema.refl EqSchema.symm EqSchema.trans EqSchema.funcExt EqSchema.relExt + +variable (L) + +abbrev eqSchema : Schema L := ⟨EqSchema⟩ -end Theory +notation "𝗘𝗤" => eqSchema + +instance : Schema.IsClosed (𝗘𝗤 L) := ⟨by rintro ω _ (_ | _ | _ | _ | _) <;> simp⟩ + +end Eq namespace Structure namespace Eq -@[simp] lemma models_eqAxiom {M : Type u} [Nonempty M] [Structure L M] [Structure.Eq L M] : M ⊧ₘ* (𝗘𝗤 : Theory L) := ⟨by - intro σ h - cases h <;> try { simp [models_iff, Semiterm.val_func, Semiformula.eval_rel, *]; try simp_all }⟩ +variable (L) (M : Type*) [Nonempty M] [Structure L M] -variable (L) - -instance models_eqAxiom' (M : Type u) [Nonempty M] [Structure L M] [Structure.Eq L M] : M ⊧ₘ* (𝗘𝗤 : Theory L) := Structure.Eq.models_eqAxiom +@[simp] instance models_eqSchema [Structure.Eq L M] : + M↓[L] ⊧* 𝗘𝗤 L := ⟨by + intro σ h + have : ∃ φ, Eq.EqSchema φ ∧ Semiformula.univCl φ = σ := by simpa using h + rcases this with ⟨φ, (_ | _ | _ | _ | _), rfl⟩ <;> simp [models_iff, Eq.funcExt, Eq.relExt] + · grind + · grind + · simp [Function.comp_def]; grind + · simp [Function.comp_def]; grind⟩ -variable {M : Type u} [Nonempty M] [Structure L M] +variable {M} def eqv (a b : M) : Prop := (@Semiformula.Operator.Eq.eq L _).val ![a, b] variable {L} -variable [H : M ⊧ₘ* (𝗘𝗤 : Theory L)] +variable [H : M↓[L] ⊧* 𝗘𝗤 L] open Semiterm Theory Semiformula lemma eqv_refl (a : M) : eqv L a a := by - have : M ⊧ₘ “∀ x, x = x” := H.models _ (Theory.eqAxiom.refl (L := L)) - have : ∀ x : M, op(=)[L].val ![x, x] := by simpa [models_iff] using this - simpa using this a + have : ∀ f : ℕ → M, op(=)[L].val ![f 0, f 0] := by + simpa [models_iff] using modelsUnivCl_of_mem_schema (M := M) (𝔖 := 𝗘𝗤 L) (Eq.EqSchema.refl &0) + simpa using this fun _ ↦ a lemma eqv_symm {a b : M} : eqv L a b → eqv L b a := by - have : M ⊧ₘ “∀ x y, x = y → y = x” := H.models _ (Theory.eqAxiom.symm (L := L)) - have : ∀ x y : M, op(=)[L].val ![x, y] → op(=)[L].val ![y, x] := by simpa [models_iff] using this - simpa using this a b + have : ∀ f : ℕ → M, op(=)[L].val ![f 0, f 1] → op(=)[L].val ![f 1, f 0] := by + simpa [models_iff] using modelsUnivCl_of_mem_schema (M := M) (𝔖 := 𝗘𝗤 L) (Eq.EqSchema.symm &0 &1) + simpa using this (a :>ₙ fun _ ↦ b) lemma eqv_trans {a b c : M} : eqv L a b → eqv L b c → eqv L a c := by - have : M ⊧ₘ “∀ x y z, x = y → y = z → x = z” := H.models _ (Theory.eqAxiom.trans (L := L)) - have : ∀ x y z : M, op(=)[L].val ![x, y] → op(=)[L].val ![y, z] → op(=)[L].val ![x, z] := by simpa [models_iff] using this - simpa using this a b c - -lemma eqv_funcExt {k} (f : L.Func k) {v w : Fin k → M} (h : ∀ i, eqv L (v i) (w i)) : - eqv L (func f v) (func f w) := by - have : M ⊧ₘ Eq.funcExt f := H.models _ (eqAxiom.funcExt f) - have : - ∀ m : Fin (k + k) → M, - (∀ (i : Fin k), op(=)[L].val ![m (Fin.addCast k i), m (i.addNat k)]) → - op(=)[L].val ![func f fun i ↦ m (Fin.addCast k i), func f fun i ↦ m (i.addNat k)] := by - simpa [models_iff, Semiterm.val_func] using this - have := this (Matrix.vecAppend rfl v w) (fun i ↦ by simpa [Matrix.vecAppend_eq_ite] using h i) - simpa [Semiterm.val_func, Matrix.vecAppend_eq_ite] using this + have : ∀ f : ℕ → M, op(=)[L].val ![f 0, f 1] → op(=)[L].val ![f 1, f 2] → op(=)[L].val ![f 0, f 2] := by + simpa [models_iff] using modelsUnivCl_of_mem_schema (M := M) (𝔖 := 𝗘𝗤 L) (Eq.EqSchema.trans &0 &1 &2) + simpa using this (a :>ₙ b :>ₙ fun _ ↦ c) + +lemma eqv_funcExt {k} (F : L.Func k) {v w : Fin k → M} (h : ∀ i, eqv L (v i) (w i)) : + eqv L (func F v) (func F w) := by + have : ∀ f : ℕ → M, + (∀ i : Fin k, op(=)[L].val ![f i, f (k + i)]) → + op(=)[L].val ![func F fun x ↦ f x, func F fun x ↦ f (k + x)] := by + have := by simpa [models_iff, Eq.funcExt,] using + modelsUnivCl_of_mem_schema (M := M) (𝔖 := 𝗘𝗤 L) (Eq.EqSchema.funcExt F (fun i ↦ &i) (fun j ↦ &(k + j))) + simpa [Function.comp_def] using this + have : (∀ i : Fin k, op(=)[L].val ![v i, w i]) → + op(=)[L].val ![func F fun x ↦ v x, func F fun x ↦ w x] := by + simpa using this <| fun x ↦ if h : x < k then v ⟨x, h⟩ else if h : x < k + k then w ⟨x - k, by grind⟩ else Classical.ofNonempty + exact this h lemma eqv_relExt_aux {k} (r : L.Rel k) {v w : Fin k → M} (h : ∀ i, eqv L (v i) (w i)) : rel r v → rel r w := by - have : M ⊧ₘ Eq.relExt r := H.models _ (eqAxiom.relExt r) - have : - ∀ m : Fin (k + k) → M, - (∀ (i : Fin k), op(=)[L].val ![m (Fin.addCast k i), m (i.addNat k)]) → - (rel r fun i ↦ m (Fin.addCast k i)) → rel r fun i ↦ m (i.addNat k) := by - simpa [models_iff, Semiterm.val_func] using this - have := this (Matrix.vecAppend rfl v w) (fun i ↦ by simpa [Matrix.vecAppend_eq_ite] using h i) - simpa [Semiterm.val_func, Matrix.vecAppend_eq_ite] using this + have : ∀ f : ℕ → M, + (∀ i : Fin k, op(=)[L].val ![f i, f (k + i)]) → + (rel r fun x ↦ f x) → rel r fun x ↦ f (k + x) := by + have := by simpa [models_iff, Eq.relExt] using + modelsUnivCl_of_mem_schema (M := M) (𝔖 := 𝗘𝗤 L) (Eq.EqSchema.relExt r (fun i ↦ &i) (fun j ↦ &(k + j))) + simpa [Function.comp_def] using this + have : (∀ i : Fin k, op(=)[L].val ![v i, w i]) → + (rel r fun x ↦ v x) → rel r fun x ↦ w x := by + simpa using this <| fun x ↦ if h : x < k then v ⟨x, h⟩ else if h : x < k + k then w ⟨x - k, by grind⟩ else Classical.ofNonempty + exact this h lemma eqv_relExt {k} (r : L.Rel k) {v w : Fin k → M} (h : ∀ i, eqv L (v i) (w i)) : rel r v ↔ rel r w := by constructor · exact eqv_relExt_aux r h - · exact eqv_relExt_aux r (fun i => eqv_symm (h i)) + · exact eqv_relExt_aux r fun i ↦ eqv_symm (h i) lemma eqv_equivalence : Equivalence (eqv L (M := M)) where refl := eqv_refl @@ -180,44 +164,30 @@ instance struc : Structure L (QuotEq L M) where func := QuotEq.func rel := QuotEq.Rel -lemma funk_mk {k} (f : L.Func k) (v : Fin k → M) : Structure.func (M := QuotEq L M) f (fun i => ⟦v i⟧) = ⟦Structure.func f v⟧ := +lemma funk_mk {k} (f : L.Func k) (v : Fin k → M) : Structure.func (M := QuotEq L M) f (Quotient.mk _ ∘ v) = ⟦Structure.func f v⟧ := Quotient.liftVec_mk (s := eqvSetoid L M) _ _ _ -lemma rel_mk {k} (r : L.Rel k) (v : Fin k → M) : Structure.rel (M := QuotEq L M) r (fun i => ⟦v i⟧) ↔ Structure.rel r v := +lemma rel_mk {k} (r : L.Rel k) (v : Fin k → M) : Structure.rel (M := QuotEq L M) r (Quotient.mk _ ∘ v) ↔ Structure.rel r v := of_eq <| Quotient.liftVec_mk (s := eqvSetoid L M) _ _ _ -lemma val_mk {e} {ε} (t : Semiterm L μ n) : - Semiterm.valm (QuotEq L M) (fun i ↦ ⟦e i⟧) (fun i ↦ ⟦ε i⟧) t = ⟦Semiterm.valm M e ε t⟧ := - by induction t <;> simp [*, funk_mk, Semiterm.val_func] - -lemma eval_mk {e} {ε} {φ : Semiformula L μ n} : - Semiformula.Evalm (QuotEq L M) (fun i ↦ ⟦e i⟧) (fun i ↦ ⟦ε i⟧) φ ↔ Semiformula.Evalm M e ε φ := by - induction φ using Semiformula.rec' - case hall n φ ih => - constructor - · intro h a; exact (ih (e := a :> e)).mp (by simpa [Matrix.comp_vecCons] using h ⟦a⟧) - · intro h a; - induction' a using Quotient.ind with a - simpa [Matrix.comp_vecCons] using ih.mpr (h a) - case hexs n φ ih => - constructor - · intro ⟨a, h⟩ - induction' a using Quotient.ind with a - exact ⟨a, (ih (e := a :> e)).mp (by simpa [Matrix.comp_vecCons] using h)⟩ - · intro ⟨a, h⟩; exact ⟨⟦a⟧, by simpa [Matrix.comp_vecCons] using ih.mpr h⟩ - case _ => simp [*] - case _ => simp [*] - case _ => simp [*, Semiformula.eval_rel, val_mk, rel_mk] - case _ => simp [*, Semiformula.eval_nrel, val_mk, rel_mk] - case _ => simp [*] - case _ => simp [*] - -lemma eval_mk₀ {ε} {φ : Formula L ξ} : - Semiformula.Evalfm (QuotEq L M) (fun i => ⟦ε i⟧) φ ↔ Semiformula.Evalfm (L := L) M ε φ := by - simpa [Matrix.empty_eq] using eval_mk (H := H) (e := ![]) (ε := ε) (φ := φ) - -lemma models_iff {σ : Sentence L} : QuotEq L M ⊧ₘ σ ↔ M ⊧ₘ σ := by - simpa [Empty.eq_elim] using eval_mk₀ (M := M) (φ := σ) (ε := Empty.elim) +lemma val_mk (e : Fin n → M) (ε : ξ → M) (t : Semiterm L ξ n) : + t.val (M := QuotEq L M) (Quotient.mk _ ∘ e) (Quotient.mk _ ∘ ε) = ⟦t.val e ε⟧ := by + match t with + | #x | &x => simp + | .func F v => + simp [←funk_mk, Function.comp_def (g := v), fun i ↦ val_mk e ε (v i)]; rfl + +lemma eval_mk {e} {ε} {φ : Semiformula L ξ n} : + φ.Eval (M := QuotEq L M) (Quotient.mk _ ∘ e) (Quotient.mk _ ∘ ε) ↔ φ.Eval e ε := by + match φ with + | .rel R v | .nrel R v => simp [←val_mk, ←rel_mk, Function.comp_def] + | ⊤ | ⊥ => simp + | φ ⋏ ψ | φ ⋎ ψ => simp [←eval_mk (φ := φ), ←eval_mk (φ := ψ)] + | ∀⁰ φ => simpa [←eval_mk (φ := φ), Matrix.comp_vecCons'', ] using Quotient.forall + | ∃⁰ φ => simpa [←eval_mk (φ := φ), Matrix.comp_vecCons'', ] using Quotient.exists + +lemma models_iff {σ : Sentence L} : (QuotEq L M)↓[L] ⊧ σ ↔ M↓[L] ⊧ σ := by + simpa [Empty.eq_elim] using eval_mk (M := M) (e := ![]) (ε := Empty.elim) (φ := σ) variable (L M) @@ -225,11 +195,11 @@ lemma elementaryEquiv : QuotEq L M ≡ₑ[L] M := ⟨models_iff⟩ variable {L M} -lemma rel_eq (a b : QuotEq L M) : (@Semiformula.Operator.Eq.eq L _).val (M := QuotEq L M) ![a, b] ↔ a = b := by +lemma rel_eq (a b : QuotEq L M) : op(=)[L].val ![a, b] ↔ a = b := by induction' a using Quotient.ind with a induction' b using Quotient.ind with b - rw [of_eq_of]; simp [eqv, Semiformula.Operator.val]; - simpa [Evalm, Matrix.fun_eq_vec_two, Empty.eq_elim] using + rw [of_eq_of] + simpa [eqv, Semiformula.Operator.val, Empty.eq_elim] using eval_mk (H := H) (e := ![a, b]) (ε := Empty.elim) (φ := Semiformula.Operator.Eq.eq.sentence) instance structureEq : Structure.Eq L (QuotEq L M) := ⟨rel_eq⟩ @@ -240,41 +210,41 @@ end Eq end Structure -lemma consequence_iff_eq {T : Theory L} [𝗘𝗤 ⪯ T] {σ : Sentence L} : - T ⊨[Struc.{v, u} L] σ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [Structure.Eq L M], M ⊧ₘ* T → M ⊧ₘ σ) := by +lemma consequence_iff_eq {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] {σ : Sentence L} : + 𝔖 ⊨[Struc.{v, u} L] σ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [Structure.Eq L M], M↓[L] ⊧* 𝔖 → M↓[L] ⊧ σ) := by simp only [consequence_iff, Nonempty.forall] constructor · intro h M x s _ hM; exact h M x hM · intro h M x s hM - haveI : Nonempty M := ⟨x⟩ - have H : M ⊧ₘ* (𝗘𝗤 : Theory L) := models_of_subtheory hM + have : Nonempty M := ⟨x⟩ + have H : M↓[L] ⊧* 𝗘𝗤 L := models_of_subtheory hM have e : Structure.Eq.QuotEq L M ≡ₑ[L] M := Structure.Eq.QuotEq.elementaryEquiv L M - exact e.models.mp $ h (Structure.Eq.QuotEq L M) ⟦x⟧ (e.modelsTheory.mpr hM) + exact e.models.mp <| h (Structure.Eq.QuotEq L M) ⟦x⟧ (e.modelsTheory.mpr hM) -lemma consequence_iff_eq' {T : Theory L} [𝗘𝗤 ⪯ T] {σ : Sentence L} : - T ⊨[Struc.{v, u} L] σ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [Structure.Eq L M] [M ⊧ₘ* T], M ⊧ₘ σ) := by +lemma consequence_iff_eq' {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] {σ : Sentence L} : + 𝔖 ⊨[Struc.{v, u} L] σ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [Structure.Eq L M] [M↓[L] ⊧* 𝔖], M↓[L] ⊧ σ) := by rw [consequence_iff_eq] -lemma satisfiable_iff_eq {T : Theory L} [𝗘𝗤 ⪯ T] : - Semantics.Satisfiable (Struc.{v, u} L) T ↔ (∃ (M : Type v) (_ : Nonempty M) (_ : Structure L M) (_ : Structure.Eq L M), M ⊧ₘ* T) := by +lemma satisfiable_iff_eq {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] : + Semantics.Satisfiable (Struc.{v, u} L) 𝔖 ↔ (∃ (M : Type v) (_ : Nonempty M) (_ : Structure L M) (_ : Structure.Eq L M), M↓[L] ⊧* 𝔖) := by simp only [satisfiable_iff, Nonempty.exists, exists_prop] constructor · intro ⟨M, x, s, hM⟩; - haveI : Nonempty M := ⟨x⟩ - have H : M ⊧ₘ* (𝗘𝗤 : Theory L) := models_of_subtheory hM + have : Nonempty M := ⟨x⟩ + have H : M↓[L] ⊧* 𝗘𝗤 L := models_of_subtheory hM have e : Structure.Eq.QuotEq L M ≡ₑ[L] M := Structure.Eq.QuotEq.elementaryEquiv L M exact ⟨Structure.Eq.QuotEq L M, ⟦x⟧, inferInstance, inferInstance, e.modelsTheory.mpr hM⟩ · intro ⟨M, i, s, _, hM⟩; exact ⟨M, i, s, hM⟩ -instance {T : Theory L} [𝗘𝗤 ⪯ T] (sat : Semantics.Satisfiable (Struc.{v, u} L) T) : - ModelOfSat sat ⊧ₘ* (𝗘𝗤 : Theory L) := models_of_subtheory (ModelOfSat.models sat) +instance {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] (sat : Semantics.Satisfiable (Struc.{v, u} L) 𝔖) : + (ModelOfSat sat)↓[L] ⊧* 𝗘𝗤 L := models_of_subtheory (ModelOfSat.models sat) -def ModelOfSatEq {T : Theory L} [𝗘𝗤 ⪯ T] (sat : Semantics.Satisfiable (Struc.{v, u} L) T) : Type _ := +def ModelOfSatEq {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] (sat : Semantics.Satisfiable (Struc.{v, u} L) 𝔖) : Type _ := Structure.Eq.QuotEq L (ModelOfSat sat) namespace ModelOfSatEq -variable {T : Theory L} [𝗘𝗤 ⪯ T] (sat : Semantics.Satisfiable (Struc.{v, u} L) T) +variable {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] (sat : Semantics.Satisfiable (Struc.{v, u} L) 𝔖) noncomputable instance : Nonempty (ModelOfSatEq sat) := Structure.Eq.QuotEq.inhabited @@ -282,11 +252,11 @@ noncomputable instance struc : Structure L (ModelOfSatEq sat) := Structure.Eq.Qu noncomputable instance : Structure.Eq L (ModelOfSatEq sat) := Structure.Eq.QuotEq.structureEq -lemma models : ModelOfSatEq sat ⊧ₘ* T := +lemma models : (ModelOfSatEq sat)↓[L] ⊧* 𝔖 := have e : ModelOfSatEq sat ≡ₑ[L] ModelOfSat sat := Structure.Eq.QuotEq.elementaryEquiv L (ModelOfSat sat) e.modelsTheory.mpr (ModelOfSat.models _) -instance mod : ModelOfSatEq sat ⊧ₘ* T := models sat +instance mod : (ModelOfSatEq sat)↓[L] ⊧* 𝔖 := models sat open Semiterm Semiformula @@ -301,22 +271,22 @@ instance [Operator.One L] : Structure.One L (ModelOfSatEq sat) := ⟨rfl⟩ noncomputable instance [Operator.Add L] : Add (ModelOfSatEq sat) := ⟨fun x y => (@Operator.Add.add L _).val ![x, y]⟩ -instance [Operator.Add L] : Structure.Add L (ModelOfSatEq sat) := ⟨fun _ _ => rfl⟩ +instance [Operator.Add L] : Structure.Add L (ModelOfSatEq sat) := ⟨fun _ _ ↦ rfl⟩ noncomputable instance [Operator.Mul L] : Mul (ModelOfSatEq sat) := ⟨fun x y => (@Operator.Mul.mul L _).val ![x, y]⟩ -instance [Operator.Mul L] : Structure.Mul L (ModelOfSatEq sat) := ⟨fun _ _ => rfl⟩ +instance [Operator.Mul L] : Structure.Mul L (ModelOfSatEq sat) := ⟨fun _ _ ↦ rfl⟩ instance [Operator.LT L] : LT (ModelOfSatEq sat) := ⟨fun x y => (@Operator.LT.lt L _).val ![x, y]⟩ -instance [Operator.LT L] : Structure.LT L (ModelOfSatEq sat) := ⟨fun _ _ => iff_of_eq rfl⟩ +instance [Operator.LT L] : Structure.LT L (ModelOfSatEq sat) := ⟨fun _ _ ↦ iff_of_eq rfl⟩ instance [Operator.Mem L] : Membership (ModelOfSatEq sat) (ModelOfSatEq sat) := ⟨fun x y => (@Operator.Mem.mem L _).val ![y, x]⟩ -instance [Operator.Mem L] : Structure.Mem L (ModelOfSatEq sat) := ⟨fun _ _ => iff_of_eq rfl⟩ +instance [Operator.Mem L] : Structure.Mem L (ModelOfSatEq sat) := ⟨fun _ _ ↦ iff_of_eq rfl⟩ end ModelOfSatEq @@ -330,8 +300,9 @@ prefix:64 "∃⁰! " => existsUnique variable {M : Type*} [s : Structure L M] [Structure.Eq L M] @[simp] lemma eval_existsUnique {e ε} {φ : Semiformula L ξ (n + 1)} : - Eval s e ε (∃⁰! φ) ↔ ∃! x, Eval s (x :> e) ε φ := by - simp [existsUnique, Semiformula.eval_substs, Matrix.comp_vecCons', ExistsUnique] + Eval e ε (∃⁰! φ) ↔ ∃! x : M, Eval (x :> e) ε φ := by + simp [existsUnique, Semiformula.eval_substs, Matrix.comp_vecCons'', ExistsUnique] + simp [Function.comp_def] end Semiformula diff --git a/Foundation/FirstOrder/Basic/Model.lean b/Foundation/FirstOrder/Basic/Model.lean index 3f7f20d8e..94267cedf 100644 --- a/Foundation/FirstOrder/Basic/Model.lean +++ b/Foundation/FirstOrder/Basic/Model.lean @@ -114,27 +114,23 @@ variable {L₁ L₂ M} @[simp] lemma rel_sigma_inr {k} (r : L₂.Rel k) (v : Fin k → M) : (add L₁ L₂ M).rel (Sum.inr r) v ↔ rel r v := iff_of_eq rfl -@[simp] lemma val_lMap_add₁ {n} (t : Semiterm L₁ μ n) (e : Fin n → M) (ε : μ → M) : - Semiterm.val (add L₁ L₂ M) e ε (t.lMap (Language.Hom.add₁ L₁ L₂)) = t.val str₁ e ε := by - induction t <;> simp [Semiterm.lMap_func, Semiterm.val, Language.Hom.func_add₁, *] +@[simp] lemma val_lMap_add₁ {n} (t : Semiterm L₁ μ n) (e : Fin n → M) (f : μ → M) : + Semiterm.val (s := add L₁ L₂ M) e f (t.lMap (Language.Hom.add₁ L₁ L₂)) = t.val (s := str₁) e f := by + induction t <;> simp [Language.Hom.func_add₁, Function.comp_def, *] -@[simp] lemma val_lMap_add₂ {n} (t : Semiterm L₂ μ n) (e : Fin n → M) (ε : μ → M) : - Semiterm.val (add L₁ L₂ M) e ε (t.lMap (Language.Hom.add₂ L₁ L₂)) = t.val str₂ e ε := by - induction t <;> simp [Semiterm.lMap_func, Semiterm.val, Language.Hom.func_add₂, *] +@[simp] lemma val_lMap_add₂ {n} (t : Semiterm L₂ μ n) (e : Fin n → M) (f : μ → M) : + Semiterm.val (s := add L₁ L₂ M) e f (t.lMap (Language.Hom.add₂ L₁ L₂)) = t.val (s := str₂) e f := by + induction t <;> simp [Language.Hom.func_add₂, Function.comp_def, *] -@[simp] lemma eval_lMap_add₁ {n} (φ : Semiformula L₁ μ n) (e : Fin n → M) (ε : μ → M) : - Semiformula.Eval (add L₁ L₂ M) e ε (Semiformula.lMap (Language.Hom.add₁ L₁ L₂) φ) - ↔ Semiformula.Eval str₁ e ε φ := by - induction φ using Semiformula.rec' <;> - simp [*, Language.Hom.rel_add₁, Semiformula.eval_rel, - Semiformula.lMap_rel, Semiformula.eval_nrel, Semiformula.lMap_nrel] +@[simp] lemma eval_lMap_add₁ {n} (φ : Semiformula L₁ μ n) (e : Fin n → M) (f : μ → M) : + Semiformula.Eval (s := add L₁ L₂ M) e f (Semiformula.lMap (Language.Hom.add₁ L₁ L₂) φ) + ↔ Semiformula.Eval (s := str₁) e f φ := by + induction φ using Semiformula.rec' <;> simp [*, Language.Hom.rel_add₁, Function.comp_def] -@[simp] lemma eval_lMap_add₂ {n} (φ : Semiformula L₂ μ n) (e : Fin n → M) (ε : μ → M) : - Semiformula.Eval (add L₁ L₂ M) e ε (Semiformula.lMap (Language.Hom.add₂ L₁ L₂) φ) - ↔ Semiformula.Eval str₂ e ε φ := by - induction φ using Semiformula.rec' <;> - simp [*, Language.Hom.rel_add₂, Semiformula.eval_rel, - Semiformula.lMap_rel, Semiformula.eval_nrel, Semiformula.lMap_nrel] +@[simp] lemma eval_lMap_add₂ {n} (φ : Semiformula L₂ μ n) (e : Fin n → M) (f : μ → M) : + Semiformula.Eval (s := add L₁ L₂ M) e f (Semiformula.lMap (Language.Hom.add₂ L₁ L₂) φ) + ↔ Semiformula.Eval (s := str₂) e f φ := by + induction φ using Semiformula.rec' <;> simp [*, Language.Hom.rel_add₂, Function.comp_def] end add @@ -143,23 +139,21 @@ section sigma variable (L : ι → Language) (M : Type*) [str : (i : ι) → Structure (L i) M] instance sigma : Structure (Language.sigma L) M where - func := fun _ ⟨_, f⟩ v => func f v - rel := fun _ ⟨_, r⟩ v => rel r v + func := fun _ ⟨_, f⟩ v ↦ func f v + rel := fun _ ⟨_, r⟩ v ↦ rel r v @[simp] lemma func_sigma {k} (f : (L i).Func k) (v : Fin k → M) : (sigma L M).func ⟨i, f⟩ v = func f v := rfl @[simp] lemma rel_sigma {k} (r : (L i).Rel k) (v : Fin k → M) : (sigma L M).rel ⟨i, r⟩ v ↔ rel r v := iff_of_eq rfl -@[simp] lemma val_lMap_sigma {n} (t : Semiterm (L i) μ n) (e : Fin n → M) (ε : μ → M) : - Semiterm.val (sigma L M) e ε (t.lMap (Language.Hom.sigma L i)) = t.val (str i) e ε := by - induction t <;> simp [Semiterm.lMap_func, Semiterm.val, Language.Hom.func_sigma, *] +@[simp] lemma val_lMap_sigma {n} (t : Semiterm (L i) μ n) (e : Fin n → M) (f : μ → M) : + Semiterm.val (s := sigma L M) e f (t.lMap (Language.Hom.sigma L i)) = t.val (s := str i) e f := by + induction t <;> simp [*, Language.Hom.func_sigma, Function.comp_def] -@[simp] lemma eval_lMap_sigma {n} (φ : Semiformula (L i) μ n) (e : Fin n → M) (ε : μ → M) : - Semiformula.Eval (sigma L M) e ε (Semiformula.lMap (Language.Hom.sigma L i) φ) - ↔ Semiformula.Eval (str i) e ε φ := by - induction φ using Semiformula.rec' <;> - simp [*, Language.Hom.rel_sigma, Semiformula.eval_rel, - Semiformula.lMap_rel, Semiformula.eval_nrel, Semiformula.lMap_nrel] +@[simp] lemma eval_lMap_sigma {n} (φ : Semiformula (L i) μ n) (e : Fin n → M) (f : μ → M) : + Semiformula.Eval (s := sigma L M) e f (Semiformula.lMap (Language.Hom.sigma L i) φ) + ↔ Semiformula.Eval (s := str i) e f φ := by + induction φ using Semiformula.rec' <;> simp [*, Language.Hom.rel_sigma, Function.comp_def] end sigma @@ -170,28 +164,28 @@ section ULift variable {L : Language.{u}} {M : Type v} [Structure L M] instance : Structure L (ULift.{v'} M) where - func := fun _ f v ↦ ⟨Structure.func f fun i ↦ (v i).down⟩ - rel := fun _ r v ↦ Structure.rel r fun i ↦ (v i).down + func _ f v := ⟨Structure.func f (ULift.down ∘ v)⟩ + rel _ r v := Structure.rel r (ULift.down ∘ v) @[simp] lemma Structure.func_uLift {k} (f : L.Func k) (v : Fin k → ULift.{v'} M) : - Structure.func f v = ⟨Structure.func f fun i ↦ (v i).down⟩ := rfl + Structure.func f v = ⟨Structure.func f (ULift.down ∘ v)⟩ := rfl @[simp] lemma Structure.rel_uLift {k} (r : L.Rel k) (v : Fin k → ULift.{v'} M) : - Structure.rel r v = Structure.rel r fun i ↦ (v i).down := rfl + Structure.rel r v = Structure.rel r (ULift.down ∘ v) := rfl -lemma Semiterm.valm_uLift {e : Fin n → ULift.{v'} M} {ε : ξ → ULift.{v'} M} {t : Semiterm L ξ n} : - Semiterm.valm (ULift.{v'} M) e ε t = ⟨Semiterm.valm M (fun i ↦ (e i).down) (fun i ↦ (ε i).down) t⟩ := by - induction t <;> simp [*, Semiterm.val_func] +lemma Semiterm.val_uLift {e : Fin n → ULift.{v'} M} {f : ξ → ULift.{v'} M} {t : Semiterm L ξ n} : + Semiterm.val e f t = ⟨Semiterm.val (ULift.down ∘ e) (ULift.down ∘ f) t⟩ := by + induction t <;> simp [*, Function.comp_def] -lemma Semiformula.evalm_uLift {e : Fin n → ULift.{v'} M} {ε : ξ → ULift.{v'} M} {φ : Semiformula L ξ n} : - Semiformula.Evalm (ULift.{v'} M) e ε φ ↔ Semiformula.Evalm M (fun i ↦ (e i).down) (fun i ↦ (ε i).down) φ := by +lemma Semiformula.eval_uLift {e : Fin n → ULift.{v'} M} {f : ξ → ULift.{v'} M} {φ : Semiformula L ξ n} : + Semiformula.Eval e f φ ↔ Semiformula.Eval (ULift.down ∘ e) (ULift.down ∘ f) φ := by induction φ using Semiformula.rec' <;> - simp [*, Semiformula.eval_rel, Semiformula.eval_nrel, Semiterm.valm_uLift, Matrix.comp_vecCons'] + simp [*, Semiterm.val_uLift, Matrix.comp_vecCons', Function.comp_def] variable (L M) lemma uLift_elementaryEquiv [Nonempty M] : ULift.{v'} M ≡ₑ[L] M := ⟨by - intro σ; simp [models_iff, Semiformula.evalm_uLift, Matrix.empty_eq, Empty.eq_elim]⟩ + intro σ; simp [models_iff, Semiformula.eval_uLift, Matrix.empty_eq, Empty.eq_elim]⟩ end ULift diff --git a/Foundation/FirstOrder/Basic/Operator.lean b/Foundation/FirstOrder/Basic/Operator.lean index 3b8ed180e..3ce5a9f81 100644 --- a/Foundation/FirstOrder/Basic/Operator.lean +++ b/Foundation/FirstOrder/Basic/Operator.lean @@ -252,33 +252,21 @@ end complexity section semantics -def Operator.val {M : Type w} [s : Structure L M] (o : Operator L k) (v : Fin k → M) : M := - Semiterm.val s v Empty.elim o.term +def Operator.val {M : Type w} [s : Structure L M] (v : Fin k → M) (o : Operator L k) : M := + Semiterm.val v Empty.elim o.term variable {M : Type w} {s : Structure L M} -lemma val_operator {k} (o : Operator L k) (v) : - val s e ε (o.operator v) = o.val (fun x => (v x).val s e ε) := by +@[simp] lemma val_operator {k} (b : Fin n → M) (f : ξ → M) (o : Operator L k) (v : Fin k → Semiterm L ξ n) : + val b f (o.operator v) = o.val (Semiterm.val b f ∘ v) := by simp [Operator.operator, val_substs, Empty.eq_elim]; congr -@[simp] lemma val_const (o : Const L) : - val s e ε o.const = o.val ![] := by - simp [Operator.const, val_operator, Matrix.empty_eq] - -@[simp] lemma val_operator₀ (o : Const L) : - val s e ε (o.operator v) = o.val ![] := by - simp [val_operator, Matrix.empty_eq] - -@[simp] lemma val_operator₁ (o : Operator L 1) : - val s e ε (o.operator ![t]) = o.val ![t.val s e ε] := by - simp [val_operator, Matrix.fun_eq_vec_one] - -@[simp] lemma val_operator₂ (o : Operator L 2) (t u) : - val s e ε (o.operator ![t, u]) = o.val ![t.val s e ε, u.val s e ε] := - by simp [val_operator, Matrix.fun_eq_vec_two] +lemma val_operator' {k} (b : Fin k → M) (f : ξ → M) (o : Operator L k) (v) : + val b f (o.operator v) = o.val fun i ↦ (v i).val b f := val_operator b f o v lemma Operator.val_comp (o₁ : Operator L k) (o₂ : Fin k → Operator L m) (v : Fin m → M) : - (o₁.comp o₂).val v = o₁.val (fun i => (o₂ i).val v) := by simp [comp, val, val_operator] + (o₁.comp o₂).val v = o₁.val (val v ∘ o₂) := by + simp [comp, val, Function.comp_def] @[simp] lemma Operator.val_bvar {n} (x : Fin n) (v : Fin n → M) : (Operator.bvar (L := L) x).val v = v x := by simp [Operator.bvar, Operator.val] @@ -390,17 +378,20 @@ lemma LE.def_of_Eq_of_LT [Operator.Eq L] [Operator.LT L] : lemma lt_def [L.LT] (t u : Semiterm L ξ n) : - LT.lt.operator ![t, u] = Semiformula.rel Language.LT.lt ![t, u] := by simp [operator, LT.sentence_eq, rew_rel] + LT.lt.operator ![t, u] = Semiformula.rel Language.LT.lt ![t, u] := by + simp [operator, LT.sentence_eq, Matrix.fun_eq_vec_two'] lemma eq_def [L.Eq] (t u : Semiterm L ξ n) : - Eq.eq.operator ![t, u] = Semiformula.rel Language.Eq.eq ![t, u] := by simp [operator, Eq.sentence_eq, rew_rel] + Eq.eq.operator ![t, u] = Semiformula.rel Language.Eq.eq ![t, u] := by + simp [operator, Eq.sentence_eq, Matrix.fun_eq_vec_two'] lemma mem_def [L.Mem] (t u : Semiterm L ξ n) : - Mem.mem.operator ![t, u] = Semiformula.rel Language.Mem.mem ![t, u] := by simp [operator, Mem.sentence_eq, rew_rel] + Mem.mem.operator ![t, u] = Semiformula.rel Language.Mem.mem ![t, u] := by + simp [operator, Mem.sentence_eq, Matrix.fun_eq_vec_two'] lemma le_def [L.Eq] [L.LT] (t u : Semiterm L ξ n) : LE.le.operator ![t, u] = Semiformula.rel Language.Eq.eq ![t, u] ⋎ Semiformula.rel Language.LT.lt ![t, u] := by - simp [operator, Eq.sentence_eq, LT.sentence_eq, LE.sentence_eq, rew_rel] + simp [operator, Eq.sentence_eq, LT.sentence_eq, LE.sentence_eq, Matrix.fun_eq_vec_two'] variable {L : Language} @@ -415,8 +406,8 @@ variable {L : Language} end Operator -def Operator.val {M : Type w} [s : Structure L M] {k} (o : Operator L k) (v : Fin k → M) : Prop := - Semiformula.Eval s v Empty.elim o.sentence +def Operator.val {M : Type w} [s : Structure L M] {k} (v : Fin k → M) (o : Operator L k) : Prop := + Semiformula.Eval v Empty.elim o.sentence section @@ -428,30 +419,10 @@ variable {M : Type w} {s : Structure L M} @[simp] lemma val_operator_or {k} {o₁ o₂ : Operator L k} {v : Fin k → M} : (o₁.or o₂).val v ↔ o₁.val v ∨ o₂.val v := by simp [Operator.or, Operator.val] -lemma eval_operator {k} {o : Operator L k} {v : Fin k → Semiterm L ξ n} : - Eval s e ε (o.operator v) ↔ o.val (fun i => (v i).val s e ε) := by +@[simp] lemma eval_operator {k} {o : Operator L k} {e : Fin n → M} {f : ξ → M} {v : Fin k → Semiterm L ξ n} : + Eval e f (o.operator v) ↔ o.val (Semiterm.val e f ∘ v) := by simp [Operator.operator, eval_substs, Operator.val] -@[simp] lemma eval_operator_zero {o : Const L} {v} : - Eval s e ε (o.operator v) ↔ o.val (M := M) ![] := by - simp [eval_operator, Matrix.empty_eq] - -@[simp] lemma eval_operator_one {o : Operator L 1} {t : Semiterm L ξ n} : - Eval s e ε (o.operator ![t]) ↔ o.val ![t.val s e ε] := by - simp [eval_operator, Matrix.constant_eq_singleton] - -@[simp] lemma eval_operator_two {o : Operator L 2} {t₁ t₂ : Semiterm L ξ n} : - Eval s e ε (o.operator ![t₁, t₂]) ↔ o.val ![t₁.val s e ε, t₂.val s e ε] := by - simp [eval_operator, Matrix.fun_eq_vec_two] - -@[simp] lemma eval_operator_three {o : Operator L 3} {t₁ t₂ t₃ : Semiterm L ξ n} : - Eval s e ε (o.operator ![t₁, t₂, t₃]) ↔ o.val ![t₁.val s e ε, t₂.val s e ε, t₃.val s e ε] := by - simp [eval_operator, Matrix.fun_eq_vec_three] - -@[simp] lemma eval_operator_four {o : Operator L 4} {t₁ t₂ t₃ t₄ : Semiterm L ξ n} : - Eval s e ε (o.operator ![t₁, t₂, t₃, t₄]) ↔ o.val ![t₁.val s e ε, t₂.val s e ε, t₃.val s e ε, t₄.val s e ε] := by - simp [eval_operator, Matrix.fun_eq_vec_four] - end def ballLT [Operator.LT L] (t : Semiterm L ξ n) (φ : Semiformula L ξ (n + 1)) : Semiformula L ξ n := ∀⁰[Operator.LT.lt.operator ![#0, Rew.bShift t]] φ @@ -533,20 +504,20 @@ lemma eq_equal_iff [L.Eq] {φ : Semiformula L ξ₁ n₁} {t u : Semiterm L ξ match φ with | .rel (arity := k') r' v => by_cases hk : k' = 2 - case neg => simp [rew_rel, Operator.operator, Operator.Eq.sentence_eq, hk] + case neg => simp [Operator.operator, Operator.Eq.sentence_eq, hk] rcases hk by_cases hr : r' = Language.Eq.eq - case neg => simp [rew_rel, Operator.operator, Operator.Eq.sentence_eq, hr] + case neg => simp [Operator.operator, Operator.Eq.sentence_eq, hr] rcases hr - simp [rew_rel, Operator.operator, Operator.Eq.sentence_eq, + simp [Operator.operator, Operator.Eq.sentence_eq, funext_iff, Fin.forall_fin_iff_zero_and_forall_succ] - | .nrel _ _ => simp [rew_rel, rew_nrel, Operator.operator, Operator.Eq.sentence_eq] - | ⊤ => simp [rew_rel, Operator.operator, Operator.Eq.sentence_eq] - | ⊥ => simp [rew_rel, Operator.operator, Operator.Eq.sentence_eq] - | _ ⋏ _ => simp [rew_rel, Operator.operator, Operator.Eq.sentence_eq] - | _ ⋎ _ => simp [rew_rel, Operator.operator, Operator.Eq.sentence_eq] - | ∀⁰ _ => simp [rew_rel, Operator.operator, Operator.Eq.sentence_eq] - | ∃⁰ _ => simp [rew_rel, Operator.operator, Operator.Eq.sentence_eq] + | .nrel _ _ => simp [Operator.operator, Operator.Eq.sentence_eq] + | ⊤ => simp [Operator.operator, Operator.Eq.sentence_eq] + | ⊥ => simp [Operator.operator, Operator.Eq.sentence_eq] + | _ ⋏ _ => simp [Operator.operator, Operator.Eq.sentence_eq] + | _ ⋎ _ => simp [Operator.operator, Operator.Eq.sentence_eq] + | ∀⁰ _ => simp [Operator.operator, Operator.Eq.sentence_eq] + | ∃⁰ _ => simp [Operator.operator, Operator.Eq.sentence_eq] lemma eq_lt_iff [L.LT] {φ : Semiformula L ξ₁ n₁} {t u : Semiterm L ξ₂ n₂} : ω ▹ φ = Operator.LT.lt.operator ![t, u] @@ -554,20 +525,20 @@ lemma eq_lt_iff [L.LT] {φ : Semiformula L ξ₁ n₁} {t u : Semiterm L ξ₂ n match φ with | .rel (arity := k') r' v => by_cases hk : k' = 2 - case neg => simp [rew_rel, Operator.operator, Operator.LT.sentence_eq, hk] + case neg => simp [Operator.operator, Operator.LT.sentence_eq, hk] rcases hk by_cases hr : r' = Language.LT.lt - case neg => simp [rew_rel, Operator.operator, Operator.LT.sentence_eq, hr] + case neg => simp [Operator.operator, Operator.LT.sentence_eq, hr] rcases hr - simp [rew_rel, Operator.operator, Operator.LT.sentence_eq, + simp [Operator.operator, Operator.LT.sentence_eq, funext_iff, Fin.forall_fin_iff_zero_and_forall_succ] - | .nrel _ _ => simp [rew_rel, rew_nrel, Operator.operator, Operator.LT.sentence_eq] - | ⊤ => simp [rew_rel, Operator.operator, Operator.LT.sentence_eq] - | ⊥ => simp [rew_rel, Operator.operator, Operator.LT.sentence_eq] - | _ ⋏ _ => simp [rew_rel, Operator.operator, Operator.LT.sentence_eq] - | _ ⋎ _ => simp [rew_rel, Operator.operator, Operator.LT.sentence_eq] - | ∀⁰ _ => simp [rew_rel, Operator.operator, Operator.LT.sentence_eq] - | ∃⁰ _ => simp [rew_rel, Operator.operator, Operator.LT.sentence_eq] + | .nrel _ _ => simp [Operator.operator, Operator.LT.sentence_eq] + | ⊤ => simp [Operator.operator, Operator.LT.sentence_eq] + | ⊥ => simp [Operator.operator, Operator.LT.sentence_eq] + | _ ⋏ _ => simp [Operator.operator, Operator.LT.sentence_eq] + | _ ⋎ _ => simp [Operator.operator, Operator.LT.sentence_eq] + | ∀⁰ _ => simp [Operator.operator, Operator.LT.sentence_eq] + | ∃⁰ _ => simp [Operator.operator, Operator.LT.sentence_eq] lemma eq_mem_iff [L.Mem] {φ : Semiformula L ξ₁ n₁} {t u : Semiterm L ξ₂ n₂} : ω ▹ φ = Operator.Mem.mem.operator ![t, u] @@ -575,20 +546,20 @@ lemma eq_mem_iff [L.Mem] {φ : Semiformula L ξ₁ n₁} {t u : Semiterm L ξ₂ match φ with | .rel (arity := k') r' v => by_cases hk : k' = 2 - case neg => simp [rew_rel, Operator.operator, Operator.Mem.sentence_eq, hk] + case neg => simp [Operator.operator, Operator.Mem.sentence_eq, hk] rcases hk by_cases hr : r' = Language.Mem.mem - case neg => simp [rew_rel, Operator.operator, Operator.Mem.sentence_eq, hr] + case neg => simp [Operator.operator, Operator.Mem.sentence_eq, hr] rcases hr - simp [rew_rel, Operator.operator, Operator.Mem.sentence_eq, + simp [Operator.operator, Operator.Mem.sentence_eq, funext_iff, Fin.forall_fin_iff_zero_and_forall_succ] - | .nrel _ _ => simp [rew_rel, rew_nrel, Operator.operator, Operator.Mem.sentence_eq] - | ⊤ => simp [rew_rel, Operator.operator, Operator.Mem.sentence_eq] - | ⊥ => simp [rew_rel, Operator.operator, Operator.Mem.sentence_eq] - | _ ⋏ _ => simp [rew_rel, Operator.operator, Operator.Mem.sentence_eq] - | _ ⋎ _ => simp [rew_rel, Operator.operator, Operator.Mem.sentence_eq] - | ∀⁰ _ => simp [rew_rel, Operator.operator, Operator.Mem.sentence_eq] - | ∃⁰ _ => simp [rew_rel, Operator.operator, Operator.Mem.sentence_eq] + | .nrel _ _ => simp [Operator.operator, Operator.Mem.sentence_eq] + | ⊤ => simp [Operator.operator, Operator.Mem.sentence_eq] + | ⊥ => simp [Operator.operator, Operator.Mem.sentence_eq] + | _ ⋏ _ => simp [Operator.operator, Operator.Mem.sentence_eq] + | _ ⋎ _ => simp [Operator.operator, Operator.Mem.sentence_eq] + | ∀⁰ _ => simp [Operator.operator, Operator.Mem.sentence_eq] + | ∃⁰ _ => simp [Operator.operator, Operator.Mem.sentence_eq] end Rew @@ -686,25 +657,25 @@ namespace Semiformula variable {M : Type*} {s : Structure L M} -variable {t : Semiterm L ξ n} {φ : Semiformula L ξ (n + 1)} +variable {e : Fin n → M} {f : ξ → M} {t : Semiterm L ξ n} {φ : Semiformula L ξ (n + 1)} -@[simp] lemma eval_ballLT [Operator.LT L] [LT M] [Structure.LT L M] {e ε} : - Eval s e ε (φ.ballLT t) ↔ ∀ x < t.val s e ε, Eval s (x :> e) ε φ := by simp [ballLT] +@[simp] lemma eval_ballLT [Operator.LT L] [LT M] [Structure.LT L M] : + (φ.ballLT t).Eval e f ↔ ∀ x < t.val e f, φ.Eval (x :> e) f := by simp [ballLT] -@[simp] lemma eval_bexsLT [Operator.LT L] [LT M] [Structure.LT L M] {e ε} : - Eval s e ε (φ.bexsLT t) ↔ ∃ x < t.val s e ε, Eval s (x :> e) ε φ := by simp [bexsLT] +@[simp] lemma eval_bexsLT [Operator.LT L] [LT M] [Structure.LT L M] : + (φ.bexsLT t).Eval e f ↔ ∃ x < t.val e f, φ.Eval (x :> e) f := by simp [bexsLT] -@[simp] lemma eval_ballLE [Operator.LE L] [LE M] [Structure.LE L M] {e ε} : - Eval s e ε (φ.ballLE t) ↔ ∀ x ≤ t.val s e ε, Eval s (x :> e) ε φ := by simp [ballLE] +@[simp] lemma eval_ballLE [Operator.LE L] [LE M] [Structure.LE L M] : + (φ.ballLE t).Eval e f ↔ ∀ x ≤ t.val e f, φ.Eval (x :> e) f := by simp [ballLE] -@[simp] lemma eval_bexsLE [Operator.LE L] [LE M] [Structure.LE L M] {e ε} : - Eval s e ε (φ.bexsLE t) ↔ ∃ x ≤ t.val s e ε, Eval s (x :> e) ε φ := by simp [bexsLE] +@[simp] lemma eval_bexsLE [Operator.LE L] [LE M] [Structure.LE L M] : + (φ.bexsLE t).Eval e f ↔ ∃ x ≤ t.val e f, φ.Eval (x :> e) f := by simp [bexsLE] -@[simp] lemma eval_ballMem [Operator.Mem L] [Membership M M] [Structure.Mem L M] {e ε} : - Eval s e ε (φ.ballMem t) ↔ ∀ x ∈ t.val s e ε, Eval s (x :> e) ε φ := by simp [ballMem] +@[simp] lemma eval_ballMem [Operator.Mem L] [Membership M M] [Structure.Mem L M] : + (φ.ballMem t).Eval e f ↔ ∀ x ∈ t.val e f, φ.Eval (x :> e) f := by simp [ballMem] -@[simp] lemma eval_bexsMem [Operator.Mem L] [Membership M M] [Structure.Mem L M] {e ε} : - Eval s e ε (φ.bexsMem t) ↔ ∃ x ∈ t.val s e ε, Eval s (x :> e) ε φ := by simp [bexsMem] +@[simp] lemma eval_bexsMem [Operator.Mem L] [Membership M M] [Structure.Mem L M] : + (φ.bexsMem t).Eval e f ↔ ∃ x ∈ t.val e f, φ.Eval (x :> e) f := by simp [bexsMem] end Semiformula diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index a89bc3894..840f25652 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -74,94 +74,94 @@ namespace Semiterm variable {M : Type w} {s : Structure L M} - {e : Fin n → M} {e₁ : Fin n₁ → M} {e₂ : Fin n₂ → M} - {ε : ξ → M} {ε₁ : μ₁ → M} {ε₂ : μ₂ → M} + {b : Fin n → M} {b₁ : Fin n₁ → M} {b₂ : Fin n₂ → M} + {f : ξ → M} {f₁ : ξ₁ → M} {f₂ : ξ₂ → M} -def val [s : Structure L M] (e : Fin n → M) (ε : ξ → M) : Semiterm L ξ n → M - | #x => e x - | &x => ε x - | func f v => s.func f fun i ↦ (v i).val e ε +def val [s : Structure L M] (b : Fin n → M) (f : ξ → M) : Semiterm L ξ n → M + | #x => b x + | &x => f x + | func F v => s.func F fun i ↦ (v i).val b f -abbrev valb (M : Type w) [s : Structure L M] (e : Fin n → M) (t : ClosedSemiterm L n) : M := t.val e Empty.elim +abbrev valb (M : Type w) [s : Structure L M] (b : Fin n → M) (t : ClosedSemiterm L n) : M := t.val b Empty.elim -abbrev valf [s : Structure L M] {n} (e : Fin n → M) : Semiterm L Empty n → M := val e Empty.elim +abbrev valf [s : Structure L M] {n} (b : Fin n → M) : Semiterm L Empty n → M := val b Empty.elim -@[simp] lemma val_bvar (x) : val e ε (#x : Semiterm L ξ n) = e x := rfl +@[simp] lemma val_bvar (x) : val b f (#x : Semiterm L ξ n) = b x := rfl -@[simp] lemma val_fvar (x) : val e ε (&x : Semiterm L ξ n) = ε x := rfl +@[simp] lemma val_fvar (x) : val b f (&x : Semiterm L ξ n) = f x := rfl -@[simp] lemma val_func {k} (f : L.Func k) (v) : - (func f v).val e ε = s.func f (Semiterm.val e ε ∘ v) := rfl +@[simp] lemma val_func {k} (F : L.Func k) (v) : + (func F v).val b f = s.func F (Semiterm.val b f ∘ v) := rfl -lemma val_func' {k} (f : L.Func k) (v) : - (func f v).val e ε = s.func f fun i ↦ Semiterm.val e ε (v i) := rfl +lemma val_func' {k} (F : L.Func k) (v) : + (func F v).val b f = s.func F fun i ↦ Semiterm.val b f (v i) := rfl -lemma val_rew (ω : Rew L μ₁ n₁ μ₂ n₂) (t : Semiterm L μ₁ n₁) : - (ω t).val e₂ ε₂ = t.val (val e₂ ε₂ ∘ ω ∘ bvar) (val e₂ ε₂ ∘ ω ∘ fvar) := by +lemma val_rew (ω : Rew L ξ₁ n₁ ξ₂ n₂) (t : Semiterm L ξ₁ n₁) : + (ω t).val b₂ f₂ = t.val (val b₂ f₂ ∘ ω ∘ bvar) (val b₂ f₂ ∘ ω ∘ fvar) := by induction t <;> simp [*, -val_func, val_func'] -lemma val_rewrite (f : μ₁ → Semiterm L μ₂ n) (t : Semiterm L μ₁ n) : - (Rew.rewrite f t).val e ε₂ = t.val e (val e ε₂ ∘ f) := by +lemma val_rewrite (f : ξ₁ → Semiterm L ξ₂ n) (t : Semiterm L ξ₁ n) : + (Rew.rewrite f t).val b f₂ = t.val b (val b f₂ ∘ f) := by simp [val_rew]; congr -lemma val_rewriteMap (f : μ₁ → μ₂) (t : Semiterm L μ₁ n) : - (Rew.rewriteMap f t).val e ε₂ = t.val e (ε₂ ∘ f) := by +lemma val_rewriteMap (f : ξ₁ → ξ₂) (t : Semiterm L ξ₁ n) : + (Rew.rewriteMap f t).val b f₂ = t.val b (f₂ ∘ f) := by simp [val_rew]; congr lemma val_substs (w : Fin n₁ → Semiterm L ξ n₂) (t : Semiterm L ξ n₁) : - (Rew.subst w t).val e₂ ε = t.val (val e₂ ε ∘ w) ε := by + (Rew.subst w t).val b₂ f = t.val (val b₂ f ∘ w) f := by simp [val_rew]; congr @[simp] lemma val_bShift (a : M) (t : Semiterm L ξ n) : - (Rew.bShift t).val (a :> e) ε = t.val e ε := by simp [val_rew, Function.comp_def] + (Rew.bShift t).val (a :> b) f = t.val b f := by simp [val_rew, Function.comp_def] -lemma val_bShift' (e : Fin (n + 1) → M) (t : Semiterm L ξ n) : - (Rew.bShift t).val e ε = t.val (e ·.succ) ε := by simp [val_rew, Function.comp_def] +lemma val_bShift' (b : Fin (n + 1) → M) (t : Semiterm L ξ n) : + (Rew.bShift t).val b f = t.val (b ·.succ) f := by simp [val_rew, Function.comp_def] @[simp] lemma val_emb {o : Type v'} [i : IsEmpty o] (t : Semiterm L o n) : - (Rew.emb t : Semiterm L ξ n).val e ε = t.val e i.elim := by + (Rew.emb t : Semiterm L ξ n).val b f = t.val b i.elim := by simp only [val_rew]; congr; funext x; exact i.elim' x @[simp] lemma val_castLE (h : n₁ ≤ n₂) (t : Semiterm L ξ n₁) : - (Rew.castLE h t).val e₂ ε = t.val (fun x ↦ e₂ (x.castLE h)) ε := by + (Rew.castLE h t).val b₂ f = t.val (fun x ↦ b₂ (x.castLE h)) f := by simp [val_rew]; congr lemma val_embSubsts (w : Fin k → Semiterm L ξ n) (t : Semiterm L Empty k) : - (Rew.embSubsts w t).val e ε = t.valb M (val e ε ∘ w) := by + (Rew.embSubsts w t).val b f = t.valb M (val b f ∘ w) := by simp [val_rew, Empty.eq_elim]; congr section Language -variable (φ : L₁ →ᵥ L₂) (e : Fin n → M) (ε : ξ → M) +variable (φ : L₁ →ᵥ L₂) (b : Fin n → M) (f : ξ → M) -lemma val_lMap (φ : L₁ →ᵥ L₂) (s₂ : Structure L₂ M) (e : Fin n → M) (ε : ξ → M) {t : Semiterm L₁ ξ n} : - (t.lMap φ).val (s := s₂) e ε = t.val (s := s₂.lMap φ) e ε := by +lemma val_lMap (φ : L₁ →ᵥ L₂) (s₂ : Structure L₂ M) (b : Fin n → M) (f : ξ → M) {t : Semiterm L₁ ξ n} : + (t.lMap φ).val (s := s₂) b f = t.val (s := s₂.lMap φ) b f := by induction t <;> simp [*, val_func, Semiterm.lMap_func, Function.comp_def] end Language section Syntactic -variable (ε : ℕ → M) +variable (f : ℕ → M) lemma val_shift (t : SyntacticSemiterm L n) : - (Rew.shift t).val e ε = t.val e (ε ∘ Nat.succ) := by simp [val_rew]; congr + (Rew.shift t).val b f = t.val b (f ∘ Nat.succ) := by simp [val_rew]; congr lemma val_free (a : M) (t : SyntacticSemiterm L (n + 1)) : - (Rew.free t).val e (a :>ₙ ε) = t.val (e <: a) ε := by + (Rew.free t).val b (a :>ₙ f) = t.val (b <: a) f := by simp only [val_rew] congr; exact funext <| Fin.lastCases (by simp) (by simp) lemma val_fix (a : M) (t : SyntacticSemiterm L n) : - (Rew.fix t).val (e <: a) ε = t.val e (a :>ₙ ε) := by + (Rew.fix t).val (b <: a) f = t.val b (a :>ₙ f) := by simp only [val_rew]; congr · simp [Function.comp_def] · simpa [Function.comp_def] using funext (Nat.cases (by simp) (by simp)) end Syntactic -lemma val_eq_of_funEqOn [DecidableEq ξ] (t : Semiterm L ξ n) (h : Function.funEqOn t.FVar? ε ε') : - t.val e ε = t.val e ε' := by +lemma val_eq_of_funEqOn [DecidableEq ξ] (t : Semiterm L ξ n) (h : Function.funEqOn t.FVar? f f') : + t.val b f = t.val b f' := by induction t case bvar => simp case fvar x => @@ -170,7 +170,7 @@ lemma val_eq_of_funEqOn [DecidableEq ξ] (t : Semiterm L ξ n) (h : Function.fun simp only [val_func, Function.comp_def] congr; funext i; exact ih i (by intro x hx; exact h x (by simpa using ⟨i, hx⟩)) -lemma val_toEmpty [DecidableEq ξ] (t : Semiterm L ξ n) (h : t.freeVariables = ∅) : t.val e ε = (t.toEmpty h).valb M e := by +lemma val_toEmpty [DecidableEq ξ] (t : Semiterm L ξ n) (h : t.freeVariables = ∅) : t.val b f = (t.toEmpty h).valb M b := by induction t case bvar => simp [Semiterm.toEmpty] case fvar => simp at h @@ -192,8 +192,8 @@ variable [s : Structure L M] (Θ : M ≃ N) lemma ofEquiv_func (f : L.Func k) (v : Fin k → N) : (ofEquiv Θ).func f v = Θ (func f (Θ.symm ∘ v)) := rfl -lemma ofEquiv_val (e : Fin n → N) (ε : ξ → N) (t : Semiterm L ξ n) : - t.val (s := ofEquiv Θ) e ε = Θ (t.val (Θ.symm ∘ e) (Θ.symm ∘ ε)) := by +lemma ofEquiv_val (b : Fin n → N) (f : ξ → N) (t : Semiterm L ξ n) : + t.val (s := ofEquiv Θ) b f = Θ (t.val (Θ.symm ∘ b) (Θ.symm ∘ f)) := by induction t <;> simp [*, Semiterm.val_func, ofEquiv_func Θ, Function.comp_def] end @@ -203,25 +203,25 @@ end Structure namespace Semiformula variable {M : Type w} {s : Structure L M} -variable {n : ℕ} {e : Fin n → M} {e₂ : Fin n₂ → M} {ε : ξ → M} {ε₂ : μ₂ → M} +variable {n : ℕ} {b : Fin n → M} {b₂ : Fin n₂ → M} {f : ξ → M} {f₂ : ξ₂ → M} -def EvalAux (s : Structure L M) (ε : ξ → M) {n} (e : Fin n → M) : Semiformula L ξ n → Prop - | rel φ v => s.rel φ (fun i ↦ Semiterm.val e ε (v i)) - | nrel φ v => ¬s.rel φ (fun i ↦ Semiterm.val e ε (v i)) +def EvalAux (s : Structure L M) (f : ξ → M) {n} (b : Fin n → M) : Semiformula L ξ n → Prop + | rel φ v => s.rel φ (fun i ↦ Semiterm.val b f (v i)) + | nrel φ v => ¬s.rel φ (fun i ↦ Semiterm.val b f (v i)) | ⊤ => True | ⊥ => False - | φ ⋏ ψ => φ.EvalAux s ε e ∧ ψ.EvalAux s ε e - | φ ⋎ ψ => φ.EvalAux s ε e ∨ ψ.EvalAux s ε e - | ∀⁰ φ => ∀ x : M, (φ.EvalAux s ε (x :> e)) - | ∃⁰ φ => ∃ x : M, (φ.EvalAux s ε (x :> e)) + | φ ⋏ ψ => φ.EvalAux s f b ∧ ψ.EvalAux s f b + | φ ⋎ ψ => φ.EvalAux s f b ∨ ψ.EvalAux s f b + | ∀⁰ φ => ∀ x : M, (φ.EvalAux s f (x :> b)) + | ∃⁰ φ => ∃ x : M, (φ.EvalAux s f (x :> b)) @[simp] lemma EvalAux_neg (φ : Semiformula L ξ n) : - EvalAux s ε e (∼φ) = ¬EvalAux s ε e φ := + EvalAux s f b (∼φ) = ¬EvalAux s f b φ := by induction φ using rec' <;> simp [*, EvalAux, or_iff_not_imp_left] -/-- Evaluation of semiformula with variation of free-variables `ε` and bounded-variables `e` -/ -def Eval [s : Structure L M] (e : Fin n → M) (ε : ξ → M) : Semiformula L ξ n →ˡᶜ Prop where - toTr := EvalAux s ε e +/-- Evaluation of semiformula with variation of free-variables `f` and bounded-variables `b` -/ +def Eval [s : Structure L M] (b : Fin n → M) (f : ξ → M) : Semiformula L ξ n →ˡᶜ Prop where + toTr := EvalAux s f b map_top' := rfl map_bot' := rfl map_and' := by simp [EvalAux] @@ -229,74 +229,74 @@ def Eval [s : Structure L M] (e : Fin n → M) (ε : ξ → M) : Semiformula L map_neg' := by simp [EvalAux_neg] map_imply' := by simp [EvalAux_neg, ←neg_eq, EvalAux, imp_iff_not_or] -abbrev Evalf [s : Structure L M] (ε : ξ → M) : Formula L ξ →ˡᶜ Prop := Eval (s := s) ![] ε +abbrev Evalf [s : Structure L M] (f : ξ → M) : Formula L ξ →ˡᶜ Prop := Eval (s := s) ![] f -abbrev Evalb (M : Type w) [s : Structure L M] (e : Fin n → M) : - Semiformula L Empty n →ˡᶜ Prop := Eval e Empty.elim +abbrev Evalb (M : Type w) [s : Structure L M] (b : Fin n → M) : + Semiformula L Empty n →ˡᶜ Prop := Eval b Empty.elim -notation:max M:90 " ⊧/" e:max => Evalb M e +notation:max M:90 " ⊧/" b:max => Evalb M b abbrev Models (s : Structure L M) : Formula L M →ˡᶜ Prop := Eval ![] id -lemma Eval.of_eq {e e' : Fin n → M} {ε ε' : ξ → M} - {φ : Semiformula L ξ n} (h : Eval e ε φ) (he : e = e') (hε : ε = ε') : Eval e' ε' φ := he ▸ hε ▸ h +lemma Eval.of_eq {b e' : Fin n → M} {f f' : ξ → M} + {φ : Semiformula L ξ n} (h : Eval b f φ) (he : b = e') (hf : f = f') : Eval e' f' φ := he ▸ hf ▸ h @[simp] lemma eval_rel {r : L.Rel k} {v} : - Eval e ε (rel r v) ↔ s.rel r (Semiterm.val e ε ∘ v) := of_eq rfl + Eval b f (rel r v) ↔ s.rel r (Semiterm.val b f ∘ v) := of_eq rfl lemma eval_rel' {r : L.Rel k} {v} : - Eval e ε (rel r v) ↔ s.rel r fun i ↦ (v i).val e ε := of_eq rfl + Eval b f (rel r v) ↔ s.rel r fun i ↦ (v i).val b f := of_eq rfl @[simp] lemma eval_nrel {r : L.Rel k} {v} : - Eval e ε (nrel r v) ↔ ¬s.rel r (Semiterm.val e ε ∘ v) := of_eq rfl + Eval b f (nrel r v) ↔ ¬s.rel r (Semiterm.val b f ∘ v) := of_eq rfl lemma eval_nrel' {r : L.Rel k} {v} : - Eval e ε (nrel r v) ↔ ¬s.rel r fun i ↦ (v i).val e ε := of_eq rfl + Eval b f (nrel r v) ↔ ¬s.rel r fun i ↦ (v i).val b f := of_eq rfl @[simp] lemma eval_all {φ : Semiformula L ξ (n + 1)} : - Eval e ε (∀⁰ φ) ↔ ∀ x : M, Eval (x :> e) ε φ := of_eq rfl + Eval b f (∀⁰ φ) ↔ ∀ x : M, Eval (x :> b) f φ := of_eq rfl @[simp] lemma eval_ex {φ : Semiformula L ξ (n + 1)} : - Eval e ε (∃⁰ φ) ↔ ∃ x : M, Eval (x :> e) ε φ := of_eq rfl + Eval b f (∃⁰ φ) ↔ ∃ x : M, Eval (x :> b) f φ := of_eq rfl @[simp] lemma eval_ball {φ ψ : Semiformula L ξ (n + 1)} : - Eval e ε (∀⁰[φ] ψ) ↔ ∀ x : M, Eval (x :> e) ε φ → Eval (x :> e) ε ψ := by + Eval b f (∀⁰[φ] ψ) ↔ ∀ x : M, Eval (x :> b) f φ → Eval (x :> b) f ψ := by simp [ball] @[simp] lemma eval_bexs {φ ψ : Semiformula L ξ (n + 1)} : - Eval e ε (∃⁰[φ] ψ) ↔ ∃ x : M, Eval (x :> e) ε φ ⋏ Eval (x :> e) ε ψ := by + Eval b f (∃⁰[φ] ψ) ↔ ∃ x : M, Eval (x :> b) f φ ⋏ Eval (x :> b) f ψ := by simp [bexs] -@[simp] lemma eval_allClosure {e} {φ : Semiformula L ξ k} : - Eval e ε (∀⁰* φ) ↔ ∀ e', Eval e' ε φ := +@[simp] lemma eval_allClosure {b} {φ : Semiformula L ξ k} : + Eval b f (∀⁰* φ) ↔ ∀ e', Eval e' f φ := match k with | 0 => by simp [eq_finZeroElim] | k + 1 => by simpa [allClosure_succ, eval_allClosure (k := k), Matrix.forall_iff] using forall_comm -@[simp] lemma eval_exsClosure {e} {φ : Semiformula L ξ k} : - Eval e ε (∃⁰* φ) ↔ ∃ e', Eval e' ε φ := +@[simp] lemma eval_exsClosure {b} {φ : Semiformula L ξ k} : + Eval b f (∃⁰* φ) ↔ ∃ e', Eval e' f φ := match k with | 0 => by simp [eq_finZeroElim] | k + 1 => by simpa [exsClosure_succ, eval_exsClosure (k := k), Matrix.exists_iff] using exists_comm -@[simp] lemma eval_allItr {e} {φ : Semiformula L ξ (n + k)} : - Eval e ε (∀⁰^[k] φ) ↔ ∀ e', Eval (Matrix.appendr e' e) ε φ := +@[simp] lemma eval_allItr {b} {φ : Semiformula L ξ (n + k)} : + Eval b f (∀⁰^[k] φ) ↔ ∀ e', Eval (Matrix.appendr e' b) f φ := match k with | 0 => by simp [Matrix.empty_eq] | k + 1 => by simpa [allItr_succ, eval_allItr (k := k), Matrix.forall_iff] using forall_comm -@[simp] lemma eval_exsItr {e} {φ : Semiformula L ξ (n + k)} : - Eval e ε (∃⁰^[k] φ) ↔ ∃ e', Eval (Matrix.appendr e' e) ε φ := +@[simp] lemma eval_exsItr {b} {φ : Semiformula L ξ (n + k)} : + Eval b f (∃⁰^[k] φ) ↔ ∃ e', Eval (Matrix.appendr e' b) f φ := match k with | 0 => by simp [Matrix.empty_eq] | k + 1 => by simpa [exsItr_succ, eval_exsItr (k := k), Matrix.exists_iff] using exists_comm section rew -variable {ε : ξ → M} {ε₂ : ξ₂ → M} +variable {f : ξ → M} {f₂ : ξ₂ → M} -lemma eval_rew {n₁ n₂ e₂ ε₂} (ω : Rew L ξ₁ n₁ ξ₂ n₂) (φ : Semiformula L ξ₁ n₁) : - Eval e₂ ε₂ (ω ▹ φ) ↔ Eval (Semiterm.val (s := s) e₂ ε₂ ∘ ω ∘ Semiterm.bvar) (Semiterm.val (s := s) e₂ ε₂ ∘ ω ∘ Semiterm.fvar) φ := by +lemma eval_rew {n₁ n₂ b₂ f₂} (ω : Rew L ξ₁ n₁ ξ₂ n₂) (φ : Semiformula L ξ₁ n₁) : + Eval b₂ f₂ (ω ▹ φ) ↔ Eval (Semiterm.val (s := s) b₂ f₂ ∘ ω ∘ Semiterm.bvar) (Semiterm.val (s := s) b₂ f₂ ∘ ω ∘ Semiterm.fvar) φ := by match φ with | .rel r v | .nrel r v => simp only [rew_rel_eq_comp, eval_rel, eval_nrel]; apply iff_of_eq @@ -311,74 +311,74 @@ lemma eval_rew {n₁ n₂ e₂ ε₂} (ω : Rew L ξ₁ n₁ ξ₂ n₂) (φ : S simpa [Function.comp_def, eval_rew ω.q φ] using exists_congr fun x ↦ iff_of_eq $ by congr; funext i; cases i using Fin.cases <;> simp -lemma eval_rew_q {ε₂ : ξ₂ → M} (ω : Rew L ξ₁ n₁ ξ₂ n₂) (φ : Semiformula L ξ₁ (n₁ + 1)) : - Eval (x :> e₂) ε₂ (ω.q ▹ φ) ↔ +lemma eval_rew_q {f₂ : ξ₂ → M} (ω : Rew L ξ₁ n₁ ξ₂ n₂) (φ : Semiformula L ξ₁ (n₁ + 1)) : + Eval (x :> b₂) f₂ (ω.q ▹ φ) ↔ Eval - (x :> Semiterm.val e₂ ε₂ ∘ ω ∘ Semiterm.bvar) - (Semiterm.val e₂ ε₂ ∘ ω ∘ Semiterm.fvar) φ := by + (x :> Semiterm.val b₂ f₂ ∘ ω ∘ Semiterm.bvar) + (Semiterm.val b₂ f₂ ∘ ω ∘ Semiterm.fvar) φ := by simp only [Nat.succ_eq_add_one, eval_rew, Function.comp_def, Rew.q_fvar, Semiterm.val_bShift] apply iff_of_eq; congr 2 · funext x cases x using Fin.cases <;> simp -lemma eval_map (b : Fin n₁ → Fin n₂) (f : ξ₁ → ξ₂) (e : Fin n₂ → M) (ε : ξ₂ → M) (φ : Semiformula L ξ₁ n₁) : - Eval e ε ((Rew.map (L := L) b f) ▹ φ) ↔ Eval (e ∘ b) (ε ∘ f) φ := by +lemma eval_map (θ : Fin n₁ → Fin n₂) (η : ξ₁ → ξ₂) (b : Fin n₂ → M) (f : ξ₂ → M) (φ : Semiformula L ξ₁ n₁) : + Eval b f ((Rew.map (L := L) θ η) ▹ φ) ↔ Eval (b ∘ θ) (f ∘ η) φ := by simp [eval_rew, Function.comp_def] lemma eval_rewrite (f : ξ₁ → Semiterm L ξ₂ n) (φ : Semiformula L ξ₁ n) : - Eval e ε₂ (Rew.rewrite f ▹ φ) ↔ Eval e (fun x ↦ (f x).val e ε₂) φ := by + Eval b f₂ (Rew.rewrite f ▹ φ) ↔ Eval b (fun x ↦ (f x).val b f₂) φ := by simp [eval_rew, Function.comp_def] lemma eval_rewriteMap (f : ξ₁ → ξ₂) (φ : Semiformula L ξ₁ n) : - Eval e ε₂ (Rew.rewriteMap (L := L) (n := n) f ▹ φ) ↔ Eval e (fun x ↦ ε₂ (f x)) φ := by + Eval b f₂ (Rew.rewriteMap (L := L) (n := n) f ▹ φ) ↔ Eval b (fun x ↦ f₂ (f x)) φ := by simp [eval_rew, Function.comp_def] @[simp] lemma eval_castLE (h : n₁ ≤ n₂) (φ : Semiformula L ξ n₁) : - Eval e₂ ε (@Rew.castLE L ξ _ _ h ▹ φ) ↔ Eval (fun x ↦ e₂ (x.castLE h)) ε φ := by + Eval b₂ f (@Rew.castLE L ξ _ _ h ▹ φ) ↔ Eval (fun x ↦ b₂ (x.castLE h)) f φ := by simp [eval_rew, Function.comp_def] @[simp] lemma eval_bShift (φ : Semiformula L ξ n) : - Eval (x :> e) ε (@Rew.bShift L ξ n ▹ φ) ↔ Eval e ε φ := by + Eval (x :> b) f (@Rew.bShift L ξ n ▹ φ) ↔ Eval b f φ := by simp [eval_rew, Function.comp_def] lemma eval_bShift' (φ : Semiformula L ξ n) : - Eval e' ε (@Rew.bShift L ξ n ▹ φ) ↔ Eval (e' ·.succ) ε φ := by + Eval e' f (@Rew.bShift L ξ n ▹ φ) ↔ Eval (e' ·.succ) f φ := by simp [eval_rew, Function.comp_def] @[simp] lemma eval_substs {k} (w : Fin k → Semiterm L ξ n) (φ : Semiformula L ξ k) : - Eval e ε (φ ⇜ w) ↔ Eval (fun i ↦ (w i).val e ε) ε φ := by + Eval b f (φ ⇜ w) ↔ φ.Eval (Semiterm.val b f ∘ w) f := by simp [eval_rew, Function.comp_def] -@[simp] lemma eval_emb {ε : ξ → M} (φ : Semiformula L Empty n) : - Eval e ε (Rewriting.emb (ξ := ξ) φ : Semiformula L ξ n) ↔ Eval e Empty.elim φ := by +@[simp] lemma eval_emb {f : ξ → M} (φ : Semiformula L Empty n) : + Eval b f (Rewriting.emb (ξ := ξ) φ : Semiformula L ξ n) ↔ Eval b Empty.elim φ := by simp [eval_rew, Function.comp_def, Empty.eq_elim] @[simp] lemma eval_empty [h : IsEmpty o] (φ : Formula L o) : - Eval e ε (@Rew.empty L o _ ξ n ▹ φ) ↔ Eval (s := s) ![] h.elim φ := by + Eval b f (@Rew.empty L o _ ξ n ▹ φ) ↔ Eval (s := s) ![] h.elim φ := by simp [eval_rew, Function.comp_def, Matrix.empty_eq] simp [IsEmpty.eq_elim] -@[simp] lemma eval_embSubsts {ξ} {ε : ξ → M} {k} (w : Fin k → Semiterm L ξ n) (σ : Semisentence L k) : - Eval e ε ((@Rew.embSubsts L ξ n k w) ▹ σ) ↔ σ.Evalb M (fun x ↦ (w x).val e ε) := by +@[simp] lemma eval_embSubsts {ξ} {f : ξ → M} {k} (w : Fin k → Semiterm L ξ n) (σ : Semisentence L k) : + Eval b f ((@Rew.embSubsts L ξ n k w) ▹ σ) ↔ σ.Evalb M (Semiterm.val b f ∘ w) := by simp [eval_rew, Function.comp_def, Empty.eq_elim] section Syntactic -variable (ε : ℕ → M) +variable (f : ℕ → M) @[simp] lemma eval_free (φ : Semiproposition L (n + 1)) : - Eval e (a :>ₙ ε) (@Rew.free L n ▹ φ) ↔ Eval (e <: a) ε φ := by + Eval b (a :>ₙ f) (@Rew.free L n ▹ φ) ↔ Eval (b <: a) f φ := by simp only [eval_rew, Function.comp_def, Rew.free_fvar, Semiterm.val_fvar, Nat.cases_succ, Nat.succ_eq_add_one] apply iff_of_eq; congr; funext x; cases x using Fin.lastCases <;> simp @[simp] lemma eval_shift (φ : Semiproposition L n) : - Eval e (a :>ₙ ε) (@Rew.shift L n ▹ φ) ↔ Eval e ε φ := by + Eval b (a :>ₙ f) (@Rew.shift L n ▹ φ) ↔ Eval b f φ := by simp [eval_rew, Function.comp_def] end Syntactic -lemma eval_iff_of_funEqOn [DecidableEq ξ] {n e} (φ : Semiformula L ξ n) (h : Function.funEqOn φ.FVar? ε ε') : - Eval e ε φ ↔ Eval e ε' φ := by +lemma eval_iff_of_funEqOn [DecidableEq ξ] {n b} (φ : Semiformula L ξ n) (h : Function.funEqOn φ.FVar? f f') : + Eval b f φ ↔ Eval b f' φ := by match φ with | .rel r v => simp only [eval_rel]; apply iff_of_eq; congr 1 @@ -390,25 +390,25 @@ lemma eval_iff_of_funEqOn [DecidableEq ξ] {n e} (φ : Semiformula L ξ n) (h : exact Semiterm.val_eq_of_funEqOn (v i) (fun x hx ↦ h x (fvar?_nrel.mpr ⟨i, hx⟩)) | ⊤ | ⊥ => simp | φ ⋏ ψ => - suffices Eval e ε φ ∧ Eval e ε ψ ↔ Eval e ε' φ ∧ Eval e ε' ψ by simpa + suffices Eval b f φ ∧ Eval b f ψ ↔ Eval b f' φ ∧ Eval b f' ψ by simpa apply and_congr · exact eval_iff_of_funEqOn φ fun x hx ↦ h x (by simp [hx]) · exact eval_iff_of_funEqOn ψ fun x hx ↦ h x (by simp [hx]) | φ ⋎ ψ => - suffices Eval e ε φ ∨ Eval e ε ψ ↔ Eval e ε' φ ∨ Eval e ε' ψ by simpa + suffices Eval b f φ ∨ Eval b f ψ ↔ Eval b f' φ ∨ Eval b f' ψ by simpa apply or_congr · exact eval_iff_of_funEqOn φ fun x hx ↦ h x (by simp [hx]) · exact eval_iff_of_funEqOn ψ fun x hx ↦ h x (by simp [hx]) | ∀⁰ φ => - suffices (∀ x, Eval (x :> e) ε φ) ↔ (∀ x, Eval (x :> e) ε' φ) by simpa + suffices (∀ x, Eval (x :> b) f φ) ↔ (∀ x, Eval (x :> b) f' φ) by simpa apply forall_congr'; intro x exact eval_iff_of_funEqOn φ fun x hx ↦ h _ (by simpa [FVar?]) | ∃⁰ φ => - suffices (∃ x, Eval (x :> e) ε φ) ↔ (∃ x, Eval (x :> e) ε' φ) by simpa + suffices (∃ x, Eval (x :> b) f φ) ↔ (∃ x, Eval (x :> b) f' φ) by simpa apply exists_congr; intro x exact eval_iff_of_funEqOn φ fun x hx ↦ h _ (by simpa [FVar?]) -lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeVariables = ∅) {e} : Eval e f φ ↔ Evalb M e (φ.toEmpty hp) := by +lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeVariables = ∅) {b} : Eval b f φ ↔ Evalb M b (φ.toEmpty hp) := by match φ with | .rel r v => simp only [eval_rel] @@ -422,23 +422,23 @@ lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeV simp [eval_toEmpty (φ := φ) (by simp [by simpa [Finset.union_eq_empty] using hp]), eval_toEmpty (φ := ψ) (by simp [by simpa [Finset.union_eq_empty] using hp])] | ∀⁰ φ => - have : ∀ x, Eval (x :> e) f φ ↔ Evalb M (x :> e) (φ.toEmpty hp) := - fun x ↦ eval_toEmpty (φ := φ) (e := (x :> e)) (by simpa using hp) + have : ∀ x, Eval (x :> b) f φ ↔ Evalb M (x :> b) (φ.toEmpty hp) := + fun x ↦ eval_toEmpty (φ := φ) (b := (x :> b)) (by simpa using hp) simp [this] | ∃⁰ φ => - have : ∀ x, Eval (x :> e) f φ ↔ Evalb M (x :> e) (φ.toEmpty hp) := - fun x ↦ eval_toEmpty (φ := φ) (e := (x :> e)) (by simpa using hp) + have : ∀ x, Eval (x :> b) f φ ↔ Evalb M (x :> b) (φ.toEmpty hp) := + fun x ↦ eval_toEmpty (φ := φ) (b := (x :> b)) (by simpa using hp) simp [this] -@[simp] lemma eval_univCl' {ε : ℕ → M} (φ : Proposition L) : - Evalf ε φ.univCl' ↔ ∀ f : ℕ → M, Evalf f φ := by +@[simp] lemma eval_univCl' {f : ℕ → M} (φ : Proposition L) : + Evalf f φ.univCl' ↔ ∀ g : ℕ → M, Evalf g φ := by simp only [univCl', eval_allClosure, eval_rew, Matrix.empty_eq, Function.comp_def] constructor - · intro h f - refine (eval_iff_of_funEqOn φ ?_).mp (h (fun x ↦ f x)) + · intro h g + refine (eval_iff_of_funEqOn φ ?_).mp (h (fun x ↦ g x)) intro x hx; simp [Rew.fixitr_fvar, lt_fvSup_of_fvar? hx] - · intro h f - refine (eval_iff_of_funEqOn φ ?_).mp (h (fun x ↦ if hx : x < φ.fvSup then f ⟨x, by simp [hx]⟩ else ε 0)) + · intro h g + refine (eval_iff_of_funEqOn φ ?_).mp (h (fun x ↦ if hx : x < φ.fvSup then g ⟨x, by simp [hx]⟩ else f 0)) intro x hx; simp [Rew.fixitr_fvar, lt_fvSup_of_fvar? hx] @[simp] lemma eval_univCl [Nonempty M] (φ : Proposition L) : @@ -465,8 +465,8 @@ variable [s : Structure L M] (Θ : M ≃ N) lemma ofEquiv_rel (r : L.Rel k) (v : Fin k → N) : (Structure.ofEquiv Θ).rel r v ↔ Structure.rel r (Θ.symm ∘ v) := iff_of_eq rfl -lemma eval_ofEquiv_iff {e : Fin n → N} {ε : ξ → N} {φ : Semiformula L ξ n} : - Eval (s := ofEquiv Θ) e ε φ ↔ Eval (Θ.symm ∘ e) (Θ.symm ∘ ε) φ := +lemma eval_ofEquiv_iff {b : Fin n → N} {f : ξ → N} {φ : Semiformula L ξ n} : + Eval (s := ofEquiv Θ) b f φ ↔ Eval (Θ.symm ∘ b) (Θ.symm ∘ f) φ := match φ with | .rel r v | .nrel r v => by simp [Function.comp_def, ofEquiv_rel Θ, Structure.ofEquiv_val Θ] | ⊤ | ⊥ => by simp @@ -478,8 +478,8 @@ lemma eval_ofEquiv_iff {e : Fin n → N} {ε : ξ → N} {φ : Semiformula L ξ ⟨by rintro ⟨x, h⟩; exists Θ.symm x; simpa [Matrix.comp_vecCons''] using eval_ofEquiv_iff.mp h, by rintro ⟨x, h⟩; exists Θ x; apply eval_ofEquiv_iff.mpr; simpa [Matrix.comp_vecCons''] using h⟩ -lemma evalf_ofEquiv_iff {ε : ξ → N} {φ : Formula L ξ} : - Evalf (s := ofEquiv Θ) ε φ ↔ Evalf (s := s) (Θ.symm ∘ ε) φ := by simpa using eval_ofEquiv_iff (Θ := Θ) (ε := ε) (φ := φ) (e := ![]) +lemma evalf_ofEquiv_iff {f : ξ → N} {φ : Formula L ξ} : + Evalf (s := ofEquiv Θ) f φ ↔ Evalf (s := s) (Θ.symm ∘ f) φ := by simpa using eval_ofEquiv_iff (Θ := Θ) (f := f) (φ := φ) (b := ![]) end @@ -599,10 +599,10 @@ namespace Semiformula variable {L₁ L₂ : Language} {Φ : L₁ →ᵥ L₂} section lMap -variable {M : Type u} {s₂ : Structure L₂ M} {n} {e : Fin n → M} {ε : ξ → M} +variable {M : Type u} {s₂ : Structure L₂ M} {n} {b : Fin n → M} {f : ξ → M} lemma eval_lMap [Nonempty M] {φ : Semiformula L₁ ξ n} : - Eval (s := s₂) e ε (lMap Φ φ) ↔ Eval (s := s₂.lMap Φ) e ε φ := by + Eval (s := s₂) b f (lMap Φ φ) ↔ Eval (s := s₂.lMap Φ) b f φ := by induction φ using rec' <;> simp [*, Semiterm.val_lMap, lMap_rel, lMap_nrel, eval_rel, eval_nrel, Function.comp_def] @@ -632,6 +632,9 @@ instance models_schema_sup (𝓢₁ 𝓢₂ : Schema L) [M↓[L] ⊧* 𝓢₁] [ · infer_instance · infer_instance +lemma modelsUnivCl_of_mem_schema {𝔖 : Schema L} [h : M↓[L] ⊧* 𝔖] (hf : φ ∈ 𝔖) : M↓[L] ⊧ φ.univCl := + h.models _ <| by simp; grind + end schema namespace Structure diff --git a/Foundation/FirstOrder/Basic/Soundness.lean b/Foundation/FirstOrder/Basic/Soundness.lean index 7edff4384..136491e92 100644 --- a/Foundation/FirstOrder/Basic/Soundness.lean +++ b/Foundation/FirstOrder/Basic/Soundness.lean @@ -97,10 +97,10 @@ instance sound (𝔖 : Schema L) : ⟨Schema.sound_sentence⟩ lemma models_of_subtheory {𝔖 𝔗 : Schema L} [𝔖 ⪯ 𝔗] {M : Type*} [Structure L M] [Nonempty M] : M↓[L] ⊧* 𝔗 → M↓[L] ⊧* 𝔖 := - fun hM ↦ ⟨ fun {σ} hσ ↦ by + fun hM ↦ ⟨fun {σ} hσ ↦ by rcases show ∃ φ ∈ 𝔖, univCl φ = σ by simpa using hσ with ⟨φ, hφ, rfl⟩ have : 𝔗 ⊢ φ := (inferInstanceAs (𝔖 ⪯ 𝔗)).pbl (Entailment.by_axm hφ) - exact Schema.sound_proposition' this hM ⟩ + exact Schema.sound_proposition' this hM⟩ lemma consistent_of_satisfiable (h : Semantics.Satisfiable (Struc.{v, u} L) 𝔖) : Entailment.Consistent 𝔖 := Entailment.Pullback.consistent <| Sound.consistent_of_satisfiable (𝓢 := Entailment.pullback 𝔖 ((↑·) : Sentence L → Proposition L)) h diff --git a/Foundation/FirstOrder/Basic/Syntax/Formula.lean b/Foundation/FirstOrder/Basic/Syntax/Formula.lean index 7d30a0eb1..247a087b4 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Formula.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Formula.lean @@ -519,31 +519,11 @@ def lMap (Φ : L₁ →ᵥ L₂) {n} : Semiformula L₁ ξ n →ˡᶜ Semiformul map_neg' := by simp [lMapAux_neg] map_imply' := by simp [Semiformula.imp_eq, lMapAux_neg, ←Semiformula.neg_eq, lMapAux] -lemma lMap_rel {k} (r : L₁.Rel k) (v : Fin k → Semiterm L₁ ξ n) : - lMap Φ (rel r v) = rel (Φ.rel r) (fun i => (v i).lMap Φ) := rfl +@[simp] lemma lMap_rel {k} (r : L₁.Rel k) (v : Fin k → Semiterm L₁ ξ n) : + lMap Φ (rel r v) = rel (Φ.rel r) (Semiterm.lMap Φ ∘ v) := rfl -@[simp] lemma lMap_rel₀ (r : L₁.Rel 0) (v : Fin 0 → Semiterm L₁ ξ n) : - lMap Φ (rel r v) = rel (Φ.rel r) ![] := by simp [lMap_rel, Matrix.empty_eq] - -@[simp] lemma lMap_rel₁ (r : L₁.Rel 1) (t : Semiterm L₁ ξ n) : - lMap Φ (rel r ![t]) = rel (Φ.rel r) ![t.lMap Φ] := by simp [lMap_rel, Matrix.constant_eq_singleton] - -@[simp] lemma lMap_rel₂ (r : L₁.Rel 2) (t₁ t₂ : Semiterm L₁ ξ n) : - lMap Φ (rel r ![t₁, t₂]) = rel (Φ.rel r) ![t₁.lMap Φ, t₂.lMap Φ] := by - simp [lMap_rel, Matrix.fun_eq_vec_two] - -lemma lMap_nrel {k} (r : L₁.Rel k) (v : Fin k → Semiterm L₁ ξ n) : - lMap Φ (nrel r v) = nrel (Φ.rel r) (fun i => (v i).lMap Φ) := rfl - -@[simp] lemma lMap_nrel₀ (r : L₁.Rel 0) (v : Fin 0 → Semiterm L₁ ξ n) : - lMap Φ (nrel r v) = nrel (Φ.rel r) ![] := by simp [lMap_nrel, Matrix.empty_eq] - -@[simp] lemma lMap_nrel₁ (r : L₁.Rel 1) (t : Semiterm L₁ ξ n) : - lMap Φ (nrel r ![t]) = nrel (Φ.rel r) ![t.lMap Φ] := by simp [lMap_nrel, Matrix.constant_eq_singleton] - -@[simp] lemma lMap_nrel₂ (r : L₁.Rel 2) (t₁ t₂ : Semiterm L₁ ξ n) : - lMap Φ (nrel r ![t₁, t₂]) = nrel (Φ.rel r) ![t₁.lMap Φ, t₂.lMap Φ] := by - simp [lMap_nrel, Matrix.fun_eq_vec_two] +@[simp] lemma lMap_nrel {k} (r : L₁.Rel k) (v : Fin k → Semiterm L₁ ξ n) : + lMap Φ (nrel r v) = nrel (Φ.rel r) (Semiterm.lMap Φ ∘ v) := rfl @[simp] lemma lMap_all (φ : Semiformula L₁ ξ (n + 1)) : lMap Φ (∀⁰ φ) = ∀⁰ lMap Φ φ := rfl diff --git a/Foundation/FirstOrder/Basic/Syntax/Rew.lean b/Foundation/FirstOrder/Basic/Syntax/Rew.lean index 0c84b6166..5a2746c2e 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Rew.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Rew.lean @@ -1,5 +1,6 @@ module +public import Foundation.Vorspiel.Finset.Basic public import Foundation.Syntax.Predicate.Rew public import Foundation.FirstOrder.Basic.Syntax.Formula @@ -19,20 +20,6 @@ Rewritings `LO.FirstOrder.Rew` is naturally converted to formula Rewritings by ` -/ -namespace Finset - -lemma biUnion_eq_empty [DecidableEq β] {s : Finset α} {f : α → Finset β} : - s.biUnion f = ∅ ↔ ∀ i ∈ s, f i = ∅ := by - constructor - · intro h a ha; ext b - have := by simpa using congrFun (congrArg Membership.mem h) b - simpa using this a ha - · intro h; ext b - suffices ∀ x ∈ s, b ∉ f x by simpa - intro a ha; simpa using congrFun (congrArg Membership.mem (h a ha)) b - -end Finset - namespace LO namespace FirstOrder diff --git a/Foundation/Logic/LogicSymbol.lean b/Foundation/Logic/LogicSymbol.lean index f5d6075f2..ba796ebba 100644 --- a/Foundation/Logic/LogicSymbol.lean +++ b/Foundation/Logic/LogicSymbol.lean @@ -320,12 +320,12 @@ variable [LogicalConnective α] [LogicalConnective β] · rintro ⟨i, h⟩ cases i using Fin.cases; { left; exact h }; { right; exact ⟨_, h⟩ } -lemma hom_conj [FunLike F α β] [LogicalConnective.HomClass F α β] (f : F) (v : Fin n → α) : f (conj v) = conj (f ∘ v) := by +@[simp] lemma hom_conj [FunLike F α β] [LogicalConnective.HomClass F α β] (f : F) (v : Fin n → α) : f (conj v) = conj (f ∘ v) := by induction' n with n ih <;> simp [*, conj] lemma hom_conj₂ [FunLike F α β] [LogicalConnective.HomClass F α β] (f : F) (v : Fin n → α) : f (conj v) = conj fun i => f (v i) := hom_conj f v -lemma hom_disj [FunLike F α β] [LogicalConnective.HomClass F α β] (f : F) (v : Fin n → α) : f (disj v) = disj (f ∘ v) := by +@[simp] lemma hom_disj [FunLike F α β] [LogicalConnective.HomClass F α β] (f : F) (v : Fin n → α) : f (disj v) = disj (f ∘ v) := by induction' n with n ih <;> simp [*, disj] lemma hom_disj' [FunLike F α β] [LogicalConnective.HomClass F α β] (f : F) (v : Fin n → α) : f (disj v) = disj fun i => f (v i) := hom_disj f v diff --git a/Foundation/Vorspiel/Finset/Basic.lean b/Foundation/Vorspiel/Finset/Basic.lean index e52cb3a2b..10a0af15f 100644 --- a/Foundation/Vorspiel/Finset/Basic.lean +++ b/Foundation/Vorspiel/Finset/Basic.lean @@ -73,6 +73,15 @@ lemma sup_univ_cast {α : Type _} [SemilatticeSup α] [OrderBot α] {n} (f : Fin end +lemma biUnion_eq_empty [DecidableEq β] {s : Finset α} {f : α → Finset β} : + s.biUnion f = ∅ ↔ ∀ i ∈ s, f i = ∅ := by + constructor + · intro h a ha; ext b + have := by simpa using congrFun (congrArg Membership.mem h) b + simpa using this a ha + · intro h; ext b + suffices ∀ x ∈ s, b ∉ f x by simpa + intro a ha; simpa using congrFun (congrArg Membership.mem (h a ha)) b end Finset diff --git a/Foundation/Vorspiel/Matrix.lean b/Foundation/Vorspiel/Matrix.lean index 628838d72..c91767769 100644 --- a/Foundation/Vorspiel/Matrix.lean +++ b/Foundation/Vorspiel/Matrix.lean @@ -128,6 +128,8 @@ lemma comp_vecCons₂' (g : β → γ) (f : α → β) (a : α) (s : Fin n → @[simp] lemma comp₃ (a₁ a₂ a₃ : α) : f ∘ ![a₁, a₂, a₃] = ![f a₁, f a₂, f a₃] := by simp [comp_vecCons''] +@[simp] lemma comp₄ (a₁ a₂ a₃ a₄ : α) : f ∘ ![a₁, a₂, a₃, a₄] = ![f a₁, f a₂, f a₃, f a₄] := by simp [comp_vecCons''] + lemma comp_vecConsLast (f : α → β) (a : α) (s : Fin n → α) : (fun x => f $ (s <: a) x) = f ∘ s <: f a := funext (fun i => lastCases (by simp) (by simp) i) @@ -144,26 +146,37 @@ lemma vecConsLast_vecEmpty {s : Fin 0 → α} (a : α) : s <: a = ![a] := · rw [this, rightConcat_last, cons_val_fin_one] have := i.isLt; contradiction ) -lemma constant_eq_singleton {a : α} : (fun _ => a) = ![a] := by funext x; simp +lemma constant_eq_singleton {a : α} : (fun _ ↦ a) = ![a] := by funext x; simp + +lemma fun_eq_vec_one (v : Fin 1 → α) : v = ![v 0] := by funext x; simp -lemma fun_eq_vec_one {v : Fin 1 → α} : v = ![v 0] := by funext x; simp [Fin.eq_zero] +lemma fun_eq_vec_one' (f : α → β) (v : Fin 1 → α) : f ∘ v = ![f (v 0)] := by funext x; simp -lemma constant_eq_vec₂ {a : α} : (fun _ => a) = ![a, a] := by - funext x; cases x using Fin.cases <;> simp [Fin.eq_zero] +lemma constant_eq_vec₂ {a : α} : (fun _ ↦ a) = ![a, a] := by + funext x; cases x using Fin.cases <;> simp -lemma fun_eq_vec_two {v : Fin 2 → α} : v = ![v 0, v 1] := by - funext x; cases x using Fin.cases <;> simp [Fin.eq_zero] +lemma fun_eq_vec_two (v : Fin 2 → α) : v = ![v 0, v 1] := by + funext x; cases x using Fin.cases <;> simp -lemma fun_eq_vec_three {v : Fin 3 → α} : v = ![v 0, v 1, v 2] := by +lemma fun_eq_vec_two' (f : α → β) (v : Fin 2 → α) : f ∘ v = ![f (v 0), f (v 1)] := by + rw [fun_eq_vec_two v]; simp + +lemma fun_eq_vec_three (v : Fin 3 → α) : v = ![v 0, v 1, v 2] := by funext x cases' x using Fin.cases with x <;> simp - cases' x using Fin.cases with x <;> simp [Fin.eq_zero] + cases' x using Fin.cases with x <;> simp -lemma fun_eq_vec_four {v : Fin 4 → α} : v = ![v 0, v 1, v 2, v 3] := by +lemma fun_eq_vec_three' (f : α → β) (v : Fin 3 → α) : f ∘ v = ![f (v 0), f (v 1), f (v 2)] := by + rw [fun_eq_vec_three v]; simp + +lemma fun_eq_vec_four (v : Fin 4 → α) : v = ![v 0, v 1, v 2, v 3] := by funext x cases' x using Fin.cases with x <;> simp cases' x using Fin.cases with x <;> simp - cases' x using Fin.cases with x <;> simp [Fin.eq_zero] + cases' x using Fin.cases with x <;> simp + +lemma fun_eq_vec_four' (f : α → β) (v : Fin 4 → α) : f ∘ v = ![f (v 0), f (v 1), f (v 2), f (v 3)] := by + rw [fun_eq_vec_four v]; simp lemma injective_vecCons {f : Fin n → α} (h : Function.Injective f) {a} (ha : ∀ i, a ≠ f i) : Function.Injective (a :> f) := by have : ∀ i, f i ≠ a := fun i => (ha i).symm From 74ec881dec7dbdc95a79da8b24267b7f4ba9f5e6 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 28 Mar 2026 01:53:40 +0900 Subject: [PATCH 16/61] basic --- Foundation/FirstOrder/Basic.lean | 2 +- Foundation/FirstOrder/Basic/Calculus2.lean | 25 +++++++++++-------- Foundation/FirstOrder/Basic/Definability.lean | 10 ++++---- .../FirstOrder/Basic/Semantics/Semantics.lean | 2 +- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/Foundation/FirstOrder/Basic.lean b/Foundation/FirstOrder/Basic.lean index d64aca6e0..849050384 100644 --- a/Foundation/FirstOrder/Basic.lean +++ b/Foundation/FirstOrder/Basic.lean @@ -2,7 +2,7 @@ module public import Foundation.FirstOrder.Basic.Syntax.Formula public import Foundation.FirstOrder.Basic.Syntax.Rew -public import Foundation.FirstOrder.Basic.Syntax.Theory +public import Foundation.FirstOrder.Basic.Syntax.Schema public import Foundation.FirstOrder.Basic.Semantics.Semantics public import Foundation.FirstOrder.Basic.Semantics.Elementary public import Foundation.FirstOrder.Basic.Operator diff --git a/Foundation/FirstOrder/Basic/Calculus2.lean b/Foundation/FirstOrder/Basic/Calculus2.lean index bef5f2be7..06839c941 100644 --- a/Foundation/FirstOrder/Basic/Calculus2.lean +++ b/Foundation/FirstOrder/Basic/Calculus2.lean @@ -4,23 +4,25 @@ public import Foundation.FirstOrder.Basic.Calculus /-! # Alternative definition of proof -/ +/- + namespace LO.FirstOrder variable {L : Language} [L.DecidableEq] section derivation2 -inductive Derivation2 (𝓢 : Schema L) : Finset (Proposition L) → Type _ -| closed (Γ) (φ : Proposition L) : φ ∈ Γ → ∼φ ∈ Γ → Derivation2 𝓢 Γ -| axm {Γ} (φ : Proposition L) : φ ∈ 𝓢 → φ ∈ Γ → Derivation2 𝓢 Γ -| verum {Γ} : ⊤ ∈ Γ → Derivation2 𝓢 Γ -| and {Γ} {φ ψ : Proposition L} : φ ⋏ ψ ∈ Γ → Derivation2 𝓢 (insert φ Γ) → Derivation2 𝓢 (insert ψ Γ) → Derivation2 𝓢 Γ -| or {Γ} {φ ψ : Proposition L} : φ ⋎ ψ ∈ Γ → Derivation2 𝓢 (insert φ (insert ψ Γ)) → Derivation2 𝓢 Γ -| all {Γ} {φ : Semiproposition L 1} : ∀⁰ φ ∈ Γ → Derivation2 𝓢 (insert (Rewriting.free φ) (Γ.image Rewriting.shift)) → Derivation2 𝓢 Γ -| exs {Γ} {φ : Semiproposition L 1} : ∃⁰ φ ∈ Γ → (t : SyntacticTerm L) → Derivation2 𝓢 (insert (φ/[t]) Γ) → Derivation2 𝓢 Γ -| wk {Δ Γ} : Derivation2 𝓢 Δ → Δ ⊆ Γ → Derivation2 𝓢 Γ -| shift {Γ} : Derivation2 𝓢 Γ → Derivation2 𝓢 (Γ.image Rewriting.shift) -| cut {Γ φ} : Derivation2 𝓢 (insert φ Γ) → Derivation2 𝓢 (insert (∼φ) Γ) → Derivation2 𝓢 Γ +inductive Derivation2 : Finset (Proposition L) → Type _ +| wk {Δ Γ} : Derivation2 Δ → Δ ⊆ Γ → Derivation2 Γ +| shift {Γ} : Derivation2 Γ → Derivation2 (Γ.image Rewriting.shift) +| identity (Γ) (φ : Proposition L) : φ ∈ Γ → ∼φ ∈ Γ → Derivation2 Γ +| cut {Γ φ} : Derivation2 (insert φ Γ) → Derivation2 (insert (∼φ) Δ) → Derivation2 (Γ ∪ Δ) +| verum {Γ} : ⊤ ∈ Γ → Derivation2 Γ +| and {Γ} {φ ψ : Proposition L} : φ ⋏ ψ ∈ Γ → Derivation2 (insert φ Γ) → Derivation2 (insert ψ Γ) → Derivation2 Γ +| or {Γ} {φ ψ : Proposition L} : φ ⋎ ψ ∈ Γ → Derivation2 (insert φ (insert ψ Γ)) → Derivation2 Γ +| all {Γ} {φ : Semiproposition L 1} : ∀⁰ φ ∈ Γ → Derivation2 (insert (Rewriting.free φ) (Γ.image Rewriting.shift)) → Derivation2 Γ +| exs {Γ} {φ : Semiproposition L 1} : ∃⁰ φ ∈ Γ → (t : SyntacticTerm L) → Derivation2 (insert (φ/[t]) Γ) → Derivation2 Γ + scoped infix:45 " ⟹₂" => Derivation2 @@ -96,3 +98,4 @@ def provable_iff_derivable2 {φ} : 𝓢 ⊢ φ ↔ 𝓢 ⊢!₂! φ := derivable end derivation2 end LO.FirstOrder +-/ diff --git a/Foundation/FirstOrder/Basic/Definability.lean b/Foundation/FirstOrder/Basic/Definability.lean index 64068eb16..5e6c8e1d0 100644 --- a/Foundation/FirstOrder/Basic/Definability.lean +++ b/Foundation/FirstOrder/Basic/Definability.lean @@ -17,19 +17,19 @@ namespace LO.FirstOrder variable {L : Language} {M : Type*} [Structure L M] abbrev IsDefinedBy (R : (Fin k → M) → Prop) (φ : Semisentence L k) : Prop := - ∀ v, Semiformula.Evalbm M v φ ↔ R v + ∀ v, Semiformula.Evalb M v φ ↔ R v class Defined (R : outParam ((Fin k → M) → Prop)) (φ : Semisentence L k) : Prop where iff : IsDefinedBy R φ abbrev IsDefinedByWithParam (R : (Fin k → M) → Prop) (φ : Semiformula L M k) : Prop := - ∀ v, Semiformula.Evalm M v id φ ↔ R v + ∀ v, Semiformula.Eval v id φ ↔ R v @[simp] lemma Defined.eval_iff {R : (Fin k → M) → Prop} {φ : Semisentence L k} [h : Defined R φ] (v) : - Semiformula.Evalbm M v φ ↔ R v := h.iff v + Semiformula.Evalb M v φ ↔ R v := h.iff v lemma IsDefinedByWithParam.iff {R : (Fin k → M) → Prop} {φ : Semiformula L M k} (h : IsDefinedByWithParam R φ) (v) : - Semiformula.Evalm M v id φ ↔ R v := h v + Semiformula.Eval v id φ ↔ R v := h v abbrev DefinedFunction (f : (Fin k → M) → M) (φ : Semisentence L (k + 1)) : Prop := Defined (fun v ↦ v 0 = f (v ·.succ)) φ @@ -271,7 +271,7 @@ lemma fintype_exs [Fintype ι] {P : ι → (Fin k → M) → Prop} lemma retraction (h : L.Definable P) {n} (f : Fin k → Fin n) : L.Definable fun v ↦ P (fun i ↦ v (f i)) := by rcases h with ⟨φ, hφ⟩ - exact ⟨(Rew.subst fun i ↦ #(f i)) ▹ φ, fun v ↦ by simp [←hφ.iff]⟩ + exact ⟨(Rew.subst fun i ↦ #(f i)) ▹ φ, fun v ↦ by simp [←hφ.iff, Function.comp_def]⟩ lemma exsVec {k l} {P : (Fin k → M) → (Fin l → M) → Prop} (h : L.Definable fun w : Fin (k + l) → M ↦ P (fun i ↦ w (i.castAdd l)) (fun j ↦ w (j.natAdd k))) : diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index 840f25652..63f814ebd 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -523,7 +523,7 @@ lemma models_iff_proposition {φ : Proposition L} : M↓[L] ⊧ φ.univCl ↔ lemma models_theory_iff : M↓[L] ⊧* T ↔ (∀ {φ}, φ ∈ T → M↓[L] ⊧ φ) := Semantics.modelsSet_iff -lemma models_schema_iff {𝓢 : Schema L} : M↓[L] ⊧* 𝓢 ↔ (∀ {φ : Proposition L}, φ ∈ 𝓢 → ∀ f : ℕ → M, φ.Evalf f) := by +lemma models_schema_iff {𝔖 : Schema L} : M↓[L] ⊧* 𝔖 ↔ (∀ {φ : Proposition L}, φ ∈ 𝔖 → ∀ f : ℕ → M, φ.Evalf f) := by simp [models_theory_iff, models_iff] lemma models_of_mem {T : Theory L} [M↓[L] ⊧* T] {φ} (h : φ ∈ T) : M↓[L] ⊧ φ := Semantics.ModelsSet.models _ h From 74f789d76ae651ec9f1d207ac2487f5ef21582d7 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Mon, 30 Mar 2026 02:10:59 +0900 Subject: [PATCH 17/61] fix? --- Foundation/FirstOrder/Basic/Calculus.lean | 6 +++ .../FirstOrder/Completeness/Coding.lean | 22 ++++---- .../FirstOrder/Completeness/SearchTree.lean | 3 +- .../FirstOrder/Completeness/SubLanguage.lean | 37 ++++---------- Foundation/FirstOrder/Polarity.lean | 2 +- Foundation/FirstOrder/Ultraproduct.lean | 50 +++++++++---------- Foundation/Meta/TwoSided.lean | 40 +++++++-------- Foundation/Syntax/Predicate/Rew.lean | 7 +++ 8 files changed, 82 insertions(+), 85 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index f993151c8..95f3f4e1e 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -30,6 +30,8 @@ lemma not_fvar?_newVar {φ : Proposition L} {Γ : Sequent L} (h : φ ∈ Γ) : @[simp] lemma rew_neg_comm {Γ : Sequent L} (ω : Rew L ℕ 0 ℕ 0) : (∼Γ).map (ω ▹ ·) = ∼Γ.map (ω ▹ ·) := by simp [List.tilde_def] +def IsClosed (Γ : Sequent L) : Prop := ∃ φ ∈ Γ, ∼φ ∈ Γ + end Sequent /-! ## Derivation for one-sided $\mathbf{LK}$ -/ @@ -118,6 +120,10 @@ def eta : (φ : Proposition L) → ⊢ᴷ [φ, ∼φ] def close (φ : Proposition L) (hp : φ ∈ Δ := by simp) (hn : ∼φ ∈ Δ := by simp) : ⊢ᴷ Δ := eta φ |>.weakening (by simp [hp, hn]) +lemma of_isClosed {Γ : Sequent L} (h : Γ.IsClosed) : Nonempty (⊢ᴷ Γ) := by + rcases h with ⟨φ, hp, hn⟩ + exact ⟨close φ hp hn⟩ + instance : OneSidedLK (Derivation (L := L)) where verum := verum and d₁ d₂ := d₁.and d₂ diff --git a/Foundation/FirstOrder/Completeness/Coding.lean b/Foundation/FirstOrder/Completeness/Coding.lean index 3aad7ff1a..69fc86ff2 100644 --- a/Foundation/FirstOrder/Completeness/Coding.lean +++ b/Foundation/FirstOrder/Completeness/Coding.lean @@ -34,21 +34,21 @@ def Code.equiv (L : Language.{u}) : toFun := fun c => match c with | (Code.axL r v) => Sum.inl ⟨_, r, v⟩ - | Code.verum => Sum.inr $ Sum.inl () + | Code.verum => Sum.inr $ Sum.inl () | (Code.and φ ψ) => Sum.inr $ Sum.inr $ Sum.inl (φ, ψ) - | (Code.or φ ψ) => Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl (φ, ψ) - | (Code.all φ) => Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl φ - | (Code.exs φ t) => Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl (φ, t) - | (Code.id σ) => Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr σ + | (Code.or φ ψ) => Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl (φ, ψ) + | (Code.all φ) => Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl φ + | (Code.exs φ t) => Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl (φ, t) + | (Code.id σ) => Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr σ invFun := fun x => match x with - | (Sum.inl ⟨_, r, v⟩) => Code.axL r v - | (Sum.inr $ Sum.inl ()) => Code.verum - | (Sum.inr $ Sum.inr $ Sum.inl (φ, ψ)) => Code.and φ ψ - | (Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl (φ, ψ)) => Code.or φ ψ - | (Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl φ) => Code.all φ + | (Sum.inl ⟨_, r, v⟩) => Code.axL r v + | (Sum.inr $ Sum.inl ()) => Code.verum + | (Sum.inr $ Sum.inr $ Sum.inl (φ, ψ)) => Code.and φ ψ + | (Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl (φ, ψ)) => Code.or φ ψ + | (Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl φ) => Code.all φ | (Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl (φ, t)) => Code.exs φ t - | (Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr σ) => Code.id σ + | (Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr σ) => Code.id σ left_inv := fun c => by cases c <;> simp right_inv := fun x => by rcases x with (⟨_, _, _⟩ | ⟨⟩ | ⟨_, _⟩ | ⟨_, _⟩ | _ | ⟨_, _⟩ | _) <;> simp diff --git a/Foundation/FirstOrder/Completeness/SearchTree.lean b/Foundation/FirstOrder/Completeness/SearchTree.lean index e61bac21f..ad95e7210 100644 --- a/Foundation/FirstOrder/Completeness/SearchTree.lean +++ b/Foundation/FirstOrder/Completeness/SearchTree.lean @@ -23,7 +23,7 @@ inductive Redux (T : Theory L) : Code L → Sequent L → Sequent L → Prop | andRefl {Γ : Sequent L} {φ ψ : Proposition L} : φ ⋏ ψ ∉ Γ → Redux T (Code.and φ ψ) Γ Γ | or {Γ : Sequent L} {φ ψ : Proposition L} : φ ⋎ ψ ∈ Γ → Redux T (Code.or φ ψ) (φ :: ψ :: Γ) Γ | orRefl {Γ : Sequent L} {φ ψ : Proposition L} : φ ⋎ ψ ∉ Γ → Redux T (Code.or φ ψ) Γ Γ - | all {Γ : Sequent L} {φ : Semiproposition L 1} : ∀⁰ φ ∈ Γ → Redux T (Code.all φ) (φ/[&(newVar Γ)] :: Γ) Γ + | all {Γ : Sequent L} {φ : Semiproposition L 1} : ∀⁰ φ ∈ Γ → Redux T (Code.all φ) (φ/[&Γ.newVar] :: Γ) Γ | allRefl {Γ : Sequent L} {φ : Semiproposition L 1} : ∀⁰ φ ∉ Γ → Redux T (Code.all φ) Γ Γ | exs {Γ : Sequent L} {φ : Semiproposition L 1} {t : SyntacticTerm L} : ∃⁰ φ ∈ Γ → Redux T (Code.exs φ t) (φ/[t] :: Γ) Γ @@ -34,6 +34,7 @@ inductive Redux (T : Theory L) : Code L → Sequent L → Sequent L → Prop local notation:25 Δ₁" ≺[" c:25 "] " Δ₂:80 => Redux T c Δ₁ Δ₂ +/--/ lemma Redux.antimonotone {c : Code L} {Δ₂ Δ₁ : Sequent L} (h : Δ₂ ≺[c] Δ₁) : Δ₁ ⊆ Δ₂ := by cases h <;> simp [List.subset_cons_of_subset _ (List.subset_cons_self _ _)] diff --git a/Foundation/FirstOrder/Completeness/SubLanguage.lean b/Foundation/FirstOrder/Completeness/SubLanguage.lean index 4edb48b0b..7477eb4da 100644 --- a/Foundation/FirstOrder/Completeness/SubLanguage.lean +++ b/Foundation/FirstOrder/Completeness/SubLanguage.lean @@ -64,8 +64,8 @@ def toSubLanguage' (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop @[simp] lemma lMap_toSubLanguage' (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) (t : Semiterm L ξ n) (h : ∀ k f, ⟨k, f⟩ ∈ t.lang → pf k f) : - (t.toSubLanguage' pf pr h).lMap L.ofSubLanguage = t := - by induction t <;> simp [*, toSubLanguage', lMap_func] + (t.toSubLanguage' pf pr h).lMap L.ofSubLanguage = t := by + induction t <;> simp [*, toSubLanguage', lMap_func, Function.comp_def] end Semiterm @@ -125,7 +125,7 @@ def toSubLanguage' (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) {n} (φ : Semiformula L ξ n) (hf : ∀ k f, ⟨k, f⟩ ∈ φ.langFunc → pf k f) (hr : ∀ k r, ⟨k, r⟩ ∈ φ.langRel → pr k r) : lMap L.ofSubLanguage (φ.toSubLanguage' pf pr hf hr) = φ := by - induction φ using rec' <;> simp [*, toSubLanguage', lMap_rel, lMap_nrel] + induction φ using rec' <;> simp [*, toSubLanguage', lMap_rel, lMap_nrel, Function.comp_def] noncomputable def languageFuncIndexed (φ : Semiformula L ξ n) (k) : Finset (L.Func k) := Finset.preimage (langFunc φ) (Sigma.mk k) (Set.injOn_of_injective sigma_mk_injective) @@ -185,11 +185,11 @@ lemma val_lMap (injf : ∀ k, Function.Injective (Φ.func : L₁.Func k → L₂.Func k)) {n} (e : Fin n → M) (ε : ξ → M) (t : Semiterm L₁ ξ n) : - Semiterm.val (s₁.extendStructure Φ) e ε (t.lMap Φ) = Semiterm.val s₁ e ε t := by + Semiterm.val (s := s₁.extendStructure Φ) e ε (t.lMap Φ) = Semiterm.val (s := s₁) e ε t := by induction t case func k f v ih => - simp only [Semiterm.lMap_func, Semiterm.val_func, ih] - exact extendStructure.func s₁ Φ (injf k) f fun i ↦ Semiterm.val s₁ e ε (v i) + simp only [Semiterm.lMap_func, Semiterm.val_func, Function.comp_def, ih] + exact extendStructure.func s₁ Φ (injf k) f fun i ↦ Semiterm.val (s := s₁) e ε (v i) case _ => simp [*] case _ => simp [*] @@ -201,15 +201,15 @@ lemma eval_lMap (injr : ∀ k, Function.Injective (Φ.rel : L₁.Rel k → L₂.Rel k)) {n} (e : Fin n → M) (ε : ξ → M) {φ : Semiformula L₁ ξ n} : - Eval (s₁.extendStructure Φ) e ε (lMap Φ φ) ↔ Eval s₁ e ε φ := by + Eval (s := s₁.extendStructure Φ) e ε (lMap Φ φ) ↔ Eval (s := s₁) e ε φ := by induction φ using Semiformula.rec' case hrel k r v => - simp only [Semiformula.lMap_rel, eval_rel, val_lMap s₁ Φ injf e ε] - exact extendStructure.rel s₁ Φ (injr k) r (fun i => Semiterm.val s₁ e ε (v i)) + simp only [Semiformula.lMap_rel, eval_rel, val_lMap s₁ Φ injf e ε, Function.comp_def] + exact extendStructure.rel s₁ Φ (injr k) r (fun i => Semiterm.val (s := s₁) e ε (v i)) case hnrel k r v => - simp only [lMap_nrel, eval_nrel, val_lMap s₁ Φ injf e ε] + simp only [lMap_nrel, eval_nrel, val_lMap s₁ Φ injf e ε, Function.comp_def] simpa [not_iff_not] using - extendStructure.rel s₁ Φ (injr k) r (fun i => Semiterm.val s₁ e ε (v i)) + extendStructure.rel s₁ Φ (injr k) r (fun i => Semiterm.val (s := s₁) e ε (v i)) case _ => simp [*] case _ => simp [*] case _ => simp [*] @@ -231,21 +231,6 @@ end Structure section lMap -lemma lMap_models_lMap_iff - (Φ : L₁ →ᵥ L₂) - (injf : ∀ k, Function.Injective (Φ.func : L₁.Func k → L₂.Func k)) - (injr : ∀ k, Function.Injective (Φ.rel : L₁.Rel k → L₂.Rel k)) - {T : Theory L₁} {φ : Sentence L₁} : - Theory.lMap Φ T ⊨ Semiformula.lMap Φ φ ↔ T ⊨ φ := by - constructor - · intro h s₁ hs₁ - refine (Structure.extendStructure.models_lMap s₁.struc Φ injf injr φ).mp <| h ?_ - suffices ∀ σ ∈ T, (Structure.extendStructure Φ s₁.struc).toStruc ⊧ Semiformula.lMap Φ σ by - simpa [Semantics.modelsSet_iff, Theory.lMap, Semantics.models] - intro σ hσ - exact (Structure.extendStructure.models_lMap s₁.struc Φ injf injr σ).mpr (hs₁.models _ hσ) - · exact lMap_models_lMap - lemma satisfiable_lMap (Φ : L₁ →ᵥ L₂) (injf : ∀ k, Function.Injective (Φ.func : L₁.Func k → L₂.Func k)) diff --git a/Foundation/FirstOrder/Polarity.lean b/Foundation/FirstOrder/Polarity.lean index 18631e22a..f22189408 100644 --- a/Foundation/FirstOrder/Polarity.lean +++ b/Foundation/FirstOrder/Polarity.lean @@ -102,6 +102,6 @@ lemma Positive.eq_true {n} {φ : Semiformula L ξ n} (h : φ.Positive) : φ.pola lemma Negative.eq_false {n} {φ : Semiformula L ξ n} (h : φ.Negative) : φ.polarity = false := h @[simp] lemma polarity_rew (ω : Rew L ξ₁ n₁ ξ₂ n₂) (φ : Semiformula L ξ₁ n₁) : (ω ▹ φ).polarity = φ.polarity := by - induction φ using rec' <;> simp [polarity, *, Semiformula.rew_rel, Semiformula.rew_nrel] + induction φ using rec' <;> simp [polarity, *] end LO.FirstOrder.Semiformula diff --git a/Foundation/FirstOrder/Ultraproduct.lean b/Foundation/FirstOrder/Ultraproduct.lean index bf156dcc0..eb97a3e72 100644 --- a/Foundation/FirstOrder/Ultraproduct.lean +++ b/Foundation/FirstOrder/Ultraproduct.lean @@ -13,9 +13,9 @@ section universe u v variable {L : Language.{u}} {ξ : Type v} - {I : Type u} (A : I → Type u) - [s : (i : I) → FirstOrder.Structure L (A i)] - (𝓤 : Ultrafilter I) + {I : Type u} (A : I → Type u) + [s : (i : I) → FirstOrder.Structure L (A i)] + (𝓤 : Ultrafilter I) namespace Structure @@ -43,8 +43,8 @@ open Structure variable (e : Fin n → Uprod A 𝓤) (ε : ξ → Uprod A 𝓤) lemma val_Uprod (t : Semiterm L ξ n) : - t.valm (Uprod A 𝓤) e ε = ⟨fun i ↦ t.val (s i) (fun x ↦ (e x).val i) (fun x ↦ (ε x).val i)⟩ := - by induction t <;> simp [*, val_func] + t.val e ε = ⟨fun i ↦ t.val (fun x ↦ (e x).val i) (fun x ↦ (ε x).val i)⟩ := by + induction t <;> simp [*, val_func, Function.comp_def] end Semiterm @@ -61,7 +61,7 @@ lemma val_vecCons_val_eq {z : Uprod A 𝓤} {i : I} : simp [Matrix.comp_vecCons (Uprod.val · i), Function.comp_def] lemma eval_Uprod [(i : I) → Nonempty (A i)] {φ : Semiformula L ξ n} : - Evalm (Uprod A 𝓤) e ε φ ↔ {i | Eval (s i) (fun x ↦ (e x).val i) (fun x ↦ (ε x).val i) φ} ∈ 𝓤 := by + φ.Eval e ε ↔ {i | Eval (fun x ↦ (e x).val i) (fun x ↦ (ε x).val i) φ} ∈ 𝓤 := by induction φ using rec' case hverum => suffices Set.univ ∈ 𝓤 by simp [*] @@ -69,7 +69,7 @@ lemma eval_Uprod [(i : I) → Nonempty (A i)] {φ : Semiformula L ξ n} : case hfalsum => simp case hrel k r v => - simp [eval_rel, Semiterm.val_Uprod] + simp [Semiterm.val_Uprod, Function.comp_def] case hnrel k r v => simpa [*, eval_nrel, Semiterm.val_Uprod] using Ultrafilter.compl_mem_iff_notMem.symm @@ -79,51 +79,51 @@ lemma eval_Uprod [(i : I) → Nonempty (A i)] {φ : Semiformula L ξ n} : simpa [*, -Ultrafilter.union_mem_iff] using Ultrafilter.union_mem_iff.symm case hall φ _ => suffices - (∀ x : Uprod A 𝓤, {i | (Eval (s i) (fun j ↦ ((x :> e) j).val i) fun x ↦ (ε x).val i) φ} ∈ 𝓤) ↔ - {i | ∀ a : A i, (Eval (s i) (a :> fun x ↦ (e x).val i) fun z ↦ (ε z).val i) φ} ∈ 𝓤 by simp [*] + (∀ x : Uprod A 𝓤, {i | (Eval (fun j ↦ ((x :> e) j).val i) fun x ↦ (ε x).val i) φ} ∈ 𝓤) ↔ + {i | ∀ a : A i, (Eval (a :> fun x ↦ (e x).val i) fun z ↦ (ε z).val i) φ} ∈ 𝓤 by simp [*] constructor · intro h let z : Uprod A 𝓤 := ⟨fun i => - Classical.epsilon (fun z => ¬Eval (s i) (z :> fun x ↦ (e x).val i) (fun x ↦ (ε x).val i) φ)⟩ + Classical.epsilon (fun z => ¬Eval (z :> fun x ↦ (e x).val i) (fun x ↦ (ε x).val i) φ)⟩ exact Filter.mem_of_superset (h z) (by intro i hι a - have : Eval (s i) (z.val i :> fun x ↦ (e x).val i) (fun x ↦ (ε x).val i) φ := + have : Eval (z.val i :> fun x ↦ (e x).val i) (fun x ↦ (ε x).val i) φ := by rw [val_vecCons_val_eq]; exact hι by_contra hc - have : ¬Evalm (A i) (z.val i :> fun x ↦ (e x).val i) (fun x ↦ (ε x).val i) φ := - Classical.epsilon_spec (p := fun z => ¬(Eval (s i) (z :> fun x ↦ (e x).val i) _ φ)) ⟨a, hc⟩ + have : ¬Eval (M := A i) (z.val i :> fun x ↦ (e x).val i) (fun x ↦ (ε x).val i) φ := + Classical.epsilon_spec (p := fun z ↦ ¬(Eval (z :> fun x ↦ (e x).val i) _ φ)) ⟨a, hc⟩ contradiction) · intro h x exact Filter.mem_of_superset h (by intro i h; simpa [val_vecCons_val_eq] using h (x.val i)) case hexs φ _ => suffices - (∃ x, {i | (Eval (s i) (fun x_1 ↦ ((x :> e) x_1).val i) fun x ↦ (ε x).val i) φ} ∈ 𝓤) ↔ - {i | ∃ x, (Eval (s i) (x :> fun x ↦ (e x).val i) fun x ↦ (ε x).val i) φ} ∈ 𝓤 by simp [*] + (∃ x, {i | (Eval (fun x_1 ↦ ((x :> e) x_1).val i) fun x ↦ (ε x).val i) φ} ∈ 𝓤) ↔ + {i | ∃ x, (Eval (x :> fun x ↦ (e x).val i) fun x ↦ (ε x).val i) φ} ∈ 𝓤 by simp [*] constructor · rintro ⟨x, hx⟩ exact Filter.mem_of_superset hx (by intro i h; use x.val i; simpa [val_vecCons_val_eq] using h) · intro h let z : Uprod A 𝓤 := ⟨fun i => - Classical.epsilon (fun z => Eval (s i) (z :> fun x ↦ (e x).val i) (fun x ↦ (ε x).val i) φ)⟩ + Classical.epsilon (fun z => Eval (z :> fun x ↦ (e x).val i) (fun x ↦ (ε x).val i) φ)⟩ use z exact Filter.mem_of_superset h (by intro i; rintro ⟨x, hx⟩ - have : Eval (s i) (z.val i :> fun x ↦ (e x).val i) (fun x ↦ (ε x).val i) φ := - Classical.epsilon_spec (p := fun z => Eval (s i) (z :> fun x ↦ (e x).val i) _ φ) ⟨x, hx⟩ + have : Eval (z.val i :> fun x ↦ (e x).val i) (fun x ↦ (ε x).val i) φ := + Classical.epsilon_spec (p := fun z ↦ Eval (z :> fun x ↦ (e x).val i) _ φ) ⟨x, hx⟩ rw [val_vecCons_val_eq] at this; exact this) lemma val_Uprod [(i : I) → Nonempty (A i)] {φ : Formula L ξ} : - Evalfm (Uprod A 𝓤) ε φ ↔ {i | Evalf (s i) (fun x ↦ (ε x).val i) φ} ∈ 𝓤 := by + Evalf ε φ ↔ {i | Evalf (fun x ↦ (ε x).val i) φ} ∈ 𝓤 := by simp [Evalf, eval_Uprod, Matrix.empty_eq] end Semiformula lemma models_Uprod [Nonempty I] [(i : I) → Nonempty (A i)] {φ : Sentence L} : - (Uprod A 𝓤) ⊧ₘ φ ↔ {i | (A i) ⊧ₘ φ} ∈ 𝓤 := by simp [models_iff, Semiformula.val_Uprod, Empty.eq_elim] + (Uprod A 𝓤)↓[L] ⊧ φ ↔ {i | (A i)↓[L] ⊧ φ} ∈ 𝓤 := by simp [models_iff, Semiformula.val_Uprod, Empty.eq_elim] variable (A) -def Sentence.domain [(i : I) → Nonempty (A i)] (φ : Sentence L) := {i | A i ⊧ₘ φ} +def Sentence.domain [(i : I) → Nonempty (A i)] (φ : Sentence L) := {i | (A i)↓[L] ⊧ φ} end @@ -138,7 +138,7 @@ variable (A : FinSubtheory T → Type u) [s : (i : FinSubtheory T) → Structure instance : Nonempty (FinSubtheory T) := ⟨∅, by simp⟩ lemma ultrafilter_exists [(t : FinSubtheory T) → Nonempty (A t)] - (H : ∀ (i : FinSubtheory T), (A i) ⊧ₘ* (i.val : Theory L)) : + (H : ∀ (i : FinSubtheory T), (A i)↓[L] ⊧* (i.val : Theory L)) : ∃ 𝓤 : Ultrafilter (FinSubtheory T), Set.image (Sentence.domain A) T ⊆ 𝓤.sets := Ultrafilter.exists_ultrafilter_of_finite_inter_nonempty _ (by haveI : DecidableEq (Set (FinSubtheory T)) := fun _ _ => Classical.propDecidable _ @@ -147,7 +147,7 @@ lemma ultrafilter_exists [(t : FinSubtheory T) → Nonempty (A t)] simpa [Finset.subset_set_image_iff] using ht rcases this with ⟨t, htT, rfl⟩ exact ⟨⟨t, htT⟩, by - suffices ∀ i ∈ t, A ⟨t, htT⟩ ⊧ₘ i by simpa [Sentence.domain] using this + suffices ∀ i ∈ t, (A ⟨t, htT⟩)↓[L] ⊧ i by simpa [Sentence.domain] using this intro i hi; exact (H ⟨t, htT⟩).models_set hi⟩) lemma compactness_aux : @@ -155,12 +155,12 @@ lemma compactness_aux : constructor · rintro h ⟨t, ht⟩; exact Semantics.Satisfiable.of_subset h ht · intro h - have : ∀ i : FinSubtheory T, ∃ (M : Type u) (_ : Nonempty M) (_ : Structure L M), M ⊧ₘ* (i.val : Theory L) := + have : ∀ i : FinSubtheory T, ∃ (M : Type u) (_ : Nonempty M) (_ : Structure L M), M ↓[L] ⊧* (i.val : Theory L) := by intro i; exact satisfiable_iff.mp (h i) choose A si s hA using this have : ∃ 𝓤 : Ultrafilter (FinSubtheory T), Set.image (Sentence.domain A) T ⊆ 𝓤.sets := ultrafilter_exists A hA rcases this with ⟨𝓤, h𝓤⟩ - have : Structure.Uprod A 𝓤 ⊧ₘ* T := ⟨by intro σ hσ; exact models_Uprod.mpr (h𝓤 $ Set.mem_image_of_mem (Sentence.domain A) hσ)⟩ + have : (Structure.Uprod A 𝓤)↓[L] ⊧* T := ⟨by intro σ hσ; exact models_Uprod.mpr (h𝓤 $ Set.mem_image_of_mem (Sentence.domain A) hσ)⟩ exact satisfiable_intro (Structure.Uprod A 𝓤) this theorem compact : diff --git a/Foundation/Meta/TwoSided.lean b/Foundation/Meta/TwoSided.lean index ab5f8ffb6..1d246c16b 100644 --- a/Foundation/Meta/TwoSided.lean +++ b/Foundation/Meta/TwoSided.lean @@ -23,7 +23,7 @@ namespace TwoSided variable {Γ Γ₁ Γ₂ Δ Δ₁ Δ₂ : List F} {φ ψ χ : F} lemma weakening (h : Γ₁ ⟹ Δ₁) (HΓ : Γ₁ ⊆ Γ₂ := by simp) (HΔ : Δ₁ ⊆ Δ₂ := by simp) : Γ₂ ⟹ Δ₂ := - FiniteContext.weakening! HΓ <| left_Disj!_intro Δ₁ (fun _ hψ ↦ right_Disj!_intro _ (HΔ hψ)) ⨀! h + FiniteContext.weakening! HΓ <| left_Disj!_intro Δ₁ (fun _ hψ ↦ right_Disj!_intro _ (HΔ hψ)) ⨀ h lemma remove_left (hφ : Γ ⟹ Δ) : φ :: Γ ⟹ Δ := weakening hφ @@ -37,20 +37,20 @@ lemma rotate_right_inv (hφ : Γ ⟹ φ :: Δ) : Γ ⟹ Δ ++ [φ] := weakening lemma rotate_left_inv (hφ : (φ :: Γ) ⟹ Δ) : (Γ ++ [φ]) ⟹ Δ := weakening hφ +omit [DecidableEq F] in lemma to_provable {φ} (h : [] ⟹ [φ]) : 𝓢 ⊢ φ := - FiniteContext.provable_iff_provable.mpr <| left_Disj!_intro [φ] (by simp) ⨀! h + FiniteContext.provable_iff_provable.mpr <| left_Disj!_intro [φ] (by simp) ⨀ h lemma add_hyp {𝒯 : S} [𝒯 ⪯ 𝓢] (hφ : 𝒯 ⊢ φ) (h : (φ :: Γ) ⟹ Δ) : Γ ⟹ Δ := - deduct! h ⨀! of'! (WeakerThan.pbl hφ) - -lemma right_closed (h : φ ∈ Γ) : Γ ⟹ φ :: Δ := right_Disj!_intro _ (φ := φ) (by simp) ⨀! (by_axm! h) + deduct! h ⨀ of'! (WeakerThan.pbl hφ) -lemma left_closed (h : φ ∈ Δ) : (φ :: Γ) ⟹ Δ := right_Disj!_intro _ (φ := φ) h ⨀! by_axm! +lemma right_closed (h : φ ∈ Γ) : Γ ⟹ φ :: Δ := right_Disj!_intro _ (φ := φ) (by simp) ⨀ (by_axm! h) -lemma verum_right : Γ ⟹ ⊤ :: Δ := right_Disj!_intro _ (φ := ⊤) (by simp) ⨀! (by simp) +lemma left_closed (h : φ ∈ Δ) : (φ :: Γ) ⟹ Δ := right_Disj!_intro _ (φ := φ) h ⨀ (by_axm!) +lemma verum_right : Γ ⟹ ⊤ :: Δ := right_Disj!_intro _ (φ := ⊤) (by simp) ⨀ (by simp) omit [DecidableEq F] in -lemma falsum_left : (⊥ :: Γ) ⟹ Δ := efq! ⨀! by_axm₀! +lemma falsum_left : (⊥ :: Γ) ⟹ Δ := efq! ⨀ by_axm₀! lemma falsum_right (h : Γ ⟹ Δ) : Γ ⟹ ⊥ :: Δ := weakening h @@ -65,13 +65,10 @@ lemma and_right (hφ : Γ ⟹ Δ ++ [φ]) (hψ : Γ ⟹ Δ ++ [ψ]) : Γ ⟹ φ apply left_Disj!_intro intro ξ hξ rcases show ξ = ψ ∨ ξ ∈ Δ by simpa using hξ with (rfl | hξ) - · apply deduct! - apply right_Disj!_intro (χ ⋏ ξ :: Δ) (φ := χ ⋏ ξ) List.mem_cons_self ⨀! (K!_intro by_axm₁! by_axm₀!) - · apply right_Disj!_intro _ (by simp [hξ]) - · apply deduct! - apply dhyp! - apply right_Disj!_intro _ (φ := χ) (by simp [hχ]) ⨀! by_axm₀! - exact this ⨀! weakening hφ ⨀! weakening hψ + · exact deduct! <| right_Disj!_intro (χ ⋏ ξ :: Δ) (φ := χ ⋏ ξ) List.mem_cons_self ⨀ (K!_intro by_axm₁! by_axm₀!) + · exact right_Disj!_intro _ (by simp [hξ]) + · exact deduct! <| dhyp! <| right_Disj!_intro _ (φ := χ) (by simp [hχ]) ⨀ by_axm₀! + exact this ⨀ weakening hφ ⨀ weakening hψ lemma or_left (hφ : Γ ++ [φ] ⟹ Δ) (hψ : Γ ++ [ψ] ⟹ Δ) : φ ⋎ ψ :: Γ ⟹ Δ := by apply deductInv! @@ -87,17 +84,17 @@ lemma or_right (h : Γ ⟹ Δ ++ [φ, ψ]) : Γ ⟹ φ ⋎ ψ :: Δ := by · apply right_Disj!_intro' (χ ⋎ ψ :: Δ) (φ := χ ⋎ ψ) (by simp) or₁! · apply right_Disj!_intro' (φ ⋎ χ :: Δ) (φ := φ ⋎ χ) (by simp) or₂! · apply right_Disj!_intro _ (by simp [hχ]) - exact this ⨀! weakening h + exact this ⨀ weakening h lemma and_left (h : Γ ++ [φ, ψ] ⟹ Δ) : (φ ⋏ ψ :: Γ) ⟹ Δ := by have : φ :: ψ :: Γ ⟹ Δ := weakening h have : (φ ⋏ ψ :: Γ) ⊢[𝓢] ψ ➝ φ ➝ Δ.disj := wk! (by simp) (deduct! <| deduct! this) - exact this ⨀! (deductInv! and₂!) ⨀! (deductInv! and₁!) + exact this ⨀ (deductInv! and₂!) ⨀ (deductInv! and₁!) lemma neg_right_int (h : Γ ++ [φ] ⟹ []) : Γ ⟹ ∼φ :: Δ := by have : φ :: Γ ⟹ [] := weakening h have : Γ ⊢[𝓢] ∼φ := N!_iff_CO!.mpr <| deduct! this - have : Γ ⟹ [∼φ] := (right_Disj!_intro _ (by simp)) ⨀! this + have : Γ ⟹ [∼φ] := (right_Disj!_intro _ (by simp)) ⨀ this exact weakening this omit [Entailment.Int 𝓢] in @@ -127,13 +124,13 @@ lemma neg_left (h : Γ ⟹ Δ ++ [φ]) : ∼φ :: Γ ⟹ Δ := lemma imply_left_int (hφ : Γ ++ [φ ➝ ψ] ⟹ Δ ++ [φ]) (hψ : Γ ++ [ψ] ⟹ Δ) : (φ ➝ ψ) :: Γ ⟹ Δ := by have hφ : (φ ➝ ψ) :: Γ ⟹ φ :: Δ := weakening hφ have hψ : ψ :: Γ ⟹ Δ := weakening hψ - suffices ((φ ➝ ψ) :: Γ) ⊢[𝓢] (φ :: Δ).disj ➝ Δ.disj from this ⨀! wk! (by simp) hφ + suffices ((φ ➝ ψ) :: Γ) ⊢[𝓢] (φ :: Δ).disj ➝ Δ.disj from this ⨀ wk! (by simp) hφ apply left_Disj!_intro intro χ hχ rcases show χ = φ ∨ χ ∈ Δ by simpa using hχ with (rfl | hχ) · apply deduct! have : Γ ⊢[𝓢] ψ ➝ Δ.disj := deduct! hψ - apply (wk! (by simp) this) ⨀! (by_axm₁! ⨀! by_axm₀!) + apply (wk! (by simp) this) ⨀ (by_axm₁! ⨀ by_axm₀!) · apply right_Disj!_intro _ (by simp [hχ]) lemma imply_left (hφ : Γ ⟹ Δ ++ [φ]) (hψ : Γ ++ [ψ] ⟹ Δ) : (φ ➝ ψ) :: Γ ⟹ Δ := @@ -142,7 +139,7 @@ lemma imply_left (hφ : Γ ⟹ Δ ++ [φ]) (hψ : Γ ++ [ψ] ⟹ Δ) : (φ ➝ lemma imply_right_int (h : Γ ++ [φ] ⟹ [ψ]) : Γ ⟹ (φ ➝ ψ) :: Δ := by have h : φ :: Γ ⟹ [ψ] := weakening h have : (φ :: Γ) ⊢[𝓢] ψ := (left_Disj!_intro _ <| by simp) ⨀ h - exact (right_Disj!_intro _ <| by simp) ⨀! deduct! this + exact (right_Disj!_intro _ <| by simp) ⨀ deduct! this omit [Entailment.Int 𝓢] in lemma imply_right_cl [Entailment.Cl 𝓢] (h : Γ ++ [φ] ⟹ Δ ++ [ψ]) : Γ ⟹ (φ ➝ ψ) :: Δ := by @@ -256,6 +253,7 @@ lemma remove : Valid 𝓢 T → Valid 𝓢 ((Γ ⟶ Δ) :: T) := variable [DecidableEq F] [Entailment.Int 𝓢] +omit [DecidableEq F] in lemma to_provable (h : Valid 𝓢 [[] ⟶ [φ]]) : 𝓢 ⊢ φ := by rcases h · exact TwoSided.to_provable <| by assumption diff --git a/Foundation/Syntax/Predicate/Rew.lean b/Foundation/Syntax/Predicate/Rew.lean index 0ee33c7ec..ce6049974 100644 --- a/Foundation/Syntax/Predicate/Rew.lean +++ b/Foundation/Syntax/Predicate/Rew.lean @@ -827,6 +827,13 @@ def shifts [Rewriting L ℕ F ℕ F] (Γ : List (F n)) : List (F n) := Γ.map Re scoped[LO.FirstOrder] postfix:max "⁺" => FirstOrder.Rewriting.shifts +@[simp] lemma shifts_nil [Rewriting L ℕ F ℕ F] : ([] : List (F n))⁺ = [] := by rfl + +@[simp] lemma shifts_cons [Rewriting L ℕ F ℕ F] (φ : F n) (Γ : List (F n)) : (φ :: Γ)⁺ = shift φ :: Γ⁺ := by simp [shifts] + +@[simp] lemma shifts_neg [Rewriting L ℕ F ℕ F] (Γ : List (F n)) : (∼Γ)⁺ = ∼(Γ⁺) := by + simp [shifts, List.tilde_def] + @[coe] abbrev emb {ο ξ} [IsEmpty ο] {O F : ℕ → Type*} [LCWQ O] [LCWQ F] [Rewriting L ο O ξ F] (φ : O n) : F n := @Rew.emb L ο _ ξ n ▹ φ end Rewriting From 98e2337cac5c002721f2a288f475e9a79815c304 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Mon, 30 Mar 2026 02:11:14 +0900 Subject: [PATCH 18/61] =?UTF-8?q?g=C3=B6delGentzen?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NegationTranslation/GoedelGentzen.lean | 95 ++++++++----------- 1 file changed, 41 insertions(+), 54 deletions(-) diff --git a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean index 39d22e553..56acebdfa 100644 --- a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean +++ b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean @@ -6,20 +6,6 @@ public import Foundation.Meta.IntProver @[expose] public section namespace LO.FirstOrder -namespace Sequent - -instance : Tilde (List (Semiformula L ξ n)) := ⟨fun Γ ↦ Γ.map (∼·)⟩ - -@[simp] lemma neg_def (Γ : List (Semiformula L ξ n)) : ∼Γ = Γ.map (∼·) := rfl - -@[simp] lemma neg_nil : ∼([] : List (Semiformula L ξ n)) = [] := rfl - -@[simp] lemma neg_cons (Γ : List (Semiformula L ξ n)) (φ) : ∼(φ :: Γ) = ∼φ :: ∼Γ := rfl - -@[simp] lemma neg_neg_eq (Γ : List (Semiformula L ξ n)) : ∼∼Γ = Γ := by simp [Function.comp_def] - -end Sequent - namespace Semiformula def doubleNegation {n} : Semiformula L ξ n → Semiformulaᵢ L ξ n @@ -66,7 +52,7 @@ lemma doubleNegation_fconj (s : Finset (Semiformula L ξ n)) : (s.conj)ᴺ = (s.toList.map Semiformula.doubleNegation).conj₂ := doubleNegation_conj₂ _ lemma rew_doubleNegation (ω : Rew L ξ₁ n₁ ξ₂ n₂) (φ : Semiformula L ξ₁ n₁) : ω ▹ φᴺ = (ω ▹ φ)ᴺ := by - induction φ using rec' generalizing n₂ <;> simp [rew_rel, rew_nrel, Semiformulaᵢ.rew_rel, *] + induction φ using rec' generalizing n₂ <;> simp [Semiformulaᵢ.rew_rel, *, Function.comp_def] lemma subst_doubleNegation (φ : Semiformula L ξ n₁) (v : Fin n₁ → Semiterm L ξ n₂) : φᴺ ⇜ v = (φ ⇜ v)ᴺ := rew_doubleNegation _ _ @@ -76,10 +62,26 @@ lemma emb_doubleNegation (φ : Semisentence L n₁) : end Semiformula -abbrev Sequent.doubleNegation (Γ : List (Semiformula L ξ n)) : List (Semiformulaᵢ L ξ n) := Γ.map (·ᴺ) +namespace Sequent + +def doubleNegation (Γ : Sequent L) : Sequentᵢ L := + Γ.map Semiformula.doubleNegation scoped[LO.FirstOrder] postfix:max "ᴺ" => Sequent.doubleNegation +@[simp] lemma doubleNegation_nil : ([] : Sequent L)ᴺ = [] := rfl + +@[simp] lemma doubleNegation_cons (φ : Proposition L) (Γ : Sequent L) : + (φ :: Γ)ᴺ = φᴺ :: Γᴺ := rfl + +@[simp] lemma doubleNegation_append (Γ Δ : Sequent L) : (Γ ++ Δ)ᴺ = Γᴺ ++ Δᴺ := by + simp [doubleNegation] + +lemma shift_doubleNegation (Γ : Sequent L) : (Γᴺ)⁺ = (Γ⁺)ᴺ := by + simp [Sequent.doubleNegation, Rewriting.shifts, Semiformula.rew_doubleNegation, Function.comp_def] + +end Sequent + def Theory.ToTheoryᵢ (T : Theory L) (Λ : Hilbertᵢ L) : Theoryᵢ L Λ where theory := Semiformula.doubleNegation '' T @@ -113,12 +115,12 @@ def negDoubleNegation : (φ : Proposition L) → Λ ⊢! ∼φᴺ ⭤ (∼φ)ᴺ have ihφ : Λ ⊢! ∼(free φ)ᴺ ⭤ (∼(free φ))ᴺ := negDoubleNegation (free φ) have : Λ ⊢! (free φ)ᴺ ⭤ (∼(∼(free φ))ᴺ) := iffnegOfNegIff (by simp) ihφ have : Λ ⊢! ∀⁰ φᴺ ⭤ ∀⁰ ∼(∼φ)ᴺ := - allIffAllOfIff <| Entailment.cast (by simp [Semiformula.rew_doubleNegation]) this + allIffAllOfIff <| Entailment.cast this (by simp [Semiformula.rew_doubleNegation]) Entailment.ENN_of_E this | ∃⁰ φ => have ihφ : Λ ⊢! ∼(free φ)ᴺ ⭤ (∼(free φ))ᴺ := negDoubleNegation (free φ) have : Λ ⊢! ∀⁰ ∼φᴺ ⭤ ∀⁰ (∼φ)ᴺ := - allIffAllOfIff <| Entailment.cast (by simp [Semiformula.rew_doubleNegation]) ihφ + allIffAllOfIff <| Entailment.cast ihφ (by simp [Semiformula.rew_doubleNegation]) have : Λ ⊢! ∼∼(∀⁰ ∼φᴺ) ⭤ ∀⁰ (∼φ)ᴺ := Entailment.E_trans (DN_of_isNegative (by simp)) this this termination_by φ => φ.complexity @@ -150,8 +152,8 @@ lemma imply_doubleNegation (φ ψ : Proposition L) : Λ ⊢ (φᴺ ➝ ψᴺ) open Entailment -def gödelGentzen {Γ : Sequent L} : ⊢ᵀ Γ → (∼Γ)ᴺ ⊢[Λ]! ⊥ - | axL r v => nthAxm 1 ⨀ nthAxm 0 +def gödelGentzen {Γ : Sequent L} : ⊢ᴷ Γ → (∼Γ)ᴺ ⊢[Λ]! ⊥ + | identity r v => nthAxm 1 ⨀ nthAxm 0 | verum => nthAxm 0 | and (Γ := Γ) (φ := φ) (ψ := ψ) dφ dψ => have ihφ : ((∼φ)ᴺ :: (∼Γ)ᴺ) ⊢[Λ]! ⊥ := gödelGentzen dφ @@ -164,50 +166,35 @@ def gödelGentzen {Γ : Sequent L} : ⊢ᵀ Γ → (∼Γ)ᴺ ⊢[Λ]! ⊥ Entailment.FiniteContext.weakening (by simp) this ⨀ (Entailment.K_right (nthAxm 0)) ⨀ (Entailment.K_left (nthAxm 0)) this | all (Γ := Γ) (φ := φ) d => - have eΓ : (∼Γ⁺)ᴺ = ((∼Γ)ᴺ)⁺ := by - simp [Sequent.doubleNegation, Rewriting.shifts, Sequent.neg_def, Semiformula.rew_doubleNegation] + have eΓ : (∼Γ⁺)ᴺ = ((∼Γ)ᴺ)⁺ := by simp [Sequent.shift_doubleNegation] have : ((∼Γ)ᴺ)⁺ ⊢[Λ]! free (∼(∼φ)ᴺ) := FiniteContext.cast (deduct (gödelGentzen d)) eΓ (by simp [Semiformula.rew_doubleNegation]; rfl) deductInv <| dni' <| geNOverFiniteContext this - | exs (Γ := Γ) (φ := φ) t d => + | exs (Γ := Γ) (φ := φ) (t := t) d => have ih : (∼Γ)ᴺ ⊢[Λ]! ∼((∼φ)ᴺ/[t]) := - Entailment.cast (by simp [Semiformula.rew_doubleNegation]; rfl) <| deduct (gödelGentzen d) + Entailment.cast (deduct (gödelGentzen d)) (by simp [Semiformula.rew_doubleNegation]; rfl) have : ((∀⁰ (∼φ)ᴺ) :: (∼Γ)ᴺ) ⊢[Λ]! (∼φ)ᴺ/[t] := specializeOverContext (nthAxm 0) t (FiniteContext.weakening (by simp) ih) ⨀ this - | cut (Γ := Γ) (φ := φ) dp dn => + | cut (Γ := Γ) (Δ := Δ) (φ := φ) dp dn => have ihp : ((∼φ)ᴺ :: (∼Γ)ᴺ) ⊢[Λ]! ⊥ := gödelGentzen dp - have ihn : (φᴺ :: (∼Γ)ᴺ) ⊢[Λ]! ⊥ := cast (by simp) (gödelGentzen dn) - have b₁ : (∼Γ)ᴺ ⊢[Λ]! ∼∼φᴺ := Entailment.C_trans (of <| Entailment.K_left (negDoubleNegation φ)) (deduct ihp) - have b₂ : (∼Γ)ᴺ ⊢[Λ]! ∼φᴺ := deduct ihn + have ihn : (φᴺ :: (∼Δ)ᴺ) ⊢[Λ]! ⊥ := cast (by simp) (gödelGentzen dn) + have b₁ : (∼(Γ ++ Δ))ᴺ ⊢[Λ]! ∼∼φᴺ := + FiniteContext.weakening (by simp) <| Entailment.C_trans (of <| Entailment.K_left (negDoubleNegation φ)) (deduct ihp) + have b₂ : (∼(Γ ++ Δ))ᴺ ⊢[Λ]! ∼φᴺ := FiniteContext.weakening (by simp) <| deduct ihn b₁ ⨀ b₂ - | wk (Γ := Γ) (Δ := Δ) d h => FiniteContext.weakening (by simpa using List.map_subset _ h) (gödelGentzen d) + | wk (Γ := Γ) (Δ := Δ) d h => + FiniteContext.weakening + (List.map_subset _ <| List.map_subset _ h) + (gödelGentzen d) end Derivation -open Classical LO.Entailment - -/-- Gödel-Gentzen translation of classical first-order logic to intiotionistic first-order logic. -/ -theorem gödel_gentzen {T : Theory L} {φ} : T ⊢ φ → T.ToTheoryᵢ Λ ⊢ φᴺ := by - intro h - let ⟨⟨s, hs⟩, b⟩ := Theory.compact' h - have h : (∅ : Schema L) ⊢ ↑s.conj ➝ ↑φ := by simpa using provable_def.mp b - let ψ : Proposition L := ↑s.conj ➝ ↑φ - have h₁ : Λ ⊢ ∼(∼ψ)ᴺ := by - simpa using Entailment.FiniteContext.provable_iff.mp ⟨Derivation.gödelGentzen h.get⟩ - have h₂ : Λ ⊢ ∼(∼ψ)ᴺ ⭤ ψᴺ := by simpa using Derivation.neg_doubleNegation (∼ψ) - have : Λ ⊢ ψᴺ := K!_left h₂ ⨀ h₁ - have H : Λ ⊢ (↑s.conj : Proposition L)ᴺ ➝ ↑φᴺ := - by simpa [Semiformula.emb_doubleNegation] using (K!_right (Derivation.imply_doubleNegation _ _)) ⨀ this - let U : Set (Propositionᵢ L) := (Rewriting.emb '' (T.ToTheoryᵢ Λ).theory) - suffices - U *⊢[Λ] ⋀ s.toList.map fun φ : Sentence L ↦ (↑φ : Proposition L)ᴺ by - apply Theoryᵢ.provable_def.mpr - apply Context.of! H ⨀ ?_ - simpa [Finset.conj, List.map_conj₂, Function.comp_def] - apply LO.Entailment.Conj₂!_intro - have : ∀ ψ ∈ s, U *⊢[Λ] ↑ψᴺ := by - intro ψ hψ - exact Context.by_axm (by simpa [U] using ⟨ψ, hs hψ, rfl⟩) - simpa [←Semiformula.emb_doubleNegation] using this +open Classical + +theorem Proof.gödel_gentzen {φ : Proposition L} : 𝐋𝐊¹ ⊢ φ → 𝗠𝗶𝗻¹ ⊢ φᴺ := by + rintro ⟨d⟩ + have : 𝗠𝗶𝗻¹ ⊢ ∼(∼φ)ᴺ := ⟨Derivation.gödelGentzen d (Λ := 𝗠𝗶𝗻¹)⟩ + exact Entailment.K!_left (Derivation.neg_doubleNegation' φ (Λ := 𝗠𝗶𝗻¹)) ⨀ this + end LO.FirstOrder From 8f70c25d60026dce847efdc7f6a94c26431e4554 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Mon, 30 Mar 2026 03:30:25 +0900 Subject: [PATCH 19/61] hauptsatz --- Foundation/FirstOrder/Hauptsatz.lean | 104 +++++++++--------- .../NegationTranslation/GoedelGentzen.lean | 6 +- 2 files changed, 52 insertions(+), 58 deletions(-) diff --git a/Foundation/FirstOrder/Hauptsatz.lean b/Foundation/FirstOrder/Hauptsatz.lean index dcb77ddc1..2f58fb731 100644 --- a/Foundation/FirstOrder/Hauptsatz.lean +++ b/Foundation/FirstOrder/Hauptsatz.lean @@ -15,65 +15,63 @@ variable {L : Language.{u}} namespace Derivation -inductive IsCutFree : {Γ : Sequent L} → ⊢ᵀ Γ → Prop -| axL (r : L.Rel k) (v) : IsCutFree (axL r v) +inductive IsCutFree : {Γ : Sequent L} → ⊢ᴷ Γ → Prop +| axL (r : L.Rel k) (v) : IsCutFree (identity r v) | verum : IsCutFree verum -| or {d : ⊢ᵀ φ :: ψ :: Γ} : IsCutFree d → IsCutFree d.or -| and {dφ : ⊢ᵀ φ :: Γ} {dψ : ⊢ᵀ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) -| all {d : ⊢ᵀ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all -| exs (t) {d : ⊢ᵀ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs -| wk {d : ⊢ᵀ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) +| or {d : ⊢ᴷ φ :: ψ :: Γ} : IsCutFree d → IsCutFree d.or +| and {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) +| all {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all +| exs (t) {d : ⊢ᴷ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs +| wk {d : ⊢ᴷ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) attribute [simp] IsCutFree.axL IsCutFree.verum variable {Γ Δ : Sequent L} -@[simp] lemma isCutFree_or_iff {d : ⊢ᵀ φ :: ψ :: Γ} : +@[simp] lemma isCutFree_or_iff {d : ⊢ᴷ φ :: ψ :: Γ} : IsCutFree d.or ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .or⟩ -@[simp] lemma isCutFree_and_iff {dφ : ⊢ᵀ φ :: Γ} {dψ : ⊢ᵀ ψ :: Γ} : +@[simp] lemma isCutFree_and_iff {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : IsCutFree (dφ.and dψ) ↔ IsCutFree dφ ∧ IsCutFree dψ := ⟨by rintro ⟨⟩; constructor <;> assumption, by intro ⟨hφ, hψ⟩; exact hφ.and hψ⟩ -@[simp] lemma isCutFree_all_iff {d : ⊢ᵀ Rewriting.free φ :: Γ⁺} : +@[simp] lemma isCutFree_all_iff {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : IsCutFree d.all ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .all⟩ -@[simp] lemma isCutFree_exs_iff {d : ⊢ᵀ φ/[t] :: Γ} : +@[simp] lemma isCutFree_exs_iff {d : ⊢ᴷ φ/[t] :: Γ} : IsCutFree d.exs ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .exs t⟩ -@[simp] lemma isCutFree_wk_iff {d : ⊢ᵀ Δ} {ss : Δ ⊆ Γ} : +@[simp] lemma isCutFree_wk_iff {d : ⊢ᴷ Δ} {ss : Δ ⊆ Γ} : IsCutFree (d.wk ss) ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .wk _⟩ -@[simp] lemma IsCutFree.cast {d : ⊢ᵀ Γ} {e : Γ = Δ} : +@[simp] lemma IsCutFree.cast {d : ⊢ᴷ Γ} {e : Γ = Δ} : IsCutFree (.cast d e) ↔ IsCutFree d := by rcases e; rfl -@[simp] lemma IsCutFree.not_cut (dp : ⊢ᵀ φ :: Γ) (dn : ⊢ᵀ ∼φ :: Γ) : ¬IsCutFree (dp.cut dn) := by rintro ⟨⟩ - -@[simp] lemma isCutFree_rewrite_iff_isCutFree {f : ℕ → SyntacticTerm L} {d : ⊢ᵀ Γ} : - IsCutFree (rewrite d f) ↔ IsCutFree d := by - induction d generalizing f - case axm => contradiction - case _ => simp [rewrite, *] - case _ => simp [rewrite, *] - case _ => simp [rewrite, *] - case _ => simp [rewrite, *] - case _ => simp [rewrite, *] - case _ => simp [rewrite, *] - case _ => simp [rewrite, *] - case _ => simp [rewrite, *] - -@[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᵀ Γ} : +@[simp] lemma IsCutFree.not_cut (dp : ⊢ᴷ φ :: Γ) (dn : ⊢ᴷ ∼φ :: Δ) : ¬IsCutFree (dp.cut dn) := by + intro h + refine h.rec + (motive := fun {_} d _ => + match d with + | .cut _ _ => False + | _ => True) + ?_ ?_ ?_ ?_ ?_ ?_ ?_ + all_goals simp + +@[simp] lemma isCutFree_rewrite_iff_isCutFree {f : ℕ → SyntacticTerm L} {d : ⊢ᴷ Γ} : + IsCutFree (rewrite f d) ↔ IsCutFree d := by + induction d generalizing f <;> simp [rewrite, *] + +@[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᴷ Γ} : IsCutFree (Derivation.map d f) ↔ IsCutFree d := isCutFree_rewrite_iff_isCutFree @[simp] lemma IsCutFree.genelalizeByNewver_isCutFree {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) - (d : ⊢ᵀ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] + (d : ⊢ᴷ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] end Derivation inductive PositiveDerivationFrom (Ξ : Sequent L) : Sequent L → Type _ -| verum : PositiveDerivationFrom Ξ [⊤] | or : PositiveDerivationFrom Ξ (φ :: ψ :: Γ) → PositiveDerivationFrom Ξ (φ ⋎ ψ :: Γ) -| exs (t) : PositiveDerivationFrom Ξ (φ/[t] :: Γ) → PositiveDerivationFrom Ξ ((∃⁰ φ) :: Γ) +| exs : PositiveDerivationFrom Ξ (φ/[t] :: Γ) → PositiveDerivationFrom Ξ ((∃⁰ φ) :: Γ) | wk : PositiveDerivationFrom Ξ Δ → Δ ⊆ Γ → PositiveDerivationFrom Ξ Γ | protected id : PositiveDerivationFrom Ξ Ξ @@ -86,18 +84,16 @@ variable {Ξ Γ Δ : Sequent L} def ofSubset (ss : Ξ ⊆ Γ) : Ξ ⟶⁺ Γ := wk .id ss def trans {Ξ Γ Δ : Sequent L} : Ξ ⟶⁺ Γ → Γ ⟶⁺ Δ → Ξ ⟶⁺ Δ - | _, verum => verum | b, or d => or (b.trans d) - | b, exs t d => exs t (b.trans d) + | b, exs d => exs (b.trans d) | b, wk d h => wk (b.trans d) h | b, .id => b def cons {Ξ Γ : Sequent L} (φ) : Ξ ⟶⁺ Γ → φ :: Ξ ⟶⁺ φ :: Γ - | verum => wk verum (List.subset_cons_self _ _) | or (Γ := Γ) (φ := ψ) (ψ := χ) d => have : φ :: Ξ ⟶⁺ ψ :: χ :: φ :: Γ := wk (cons φ d) (by simp; tauto) wk (or this) (by simp) - | exs (Ξ := Ξ) (Γ := Γ) (φ := ψ) t d => + | exs (Ξ := Ξ) (Γ := Γ) (φ := ψ) (t := t) d => have : φ :: Ξ ⟶⁺ ψ/[t] :: φ :: Γ := wk (cons φ d) (by simp) wk this.exs (by simp) | wk d h => wk (d.cons φ) (by simp [h]) @@ -108,20 +104,18 @@ def append {Ξ Γ : Sequent L} : (Δ : Sequent L) → Ξ ⟶⁺ Γ → Δ ++ Ξ | φ :: Δ, d => (d.append Δ).cons φ def add {Γ Δ Ξ Θ : Sequent L} : Γ ⟶⁺ Δ → Ξ ⟶⁺ Θ → Γ ++ Ξ ⟶⁺ Δ ++ Θ - | verum, d => wk verum (by simp) | or d, b => or (d.add b) - | exs t d, b => exs t (d.add b) + | exs d, b => exs (d.add b) | wk d h, b => wk (d.add b) (by simp [h]) | .id, b => b.append Γ -def graft {Ξ Γ : Sequent L} (b : ⊢ᵀ Ξ) : Ξ ⟶⁺ Γ → ⊢ᵀ Γ - | .verum => .verum +def graft {Ξ Γ : Sequent L} (b : ⊢ᴷ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴷ Γ | or d => .or (d.graft b) - | exs t d => .exs t (d.graft b) + | exs d => .exs (d.graft b) | wk d h => .wk (d.graft b) h | .id => b -lemma graft_isCutFree_of_isCutFree {b : ⊢ᵀ Ξ} {d : Ξ ⟶⁺ Γ} (hb : Derivation.IsCutFree b) : Derivation.IsCutFree (d.graft b) := by +lemma graft_isCutFree_of_isCutFree {b : ⊢ᴷ Ξ} {d : Ξ ⟶⁺ Γ} (hb : Derivation.IsCutFree b) : Derivation.IsCutFree (d.graft b) := by induction d <;> simp [graft, *] end PositiveDerivationFrom @@ -157,7 +151,7 @@ def K_left {p : ℙ} (φ ψ : Proposition L) : φ ⋏ ψ :: p ≼ φ :: p := tra def K_right {p : ℙ} (φ ψ : Proposition L) : φ ⋏ ψ :: p ≼ ψ :: p := trans (and φ ψ) (ofSubset <| by simp) -def all {p : ℙ} (φ : Semiproposition L 1) (t) : (∀⁰ φ) :: p ≼ φ/[t] :: p := ⟨.exs t (by simpa [← Semiformula.neg_eq] using .id)⟩ +def all {p : ℙ} (φ : Semiproposition L 1) (t) : (∀⁰ φ) :: p ≼ φ/[t] :: p := ⟨.exs (t := t) (by simpa [← Semiformula.neg_eq] using .id)⟩ def minLeLeft (p q : ℙ) : p ⊓ q ≼ p := ofSubset (by simp [inf_def]) @@ -172,8 +166,8 @@ def leMinRightOfLe (s : q ≼ p) : q ≼ p ⊓ q := leMinOfle s (.refl q) end StrongerThan def Forces (p : ℙ) : Propositionᵢ L → Type u - | ⊥ => { b : ⊢ᵀ ∼p // Derivation.IsCutFree b } - | .rel R v => { b : ⊢ᵀ .rel R v :: ∼p // Derivation.IsCutFree b } + | ⊥ => { b : ⊢ᴷ ∼p // Derivation.IsCutFree b } + | .rel R v => { b : ⊢ᴷ .rel R v :: ∼p // Derivation.IsCutFree b } | φ ⋏ ψ => Forces p φ × Forces p ψ | φ ⋎ ψ => Forces p φ ⊕ Forces p ψ | φ ➝ ψ => (q : ℙ) → q ≼ p → Forces q φ → Forces q ψ @@ -189,9 +183,9 @@ scoped prefix:45 "⊩ " => allForces namespace Forces -def falsumEquiv : p ⊩ ⊥ ≃ { b : ⊢ᵀ ∼p // Derivation.IsCutFree b} := by unfold Forces; exact .refl _ +def falsumEquiv : p ⊩ ⊥ ≃ { b : ⊢ᴷ ∼p // Derivation.IsCutFree b} := by unfold Forces; exact .refl _ -def relEquiv {k} {R : L.Rel k} {v} : p ⊩ .rel R v ≃ { b : ⊢ᵀ .rel R v :: ∼p // Derivation.IsCutFree b } := by +def relEquiv {k} {R : L.Rel k} {v} : p ⊩ .rel R v ≃ { b : ⊢ᴷ .rel R v :: ∼p // Derivation.IsCutFree b } := by unfold Forces; exact .refl _ def andEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ ⋏ ψ ≃ (p ⊩ φ) × (p ⊩ ψ) := by @@ -326,7 +320,7 @@ def ofMinimalProof {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢! φ → ⊩ φ termination_by b => HilbertProofᵢ.depth b def relRefl {k} (R : L.Rel k) (v : Fin k → SyntacticTerm L) : [.rel R v] ⊩ rel R v := - relEquiv.symm ⟨Derivation.axL _ _, by simp⟩ + relEquiv.symm ⟨Derivation.identity _ _, by simp⟩ protected def refl.or (ihφ : [φ] ⊩ φᴺ) (ihψ : [ψ] ⊩ ψᴺ) : [φ ⋎ ψ] ⊩ (φ ⋎ ψ)ᴺ := implyOf fun q dq ↦ @@ -337,22 +331,22 @@ protected def refl.or (ihφ : [φ] ⊩ φᴺ) (ihψ : [ψ] ⊩ ψᴺ) : [φ ⋎ let bψ : [ψ] ⊓ q ⊩ ⊥ := dψ.implyEquiv ([ψ] ⊓ q) (.minLeRight _ _) (ihψ.monotone (.minLeLeft _ _)) let ⟨bbφ, hbbφ⟩ := bφ.falsumEquiv let ⟨bbψ, hbbψ⟩ := bψ.falsumEquiv - let band : ⊢ᵀ ∼φ ⋏ ∼ψ :: ∼q := Derivation.and + let band : ⊢ᴷ ∼φ ⋏ ∼ψ :: ∼q := Derivation.and (Derivation.cast bbφ (by simp [inf_def])) (Derivation.cast bbψ (by simp [inf_def])) falsumEquiv.symm ⟨Derivation.cast band (by simp [inf_def]), by simp [band, hbbφ, hbbψ]⟩ protected def refl.exs (d : ∀ x, [φ/[&x]] ⊩ (φ/[&x])ᴺ) : [∃⁰ φ] ⊩ (∃⁰ φ)ᴺ := implyOf fun q f ↦ - let x := newVar ((∀⁰ ∼φ) :: ∼q) + let x := Sequent.newVar ((∀⁰ ∼φ) :: ∼q) let ih : [φ/[&x]] ⊩ φᴺ/[&x] := cast (d x) (by simp [Semiformula.subst_doubleNegation]) let b : [φ/[&x]] ⊓ q ⊩ ⊥ := (f.allEquiv &x).implyEquiv ([φ/[&x]] ⊓ q) (StrongerThan.minLeRight _ _) (ih.monotone (StrongerThan.minLeLeft _ _)) let ⟨b, hb⟩ := b.falsumEquiv - let ba : ⊢ᵀ (∀⁰ ∼φ) :: ∼q := + let ba : ⊢ᴷ (∀⁰ ∼φ) :: ∼q := Derivation.genelalizeByNewver (m := x) - (by have : ¬Semiformula.FVar? (∀⁰ ∼φ) x := not_fvar?_newVar (by simp) + (by have : ¬Semiformula.FVar? (∀⁰ ∼φ) x := Sequent.not_fvar?_newVar (by simp) simpa using this) - (fun ψ hψ ↦ not_fvar?_newVar (List.mem_cons_of_mem (∀⁰ ∼φ) hψ)) + (fun ψ hψ ↦ Sequent.not_fvar?_newVar (List.mem_cons_of_mem (∀⁰ ∼φ) hψ)) (Derivation.cast b (by simp [inf_def])) falsumEquiv.symm ⟨ba, by simp [ba, hb]⟩ @@ -388,14 +382,14 @@ def conj' : {Γ : Sequent L} → (b : (φ : Proposition L) → φ ∈ Γ → p end Forces -def main [L.DecidableEq] {Γ : Sequent L} : ⊢ᵀ Γ → {d : ⊢ᵀ Γ // Derivation.IsCutFree d} := fun d ↦ +def main [L.DecidableEq] {Γ : Sequent L} : ⊢ᴷ Γ → {d : ⊢ᴷ Γ // Derivation.IsCutFree d} := fun d ↦ let d : 𝗠𝗶𝗻¹ ⊢! ⋀(∼Γ)ᴺ ➝ ⊥ := Entailment.FiniteContext.toDef (Derivation.gödelGentzen d) let ff : ∼Γ ⊩ ⋀(∼Γ)ᴺ ➝ ⊥ := Forces.ofMinimalProof d (∼Γ) let fc : ∼Γ ⊩ ⋀(∼Γ)ᴺ := Forces.conj' fun φ hφ ↦ (Forces.refl φ).monotone (StrongerThan.ofSubset <| List.cons_subset.mpr ⟨hφ, by simp⟩) let b : ∼Γ ⊩ ⊥ := ff.modusPonens fc let ⟨b, hb⟩ := b.falsumEquiv - ⟨Derivation.cast b (Sequent.neg_neg_eq Γ), by simp [hb]⟩ + ⟨Derivation.cast b (by simp), by simp [hb]⟩ end Hauptsatz diff --git a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean index 56acebdfa..4bf06a42b 100644 --- a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean +++ b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean @@ -191,10 +191,10 @@ end Derivation open Classical -theorem Proof.gödel_gentzen {φ : Proposition L} : 𝐋𝐊¹ ⊢ φ → 𝗠𝗶𝗻¹ ⊢ φᴺ := by +theorem Proof.gödel_gentzen {φ : Proposition L} {Λ : Hilbertᵢ L} : 𝐋𝐊¹ ⊢ φ → Λ ⊢ φᴺ := by rintro ⟨d⟩ - have : 𝗠𝗶𝗻¹ ⊢ ∼(∼φ)ᴺ := ⟨Derivation.gödelGentzen d (Λ := 𝗠𝗶𝗻¹)⟩ - exact Entailment.K!_left (Derivation.neg_doubleNegation' φ (Λ := 𝗠𝗶𝗻¹)) ⨀ this + have : Λ ⊢ ∼(∼φ)ᴺ := ⟨Derivation.gödelGentzen d⟩ + exact Entailment.K!_left (Derivation.neg_doubleNegation' φ) ⨀ this end LO.FirstOrder From 8ca12838a0f74d4133db8d85ccf2d6e1e892bb13 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Mon, 30 Mar 2026 03:30:38 +0900 Subject: [PATCH 20/61] fix --- .../FirstOrder/Completeness/Completeness.lean | 121 +++++++----------- .../FirstOrder/Intuitionistic/Deduction.lean | 16 +-- Foundation/FirstOrder/Kripke/Basic.lean | 4 +- Foundation/FirstOrder/Kripke/WeakForcing.lean | 13 +- 4 files changed, 66 insertions(+), 88 deletions(-) diff --git a/Foundation/FirstOrder/Completeness/Completeness.lean b/Foundation/FirstOrder/Completeness/Completeness.lean index 85011f4c4..0f8a91529 100644 --- a/Foundation/FirstOrder/Completeness/Completeness.lean +++ b/Foundation/FirstOrder/Completeness/Completeness.lean @@ -1,94 +1,61 @@ module -public import Foundation.FirstOrder.Completeness.SearchTree -public import Foundation.FirstOrder.Completeness.SubLanguage public import Foundation.FirstOrder.Ultraproduct +public import Foundation.Vorspiel.List.ChainI +public import Mathlib.Data.Finset.Lattice.Lemmas @[expose] public section -namespace LO +namespace LO.FirstOrder -namespace FirstOrder +namespace Completeness -open Classical Semiformula Completeness +variable (L : Language) -variable {L : Language.{u}} {T : Theory L} +abbrev Clause := Finset (Proposition L) -section Encodable +variable {L} -variable [L.Encodable] +namespace Clause -noncomputable def Derivation.completeness_of_encodable - {Γ : Sequent L} (h : ∀ M [Nonempty M] [Structure L M], M ⊧ₘ* T → ∃ φ ∈ Γ, ∀ f, Semiformula.Evalfm M f φ) : (T : Schema L) ⟹ Γ := by - have : WellFounded (SearchTree.Lt T Γ) := by - by_contra nwf - have : ∃ φ ∈ Γ, ∀ f, Semiformula.Evalfm (Model T Γ) f φ := h _ (Model.models nwf) - rcases this with ⟨φ, hp, h⟩ - have : Evalf (Model.structure T Γ) (&·) φ := h (&·) - have : ¬Evalf (Model.structure T Γ) (&·) φ := by simpa using semanticMainLemmaTop nwf (φ := φ) hp - contradiction - exact syntacticMainLemmaTop this +def IsClosed (C : Clause L) : Prop := ∃ φ ∈ C, ∼φ ∈ C -lemma completeness_of_encodable {φ : Sentence L} : - T ⊨ φ → T ⊢ φ := fun h ↦ - ⟨Derivation.completeness_of_encodable (T := T) (Γ := [φ]) - fun _ _ _ hM ↦ ⟨φ, List.mem_of_mem_head? rfl, fun _ ↦ by simpa using h hM⟩⟩ +def shift (C : Clause L) : Clause L := C.map ⟨Semiformula.shift, LawfulSyntacticRewriting.shift_injective⟩ -instance : Complete T (Semantics.models (SmallStruc L) T):= ⟨completeness_of_encodable⟩ +inductive IsBoundary (C : Clause L) : Proposition L → Prop +| rel (R : L.Rel k) (v) : IsBoundary C (.rel R v) +| nrel (R : L.Rel k) (v) : IsBoundary C (.nrel R v) +| verum : IsBoundary C ⊤ +| falsum : IsBoundary C ⊥ +| and {φ ψ} : φ ∉ C → ψ ∉ C → IsBoundary C (φ ⋏ ψ) +| or {φ ψ} : φ ∉ C ∨ ψ ∉ C → IsBoundary C (φ ⋎ ψ) -end Encodable + +def rank (C : Clause L) : ℕ := C.fold (λ φ r => max φ.rank r) 0 + +end Clause open Classical -theorem complete {φ : Sentence L} : - T ⊨ φ → T ⊢ φ := fun h ↦ by - have : ∃ u : Finset (Sentence L), ↑u ⊆ insert (∼φ) T ∧ ¬Satisfiable (u : Theory L) := by - simpa using compact.not.mp (consequence_iff_unsatisfiable.mp h) - rcases this with ⟨u, ssu, hu⟩ - haveI : ∀ k, Encodable ((languageFinset u).Func k) := fun _ ↦ Fintype.toEncodable _ - haveI : ∀ k, Encodable ((languageFinset u).Rel k) := fun _ ↦ Fintype.toEncodable _ - let u' : Finset (Sentence (languageFinset u)) := Finset.imageOfFinset u (fun _ hp ↦ toSubLanguageFinsetSelf hp) - have image_u' : u'.image (Semiformula.lMap L.ofSubLanguage) = u := by - ext τ - simp only [Finset.mem_image, Finset.mem_imageOfFinset_iff, u'] - exact ⟨by rintro ⟨a, ⟨τ, hτ, rfl⟩, rfl⟩; simp [hτ], - by intro hτ; exact ⟨toSubLanguageFinsetSelf hτ, ⟨τ, hτ, rfl⟩, Semiformula.lMap_toSubLanguageFinsetSelf hτ⟩⟩ - have : ¬Satisfiable (u' : Theory (languageFinset u)) := by - intro h - have : Satisfiable (u : Theory L) := by - rw [←image_u'] - simpa using (satisfiable_lMap L.ofSubLanguage (fun k ↦ Subtype.val_injective) (fun _ ↦ Subtype.val_injective) h) - contradiction - have : Entailment.Inconsistent (u' : Theory (languageFinset u)) := Complete.inconsistent_of_unsatisfiable this - have : Entailment.Inconsistent (u : Theory L) := by rw [←image_u']; simpa using Theory.inconsistent_lMap L.ofSubLanguage this - have : Entailment.Inconsistent (insert (∼φ) T) := this.of_supset ssu - exact Entailment.provable_iff_inconsistent_adjoin.mpr this - -theorem complete_iff : T ⊨ φ ↔ T ⊢ φ := - ⟨fun h ↦ complete h, sound!⟩ - -instance (T : Theory L) : Complete T (Semantics.models (SmallStruc L) T) := ⟨complete⟩ - -lemma satisfiable_of_consistent' (h : Entailment.Consistent T) : Semantics.Satisfiable (SmallStruc L) T := - Complete.satisfiable_of_consistent h - -lemma satisfiable_of_consistent (h : Entailment.Consistent T) : Semantics.Satisfiable (Struc.{max u w} L) T := by - let ⟨M, _, _, h⟩ := satisfiable_iff.mp (satisfiable_of_consistent' h) - exact satisfiable_iff.mpr ⟨ULift.{w} M, inferInstance, inferInstance, ((uLift_elementaryEquiv L M).modelsTheory).mpr h⟩ - -lemma satisfiable_iff_consistent' : Semantics.Satisfiable (Struc.{max u w} L) T ↔ Entailment.Consistent T := - ⟨consistent_of_satisfiable, satisfiable_of_consistent.{u, w}⟩ - -lemma satisfiable_iff_consistent : Satisfiable T ↔ Entailment.Consistent T := satisfiable_iff_consistent'.{u, u} - -lemma satisfiable_iff_satisfiable : Semantics.Satisfiable (Struc.{max u w} L) T ↔ Satisfiable T := by - simp [satisfiable_iff_consistent'.{u, w}, satisfiable_iff_consistent] - -lemma consequence_iff_consequence : T ⊨[Struc.{max u w} L] φ ↔ T ⊨ φ := by - simp [consequence_iff_unsatisfiable, satisfiable_iff_satisfiable.{u, w}] - -theorem complete' {φ : Sentence L} : - T ⊨[Struc.{max u w} L] φ → T ⊢ φ := fun h ↦ complete <| consequence_iff_consequence.{u, w}.mp h - -instance (T : Theory L) : Complete T (Semantics.models (Struc.{max u w} L) T) := ⟨complete'.{u, w}⟩ - -end FirstOrder +inductive Search : Clause L → Clause L → Prop +| and_left {C : Clause L} : ¬C.IsClosed → φ ⋏ ψ ∈ C → Search (insert φ C) C +| and_right {C : Clause L} : ¬C.IsClosed → φ ⋏ ψ ∈ C → Search (insert ψ C) C +| or {C : Clause L} : ¬C.IsClosed → φ ⋎ ψ ∈ C → Search (insert φ (insert ψ C)) C +| all {C : Clause L} : ¬C.IsClosed → ∀⁰ φ ∈ C → Search (insert φ.free C.shift) C +| exs {C : Clause L} : ¬C.IsClosed → ∃⁰ φ ∈ C → (t : SyntacticTerm L) → Search (insert (φ/[t]) C) C + +structure SearchPath (C : Clause L) where + path : List (Clause L) + last : Clause L + chain : path.ChainI Search last C + +namespace SearchPath + +variable {C : Clause L} + +instance : LE (SearchPath C) where + le π τ := π.path <+: τ.path + +end SearchPath + + +end LO.FirstOrder.Completeness diff --git a/Foundation/FirstOrder/Intuitionistic/Deduction.lean b/Foundation/FirstOrder/Intuitionistic/Deduction.lean index 3086bb09e..7804631af 100644 --- a/Foundation/FirstOrder/Intuitionistic/Deduction.lean +++ b/Foundation/FirstOrder/Intuitionistic/Deduction.lean @@ -99,7 +99,7 @@ variable {Λ} instance : Entailment.Int (𝗜𝗻𝘁¹ : Hilbertᵢ L) where efq := eaxm <| by simp [Hilbertᵢ.Intuitionistic] -protected def cast {φ ψ} (b : Λ ⊢! φ) (e : φ = ψ) : Λ ⊢! ψ := e ▸ b +protected def cast {φ ψ} (b : Λ ⊢! φ) (e : φ = ψ := by simp) : Λ ⊢! ψ := e ▸ b def depth {φ} : Λ ⊢! φ → ℕ | mdp b d => max (depth b) (depth d) + 1 @@ -146,15 +146,15 @@ def allImplyAllOfAllImply (φ ψ) : Λ ⊢! ∀⁰ (φ ➝ ψ) ➝ ∀⁰ φ ➝ apply deduct apply geNOverFiniteContext have b₁ : [∀⁰ shift φ, ∀⁰ (shift φ ➝ shift ψ)] ⊢[Λ]! free φ ➝ free ψ := - Entailment.cast (by simp) (specializeOverContext (nthAxm 1) &0) + Entailment.cast (specializeOverContext (nthAxm 1) &0) have b₂ : [∀⁰ shift φ, ∀⁰ (shift φ ➝ shift ψ)] ⊢[Λ]! free φ := - Entailment.cast (by simp) (specializeOverContext (nthAxm 0) &0) + Entailment.cast (specializeOverContext (nthAxm 0) &0) have : [∀⁰ φ, ∀⁰ (φ ➝ ψ)]⁺ ⊢[Λ]! free ψ := cast (by simp) (b₁ ⨀ b₂) exact this def allIffAllOfIff {φ ψ} (b : Λ ⊢! free φ ⭤ free ψ) : Λ ⊢! ∀⁰ φ ⭤ ∀⁰ ψ := Entailment.K_intro - (allImplyAllOfAllImply φ ψ ⨀ gen (Entailment.cast (by simp) (Entailment.K_left b))) - (allImplyAllOfAllImply ψ φ ⨀ gen (Entailment.cast (by simp) (Entailment.K_right b))) + (allImplyAllOfAllImply φ ψ ⨀ gen (Entailment.cast (Entailment.K_left b))) + (allImplyAllOfAllImply ψ φ ⨀ gen (Entailment.cast (Entailment.K_right b))) def dneOfNegative [L.DecidableEq] : {φ : Propositionᵢ L} → φ.IsNegative → Λ ⊢! ∼∼φ ➝ φ | ⊥, _ => Entailment.CNNOO @@ -176,9 +176,9 @@ def dneOfNegative [L.DecidableEq] : {φ : Propositionᵢ L} → φ.IsNegative have ihφ : Λ ⊢! ∼∼(free φ) ➝ free φ := dneOfNegative (by simp [by simpa using h]) have : [∀⁰ shift φ, ∼(free φ), ∼∼(∀⁰ shift φ)] ⊢[Λ]! ⊥ := have : [∀⁰ shift φ, ∼(free φ), ∼∼(∀⁰ shift φ)] ⊢[Λ]! ∀⁰ shift φ := byAxm₀ - byAxm₁ ⨀ Entailment.cast (by simp) (specializeOverContext this &0) + byAxm₁ ⨀ Entailment.cast (specializeOverContext this &0) have : [∼∼(∀⁰ shift φ)] ⊢[Λ]! free φ := of ihφ ⨀ deduct (byAxm₁ ⨀ deduct this) - implyAll (Entailment.cast (by simp) (deduct' this)) + implyAll (Entailment.cast (deduct' this)) termination_by φ _ => φ.complexity def ofDNOfNegative [L.DecidableEq] {φ : Propositionᵢ L} {Γ} (b : Γ ⊢[Λ]! ∼∼φ) (h : φ.IsNegative) : Γ ⊢[Λ]! φ := @@ -198,7 +198,7 @@ def efqOfNegative : {φ : Propositionᵢ L} → φ.IsNegative → Λ ⊢! ⊥ Entailment.C_trans ihψ Entailment.implyK | ∀⁰ φ, h => have ihφ : Λ ⊢! ⊥ ➝ free φ := efqOfNegative (by simp [by simpa using h]) - implyAll <| Entailment.cast (by simp) ihφ + implyAll <| Entailment.cast ihφ termination_by φ _ => φ.complexity def iffnegOfNegIff [L.DecidableEq] {φ ψ : Propositionᵢ L} (h : φ.IsNegative) (b : Λ ⊢! ∼φ ⭤ ψ) : Λ ⊢! φ ⭤ ∼ψ := diff --git a/Foundation/FirstOrder/Kripke/Basic.lean b/Foundation/FirstOrder/Kripke/Basic.lean index 314cd63c2..ac820801b 100644 --- a/Foundation/FirstOrder/Kripke/Basic.lean +++ b/Foundation/FirstOrder/Kripke/Basic.lean @@ -68,10 +68,10 @@ variable {w : W} @[simp] lemma domain'_models_rel {R : L.Rel k} {v : Fin k → Point w} : (domain' w).rel R v ↔ Rel w R fun i ↦ ↑(v i) := by rfl -@[simp] lemma domain_val (t : Semiterm L ξ n) : t.val (domain w) bv fv = t.relationalVal bv fv := by +@[simp] lemma domain_val (t : Semiterm L ξ n) : t.val (s := domain w) bv fv = t.relationalVal bv fv := by rcases Semiterm.bvar_or_fvar_of_relational t with (⟨x, rfl⟩ | ⟨x, rfl⟩) <;> simp -@[simp] lemma domain'_val (t : Semiterm L ξ n) : t.val (domain' w) bv fv = t.relationalVal bv fv := by +@[simp] lemma domain'_val (t : Semiterm L ξ n) : t.val (s := domain' w) bv fv = t.relationalVal bv fv := by rcases Semiterm.bvar_or_fvar_of_relational t with (⟨x, rfl⟩ | ⟨x, rfl⟩) <;> simp end point_model diff --git a/Foundation/FirstOrder/Kripke/WeakForcing.lean b/Foundation/FirstOrder/Kripke/WeakForcing.lean index 6ace3891e..a18be6e1f 100644 --- a/Foundation/FirstOrder/Kripke/WeakForcing.lean +++ b/Foundation/FirstOrder/Kripke/WeakForcing.lean @@ -280,11 +280,22 @@ instance : WeakForcingRelation.ClassicalKripke ℙ (· ≥ ·) where monotone := monotone generic := generic -lemma sound {T : Theory L} (b : T ⊢ φ) : ℙ ∀⊩ᶜ* T → ℙ ∀⊩ᶜ φ := fun H ↦ +lemma sound : 𝐋𝐊¹ ⊢ φ → ∀ p : ℙ, ∀ fv, (∀ i, p ⊩↓ fv i) → p ⊩ᶜ[![] | fv] φ := fun b p fv Hfv ↦ by + have : 𝗜𝗻𝘁¹ ⊢ φᴺ := Proof.gödel_gentzen b + exact Forces.sound p fv Hfv this + +lemma sound₀ {φ : Sentence L} : 𝐋𝐊¹ ⊢ (φ : Proposition L) → ℙ ∀⊩ᶜ φ := fun b p ↦ by { + have := sound b p + } + + + +lemma sound : 𝐋𝐊¹ ⊢ φ → ℙ ∀⊩ᶜ φ.univCl := fun H ↦ Forces₀.sound (W := ℙ) (gödel_gentzen b (Λ := 𝗜𝗻𝘁¹)) fun φ hφ ↦ (by rcases show ∃ ψ ∈ T, ψᴺ = φ by simpa [Theory.ToTheoryᵢ] using hφ with ⟨ψ, hψ, rfl⟩ exact H ψ hψ) +/--/ end WeaklyForces₀ end KripkeModel From f3a40d3f411b7b526ea200ccf80f89461f607961 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Mon, 30 Mar 2026 14:57:42 +0900 Subject: [PATCH 21/61] Forcing --- Foundation/FirstOrder/Kripke/Basic.lean | 4 +++ Foundation/FirstOrder/Kripke/WeakForcing.lean | 29 +++++++++---------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/Foundation/FirstOrder/Kripke/Basic.lean b/Foundation/FirstOrder/Kripke/Basic.lean index ac820801b..473fbde4e 100644 --- a/Foundation/FirstOrder/Kripke/Basic.lean +++ b/Foundation/FirstOrder/Kripke/Basic.lean @@ -39,6 +39,10 @@ namespace KripkeModel lemma domain_nonempty' (p : W) : ∃ x, p ⊩↓ x := domain_nonempty p +instance (p : W) : Nonempty p := by + rcases domain_nonempty p with ⟨x, _⟩ + exact ⟨x, by assumption⟩ + lemma domain_monotone {p : W} : p ⊩↓ x → ∀ q ≤ p, q ⊩↓ x := fun hx _ h ↦ domain_antimonotone h hx diff --git a/Foundation/FirstOrder/Kripke/WeakForcing.lean b/Foundation/FirstOrder/Kripke/WeakForcing.lean index a18be6e1f..8df19a54a 100644 --- a/Foundation/FirstOrder/Kripke/WeakForcing.lean +++ b/Foundation/FirstOrder/Kripke/WeakForcing.lean @@ -11,7 +11,7 @@ Main reference: Jeremy Avigad, "Forcing in proof theory" [Avi04] namespace LO.FirstOrder -variable {L : Language} [L.Relational] +variable {L : Language.{u}} [L.Relational] namespace KripkeModel @@ -59,6 +59,10 @@ lemma rew {bv : Fin n₂ → Name} {fv : ξ₂ → Name} {ω : Rew L ξ₁ n₁ p ⊩ᶜ[fun x ↦ (ω #x).relationalVal bv fv|fun x ↦ (ω &x).relationalVal bv fv] φ := by simp [WeaklyForces, ←Semiformula.rew_doubleNegation, Forces.rew] +@[simp] lemma emb {bv : Fin n → Name} {fv : ξ → Name} {φ : Semiformula L Empty n} : + p ⊩ᶜ[bv|fv] (Rew.emb ▹ φ) ↔ + p ⊩ᶜ[bv|Empty.elim] φ := by simp [rew, Empty.eq_elim] + @[simp] lemma ex {φ : Semiformula L ξ (n + 1)} : p ⊩ᶜ[bv|fv] ∃⁰ φ ↔ ∀ q ≤ p, ∃ r ≤ q, ∃ x : r, r ⊩ᶜ[↑x :> bv|fv] φ := by suffices @@ -284,18 +288,9 @@ lemma sound : 𝐋𝐊¹ ⊢ φ → ∀ p : ℙ, ∀ fv, (∀ i, p ⊩↓ fv i) have : 𝗜𝗻𝘁¹ ⊢ φᴺ := Proof.gödel_gentzen b exact Forces.sound p fv Hfv this -lemma sound₀ {φ : Sentence L} : 𝐋𝐊¹ ⊢ (φ : Proposition L) → ℙ ∀⊩ᶜ φ := fun b p ↦ by { - have := sound b p - } - - - -lemma sound : 𝐋𝐊¹ ⊢ φ → ℙ ∀⊩ᶜ φ.univCl := fun H ↦ - Forces₀.sound (W := ℙ) (gödel_gentzen b (Λ := 𝗜𝗻𝘁¹)) fun φ hφ ↦ (by - rcases show ∃ ψ ∈ T, ψᴺ = φ by simpa [Theory.ToTheoryᵢ] using hφ with ⟨ψ, hψ, rfl⟩ - exact H ψ hψ) +lemma sound₀ {σ : Sentence L} : 𝐋𝐊¹ ⊢ (σ : Proposition L) → ℙ ∀⊩ᶜ σ := fun b p ↦ by + simpa using sound b p (fun _ ↦ (Classical.ofNonempty : p).val) fun _ ↦ by simp -/--/ end WeaklyForces₀ end KripkeModel @@ -307,7 +302,7 @@ namespace ForcingNotion variable (ℙ : ForcingNotion L) -abbrev Condition := ℙ.World +@[coe] abbrev Condition := ℙ.World abbrev Name := ℙ.Carrier @@ -329,9 +324,11 @@ instance : Semantics (ForcingNotion L) (Sentence L) := ⟨fun ℙ φ ↦ ℙ ∀ lemma models_def : ℙ ⊧ φ ↔ ℙ ∀⊩ᶜ φ := by rfl -lemma sound {T : Theory L} (b : T ⊢ φ) : ℙ ⊧* T → ℙ ⊧ φ := fun H ↦ - WeaklyForces₀.sound (ℙ := ℙ) b fun _ hφ ↦ H.models_set hφ +lemma sound {σ : Sentence L} : 𝐋𝐊¹ ⊢ (σ : Proposition L) → ℙ ⊧ σ := + WeaklyForces₀.sound₀ -instance (T : Theory L) : Sound T (Semantics.models (ForcingNotion L) T) := ⟨fun b _ H ↦ sound b H⟩ +instance (ℙ : ForcingNotion L) : + Sound (Entailment.pullback (𝐋𝐊¹ : Proof.Symbol L) ((↑·) : Sentence L → Proposition L)) ℙ := + ⟨fun {_} ↦ sound⟩ end ForcingNotion From b0d462f34955b4978da2cc25460d029bf1a7db8f Mon Sep 17 00:00:00 2001 From: palalansouki Date: Mon, 30 Mar 2026 22:58:21 +0900 Subject: [PATCH 22/61] preorder --- Foundation/FirstOrder/Kripke/Basic.lean | 4 + Foundation/Vorspiel/Order/Preorder.lean | 105 ++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 Foundation/Vorspiel/Order/Preorder.lean diff --git a/Foundation/FirstOrder/Kripke/Basic.lean b/Foundation/FirstOrder/Kripke/Basic.lean index 473fbde4e..26d634c2c 100644 --- a/Foundation/FirstOrder/Kripke/Basic.lean +++ b/Foundation/FirstOrder/Kripke/Basic.lean @@ -123,6 +123,10 @@ end Filter end filter +variable (W) + + + end KripkeModel end LO.FirstOrder diff --git a/Foundation/Vorspiel/Order/Preorder.lean b/Foundation/Vorspiel/Order/Preorder.lean new file mode 100644 index 000000000..c43756157 --- /dev/null +++ b/Foundation/Vorspiel/Order/Preorder.lean @@ -0,0 +1,105 @@ +module + +public import Mathlib.Topology.Order.UpperLowerSetTopology +public import Mathlib.Topology.Sets.Opens +public import Mathlib.Order.Heyting.Regular + +@[expose] public section + +variable {α : Type*} [Preorder α] + +namespace LowerSet + +def IsCompatiblePair (a b : α) : Prop := ∃ c, c ≤ a ∧ c ≤ b + +infix:50 " ‖ " => IsCompatiblePair + +@[simp, refl] protected lemma IsCompatiblePair.refl (a : α) : a ‖ a := ⟨a, by simp⟩ + +@[symm] protected lemma IsCompatiblePair.symm_iff {a b : α} : a ‖ b ↔ b ‖ a := by + constructor + · rintro ⟨c, hca, hcb⟩; exact ⟨c, hcb, hca⟩ + · rintro ⟨c, hcb, hca⟩; exact ⟨c, hca, hcb⟩ + +alias ⟨IsCompatiblePair.symm, _⟩ := IsCompatiblePair.symm_iff + +def IsIncompatiblePair (a b : α) : Prop := ¬(a ‖ b) + +infix:50 " ⟂ " => IsIncompatiblePair + +lemma isIncompatiblePair_iff {a b : α} : a ⟂ b ↔ ∀ c ≤ a, ¬c ≤ b := by + simp [IsIncompatiblePair, IsCompatiblePair] + +@[simp] lemma IsIncompatiblePair.antirefl (a : α) : ¬(a ⟂ a) := by simp [IsIncompatiblePair] + +lemma IsIncompatiblePair.symm_iff {a b : α} : a ⟂ b ↔ b ⟂ a := by + contrapose; simpa [IsIncompatiblePair] using IsCompatiblePair.symm_iff + +alias ⟨IsIncompatiblePair.symm, _⟩ := IsIncompatiblePair.symm_iff + +lemma IsIncompatiblePair.lower {a a' b b' : α} (h : a ⟂ b) (ha'a : a' ≤ a) (hb'b : b' ≤ b) : a' ⟂ b' := by + rintro ⟨c, hca, hcb⟩ + exact h ⟨c, le_trans hca ha'a, le_trans hcb hb'b⟩ + +@[simp, grind =] lemma not_isCompatiblePair_iff_isIncompatiblePair {a b : α} : ¬(a ‖ b) ↔ a ⟂ b := by + rfl + +@[simp, grind =] lemma not_isIncompatiblePair_iff_isCompatiblePair {a b : α} : ¬(a ⟂ b) ↔ a ‖ b := by + simp [IsIncompatiblePair, IsCompatiblePair] + +instance : HeytingAlgebra (LowerSet α) := inferInstance + +lemma inf_eq_bot_iff_incompatible {u v : LowerSet α} : u ⊓ v = ⊥ ↔ (∀ x ∈ u, ∀ y ∈ v, x ⟂ y) := by + suffices (u ∩ v : Set α) = ∅ ↔ ∀ x ∈ u, ∀ y ∈ v, x ⟂ y by simpa [LowerSet.ext_iff] + constructor + · rintro e x hx y hy ⟨z, hzx, hzy⟩ + have hzu : z ∈ u := u.lower hzx hx + have hzv : z ∈ v := v.lower hzy hy + have : z ∈ (u ∩ v : Set α) := ⟨hzu, hzv⟩ + simp_all + · rintro h + suffices ∀ x ∈ u, x ∉ v by + apply Set.eq_empty_of_forall_notMem + simpa + intro x hx hx' + simpa using h x hx x hx' + +lemma mem_dual_iff {u : LowerSet α} : x ∈ uᶜ ↔ ∀ y ∈ u, x ⟂ y := by + suffices (∃ i, (∀ y ∈ i, ∀ z ∈ u, y ⟂ z) ∧ x ∈ i) ↔ ∀ y ∈ u, x ⟂ y by simpa [Compl.compl, inf_eq_bot_iff_incompatible] + constructor + · rintro ⟨i, hi, hxi⟩ y hyu + exact hi x hxi y hyu + · intro h + let i : LowerSet α := ⟨{x | ∀ y ∈ u, x ⟂ y}, by + intro a b hba ha y hyu + exact (ha y hyu).lower hba (by rfl)⟩ + refine ⟨i, by simp [i], by simpa [i] using h⟩ + +lemma coe_dual (u : LowerSet α) : uᶜ = {x | ∀ y ∈ u, x ⟂ y} := by + ext x; simp [mem_dual_iff] + +lemma sSup_dual (𝒮 : Set (LowerSet α)) : (sSup 𝒮)ᶜ = sInf (Compl.compl '' 𝒮) := by + ext; simp [coe_dual]; grind + +variable (α) + +abbrev Regular := Heyting.Regular (LowerSet α) + +variable {α} + +namespace Regular + +instance : BooleanAlgebra (Regular α) := inferInstance + +/- +instance : CompleteBooleanAlgebra (Regular α) where + sSup s := ⟨sSup (Subtype.val '' s), by { + suffices (sSup (Subtype.val '' s))ᶜᶜ = (sSup (Subtype.val '' s)) by simpa + simp [sSup_dual] + + }⟩ +-/ + +end Regular + +end LowerSet From ddf81f6ff87406792524d34578ffccc1a32797b2 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 4 Apr 2026 00:05:50 +0900 Subject: [PATCH 23/61] regular --- Foundation/Vorspiel/Order/Preorder.lean | 10 ++----- Foundation/Vorspiel/Order/Regular.lean | 36 +++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 Foundation/Vorspiel/Order/Regular.lean diff --git a/Foundation/Vorspiel/Order/Preorder.lean b/Foundation/Vorspiel/Order/Preorder.lean index c43756157..79bc010a8 100644 --- a/Foundation/Vorspiel/Order/Preorder.lean +++ b/Foundation/Vorspiel/Order/Preorder.lean @@ -3,6 +3,7 @@ module public import Mathlib.Topology.Order.UpperLowerSetTopology public import Mathlib.Topology.Sets.Opens public import Mathlib.Order.Heyting.Regular +public import Foundation.Vorspiel.Order.Regular @[expose] public section @@ -91,14 +92,7 @@ namespace Regular instance : BooleanAlgebra (Regular α) := inferInstance -/- -instance : CompleteBooleanAlgebra (Regular α) where - sSup s := ⟨sSup (Subtype.val '' s), by { - suffices (sSup (Subtype.val '' s))ᶜᶜ = (sSup (Subtype.val '' s)) by simpa - simp [sSup_dual] - - }⟩ --/ +instance : CompleteBooleanAlgebra (Regular α) := inferInstance end Regular diff --git a/Foundation/Vorspiel/Order/Regular.lean b/Foundation/Vorspiel/Order/Regular.lean new file mode 100644 index 000000000..da3d9e1e3 --- /dev/null +++ b/Foundation/Vorspiel/Order/Regular.lean @@ -0,0 +1,36 @@ +module + +public import Mathlib.Order.Heyting.Regular +public import Mathlib.Order.CompleteBooleanAlgebra + +public section + +namespace Heyting.Regular + +variable {α : Type*} [Order.Frame α] + +open Heyting Regular + +instance completelattice : CompleteLattice (Regular α) where + __ : Lattice (Regular α) := inferInstance + __ := gi.liftCompleteLattice + +instance : CompleteBooleanAlgebra (Regular α) where + __ : BooleanAlgebra (Regular α) := inferInstance + __ : CompleteLattice (Regular α) := inferInstance + +theorem coe_sSup (s : Set (Regular α)) : (↑(sSup s) : α) = (sSup ((↑) '' s))ᶜᶜ := by + simp [sSup, sSup_image] + +theorem coe_iSup (a : ι → Regular α) : (↑(⨆ i, a i) : α) = (⨆ i, (a i : α))ᶜᶜ := calc + (↑(⨆ i, a i) : α) = (↑(sSup (Set.range a)) : α) := by rfl + _ = (⨆ i, (a i : α))ᶜᶜ := by rw [coe_sSup]; congr; grind + +theorem coe_sInf (s : Set (Regular α)) : (↑(sInf s) : α) = sInf ((↑) '' s) := by + simp [sInf, sInf_image]; rfl + +theorem coe_iInf (a : ι → Regular α) : (↑(⨅ i, a i) : α) = (⨅ i, (a i : α)) := calc + (↑(⨅ i, a i) : α) = (↑(sInf (Set.range a)) : α) := by rfl + _ = (⨅ i, (a i : α)) := by rw [coe_sInf]; congr; grind + +end Heyting.Regular From ebe5e6cd9a2748381f6ae42d367a97c4f34fa2fe Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 4 Apr 2026 06:23:42 +0900 Subject: [PATCH 24/61] hauptsatz --- Foundation/FirstOrder/Hauptsatz.lean | 162 ++++++++++++++++-- Foundation/FirstOrder/Kripke/Basic.lean | 28 --- Foundation/FirstOrder/Kripke/WeakForcing.lean | 73 ++++++++ .../NegationTranslation/GoedelGentzen.lean | 3 +- Foundation/Logic/ForcingRelation.lean | 31 ++-- Foundation/Vorspiel/Order/Preorder.lean | 12 +- 6 files changed, 257 insertions(+), 52 deletions(-) diff --git a/Foundation/FirstOrder/Hauptsatz.lean b/Foundation/FirstOrder/Hauptsatz.lean index 2f58fb731..88660f266 100644 --- a/Foundation/FirstOrder/Hauptsatz.lean +++ b/Foundation/FirstOrder/Hauptsatz.lean @@ -1,6 +1,8 @@ module public import Foundation.FirstOrder.NegationTranslation.GoedelGentzen +public import Foundation.Logic.ForcingRelation +public import Foundation.Vorspiel.Order.Preorder @[expose] public section /-! @@ -163,6 +165,14 @@ def leMinOfle (srp : r ≼ p) (srq : r ≼ q) : r ≼ p ⊓ q := ⟨ def leMinRightOfLe (s : q ≼ p) : q ≼ p ⊓ q := leMinOfle s (.refl q) +instance : LE ℙ := ⟨fun q p ↦ Nonempty (q ≼ p)⟩ + +instance : Preorder ℙ where + le_refl p := ⟨StrongerThan.refl p⟩ + le_trans p q r := by + rintro ⟨hqp⟩ ⟨hrq⟩ + exact ⟨StrongerThan.trans hqp hrq⟩ + end StrongerThan def Forces (p : ℙ) : Propositionᵢ L → Type u @@ -175,13 +185,15 @@ def Forces (p : ℙ) : Propositionᵢ L → Type u | ∃⁰ φ => (t : SyntacticTerm L) × Forces p (φ/[t]) termination_by φ => φ.complexity -scoped infix:45 " ⊩ " => Forces -abbrev allForces (φ : Propositionᵢ L) := (p : ℙ) → p ⊩ φ +abbrev allForces (φ : Propositionᵢ L) := (p : ℙ) → Forces p φ + +namespace Forces + +scoped infix:45 " ⊩ " => Forces scoped prefix:45 "⊩ " => allForces -namespace Forces def falsumEquiv : p ⊩ ⊥ ≃ { b : ⊢ᴷ ∼p // Derivation.IsCutFree b} := by unfold Forces; exact .refl _ @@ -260,15 +272,15 @@ open LawfulSyntacticRewriting def modusPonens {φ ψ : Propositionᵢ L} (f : p ⊩ φ ➝ ψ) (g : p ⊩ φ) : p ⊩ ψ := f.implyEquiv p (StrongerThan.refl p) g -def ofMinimalProof {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢! φ → ⊩ φ +def sound {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢! φ → ⊩ φ | .mdp (φ := ψ) b d => fun p ↦ - let b : p ⊩ ψ ➝ φ := ofMinimalProof b p - let d : p ⊩ ψ := ofMinimalProof d p + let b : p ⊩ ψ ➝ φ := sound b p + let d : p ⊩ ψ := sound d p b.implyEquiv p (StrongerThan.refl p) d | .gen (φ := φ) b => fun p ↦ allEquiv.symm fun t ↦ let d : 𝗠𝗶𝗻¹ ⊢! φ/[t] := HilbertProofᵢ.cast (HilbertProofᵢ.rewrite (t :>ₙ fun x ↦ &x) b) (by simp [rewrite_free_eq_subst]) - ofMinimalProof d p + sound d p | .verum => fun p ↦ implyEquiv.symm fun q sqp bφ ↦ bφ | .implyK φ ψ => fun p ↦ implyEquiv.symm fun q sqp bφ ↦ implyEquiv.symm fun r srq bψ ↦ bφ.monotone srq | .implyS φ ψ χ => fun p ↦ @@ -384,13 +396,143 @@ end Forces def main [L.DecidableEq] {Γ : Sequent L} : ⊢ᴷ Γ → {d : ⊢ᴷ Γ // Derivation.IsCutFree d} := fun d ↦ let d : 𝗠𝗶𝗻¹ ⊢! ⋀(∼Γ)ᴺ ➝ ⊥ := Entailment.FiniteContext.toDef (Derivation.gödelGentzen d) - let ff : ∼Γ ⊩ ⋀(∼Γ)ᴺ ➝ ⊥ := Forces.ofMinimalProof d (∼Γ) - let fc : ∼Γ ⊩ ⋀(∼Γ)ᴺ := Forces.conj' fun φ hφ ↦ + let ff : Forces (∼Γ) (⋀(∼Γ)ᴺ ➝ ⊥) := Forces.sound d (∼Γ) + let fc : Forces (∼Γ) (⋀(∼Γ)ᴺ) := Forces.conj' fun φ hφ ↦ (Forces.refl φ).monotone (StrongerThan.ofSubset <| List.cons_subset.mpr ⟨hφ, by simp⟩) - let b : ∼Γ ⊩ ⊥ := ff.modusPonens fc + let b : Forces (∼Γ) ⊥ := ff.modusPonens fc let ⟨b, hb⟩ := b.falsumEquiv ⟨Derivation.cast b (by simp), by simp [hb]⟩ +abbrev IsForced (p : ℙ) (φ : Propositionᵢ L) := Nonempty (Forces p φ) + +instance : ForcingRelation ℙ (Propositionᵢ L) where + Forces := IsForced + +namespace IsForced + +open Classical + +@[simp] lemma rel {p : ℙ} {k} {R : L.Rel k} {v} : p ⊩ .rel R v ↔ Nonempty (⊢ᴷ .rel R v :: ∼p) := by + constructor + · rintro ⟨b⟩ + have ⟨d, hd⟩ := b.relEquiv + exact ⟨d⟩ + · rintro ⟨d⟩ + let ⟨b, hb⟩ := main d + exact ⟨Forces.relEquiv.symm ⟨b, hb⟩⟩ + +@[simp] lemma fal {p : ℙ} : p ⊩ ∀⁰ φ ↔ ∀ t, p ⊩ φ/[t] := by + constructor + · rintro ⟨b⟩ t + exact ⟨b.allEquiv t⟩ + · rintro h + exact ⟨Forces.allEquiv.symm fun t ↦ (h t).some⟩ + +@[simp] lemma and {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ ⋏ ψ ↔ p ⊩ φ ∧ p ⊩ ψ := by + constructor + · rintro ⟨b⟩ + have ⟨bφ, bψ⟩ := b.andEquiv + exact ⟨⟨bφ⟩, ⟨bψ⟩⟩ + · rintro ⟨⟨bφ⟩, ⟨bψ⟩⟩ + exact ⟨Forces.andEquiv.symm ⟨bφ, bψ⟩⟩ + +@[simp] lemma or {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ ⋎ ψ ↔ p ⊩ φ ∨ p ⊩ ψ := by + constructor + · rintro ⟨b⟩ + have b' := b.orEquiv + exact b'.rec (fun bφ ↦ .inl ⟨bφ⟩) (fun bψ ↦ .inr ⟨bψ⟩) + · rintro (⟨⟨hφ⟩⟩ | ⟨⟨hψ⟩⟩) + · exact ⟨Forces.orEquiv.symm <| .inl hφ⟩ + · exact ⟨Forces.orEquiv.symm <| .inr hψ⟩ + +lemma imply {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ ➝ ψ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ψ) := by + constructor + · rintro ⟨b⟩ q ⟨sqp⟩ ⟨bφ⟩ + exact ⟨b.implyEquiv _ sqp bφ⟩ + · rintro h + refine ⟨Forces.implyEquiv.symm fun q sqp hφ ↦ (h q ⟨sqp⟩ ⟨hφ⟩).some⟩ + +@[simp] lemma exs {p : ℙ} : p ⊩ ∃⁰ φ ↔ ∃ t, p ⊩ φ/[t] := by + constructor + · rintro ⟨b⟩ + have ⟨t, f⟩ := b.exsEquiv + exact ⟨t, ⟨f⟩⟩ + · rintro ⟨t, h⟩ + exact ⟨Forces.exsEquiv.symm ⟨t, h.some⟩⟩ + +lemma falsum {p : ℙ} : p ⊩ ⊥ ↔ Nonempty (⊢ᴷ ∼p) := by + constructor + · rintro ⟨b⟩ + have ⟨d, hd⟩ := b.falsumEquiv + exact ⟨d⟩ + · rintro ⟨d⟩ + let ⟨b, hb⟩ := main d + exact ⟨Forces.falsumEquiv.symm ⟨b, hb⟩⟩ + +lemma neg {p : ℙ} {φ : Propositionᵢ L} : p ⊩ ∼φ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ⊥) := by + simp [Semiformulaᵢ.neg_def, imply] + +lemma monotone {p q : ℙ} (hqp : q ≤ p) {φ : Propositionᵢ L} (hφ : p ⊩ φ) : q ⊩ φ := + ⟨Forces.monotone hqp.some hφ.some⟩ + +instance : ForcingRelation.PreIntKripke ℙ (· ≥ ·) where + verum _ := ⟨Forces.implyEquiv.symm fun _ _ d ↦ d⟩ + and _ := and + or _ := or + imply _ := imply + monotone hφ _ hpq := hφ.monotone hpq + +lemma sound_minimal {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢ φ → ℙ ∀⊩ φ := by + rintro ⟨d⟩ p; exact ⟨Forces.sound d p⟩ + +lemma dn_neg_iff {φ : Proposition L} {p : ℙ} : p ⊩ (∼φ)ᴺ ↔ p ⊩ ∼(φᴺ) := by + have := by simpa using (sound_minimal (Derivation.neg_doubleNegation φ) p) + exact (this p (by simp)).symm + +protected lemma refl (φ : Proposition L) : [φ] ⊩ φᴺ := ⟨Forces.refl φ⟩ + +lemma complete {φ : Proposition L} : ℙ ∀⊩ φᴺ ↔ 𝐋𝐊¹ ⊢ φ := by + constructor + · intro h + have hn : [∼φ] ⊩ ∼(φᴺ) := by simpa [dn_neg_iff] using (IsForced.refl (∼φ)) + have hp : [∼φ] ⊩ φᴺ := h [∼φ] + have : 𝐋𝐊¹ ⊢ φ := by simpa using falsum.mp <| neg.mp hn [∼φ] (by simp) hp + exact this + · intro b + exact sound_minimal <| Provable.gödel_gentzen b + +end IsForced + +def hValue (φ : Propositionᵢ L) : LowerSet ℙ where + carrier := { p | p ⊩ φ } + lower' := fun _ _ hqp hp ↦ IsForced.monotone hqp hp + +scoped prefix:max "♯" => hValue + +@[simp] lemma mem_hValue {p : ℙ} {φ : Propositionᵢ L} : p ∈ ♯φ ↔ p ⊩ φ := by simp [hValue] + +@[simp] lemma hValue_and_eq_inf {φ ψ : Propositionᵢ L} : ♯(φ ⋏ ψ) = (♯φ ⊓ ♯ψ) := by + ext p; simp [hValue] + +@[simp] lemma hValue_or_eq_sup {φ ψ : Propositionᵢ L} : ♯(φ ⋎ ψ) = (♯φ ⊔ ♯ψ) := by + ext p; simp only [hValue, ForcingRelation.BasicSemantics.or, LowerSet.coe_mk, Set.mem_setOf_eq, + LowerSet.coe_sup, Set.mem_union] + +@[simp] lemma hValue_fal_eq_Inf {φ : Semipropositionᵢ L 1} : ♯(∀⁰ φ) = ⨅ t, ♯(φ/[t]) := by + ext p; simp [hValue,] + +@[simp] lemma hValue_exs_eq_Sup {φ : Semipropositionᵢ L 1} : ♯(∃⁰ φ) = ⨆ t, ♯(φ/[t]) := by + ext p; simp [hValue,] + +@[simp] lemma hValue_imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ ➝ ψ) = (♯φ ⇨ ♯ψ) := by + ext p; simp [IsForced.imply, LowerSet.mem_himp_iff] + +lemma hValue_falsum : p ∈ ♯(⊥ : Propositionᵢ L) ↔ Nonempty (⊢ᴷ ∼p) := by + simp [hValue, IsForced.falsum] + +@[simp] lemma hValue_neg_eq_himp_bot (φ : Propositionᵢ L) : ♯(∼φ) = (♯φ ⇨ ♯⊥) := by + simp [Semiformulaᵢ.neg_def] + end Hauptsatz alias hauptsatz := Hauptsatz.main diff --git a/Foundation/FirstOrder/Kripke/Basic.lean b/Foundation/FirstOrder/Kripke/Basic.lean index 26d634c2c..b94f321ce 100644 --- a/Foundation/FirstOrder/Kripke/Basic.lean +++ b/Foundation/FirstOrder/Kripke/Basic.lean @@ -51,34 +51,6 @@ lemma domain_monotone {p : W} : p ⊩↓ x → ∀ q ≤ p, q ⊩↓ x := fun hx @[simp] lemma forcingExists_of_constantDomain [ConstantDomain W] (w : W) (x : C) : w ⊩↓ x := by suffices x ∈ Domain w from this; simp -section point_model - -instance domain (w : W) : Structure L w where - func _ f _ := IsEmpty.elim' inferInstance f - rel _ R v := Rel w R fun i ↦ ↑(v i) - -set_option linter.unusedVariables false in -def Point [KripkeModel L W C] (w : W) := C - -instance domain' (w : W) : Structure L (Point w) where - func _ f _ := IsEmpty.elim' inferInstance f - rel _ R v := Rel w R v - -variable {w : W} - -@[simp] lemma domain_models_rel {R : L.Rel k} {v : Fin k → w} : - (domain w).rel R v ↔ Rel w R fun i ↦ ↑(v i) := by rfl - -@[simp] lemma domain'_models_rel {R : L.Rel k} {v : Fin k → Point w} : - (domain' w).rel R v ↔ Rel w R fun i ↦ ↑(v i) := by rfl - -@[simp] lemma domain_val (t : Semiterm L ξ n) : t.val (s := domain w) bv fv = t.relationalVal bv fv := by - rcases Semiterm.bvar_or_fvar_of_relational t with (⟨x, rfl⟩ | ⟨x, rfl⟩) <;> simp - -@[simp] lemma domain'_val (t : Semiterm L ξ n) : t.val (s := domain' w) bv fv = t.relationalVal bv fv := by - rcases Semiterm.bvar_or_fvar_of_relational t with (⟨x, rfl⟩ | ⟨x, rfl⟩) <;> simp - -end point_model section filter diff --git a/Foundation/FirstOrder/Kripke/WeakForcing.lean b/Foundation/FirstOrder/Kripke/WeakForcing.lean index 8df19a54a..10e2e81d9 100644 --- a/Foundation/FirstOrder/Kripke/WeakForcing.lean +++ b/Foundation/FirstOrder/Kripke/WeakForcing.lean @@ -332,3 +332,76 @@ instance (ℙ : ForcingNotion L) : ⟨fun {_} ↦ sound⟩ end ForcingNotion + +/-! ## Completeness -/ + +section completeness + + +inductive PositiveDerivationFrom (Ξ : Sequent L) : Sequent L → Type _ +| or : PositiveDerivationFrom Ξ (φ :: ψ :: Γ) → PositiveDerivationFrom Ξ (φ ⋎ ψ :: Γ) +| exs : PositiveDerivationFrom Ξ (φ/[t] :: Γ) → PositiveDerivationFrom Ξ ((∃⁰ φ) :: Γ) +| wk : PositiveDerivationFrom Ξ Δ → Δ ⊆ Γ → PositiveDerivationFrom Ξ Γ +| protected id : PositiveDerivationFrom Ξ Ξ + +infix:45 " ⟶⁺ " => PositiveDerivationFrom + +namespace PositiveDerivationFrom + +variable {Ξ Γ Δ : Sequent L} + +def ofSubset (ss : Ξ ⊆ Γ) : Ξ ⟶⁺ Γ := wk .id ss + +def trans {Ξ Γ Δ : Sequent L} : Ξ ⟶⁺ Γ → Γ ⟶⁺ Δ → Ξ ⟶⁺ Δ + | b, or d => or (b.trans d) + | b, exs d => exs (b.trans d) + | b, wk d h => wk (b.trans d) h + | b, .id => b + +def cons {Ξ Γ : Sequent L} (φ) : Ξ ⟶⁺ Γ → φ :: Ξ ⟶⁺ φ :: Γ + | or (Γ := Γ) (φ := ψ) (ψ := χ) d => + have : φ :: Ξ ⟶⁺ ψ :: χ :: φ :: Γ := wk (cons φ d) (by simp; tauto) + wk (or this) (by simp) + | exs (Ξ := Ξ) (Γ := Γ) (φ := ψ) (t := t) d => + have : φ :: Ξ ⟶⁺ ψ/[t] :: φ :: Γ := wk (cons φ d) (by simp) + wk this.exs (by simp) + | wk d h => wk (d.cons φ) (by simp [h]) + | .id => .id + +def append {Ξ Γ : Sequent L} : (Δ : Sequent L) → Ξ ⟶⁺ Γ → Δ ++ Ξ ⟶⁺ Δ ++ Γ + | [], d => d + | φ :: Δ, d => (d.append Δ).cons φ + +def add {Γ Δ Ξ Θ : Sequent L} : Γ ⟶⁺ Δ → Ξ ⟶⁺ Θ → Γ ++ Ξ ⟶⁺ Δ ++ Θ + | or d, b => or (d.add b) + | exs d, b => exs (d.add b) + | wk d h, b => wk (d.add b) (by simp [h]) + | .id, b => b.append Γ + +def graft {Ξ Γ : Sequent L} (b : ⊢ᴷ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴷ Γ + | or d => .or (d.graft b) + | exs d => .exs (d.graft b) + | wk d h => .wk (d.graft b) h + | .id => b + +end PositiveDerivationFrom + +variable (L) + +abbrev ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴷ ∼Γ)} + +variable {L} + +instance : Preorder (ConsistentSequent L) where + le := fun Γ Δ ↦ Nonempty (PositiveDerivationFrom (∼Δ.val) (∼Γ.val)) + le_refl Γ := ⟨PositiveDerivationFrom.id⟩ + le_trans Γ Δ Ξ := by + rintro ⟨bΔ⟩ ⟨bΞ⟩ + exact ⟨PositiveDerivationFrom.trans bΞ bΔ⟩ + +insta + + +end completeness + +end LO.FirstOrder diff --git a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean index 4bf06a42b..966b85e1d 100644 --- a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean +++ b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean @@ -191,10 +191,9 @@ end Derivation open Classical -theorem Proof.gödel_gentzen {φ : Proposition L} {Λ : Hilbertᵢ L} : 𝐋𝐊¹ ⊢ φ → Λ ⊢ φᴺ := by +theorem Provable.gödel_gentzen {φ : Proposition L} {Λ : Hilbertᵢ L} : 𝐋𝐊¹ ⊢ φ → Λ ⊢ φᴺ := by rintro ⟨d⟩ have : Λ ⊢ ∼(∼φ)ᴺ := ⟨Derivation.gödelGentzen d⟩ exact Entailment.K!_left (Derivation.neg_doubleNegation' φ) ⨀ this - end LO.FirstOrder diff --git a/Foundation/Logic/ForcingRelation.lean b/Foundation/Logic/ForcingRelation.lean index 55d3aacca..e6f8e5769 100644 --- a/Foundation/Logic/ForcingRelation.lean +++ b/Foundation/Logic/ForcingRelation.lean @@ -31,20 +31,33 @@ variable (W) class BasicSemantics where verum (w : W) : w ⊩ ⊤ - falsum (w : W) : ¬w ⊩ ⊥ and (w : W) : w ⊩ φ ⋏ ψ ↔ w ⊩ φ ∧ w ⊩ ψ or (w : W) : w ⊩ φ ⋎ ψ ↔ w ⊩ φ ∨ w ⊩ ψ -class IntKripke (R : outParam (W → W → Prop)) extends BasicSemantics W where - not (w : W) : w ⊩ ∼φ ↔ (∀ v, R w v → ¬v ⊩ φ) - imply (w : W) : w ⊩ φ ➝ ψ ↔ (∀ v, R w v → v ⊩ φ → v ⊩ ψ) +class Monotone (R : outParam (W → W → Prop)) where monotone {w : W} : w ⊩ φ → ∀ v, R w v → v ⊩ φ +class PreIntKripke (R : outParam (W → W → Prop)) extends BasicSemantics W, Monotone W R where + imply (w : W) : w ⊩ φ ➝ ψ ↔ (∀ v, R w v → v ⊩ φ → v ⊩ ψ) + +class IntKripke (R : outParam (W → W → Prop)) extends BasicSemantics W, PreIntKripke W R where + falsum (w : W) : ¬w ⊩ ⊥ + not (w : W) : w ⊩ ∼φ ↔ (∀ v, R w v → ¬v ⊩ φ) + variable {W} -attribute [simp, grind] - BasicSemantics.verum BasicSemantics.falsum BasicSemantics.and - BasicSemantics.or IntKripke.imply IntKripke.not +attribute [simp, grind .] + BasicSemantics.verum BasicSemantics.and + BasicSemantics.or + IntKripke.falsum + +attribute [grind .] + PreIntKripke.imply + IntKripke.not + +@[simp, grind =] +lemma iff (R : W → W → Prop) [PreIntKripke W R] : w ⊩ (φ ⭤ ψ) ↔ (∀ v, R w v → (v ⊩ φ ↔ v ⊩ ψ)) := by + simp [LogicalConnective.iff, PreIntKripke.imply]; grind variable (W) @@ -62,8 +75,6 @@ namespace AllForces @[simp] lemma verum [BasicSemantics W] : W ∀⊩ ⊤ := fun _ ↦ by simp -@[simp] lemma falsum [BasicSemantics W] [Inhabited W] : ¬W ∀⊩ ⊥ := fun h ↦ by simpa using h default - @[simp] lemma and [BasicSemantics W] : W ∀⊩ φ ⋏ ψ ↔ W ∀⊩ φ ∧ W ∀⊩ ψ := by simp [AllForces]; grind @@ -102,7 +113,7 @@ class ClassicalKripke (R : outParam (ℙ → ℙ → Prop)) extends BasicSemanti variable {ℙ} -attribute [simp, grind] +attribute [simp, grind .] BasicSemantics.verum BasicSemantics.falsum BasicSemantics.and ClassicalKripke.or ClassicalKripke.imply ClassicalKripke.not diff --git a/Foundation/Vorspiel/Order/Preorder.lean b/Foundation/Vorspiel/Order/Preorder.lean index 79bc010a8..da4aeb623 100644 --- a/Foundation/Vorspiel/Order/Preorder.lean +++ b/Foundation/Vorspiel/Order/Preorder.lean @@ -79,8 +79,16 @@ lemma mem_dual_iff {u : LowerSet α} : x ∈ uᶜ ↔ ∀ y ∈ u, x ⟂ y := by lemma coe_dual (u : LowerSet α) : uᶜ = {x | ∀ y ∈ u, x ⟂ y} := by ext x; simp [mem_dual_iff] -lemma sSup_dual (𝒮 : Set (LowerSet α)) : (sSup 𝒮)ᶜ = sInf (Compl.compl '' 𝒮) := by - ext; simp [coe_dual]; grind +lemma mem_himp_iff {u v : LowerSet α} : x ∈ u ⇨ v ↔ ∀ y ≤ x, y ∈ u → y ∈ v := by + suffices (∃ s, s ⊓ u ≤ v ∧ x ∈ s) ↔ ∀ y ≤ x, y ∈ u → y ∈ v by simpa [HImp.himp] + constructor + · rintro ⟨s, hs, hxs⟩ y hyx hyu + have : y ∈ s := s.lower hyx hxs + have : y ∈ s ⊓ u := ⟨this, hyu⟩ + exact hs this + · intro h + refine ⟨LowerSet.Iic x, ?_, by simp⟩ + intro y; simp; grind variable (α) From cdf62d393b2331c87e40c44047b000fe857bd444 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 4 Apr 2026 06:23:48 +0900 Subject: [PATCH 25/61] heyting --- Foundation/FirstOrder/Hauptsatz.lean | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/Foundation/FirstOrder/Hauptsatz.lean b/Foundation/FirstOrder/Hauptsatz.lean index 88660f266..f2ee8ee56 100644 --- a/Foundation/FirstOrder/Hauptsatz.lean +++ b/Foundation/FirstOrder/Hauptsatz.lean @@ -482,6 +482,10 @@ instance : ForcingRelation.PreIntKripke ℙ (· ≥ ·) where imply _ := imply monotone hφ _ hpq := hφ.monotone hpq +lemma efq {p : ℙ} (h : p ⊩ ⊥) (φ : Propositionᵢ L) : p ⊩ φ := by + have : p ⊩ ⊥ ➝ φ := ⟨Forces.efq φ p⟩ + exact imply.mp this p (by simp) h + lemma sound_minimal {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢ φ → ℙ ∀⊩ φ := by rintro ⟨d⟩ p; exact ⟨Forces.sound d p⟩ @@ -515,8 +519,7 @@ scoped prefix:max "♯" => hValue ext p; simp [hValue] @[simp] lemma hValue_or_eq_sup {φ ψ : Propositionᵢ L} : ♯(φ ⋎ ψ) = (♯φ ⊔ ♯ψ) := by - ext p; simp only [hValue, ForcingRelation.BasicSemantics.or, LowerSet.coe_mk, Set.mem_setOf_eq, - LowerSet.coe_sup, Set.mem_union] + ext p; simp [hValue] @[simp] lemma hValue_fal_eq_Inf {φ : Semipropositionᵢ L 1} : ♯(∀⁰ φ) = ⨅ t, ♯(φ/[t]) := by ext p; simp [hValue,] @@ -533,6 +536,17 @@ lemma hValue_falsum : p ∈ ♯(⊥ : Propositionᵢ L) ↔ Nonempty (⊢ᴷ ∼ @[simp] lemma hValue_neg_eq_himp_bot (φ : Propositionᵢ L) : ♯(∼φ) = (♯φ ⇨ ♯⊥) := by simp [Semiformulaᵢ.neg_def] +@[simp] lemma hValue_falsum_le (φ : Propositionᵢ L) : ♯⊥ ≤ ♯φ := fun _ h ↦ IsForced.efq h φ + +lemma eq_top_iff_provable {φ : Proposition L} : ♯φᴺ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc + ♯φᴺ = ⊤ ↔ ⊤ ≤ ♯φᴺ := by simp only [top_le_iff] + _ ↔ ℙ ∀⊩ φᴺ := by simp [SetLike.le_def] + _ ↔ 𝐋𝐊¹ ⊢ φ := IsForced.complete + +lemma lt_top_iff_provable {φ : Proposition L} : ♯φᴺ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by + simp [Entailment.Unprovable, ←eq_top_iff_provable, lt_top_iff_ne_top] + + end Hauptsatz alias hauptsatz := Hauptsatz.main From 3f67352797687f3e5cb0be13f391ebd0bf17c8d6 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 4 Apr 2026 20:27:30 +0900 Subject: [PATCH 26/61] canonical model --- .../Completeness/CanonicalModel.lean | 587 ++++++++++++++++++ .../FirstOrder/Completeness/Hauptsatz.lean | 72 +++ Foundation/FirstOrder/Hauptsatz.lean | 73 ++- 3 files changed, 712 insertions(+), 20 deletions(-) create mode 100644 Foundation/FirstOrder/Completeness/CanonicalModel.lean create mode 100644 Foundation/FirstOrder/Completeness/Hauptsatz.lean diff --git a/Foundation/FirstOrder/Completeness/CanonicalModel.lean b/Foundation/FirstOrder/Completeness/CanonicalModel.lean new file mode 100644 index 000000000..7610e13ba --- /dev/null +++ b/Foundation/FirstOrder/Completeness/CanonicalModel.lean @@ -0,0 +1,587 @@ +module + +public import Foundation.FirstOrder.NegationTranslation.GoedelGentzen +public import Foundation.Logic.ForcingRelation +public import Foundation.Vorspiel.Order.Preorder + +@[expose] public section +/-! +# Canonical model of classical first-order logic + +Main reference: Jeremy Avigad, Algebraic proofs of cut elimination [Avi01] + -/ + +namespace LO.FirstOrder + +variable {L : Language.{u}} + +namespace Derivation + +inductive IsCutFree : {Γ : Sequent L} → ⊢ᴷ Γ → Prop +| axL (r : L.Rel k) (v) : IsCutFree (identity r v) +| verum : IsCutFree verum +| or {d : ⊢ᴷ φ :: ψ :: Γ} : IsCutFree d → IsCutFree d.or +| and {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) +| all {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all +| exs (t) {d : ⊢ᴷ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs +| wk {d : ⊢ᴷ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) + +attribute [simp] IsCutFree.axL IsCutFree.verum + +variable {Γ Δ : Sequent L} + +@[simp] lemma isCutFree_or_iff {d : ⊢ᴷ φ :: ψ :: Γ} : + IsCutFree d.or ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .or⟩ + +@[simp] lemma isCutFree_and_iff {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : + IsCutFree (dφ.and dψ) ↔ IsCutFree dφ ∧ IsCutFree dψ := + ⟨by rintro ⟨⟩; constructor <;> assumption, by intro ⟨hφ, hψ⟩; exact hφ.and hψ⟩ + +@[simp] lemma isCutFree_all_iff {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : + IsCutFree d.all ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .all⟩ + +@[simp] lemma isCutFree_exs_iff {d : ⊢ᴷ φ/[t] :: Γ} : + IsCutFree d.exs ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .exs t⟩ + +@[simp] lemma isCutFree_wk_iff {d : ⊢ᴷ Δ} {ss : Δ ⊆ Γ} : + IsCutFree (d.wk ss) ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .wk _⟩ + +@[simp] lemma IsCutFree.cast {d : ⊢ᴷ Γ} {e : Γ = Δ} : + IsCutFree (.cast d e) ↔ IsCutFree d := by rcases e; rfl + +@[simp] lemma IsCutFree.not_cut (dp : ⊢ᴷ φ :: Γ) (dn : ⊢ᴷ ∼φ :: Δ) : ¬IsCutFree (dp.cut dn) := by + intro h + refine h.rec + (motive := fun {_} d _ => + match d with + | .cut _ _ => False + | _ => True) + ?_ ?_ ?_ ?_ ?_ ?_ ?_ + all_goals simp + +@[simp] lemma isCutFree_rewrite_iff_isCutFree {f : ℕ → SyntacticTerm L} {d : ⊢ᴷ Γ} : + IsCutFree (rewrite f d) ↔ IsCutFree d := by + induction d generalizing f <;> simp [rewrite, *] + +@[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᴷ Γ} : + IsCutFree (Derivation.map d f) ↔ IsCutFree d := isCutFree_rewrite_iff_isCutFree + +@[simp] lemma IsCutFree.genelalizeByNewver_isCutFree {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) + (d : ⊢ᴷ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] + +end Derivation + +inductive PositiveDerivationFrom (Ξ : Sequent L) : Sequent L → Type _ +| or : PositiveDerivationFrom Ξ (φ :: ψ :: Γ) → PositiveDerivationFrom Ξ (φ ⋎ ψ :: Γ) +| exs : PositiveDerivationFrom Ξ (φ/[t] :: Γ) → PositiveDerivationFrom Ξ ((∃⁰ φ) :: Γ) +| wk : PositiveDerivationFrom Ξ Δ → Δ ⊆ Γ → PositiveDerivationFrom Ξ Γ +| protected id : PositiveDerivationFrom Ξ Ξ + +infix:45 " ⟶⁺ " => PositiveDerivationFrom + +namespace PositiveDerivationFrom + +variable {Ξ Γ Δ : Sequent L} + +def ofSubset (ss : Ξ ⊆ Γ) : Ξ ⟶⁺ Γ := wk .id ss + +def trans {Ξ Γ Δ : Sequent L} : Ξ ⟶⁺ Γ → Γ ⟶⁺ Δ → Ξ ⟶⁺ Δ + | b, or d => or (b.trans d) + | b, exs d => exs (b.trans d) + | b, wk d h => wk (b.trans d) h + | b, .id => b + +def cons {Ξ Γ : Sequent L} (φ) : Ξ ⟶⁺ Γ → φ :: Ξ ⟶⁺ φ :: Γ + | or (Γ := Γ) (φ := ψ) (ψ := χ) d => + have : φ :: Ξ ⟶⁺ ψ :: χ :: φ :: Γ := wk (cons φ d) (by simp; tauto) + wk (or this) (by simp) + | exs (Ξ := Ξ) (Γ := Γ) (φ := ψ) (t := t) d => + have : φ :: Ξ ⟶⁺ ψ/[t] :: φ :: Γ := wk (cons φ d) (by simp) + wk this.exs (by simp) + | wk d h => wk (d.cons φ) (by simp [h]) + | .id => .id + +def append {Ξ Γ : Sequent L} : (Δ : Sequent L) → Ξ ⟶⁺ Γ → Δ ++ Ξ ⟶⁺ Δ ++ Γ + | [], d => d + | φ :: Δ, d => (d.append Δ).cons φ + +def add {Γ Δ Ξ Θ : Sequent L} : Γ ⟶⁺ Δ → Ξ ⟶⁺ Θ → Γ ++ Ξ ⟶⁺ Δ ++ Θ + | or d, b => or (d.add b) + | exs d, b => exs (d.add b) + | wk d h, b => wk (d.add b) (by simp [h]) + | .id, b => b.append Γ + +def graft {Ξ Γ : Sequent L} (b : ⊢ᴷ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴷ Γ + | or d => .or (d.graft b) + | exs d => .exs (d.graft b) + | wk d h => .wk (d.graft b) h + | .id => b + +lemma graft_isCutFree_of_isCutFree {b : ⊢ᴷ Ξ} {d : Ξ ⟶⁺ Γ} (hb : Derivation.IsCutFree b) : Derivation.IsCutFree (d.graft b) := by + induction d <;> simp [graft, *] + +end PositiveDerivationFrom + +namespace Hauptsatz + +open Semiformulaᵢ + +local notation "ℙ" => Sequent L + +structure StrongerThan (q p : ℙ) where + val : ∼p ⟶⁺ ∼q + +scoped infix:60 " ≼ " => StrongerThan + +scoped instance : Min ℙ := ⟨fun p q ↦ p ++ q⟩ + +lemma inf_def (p q : ℙ) : p ⊓ q = p ++ q := rfl + +@[simp] lemma neg_inf_p_eq (p q : ℙ) : ∼(p ⊓ q) = ∼p ⊓ ∼q := List.map_append + +namespace StrongerThan + +protected def refl (p : ℙ) : p ≼ p := ⟨.id⟩ + +def trans {r q p : ℙ} (srq : r ≼ q) (sqp : q ≼ p) : r ≼ p := ⟨sqp.val.trans srq.val⟩ + +def ofSubset {q p : ℙ} (h : q ⊇ p) : q ≼ p := ⟨.ofSubset <| List.map_subset _ h⟩ + +def and {p : ℙ} (φ ψ : Proposition L) : φ ⋏ ψ :: p ≼ φ :: ψ :: p := ⟨.or .id⟩ + +def K_left {p : ℙ} (φ ψ : Proposition L) : φ ⋏ ψ :: p ≼ φ :: p := trans (and φ ψ) (ofSubset <| by simp) + +def K_right {p : ℙ} (φ ψ : Proposition L) : φ ⋏ ψ :: p ≼ ψ :: p := trans (and φ ψ) (ofSubset <| by simp) + +def all {p : ℙ} (φ : Semiproposition L 1) (t) : (∀⁰ φ) :: p ≼ φ/[t] :: p := ⟨.exs (t := t) (by simpa [← Semiformula.neg_eq] using .id)⟩ + +def minLeLeft (p q : ℙ) : p ⊓ q ≼ p := ofSubset (by simp [inf_def]) + +def minLeRight (p q : ℙ) : p ⊓ q ≼ q := ofSubset (by simp [inf_def]) + +def leMinOfle (srp : r ≼ p) (srq : r ≼ q) : r ≼ p ⊓ q := ⟨ + let d : ∼p ++ ∼q ⟶⁺ ∼r := .wk (srp.val.add srq.val) (by simp) + neg_inf_p_eq _ _ ▸ d⟩ + +def leMinRightOfLe (s : q ≼ p) : q ≼ p ⊓ q := leMinOfle s (.refl q) + +end StrongerThan + +def Forces (p : ℙ) : Propositionᵢ L → Type u + | ⊥ => { b : ⊢ᴷ ∼p // Derivation.IsCutFree b } + | .rel R v => { b : ⊢ᴷ .rel R v :: ∼p // Derivation.IsCutFree b } + | φ ⋏ ψ => Forces p φ × Forces p ψ + | φ ⋎ ψ => Forces p φ ⊕ Forces p ψ + | φ ➝ ψ => (q : ℙ) → q ≼ p → Forces q φ → Forces q ψ + | ∀⁰ φ => (t : SyntacticTerm L) → Forces p (φ/[t]) + | ∃⁰ φ => (t : SyntacticTerm L) × Forces p (φ/[t]) + termination_by φ => φ.complexity + + +abbrev allForces (φ : Propositionᵢ L) := (p : ℙ) → Forces p φ + +namespace Forces + +scoped infix:45 " ⊩ " => Forces + +scoped prefix:45 "⊩ " => allForces + + +def falsumEquiv : p ⊩ ⊥ ≃ { b : ⊢ᴷ ∼p // Derivation.IsCutFree b} := by unfold Forces; exact .refl _ + +def relEquiv {k} {R : L.Rel k} {v} : p ⊩ .rel R v ≃ { b : ⊢ᴷ .rel R v :: ∼p // Derivation.IsCutFree b } := by + unfold Forces; exact .refl _ + +def andEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ ⋏ ψ ≃ (p ⊩ φ) × (p ⊩ ψ) := by + conv => + lhs + unfold Forces + exact .refl _ + +def orEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ ⋎ ψ ≃ (p ⊩ φ) ⊕ (p ⊩ ψ) := by + conv => + lhs + unfold Forces + exact .refl _ + +def implyEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ ➝ ψ ≃ ((q : ℙ) → q ≼ p → q ⊩ φ → q ⊩ ψ) := by + conv => + lhs + unfold Forces + exact .refl _ + +def allEquiv {φ} : p ⊩ ∀⁰ φ ≃ ((t : SyntacticTerm L) → Forces p (φ/[t])) := by + conv => + lhs + unfold Forces + exact .refl _ + +def exsEquiv {φ} : p ⊩ ∃⁰ φ ≃ ((t : SyntacticTerm L) × Forces p (φ/[t])) := by + conv => + lhs + unfold Forces + exact .refl _ + +def cast {p : ℙ} (f : p ⊩ φ) (s : φ = ψ) : p ⊩ ψ := s ▸ f + +def monotone {q p : ℙ} (s : q ≼ p) : {φ : Propositionᵢ L} → p ⊩ φ → q ⊩ φ + | ⊥, b => + let ⟨d, hd⟩ := b.falsumEquiv + falsumEquiv.symm ⟨s.val.graft d, PositiveDerivationFrom.graft_isCutFree_of_isCutFree hd⟩ + | .rel R v, b => + let ⟨d, hd⟩ := b.relEquiv + relEquiv.symm ⟨s.val.cons (.rel R v) |>.graft d, PositiveDerivationFrom.graft_isCutFree_of_isCutFree hd⟩ + | φ ⋏ ψ, b => andEquiv.symm ⟨monotone s b.andEquiv.1, monotone s b.andEquiv.2⟩ + | φ ⋎ ψ, b => orEquiv.symm <| b.orEquiv.rec (fun b ↦ .inl <| b.monotone s) (fun b ↦ .inr <| b.monotone s) + | φ ➝ ψ, b => implyEquiv.symm fun r srq bφ ↦ b.implyEquiv r (srq.trans s) bφ + | ∀⁰ φ, b => allEquiv.symm fun t ↦ (b.allEquiv t).monotone s + | ∃⁰ φ, b => + let ⟨t, d⟩ : (t : SyntacticTerm L) × p ⊩ φ/[t] := b.exsEquiv + exsEquiv.symm ⟨t, d.monotone s⟩ + termination_by φ => φ.complexity + +def explosion {p : ℙ} (b : p ⊩ ⊥) : (φ : Propositionᵢ L) → p ⊩ φ + | ⊥ => b + | .rel R v => + let ⟨d, hd⟩ := b.falsumEquiv + relEquiv.symm ⟨.wk d (by simp), by simp [hd]⟩ + | φ ⋏ ψ => andEquiv.symm ⟨b.explosion φ, b.explosion ψ⟩ + | φ ⋎ ψ => orEquiv.symm <| .inl <| b.explosion φ + | φ ➝ ψ => implyEquiv.symm fun q sqp dφ ↦ (b.monotone sqp).explosion ψ + | ∀⁰ φ => allEquiv.symm fun t ↦ b.explosion (φ/[t]) + | ∃⁰ φ => exsEquiv.symm ⟨default, b.explosion (φ/[default])⟩ + termination_by φ => φ.complexity + +def efq (φ : Propositionᵢ L) : ⊩ ⊥ ➝ φ := fun _ ↦ implyEquiv.symm fun _ _ d ↦ d.explosion φ + +def implyOf {φ ψ : Propositionᵢ L} (b : (q : ℙ) → q ⊩ φ → p ⊓ q ⊩ ψ) : + p ⊩ φ ➝ ψ := implyEquiv.symm fun q sqp fφ ↦ + let fψ : p ⊓ q ⊩ ψ := b q fφ + fψ.monotone (StrongerThan.leMinRightOfLe sqp) + +open LawfulSyntacticRewriting + +def modusPonens {φ ψ : Propositionᵢ L} (f : p ⊩ φ ➝ ψ) (g : p ⊩ φ) : p ⊩ ψ := + f.implyEquiv p (StrongerThan.refl p) g + +def sound {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢! φ → ⊩ φ + | .mdp (φ := ψ) b d => fun p ↦ + let b : p ⊩ ψ ➝ φ := sound b p + let d : p ⊩ ψ := sound d p + b.implyEquiv p (StrongerThan.refl p) d + | .gen (φ := φ) b => fun p ↦ allEquiv.symm fun t ↦ + let d : 𝗠𝗶𝗻¹ ⊢! φ/[t] := + HilbertProofᵢ.cast (HilbertProofᵢ.rewrite (t :>ₙ fun x ↦ &x) b) (by simp [rewrite_free_eq_subst]) + sound d p + | .verum => fun p ↦ implyEquiv.symm fun q sqp bφ ↦ bφ + | .implyK φ ψ => fun p ↦ implyEquiv.symm fun q sqp bφ ↦ implyEquiv.symm fun r srq bψ ↦ bφ.monotone srq + | .implyS φ ψ χ => fun p ↦ + implyEquiv.symm fun q sqp b₁ ↦ + implyEquiv.symm fun r srq b₂ ↦ + implyEquiv.symm fun s ssr b₃ ↦ + let d₁ : s ⊩ ψ ➝ χ := b₁.implyEquiv s (ssr.trans srq) b₃ + let d₂ : s ⊩ ψ := b₂.implyEquiv s ssr b₃ + d₁.implyEquiv s (StrongerThan.refl s) d₂ + | .and₁ φ ψ => fun p ↦ + implyEquiv.symm fun q sqp b ↦ + let ⟨dφ, dψ⟩ : q ⊩ φ × q ⊩ ψ := b.andEquiv + dφ + | .and₂ φ ψ => fun p ↦ + implyEquiv.symm fun q sqp b ↦ + let ⟨dφ, dψ⟩ : q ⊩ φ × q ⊩ ψ := b.andEquiv + dψ + | .and₃ φ ψ => fun p ↦ + implyEquiv.symm fun q sqp bφ ↦ + implyEquiv.symm fun r srq bψ ↦ + andEquiv.symm ⟨bφ.monotone srq, bψ⟩ + | .or₁ φ ψ => fun p ↦ + implyEquiv.symm fun q sqp bφ ↦ orEquiv.symm <| .inl bφ + | .or₂ φ ψ => fun p ↦ + implyEquiv.symm fun q sqp bψ ↦ orEquiv.symm <| .inr bψ + | .or₃ φ ψ χ => fun p ↦ + implyEquiv.symm fun q sqp bφχ ↦ + implyEquiv.symm fun r srq bψχ ↦ + implyEquiv.symm fun s ssr b ↦ + let d : s ⊩ φ ⊕ s ⊩ ψ := b.orEquiv + d.rec + (fun dφ ↦ bφχ.implyEquiv s (ssr.trans srq) dφ) + (fun dψ ↦ bψχ.implyEquiv s ssr dψ) + | .all₁ φ t => fun p ↦ implyEquiv.symm fun q sqp b ↦ b.allEquiv t + | .all₂ φ ψ => fun p ↦ + implyEquiv.symm fun q sqp b ↦ + implyEquiv.symm fun r srq bφ ↦ + allEquiv.symm fun t ↦ + let d : q ⊩ φ ➝ ψ/[t] := by simpa using (b.allEquiv t) + d.implyEquiv r srq bφ + | .ex₁ t φ => fun p ↦ + implyEquiv.symm fun q sqp bφ ↦ exsEquiv.symm ⟨t, bφ⟩ + | .ex₂ φ ψ => fun p ↦ + implyEquiv.symm fun q sqp b ↦ + implyEquiv.symm fun r srq bφ ↦ + let ⟨t, dt⟩ : (t : SyntacticTerm L) × r ⊩ φ/[t] := bφ.exsEquiv + let d : q ⊩ φ/[t] ➝ ψ := by simpa using b.allEquiv t + d.implyEquiv r srq dt + termination_by b => HilbertProofᵢ.depth b + +def relRefl {k} (R : L.Rel k) (v : Fin k → SyntacticTerm L) : [.rel R v] ⊩ rel R v := + relEquiv.symm ⟨Derivation.identity _ _, by simp⟩ + +protected def refl.or (ihφ : [φ] ⊩ φᴺ) (ihψ : [ψ] ⊩ ψᴺ) : [φ ⋎ ψ] ⊩ (φ ⋎ ψ)ᴺ := + implyOf fun q dq ↦ + let ⟨dφ, dψ⟩ : q ⊩ ∼φᴺ × q ⊩ ∼ψᴺ := dq.andEquiv + let ihφ : [φ] ⊩ φᴺ := ihφ + let ihψ : [ψ] ⊩ ψᴺ := ihψ + let bφ : [φ] ⊓ q ⊩ ⊥ := dφ.implyEquiv ([φ] ⊓ q) (.minLeRight _ _) (ihφ.monotone (.minLeLeft _ _)) + let bψ : [ψ] ⊓ q ⊩ ⊥ := dψ.implyEquiv ([ψ] ⊓ q) (.minLeRight _ _) (ihψ.monotone (.minLeLeft _ _)) + let ⟨bbφ, hbbφ⟩ := bφ.falsumEquiv + let ⟨bbψ, hbbψ⟩ := bψ.falsumEquiv + let band : ⊢ᴷ ∼φ ⋏ ∼ψ :: ∼q := Derivation.and + (Derivation.cast bbφ (by simp [inf_def])) (Derivation.cast bbψ (by simp [inf_def])) + falsumEquiv.symm ⟨Derivation.cast band (by simp [inf_def]), by simp [band, hbbφ, hbbψ]⟩ + +protected def refl.exs (d : ∀ x, [φ/[&x]] ⊩ (φ/[&x])ᴺ) : [∃⁰ φ] ⊩ (∃⁰ φ)ᴺ := + implyOf fun q f ↦ + let x := Sequent.newVar ((∀⁰ ∼φ) :: ∼q) + let ih : [φ/[&x]] ⊩ φᴺ/[&x] := cast (d x) (by simp [Semiformula.subst_doubleNegation]) + let b : [φ/[&x]] ⊓ q ⊩ ⊥ := + (f.allEquiv &x).implyEquiv ([φ/[&x]] ⊓ q) (StrongerThan.minLeRight _ _) (ih.monotone (StrongerThan.minLeLeft _ _)) + let ⟨b, hb⟩ := b.falsumEquiv + let ba : ⊢ᴷ (∀⁰ ∼φ) :: ∼q := + Derivation.genelalizeByNewver (m := x) + (by have : ¬Semiformula.FVar? (∀⁰ ∼φ) x := Sequent.not_fvar?_newVar (by simp) + simpa using this) + (fun ψ hψ ↦ Sequent.not_fvar?_newVar (List.mem_cons_of_mem (∀⁰ ∼φ) hψ)) + (Derivation.cast b (by simp [inf_def])) + falsumEquiv.symm ⟨ba, by simp [ba, hb]⟩ + +protected def refl : (φ : Proposition L) → [φ] ⊩ φᴺ + | ⊤ => implyEquiv.symm fun q sqp dφ ↦ dφ + | ⊥ => falsumEquiv.symm ⟨Derivation.verum, by simp⟩ + | .rel R v => implyOf fun q dq ↦ + let b : [.rel R v] ⊓ q ⊩ rel R v := (relRefl R v).monotone (StrongerThan.minLeLeft _ _) + dq.implyEquiv ([.rel R v] ⊓ q) (StrongerThan.minLeRight _ _) b + | .nrel R v => implyOf fun q dq ↦ + let ⟨d, hd⟩ := dq.relEquiv + falsumEquiv.symm ⟨Derivation.cast d (by simp [inf_def]), by simp [hd]⟩ + | φ ⋏ ψ => + let ihφ : [φ] ⊩ φᴺ := Forces.refl φ + let ihψ : [ψ] ⊩ ψᴺ := Forces.refl ψ + andEquiv.symm ⟨ihφ.monotone (.K_left φ ψ), ihψ.monotone (.K_right φ ψ)⟩ + | φ ⋎ ψ => refl.or (Forces.refl φ) (Forces.refl ψ) + | ∀⁰ φ => allEquiv.symm fun t ↦ + let b : [φ/[t]] ⊩ φᴺ/[t] := by simpa [Semiformula.rew_doubleNegation] using Forces.refl (φ/[t]) + b.monotone (StrongerThan.all φ t) + | ∃⁰ φ => refl.exs fun x ↦ Forces.refl (φ/[&x]) + termination_by φ => φ.complexity + +def conj : {Γ : Sequentᵢ L} → (b : (φ : Propositionᵢ L) → φ ∈ Γ → p ⊩ φ) → p ⊩ ⋀Γ + | [], _ => implyEquiv.symm fun q sqp bφ ↦ bφ + | [φ], b => b φ (by simp) + | φ :: ψ :: Γ, b => andEquiv.symm ⟨b φ (by simp), conj (fun χ hχ ↦ b χ (List.mem_cons_of_mem φ hχ))⟩ + +def conj' : {Γ : Sequent L} → (b : (φ : Proposition L) → φ ∈ Γ → p ⊩ φᴺ) → p ⊩ ⋀Γᴺ + | [], _ => implyEquiv.symm fun q sqp bφ ↦ bφ + | [φ], b => b φ (by simp) + | φ :: ψ :: Γ, b => andEquiv.symm ⟨b φ (by simp), conj' (fun χ hχ ↦ b χ (List.mem_cons_of_mem φ hχ))⟩ + +end Forces + +def main [L.DecidableEq] {Γ : Sequent L} : ⊢ᴷ Γ → {d : ⊢ᴷ Γ // Derivation.IsCutFree d} := fun d ↦ + let d : 𝗠𝗶𝗻¹ ⊢! ⋀(∼Γ)ᴺ ➝ ⊥ := Entailment.FiniteContext.toDef (Derivation.gödelGentzen d) + let ff : Forces (∼Γ) (⋀(∼Γ)ᴺ ➝ ⊥) := Forces.sound d (∼Γ) + let fc : Forces (∼Γ) (⋀(∼Γ)ᴺ) := Forces.conj' fun φ hφ ↦ + (Forces.refl φ).monotone (StrongerThan.ofSubset <| List.cons_subset.mpr ⟨hφ, by simp⟩) + let b : Forces (∼Γ) ⊥ := ff.modusPonens fc + let ⟨b, hb⟩ := b.falsumEquiv + ⟨Derivation.cast b (by simp), by simp [hb]⟩ + + + +instance : LE ℙ := ⟨fun q p ↦ Nonempty (q ≼ p)⟩ + +instance : Preorder ℙ where + le_refl p := ⟨StrongerThan.refl p⟩ + le_trans p q r := by + rintro ⟨hqp⟩ ⟨hrq⟩ + exact ⟨StrongerThan.trans hqp hrq⟩ + +abbrev IsForced (p : ℙ) (φ : Propositionᵢ L) := Nonempty (Forces p φ) + +instance : ForcingRelation ℙ (Propositionᵢ L) where + Forces := IsForced + +namespace IsForced + +open Classical + +@[simp] lemma rel {p : ℙ} {k} {R : L.Rel k} {v} : p ⊩ .rel R v ↔ Nonempty (⊢ᴷ .rel R v :: ∼p) := by + constructor + · rintro ⟨b⟩ + have ⟨d, hd⟩ := b.relEquiv + exact ⟨d⟩ + · rintro ⟨d⟩ + let ⟨b, hb⟩ := main d + exact ⟨Forces.relEquiv.symm ⟨b, hb⟩⟩ + +@[simp] lemma fal {p : ℙ} : p ⊩ ∀⁰ φ ↔ ∀ t, p ⊩ φ/[t] := by + constructor + · rintro ⟨b⟩ t + exact ⟨b.allEquiv t⟩ + · rintro h + exact ⟨Forces.allEquiv.symm fun t ↦ (h t).some⟩ + +@[simp] lemma and {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ ⋏ ψ ↔ p ⊩ φ ∧ p ⊩ ψ := by + constructor + · rintro ⟨b⟩ + have ⟨bφ, bψ⟩ := b.andEquiv + exact ⟨⟨bφ⟩, ⟨bψ⟩⟩ + · rintro ⟨⟨bφ⟩, ⟨bψ⟩⟩ + exact ⟨Forces.andEquiv.symm ⟨bφ, bψ⟩⟩ + +@[simp] lemma or {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ ⋎ ψ ↔ p ⊩ φ ∨ p ⊩ ψ := by + constructor + · rintro ⟨b⟩ + have b' := b.orEquiv + exact b'.rec (fun bφ ↦ .inl ⟨bφ⟩) (fun bψ ↦ .inr ⟨bψ⟩) + · rintro (⟨⟨hφ⟩⟩ | ⟨⟨hψ⟩⟩) + · exact ⟨Forces.orEquiv.symm <| .inl hφ⟩ + · exact ⟨Forces.orEquiv.symm <| .inr hψ⟩ + +lemma imply {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ ➝ ψ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ψ) := by + constructor + · rintro ⟨b⟩ q ⟨sqp⟩ ⟨bφ⟩ + exact ⟨b.implyEquiv _ sqp bφ⟩ + · rintro h + refine ⟨Forces.implyEquiv.symm fun q sqp hφ ↦ (h q ⟨sqp⟩ ⟨hφ⟩).some⟩ + +@[simp] lemma exs {p : ℙ} : p ⊩ ∃⁰ φ ↔ ∃ t, p ⊩ φ/[t] := by + constructor + · rintro ⟨b⟩ + have ⟨t, f⟩ := b.exsEquiv + exact ⟨t, ⟨f⟩⟩ + · rintro ⟨t, h⟩ + exact ⟨Forces.exsEquiv.symm ⟨t, h.some⟩⟩ + +lemma falsum {p : ℙ} : p ⊩ ⊥ ↔ Nonempty (⊢ᴷ ∼p) := by + constructor + · rintro ⟨b⟩ + have ⟨d, hd⟩ := b.falsumEquiv + exact ⟨d⟩ + · rintro ⟨d⟩ + let ⟨b, hb⟩ := main d + exact ⟨Forces.falsumEquiv.symm ⟨b, hb⟩⟩ + +lemma neg {p : ℙ} {φ : Propositionᵢ L} : p ⊩ ∼φ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ⊥) := by + simp [Semiformulaᵢ.neg_def, imply] + +lemma monotone {p q : ℙ} (hqp : q ≤ p) {φ : Propositionᵢ L} (hφ : p ⊩ φ) : q ⊩ φ := + ⟨Forces.monotone hqp.some hφ.some⟩ + +instance : ForcingRelation.PreIntKripke ℙ (· ≥ ·) where + verum _ := ⟨Forces.implyEquiv.symm fun _ _ d ↦ d⟩ + and _ := and + or _ := or + imply _ := imply + monotone hφ _ hpq := hφ.monotone hpq + +lemma efq {p : ℙ} (h : p ⊩ ⊥) (φ : Propositionᵢ L) : p ⊩ φ := by + have : p ⊩ ⊥ ➝ φ := ⟨Forces.efq φ p⟩ + exact imply.mp this p (by simp) h + +lemma sound_minimal {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢ φ → ℙ ∀⊩ φ := by + rintro ⟨d⟩ p; exact ⟨Forces.sound d p⟩ + +lemma dn_neg_iff {φ : Proposition L} {p : ℙ} : p ⊩ (∼φ)ᴺ ↔ p ⊩ ∼(φᴺ) := by + have := by simpa using (sound_minimal (Derivation.neg_doubleNegation φ) p) + exact (this p (by simp)).symm + +protected lemma refl (φ : Proposition L) : [φ] ⊩ φᴺ := ⟨Forces.refl φ⟩ + +lemma complete {φ : Proposition L} : ℙ ∀⊩ φᴺ ↔ 𝐋𝐊¹ ⊢ φ := by + constructor + · intro h + have hn : [∼φ] ⊩ ∼(φᴺ) := by simpa [dn_neg_iff] using (IsForced.refl (∼φ)) + have hp : [∼φ] ⊩ φᴺ := h [∼φ] + have : 𝐋𝐊¹ ⊢ φ := by simpa using falsum.mp <| neg.mp hn [∼φ] (by simp) hp + exact this + · intro b + exact sound_minimal <| Provable.gödel_gentzen b + +end IsForced + +variable (L) + +def ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴷ ∼Γ)} + +local notation "ℂ" => ConsistentSequent L + +variable {L} + +namespace ConsistentSequent + +instance : Preorder ℂ where + le q p := q.val ≤ p.val + le_refl p := by simp + le_trans p q r := le_trans + +end ConsistentSequent + +def hValue (φ : Propositionᵢ L) : LowerSet ℂ where + carrier := { p | p.val ⊩ φ } + lower' := fun _ _ hqp hp ↦ IsForced.monotone hqp hp + +scoped prefix:max "♯" => hValue + +@[simp] lemma mem_hValue {p : ℂ} {φ : Propositionᵢ L} : p ∈ ♯φ ↔ p.val ⊩ φ := by simp [hValue] + +@[simp] lemma hValue_and_eq_inf {φ ψ : Propositionᵢ L} : ♯(φ ⋏ ψ) = (♯φ ⊓ ♯ψ) := by + ext p; simp [hValue] + +@[simp] lemma hValue_or_eq_sup {φ ψ : Propositionᵢ L} : ♯(φ ⋎ ψ) = (♯φ ⊔ ♯ψ) := by + ext p; simp [hValue] + +@[simp] lemma hValue_fal_eq_Inf {φ : Semipropositionᵢ L 1} : ♯(∀⁰ φ) = ⨅ t, ♯(φ/[t]) := by + ext p; simp [hValue,] + +@[simp] lemma hValue_exs_eq_Sup {φ : Semipropositionᵢ L 1} : ♯(∃⁰ φ) = ⨆ t, ♯(φ/[t]) := by + ext p; simp [hValue,] + +@[simp] lemma hValue_falsum : ♯(⊥ : Propositionᵢ L) = ⊥ := by + ext p; simp [hValue, IsForced.falsum, p.prop] + +@[simp] lemma hValue_imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ ➝ ψ) = (♯φ ⇨ ♯ψ) := by + ext p + suffices (∀ q ≤ p.val, q ⊩ φ → q ⊩ ψ) ↔ ∀ q ≤ p, q.val ⊩ φ → q.val ⊩ ψ by + simpa [IsForced.imply, LowerSet.mem_himp_iff] + constructor + · intro h q hqp hqφ + exact h q.val hqp hqφ + · intro h q hqp hqφ + by_cases! hq : IsEmpty (⊢ᴷ ∼q) + · exact h ⟨q, hq⟩ hqp hqφ + · exact IsForced.efq (p := q) (by simp [IsForced.falsum, hq]) ψ + +@[simp] lemma hValue_neg_eq_himp_bot (φ : Propositionᵢ L) : ♯(∼φ) = (♯φ)ᶜ := by + simp [Semiformulaᵢ.neg_def] + +lemma eq_top_iff_provable {φ : Proposition L} : ♯φᴺ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc + ♯φᴺ = ⊤ ↔ ⊤ ≤ ♯φᴺ := by simp only [top_le_iff] + _ ↔ (∀ p : ℂ, p.val ⊩ φᴺ) := by simp [SetLike.le_def] + _ ↔ ℙ ∀⊩ φᴺ := by + constructor + · intro h p + by_cases! hp : IsEmpty (⊢ᴷ ∼p) + · exact h ⟨p, hp⟩ + · exact IsForced.efq (p := p) (by simp [IsForced.falsum, hp]) φᴺ + · intro h p; exact h p.val + _ ↔ 𝐋𝐊¹ ⊢ φ := IsForced.complete + +lemma lt_top_iff_provable {φ : Proposition L} : ♯φᴺ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by + simp [Entailment.Unprovable, ←eq_top_iff_provable, lt_top_iff_ne_top] + + +end Hauptsatz + +alias hauptsatz := Hauptsatz.main + +end LO.FirstOrder diff --git a/Foundation/FirstOrder/Completeness/Hauptsatz.lean b/Foundation/FirstOrder/Completeness/Hauptsatz.lean new file mode 100644 index 000000000..f33c1acd6 --- /dev/null +++ b/Foundation/FirstOrder/Completeness/Hauptsatz.lean @@ -0,0 +1,72 @@ +module + +public import Foundation.FirstOrder.NegationTranslation.GoedelGentzen +public import Foundation.Logic.ForcingRelation +public import Foundation.Vorspiel.Order.Preorder + +@[expose] public section +/-! +# Canonical model of classical first-order logic + +Main reference: Jeremy Avigad, Algebraic proofs of cut elimination [Avi01] + -/ + +namespace LO.FirstOrder + +variable {L : Language.{u}} + +namespace Derivation + +inductive IsCutFree : {Γ : Sequent L} → ⊢ᴷ Γ → Prop +| axL (r : L.Rel k) (v) : IsCutFree (identity r v) +| verum : IsCutFree verum +| or {d : ⊢ᴷ φ :: ψ :: Γ} : IsCutFree d → IsCutFree d.or +| and {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) +| all {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all +| exs (t) {d : ⊢ᴷ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs +| wk {d : ⊢ᴷ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) + +attribute [simp] IsCutFree.axL IsCutFree.verum + +variable {Γ Δ : Sequent L} + +@[simp] lemma isCutFree_or_iff {d : ⊢ᴷ φ :: ψ :: Γ} : + IsCutFree d.or ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .or⟩ + +@[simp] lemma isCutFree_and_iff {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : + IsCutFree (dφ.and dψ) ↔ IsCutFree dφ ∧ IsCutFree dψ := + ⟨by rintro ⟨⟩; constructor <;> assumption, by intro ⟨hφ, hψ⟩; exact hφ.and hψ⟩ + +@[simp] lemma isCutFree_all_iff {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : + IsCutFree d.all ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .all⟩ + +@[simp] lemma isCutFree_exs_iff {d : ⊢ᴷ φ/[t] :: Γ} : + IsCutFree d.exs ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .exs t⟩ + +@[simp] lemma isCutFree_wk_iff {d : ⊢ᴷ Δ} {ss : Δ ⊆ Γ} : + IsCutFree (d.wk ss) ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .wk _⟩ + +@[simp] lemma IsCutFree.cast {d : ⊢ᴷ Γ} {e : Γ = Δ} : + IsCutFree (.cast d e) ↔ IsCutFree d := by rcases e; rfl + +@[simp] lemma IsCutFree.not_cut (dp : ⊢ᴷ φ :: Γ) (dn : ⊢ᴷ ∼φ :: Δ) : ¬IsCutFree (dp.cut dn) := by + intro h + refine h.rec + (motive := fun {_} d _ => + match d with + | .cut _ _ => False + | _ => True) + ?_ ?_ ?_ ?_ ?_ ?_ ?_ + all_goals simp + +@[simp] lemma isCutFree_rewrite_iff_isCutFree {f : ℕ → SyntacticTerm L} {d : ⊢ᴷ Γ} : + IsCutFree (rewrite f d) ↔ IsCutFree d := by + induction d generalizing f <;> simp [rewrite, *] + +@[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᴷ Γ} : + IsCutFree (Derivation.map d f) ↔ IsCutFree d := isCutFree_rewrite_iff_isCutFree + +@[simp] lemma IsCutFree.genelalizeByNewver_isCutFree {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) + (d : ⊢ᴷ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] + +end Derivation diff --git a/Foundation/FirstOrder/Hauptsatz.lean b/Foundation/FirstOrder/Hauptsatz.lean index f2ee8ee56..14595f93b 100644 --- a/Foundation/FirstOrder/Hauptsatz.lean +++ b/Foundation/FirstOrder/Hauptsatz.lean @@ -165,14 +165,6 @@ def leMinOfle (srp : r ≼ p) (srq : r ≼ q) : r ≼ p ⊓ q := ⟨ def leMinRightOfLe (s : q ≼ p) : q ≼ p ⊓ q := leMinOfle s (.refl q) -instance : LE ℙ := ⟨fun q p ↦ Nonempty (q ≼ p)⟩ - -instance : Preorder ℙ where - le_refl p := ⟨StrongerThan.refl p⟩ - le_trans p q r := by - rintro ⟨hqp⟩ ⟨hrq⟩ - exact ⟨StrongerThan.trans hqp hrq⟩ - end StrongerThan def Forces (p : ℙ) : Propositionᵢ L → Type u @@ -403,6 +395,16 @@ def main [L.DecidableEq] {Γ : Sequent L} : ⊢ᴷ Γ → {d : ⊢ᴷ Γ // Deri let ⟨b, hb⟩ := b.falsumEquiv ⟨Derivation.cast b (by simp), by simp [hb]⟩ + + +instance : LE ℙ := ⟨fun q p ↦ Nonempty (q ≼ p)⟩ + +instance : Preorder ℙ where + le_refl p := ⟨StrongerThan.refl p⟩ + le_trans p q r := by + rintro ⟨hqp⟩ ⟨hrq⟩ + exact ⟨StrongerThan.trans hqp hrq⟩ + abbrev IsForced (p : ℙ) (φ : Propositionᵢ L) := Nonempty (Forces p φ) instance : ForcingRelation ℙ (Propositionᵢ L) where @@ -507,13 +509,30 @@ lemma complete {φ : Proposition L} : ℙ ∀⊩ φᴺ ↔ 𝐋𝐊¹ ⊢ φ := end IsForced -def hValue (φ : Propositionᵢ L) : LowerSet ℙ where - carrier := { p | p ⊩ φ } +variable (L) + +def ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴷ ∼Γ)} + +local notation "ℂ" => ConsistentSequent L + +variable {L} + +namespace ConsistentSequent + +instance : Preorder ℂ where + le q p := q.val ≤ p.val + le_refl p := by simp + le_trans p q r := le_trans + +end ConsistentSequent + +def hValue (φ : Propositionᵢ L) : LowerSet ℂ where + carrier := { p | p.val ⊩ φ } lower' := fun _ _ hqp hp ↦ IsForced.monotone hqp hp scoped prefix:max "♯" => hValue -@[simp] lemma mem_hValue {p : ℙ} {φ : Propositionᵢ L} : p ∈ ♯φ ↔ p ⊩ φ := by simp [hValue] +@[simp] lemma mem_hValue {p : ℂ} {φ : Propositionᵢ L} : p ∈ ♯φ ↔ p.val ⊩ φ := by simp [hValue] @[simp] lemma hValue_and_eq_inf {φ ψ : Propositionᵢ L} : ♯(φ ⋏ ψ) = (♯φ ⊓ ♯ψ) := by ext p; simp [hValue] @@ -527,20 +546,34 @@ scoped prefix:max "♯" => hValue @[simp] lemma hValue_exs_eq_Sup {φ : Semipropositionᵢ L 1} : ♯(∃⁰ φ) = ⨆ t, ♯(φ/[t]) := by ext p; simp [hValue,] -@[simp] lemma hValue_imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ ➝ ψ) = (♯φ ⇨ ♯ψ) := by - ext p; simp [IsForced.imply, LowerSet.mem_himp_iff] - -lemma hValue_falsum : p ∈ ♯(⊥ : Propositionᵢ L) ↔ Nonempty (⊢ᴷ ∼p) := by - simp [hValue, IsForced.falsum] +@[simp] lemma hValue_falsum : ♯(⊥ : Propositionᵢ L) = ⊥ := by + ext p; simp [hValue, IsForced.falsum, p.prop] -@[simp] lemma hValue_neg_eq_himp_bot (φ : Propositionᵢ L) : ♯(∼φ) = (♯φ ⇨ ♯⊥) := by +@[simp] lemma hValue_imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ ➝ ψ) = (♯φ ⇨ ♯ψ) := by + ext p + suffices (∀ q ≤ p.val, q ⊩ φ → q ⊩ ψ) ↔ ∀ q ≤ p, q.val ⊩ φ → q.val ⊩ ψ by + simpa [IsForced.imply, LowerSet.mem_himp_iff] + constructor + · intro h q hqp hqφ + exact h q.val hqp hqφ + · intro h q hqp hqφ + by_cases! hq : IsEmpty (⊢ᴷ ∼q) + · exact h ⟨q, hq⟩ hqp hqφ + · exact IsForced.efq (p := q) (by simp [IsForced.falsum, hq]) ψ + +@[simp] lemma hValue_neg_eq_himp_bot (φ : Propositionᵢ L) : ♯(∼φ) = (♯φ)ᶜ := by simp [Semiformulaᵢ.neg_def] -@[simp] lemma hValue_falsum_le (φ : Propositionᵢ L) : ♯⊥ ≤ ♯φ := fun _ h ↦ IsForced.efq h φ - lemma eq_top_iff_provable {φ : Proposition L} : ♯φᴺ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc ♯φᴺ = ⊤ ↔ ⊤ ≤ ♯φᴺ := by simp only [top_le_iff] - _ ↔ ℙ ∀⊩ φᴺ := by simp [SetLike.le_def] + _ ↔ (∀ p : ℂ, p.val ⊩ φᴺ) := by simp [SetLike.le_def] + _ ↔ ℙ ∀⊩ φᴺ := by + constructor + · intro h p + by_cases! hp : IsEmpty (⊢ᴷ ∼p) + · exact h ⟨p, hp⟩ + · exact IsForced.efq (p := p) (by simp [IsForced.falsum, hp]) φᴺ + · intro h p; exact h p.val _ ↔ 𝐋𝐊¹ ⊢ φ := IsForced.complete lemma lt_top_iff_provable {φ : Proposition L} : ♯φᴺ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by From fb54a62c19fc41debc30bf85b610eb76fc67f304 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 4 Apr 2026 20:29:38 +0900 Subject: [PATCH 27/61] add CutFree --- Foundation/FirstOrder/Basic.lean | 1 + Foundation/FirstOrder/Basic/CutFree.lean | 70 ++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 Foundation/FirstOrder/Basic/CutFree.lean diff --git a/Foundation/FirstOrder/Basic.lean b/Foundation/FirstOrder/Basic.lean index 849050384..2b8fb7c17 100644 --- a/Foundation/FirstOrder/Basic.lean +++ b/Foundation/FirstOrder/Basic.lean @@ -9,6 +9,7 @@ public import Foundation.FirstOrder.Basic.Operator public import Foundation.FirstOrder.Basic.BinderNotation public import Foundation.FirstOrder.Basic.Model public import Foundation.FirstOrder.Basic.Calculus +public import Foundation.FirstOrder.Basic.CutFree public import Foundation.FirstOrder.Basic.Calculus2 public import Foundation.FirstOrder.Basic.Coding public import Foundation.FirstOrder.Basic.Eq diff --git a/Foundation/FirstOrder/Basic/CutFree.lean b/Foundation/FirstOrder/Basic/CutFree.lean new file mode 100644 index 000000000..9d71afcf2 --- /dev/null +++ b/Foundation/FirstOrder/Basic/CutFree.lean @@ -0,0 +1,70 @@ +module + +public import Foundation.FirstOrder.Basic.Calculus + +@[expose] public section +/-! +# Canonical model of classical first-order logic + +Main reference: Jeremy Avigad, Algebraic proofs of cut elimination [Avi01] + -/ + +namespace LO.FirstOrder + +variable {L : Language.{u}} + +namespace Derivation + +inductive IsCutFree : {Γ : Sequent L} → ⊢ᴷ Γ → Prop +| identity (r : L.Rel k) (v) : IsCutFree (identity r v) +| verum : IsCutFree verum +| or {d : ⊢ᴷ φ :: ψ :: Γ} : IsCutFree d → IsCutFree d.or +| and {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) +| all {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all +| exs (t) {d : ⊢ᴷ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs +| wk {d : ⊢ᴷ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) + +attribute [simp] IsCutFree.identity IsCutFree.verum + +variable {Γ Δ : Sequent L} + +@[simp] lemma isCutFree_or_iff {d : ⊢ᴷ φ :: ψ :: Γ} : + IsCutFree d.or ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .or⟩ + +@[simp] lemma isCutFree_and_iff {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : + IsCutFree (dφ.and dψ) ↔ IsCutFree dφ ∧ IsCutFree dψ := + ⟨by rintro ⟨⟩; constructor <;> assumption, by intro ⟨hφ, hψ⟩; exact hφ.and hψ⟩ + +@[simp] lemma isCutFree_all_iff {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : + IsCutFree d.all ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .all⟩ + +@[simp] lemma isCutFree_exs_iff {d : ⊢ᴷ φ/[t] :: Γ} : + IsCutFree d.exs ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .exs t⟩ + +@[simp] lemma isCutFree_wk_iff {d : ⊢ᴷ Δ} {ss : Δ ⊆ Γ} : + IsCutFree (d.wk ss) ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .wk _⟩ + +@[simp] lemma IsCutFree.cast {d : ⊢ᴷ Γ} {e : Γ = Δ} : + IsCutFree (.cast d e) ↔ IsCutFree d := by rcases e; rfl + +@[simp] lemma IsCutFree.not_cut (dp : ⊢ᴷ φ :: Γ) (dn : ⊢ᴷ ∼φ :: Δ) : ¬IsCutFree (dp.cut dn) := by + intro h + refine h.rec + (motive := fun {_} d _ => + match d with + | .cut _ _ => False + | _ => True) + ?_ ?_ ?_ ?_ ?_ ?_ ?_ + all_goals simp + +@[simp] lemma isCutFree_rewrite_iff_isCutFree {f : ℕ → SyntacticTerm L} {d : ⊢ᴷ Γ} : + IsCutFree (rewrite f d) ↔ IsCutFree d := by + induction d generalizing f <;> simp [rewrite, *] + +@[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᴷ Γ} : + IsCutFree (Derivation.map d f) ↔ IsCutFree d := isCutFree_rewrite_iff_isCutFree + +@[simp] lemma IsCutFree.genelalizeByNewver_isCutFree {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) + (d : ⊢ᴷ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] + +end Derivation From 6e2dd244e62e076655767ef64f16e4a8e0b19ec1 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sun, 5 Apr 2026 01:23:06 +0900 Subject: [PATCH 28/61] rm --- .../FirstOrder/Completeness/Coding.lean | 63 ---- .../FirstOrder/Completeness/Completeness.lean | 61 ---- .../FirstOrder/Completeness/Hauptsatz.lean | 72 ---- .../FirstOrder/Completeness/SearchTree.lean | 345 ------------------ .../FirstOrder/Completeness/SubLanguage.lean | 251 ------------- Foundation/Vorspiel/Order/Preorder.lean | 107 ------ 6 files changed, 899 deletions(-) delete mode 100644 Foundation/FirstOrder/Completeness/Coding.lean delete mode 100644 Foundation/FirstOrder/Completeness/Completeness.lean delete mode 100644 Foundation/FirstOrder/Completeness/Hauptsatz.lean delete mode 100644 Foundation/FirstOrder/Completeness/SearchTree.lean delete mode 100644 Foundation/FirstOrder/Completeness/SubLanguage.lean delete mode 100644 Foundation/Vorspiel/Order/Preorder.lean diff --git a/Foundation/FirstOrder/Completeness/Coding.lean b/Foundation/FirstOrder/Completeness/Coding.lean deleted file mode 100644 index 69fc86ff2..000000000 --- a/Foundation/FirstOrder/Completeness/Coding.lean +++ /dev/null @@ -1,63 +0,0 @@ -module - -public import Foundation.FirstOrder.Basic -public import Mathlib.Logic.Encodable.Pi - -@[expose] public section -namespace LO - -namespace FirstOrder - -open Semiformula -variable {L : Language.{u}} - -namespace Entailment - -inductive Code (L : Language.{u}) - | axL : {k : ℕ} → (r : L.Rel k) → (v : Fin k → SyntacticTerm L) → Code L - | verum : Code L - | and : Proposition L → Proposition L → Code L - | or : Proposition L → Proposition L → Code L - | all : Semiproposition L 1 → Code L - | exs : Semiproposition L 1 → SyntacticTerm L → Code L - | id : Sentence L → Code L - -def Code.equiv (L : Language.{u}) : - Code L ≃ - ((k : ℕ) × (L.Rel k) × (Fin k → SyntacticTerm L)) ⊕ - Unit ⊕ - (Proposition L × Proposition L) ⊕ - (Proposition L × Proposition L) ⊕ - (Semiproposition L 1) ⊕ - (Semiproposition L 1 × SyntacticTerm L) ⊕ - (Sentence L) where - toFun := fun c => - match c with - | (Code.axL r v) => Sum.inl ⟨_, r, v⟩ - | Code.verum => Sum.inr $ Sum.inl () - | (Code.and φ ψ) => Sum.inr $ Sum.inr $ Sum.inl (φ, ψ) - | (Code.or φ ψ) => Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl (φ, ψ) - | (Code.all φ) => Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl φ - | (Code.exs φ t) => Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl (φ, t) - | (Code.id σ) => Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr σ - invFun := fun x => - match x with - | (Sum.inl ⟨_, r, v⟩) => Code.axL r v - | (Sum.inr $ Sum.inl ()) => Code.verum - | (Sum.inr $ Sum.inr $ Sum.inl (φ, ψ)) => Code.and φ ψ - | (Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl (φ, ψ)) => Code.or φ ψ - | (Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl φ) => Code.all φ - | (Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inl (φ, t)) => Code.exs φ t - | (Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr $ Sum.inr σ) => Code.id σ - left_inv := fun c => by cases c <;> simp - right_inv := fun x => by - rcases x with (⟨_, _, _⟩ | ⟨⟩ | ⟨_, _⟩ | ⟨_, _⟩ | _ | ⟨_, _⟩ | _) <;> simp - -instance [L.DecidableEq] [L.Encodable] : Encodable (Code L) := - Encodable.ofEquiv _ (Code.equiv L) - -end Entailment - -end FirstOrder - -end LO diff --git a/Foundation/FirstOrder/Completeness/Completeness.lean b/Foundation/FirstOrder/Completeness/Completeness.lean deleted file mode 100644 index 0f8a91529..000000000 --- a/Foundation/FirstOrder/Completeness/Completeness.lean +++ /dev/null @@ -1,61 +0,0 @@ -module - -public import Foundation.FirstOrder.Ultraproduct -public import Foundation.Vorspiel.List.ChainI -public import Mathlib.Data.Finset.Lattice.Lemmas - -@[expose] public section -namespace LO.FirstOrder - -namespace Completeness - -variable (L : Language) - -abbrev Clause := Finset (Proposition L) - -variable {L} - -namespace Clause - -def IsClosed (C : Clause L) : Prop := ∃ φ ∈ C, ∼φ ∈ C - -def shift (C : Clause L) : Clause L := C.map ⟨Semiformula.shift, LawfulSyntacticRewriting.shift_injective⟩ - -inductive IsBoundary (C : Clause L) : Proposition L → Prop -| rel (R : L.Rel k) (v) : IsBoundary C (.rel R v) -| nrel (R : L.Rel k) (v) : IsBoundary C (.nrel R v) -| verum : IsBoundary C ⊤ -| falsum : IsBoundary C ⊥ -| and {φ ψ} : φ ∉ C → ψ ∉ C → IsBoundary C (φ ⋏ ψ) -| or {φ ψ} : φ ∉ C ∨ ψ ∉ C → IsBoundary C (φ ⋎ ψ) - - -def rank (C : Clause L) : ℕ := C.fold (λ φ r => max φ.rank r) 0 - -end Clause - -open Classical - -inductive Search : Clause L → Clause L → Prop -| and_left {C : Clause L} : ¬C.IsClosed → φ ⋏ ψ ∈ C → Search (insert φ C) C -| and_right {C : Clause L} : ¬C.IsClosed → φ ⋏ ψ ∈ C → Search (insert ψ C) C -| or {C : Clause L} : ¬C.IsClosed → φ ⋎ ψ ∈ C → Search (insert φ (insert ψ C)) C -| all {C : Clause L} : ¬C.IsClosed → ∀⁰ φ ∈ C → Search (insert φ.free C.shift) C -| exs {C : Clause L} : ¬C.IsClosed → ∃⁰ φ ∈ C → (t : SyntacticTerm L) → Search (insert (φ/[t]) C) C - -structure SearchPath (C : Clause L) where - path : List (Clause L) - last : Clause L - chain : path.ChainI Search last C - -namespace SearchPath - -variable {C : Clause L} - -instance : LE (SearchPath C) where - le π τ := π.path <+: τ.path - -end SearchPath - - -end LO.FirstOrder.Completeness diff --git a/Foundation/FirstOrder/Completeness/Hauptsatz.lean b/Foundation/FirstOrder/Completeness/Hauptsatz.lean deleted file mode 100644 index f33c1acd6..000000000 --- a/Foundation/FirstOrder/Completeness/Hauptsatz.lean +++ /dev/null @@ -1,72 +0,0 @@ -module - -public import Foundation.FirstOrder.NegationTranslation.GoedelGentzen -public import Foundation.Logic.ForcingRelation -public import Foundation.Vorspiel.Order.Preorder - -@[expose] public section -/-! -# Canonical model of classical first-order logic - -Main reference: Jeremy Avigad, Algebraic proofs of cut elimination [Avi01] - -/ - -namespace LO.FirstOrder - -variable {L : Language.{u}} - -namespace Derivation - -inductive IsCutFree : {Γ : Sequent L} → ⊢ᴷ Γ → Prop -| axL (r : L.Rel k) (v) : IsCutFree (identity r v) -| verum : IsCutFree verum -| or {d : ⊢ᴷ φ :: ψ :: Γ} : IsCutFree d → IsCutFree d.or -| and {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) -| all {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all -| exs (t) {d : ⊢ᴷ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs -| wk {d : ⊢ᴷ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) - -attribute [simp] IsCutFree.axL IsCutFree.verum - -variable {Γ Δ : Sequent L} - -@[simp] lemma isCutFree_or_iff {d : ⊢ᴷ φ :: ψ :: Γ} : - IsCutFree d.or ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .or⟩ - -@[simp] lemma isCutFree_and_iff {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : - IsCutFree (dφ.and dψ) ↔ IsCutFree dφ ∧ IsCutFree dψ := - ⟨by rintro ⟨⟩; constructor <;> assumption, by intro ⟨hφ, hψ⟩; exact hφ.and hψ⟩ - -@[simp] lemma isCutFree_all_iff {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : - IsCutFree d.all ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .all⟩ - -@[simp] lemma isCutFree_exs_iff {d : ⊢ᴷ φ/[t] :: Γ} : - IsCutFree d.exs ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .exs t⟩ - -@[simp] lemma isCutFree_wk_iff {d : ⊢ᴷ Δ} {ss : Δ ⊆ Γ} : - IsCutFree (d.wk ss) ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .wk _⟩ - -@[simp] lemma IsCutFree.cast {d : ⊢ᴷ Γ} {e : Γ = Δ} : - IsCutFree (.cast d e) ↔ IsCutFree d := by rcases e; rfl - -@[simp] lemma IsCutFree.not_cut (dp : ⊢ᴷ φ :: Γ) (dn : ⊢ᴷ ∼φ :: Δ) : ¬IsCutFree (dp.cut dn) := by - intro h - refine h.rec - (motive := fun {_} d _ => - match d with - | .cut _ _ => False - | _ => True) - ?_ ?_ ?_ ?_ ?_ ?_ ?_ - all_goals simp - -@[simp] lemma isCutFree_rewrite_iff_isCutFree {f : ℕ → SyntacticTerm L} {d : ⊢ᴷ Γ} : - IsCutFree (rewrite f d) ↔ IsCutFree d := by - induction d generalizing f <;> simp [rewrite, *] - -@[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᴷ Γ} : - IsCutFree (Derivation.map d f) ↔ IsCutFree d := isCutFree_rewrite_iff_isCutFree - -@[simp] lemma IsCutFree.genelalizeByNewver_isCutFree {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) - (d : ⊢ᴷ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] - -end Derivation diff --git a/Foundation/FirstOrder/Completeness/SearchTree.lean b/Foundation/FirstOrder/Completeness/SearchTree.lean deleted file mode 100644 index ad95e7210..000000000 --- a/Foundation/FirstOrder/Completeness/SearchTree.lean +++ /dev/null @@ -1,345 +0,0 @@ -module - -public import Foundation.FirstOrder.Completeness.Coding -public import Foundation.Vorspiel.Order - -@[expose] public section -namespace LO - -namespace FirstOrder - -namespace Completeness - -open Classical Semiformula Encodable Entailment - -variable {L : Language.{u}} {T : Theory L} {Γ : Sequent L} - -inductive Redux (T : Theory L) : Code L → Sequent L → Sequent L → Prop - | axLRefl {Γ : Sequent L} {k} (r : L.Rel k) (v) : - Semiformula.rel r v ∉ Γ ∨ Semiformula.nrel r v ∉ Γ → Redux T (Code.axL r v) Γ Γ - | verumRefl {Γ : Sequent L} : ⊤ ∉ Γ → Redux T Code.verum Γ Γ - | and₁ {Γ : Sequent L} {φ ψ : Proposition L} : φ ⋏ ψ ∈ Γ → Redux T (Code.and φ ψ) (φ :: Γ) Γ - | and₂ {Γ : Sequent L} {φ ψ : Proposition L} : φ ⋏ ψ ∈ Γ → Redux T (Code.and φ ψ) (ψ :: Γ) Γ - | andRefl {Γ : Sequent L} {φ ψ : Proposition L} : φ ⋏ ψ ∉ Γ → Redux T (Code.and φ ψ) Γ Γ - | or {Γ : Sequent L} {φ ψ : Proposition L} : φ ⋎ ψ ∈ Γ → Redux T (Code.or φ ψ) (φ :: ψ :: Γ) Γ - | orRefl {Γ : Sequent L} {φ ψ : Proposition L} : φ ⋎ ψ ∉ Γ → Redux T (Code.or φ ψ) Γ Γ - | all {Γ : Sequent L} {φ : Semiproposition L 1} : ∀⁰ φ ∈ Γ → Redux T (Code.all φ) (φ/[&Γ.newVar] :: Γ) Γ - | allRefl {Γ : Sequent L} {φ : Semiproposition L 1} : ∀⁰ φ ∉ Γ → Redux T (Code.all φ) Γ Γ - | exs {Γ : Sequent L} {φ : Semiproposition L 1} {t : SyntacticTerm L} : - ∃⁰ φ ∈ Γ → Redux T (Code.exs φ t) (φ/[t] :: Γ) Γ - | exsRefl {Γ : Sequent L} {φ : Semiproposition L 1} {t : SyntacticTerm L} : - ∃⁰ φ ∉ Γ → Redux T (Code.exs φ t) Γ Γ - | id {Γ : Sequent L} {σ : Sentence L} (hσ : σ ∈ T) : Redux T (Code.id σ) ((∼σ) :: Γ) Γ - | idRefl {Γ : Sequent L} {σ : Sentence L} (hσ : σ ∉ T) : Redux T (Code.id σ) Γ Γ - -local notation:25 Δ₁" ≺[" c:25 "] " Δ₂:80 => Redux T c Δ₁ Δ₂ - -/--/ -lemma Redux.antimonotone {c : Code L} {Δ₂ Δ₁ : Sequent L} (h : Δ₂ ≺[c] Δ₁) : Δ₁ ⊆ Δ₂ := by - cases h <;> simp [List.subset_cons_of_subset _ (List.subset_cons_self _ _)] - -variable [L.Encodable] - -inductive ReduxNat (T : Theory L) (s : ℕ) : Sequent L → Sequent L → Prop - | redux {c : Code L} : decode s.unpair.1 = some c → ∀ {Δ₂ Δ₁}, Redux T c Δ₂ Δ₁ → ReduxNat T s Δ₂ Δ₁ - | refl : decode (α := Code L) s.unpair.1 = none → ∀ Δ, ReduxNat T s Δ Δ - -local notation:25 Δ₁" ≺⟨" s:25 "⟩ " Δ₂:80 => ReduxNat T s Δ₁ Δ₂ - -lemma ReduxNat.antimonotone {s : ℕ} {Δ₂ Δ₁ : Sequent L} (h : Δ₂ ≺⟨s⟩ Δ₁) : Δ₁ ⊆ Δ₂ := by - cases h; { exact Redux.antimonotone (by assumption) }; { exact List.Subset.refl Δ₂ } - -lemma ReduxNat.toRedux {c : Code L} {i} {Δ₂ Δ₁ : Sequent L} (h : Δ₂ ≺⟨(encode c).pair i⟩ Δ₁) : Δ₂ ≺[c] Δ₁ := by - rcases h with (⟨h, r⟩ | ⟨h⟩); { simp at h; simpa [h] using r }; { simp at h } - -inductive SearchTreeAux (T : Theory L) (Γ : Sequent L) : ℕ → Sequent L → Type u - | zero : SearchTreeAux T Γ 0 Γ - | succ : SearchTreeAux T Γ s Δ₁ → ReduxNat T s Δ₂ Δ₁ → SearchTreeAux T Γ (s + 1) Δ₂ - -def SearchTree (T : Theory L) (Γ : Sequent L) := (s : ℕ) × (Δ : Sequent L) × SearchTreeAux T Γ s Δ - -namespace SearchTree - -abbrev rank (τ : SearchTree T Γ) := τ.1 - -abbrev seq (τ : SearchTree T Γ) := τ.2.1 - -inductive Lt (T : Theory L) (Γ : Sequent L) : SearchTree T Γ → SearchTree T Γ → Prop - | intro {s} {Δ₂ Δ₁} (a : SearchTreeAux T Γ s Δ₁) (r : ReduxNat T s Δ₂ Δ₁) : Lt T Γ ⟨s + 1, Δ₂, a.succ r⟩ ⟨s, Δ₁, a⟩ - -lemma rank_of_lt {τ₁ τ₂ : SearchTree T Γ} (h : Lt T Γ τ₂ τ₁) : τ₂.rank = τ₁.rank + 1 := by - cases h; simp - -lemma seq_of_lt {τ₁ τ₂ : SearchTree T Γ} (h : Lt T Γ τ₂ τ₁) : τ₂.seq ≺⟨τ₁.rank⟩ τ₁.seq := by - cases h; simpa [rank, seq] - -instance : Top (SearchTree T Γ) := ⟨⟨0, Γ, SearchTreeAux.zero⟩⟩ - -@[simp] lemma rank_top : (⊤ : SearchTree T Γ).rank = 0 := rfl - -@[simp] lemma seq_top : (⊤ : SearchTree T Γ).seq = Γ := rfl - -end SearchTree - -section WellFounded - -variable (wf : WellFounded (SearchTree.Lt T Γ)) - -noncomputable def SearchTree.recursion {C : SearchTree T Γ → Sort v} - (τ) (h : ∀ τ₁, (∀ τ₂, SearchTree.Lt T Γ τ₂ τ₁ → C τ₂) → C τ₁) : C τ := - WellFounded.fix wf h τ - -noncomputable def syntacticMainLemma (φ : SearchTree T Γ) : (T : Schema L) ⟹ φ.seq := by - apply SearchTree.recursion wf φ - intro ⟨s, Δ₁, a₁⟩ ih - have ih' : ∀ {Δ₂}, ReduxNat T s Δ₂ Δ₁ → (T : Schema L) ⟹ Δ₂ := - fun {Δ₂} r => ih ⟨s + 1, Δ₂, a₁.succ r⟩ (SearchTree.Lt.intro a₁ r) - rcases hs : (decode s.unpair.1 : Option (Code L)) with (_ | c) - · have : ReduxNat T s Δ₁ Δ₁ := ReduxNat.refl hs Δ₁ - exact ih' this - · cases c - case axL r v => - by_cases hr : rel r v ∈ Δ₁ ∧ nrel r v ∈ Δ₁ - · exact Tait.em hr.1 hr.2 - · exact ih' (ReduxNat.redux hs $ Redux.axLRefl r v (not_and_or.mp hr)) - case verum => - by_cases h : ⊤ ∈ Δ₁ - · exact Tait.verum' h - · exact ih' (ReduxNat.redux hs $ Redux.verumRefl h) - case and φ ψ => - by_cases h : φ ⋏ ψ ∈ Δ₁ - · have rp : φ :: Δ₁ ≺[Code.and φ ψ] Δ₁ := Redux.and₁ h - have rq : ψ :: Δ₁ ≺[Code.and φ ψ] Δ₁ := Redux.and₂ h - have dp : (T : Schema L) ⟹ φ :: Δ₁ := ih' (ReduxNat.redux hs rp) - have dq : (T : Schema L) ⟹ ψ :: Δ₁ := ih' (ReduxNat.redux hs rq) - exact Tait.wk (Tait.and dp dq) (by simpa using h) - · exact ih' (ReduxNat.redux hs $ Redux.andRefl h) - case or φ ψ => - by_cases h : φ ⋎ ψ ∈ Δ₁ - · have : φ :: ψ :: Δ₁ ≺[Code.or φ ψ] Δ₁ := Redux.or h - have : (T : Schema L) ⟹ φ :: ψ :: Δ₁ := ih' (ReduxNat.redux hs this) - exact Tait.wk (Tait.or this) (by simpa using h) - · exact ih' (ReduxNat.redux hs $ Redux.orRefl h) - case all φ => - by_cases h : ∀⁰ φ ∈ Δ₁ - · have : φ/[&(newVar Δ₁)] :: Δ₁ ≺[Code.all φ] Δ₁ := Redux.all h - have : (T : Schema L) ⟹ φ/[&(newVar Δ₁)] :: Δ₁ := ih' (ReduxNat.redux hs this) - exact Derivation.allNvar h this - · exact ih' (ReduxNat.redux hs $ Redux.allRefl h) - case exs φ t => - by_cases h : ∃⁰ φ ∈ Δ₁ - · have : φ/[t] :: Δ₁ ≺[Code.exs φ t] Δ₁ := Redux.exs h - have : (T : Schema L) ⟹ φ/[t] :: Δ₁ := ih' (ReduxNat.redux hs this) - exact Tait.wk (Derivation.exs t this) (by simpa using h) - · exact ih' (ReduxNat.redux hs $ Redux.exsRefl h) - case id φ => - by_cases h : φ ∈ T - · have : (∼φ) :: Δ₁ ≺[Code.id φ] Δ₁ := Redux.id h - have : (T : Schema L) ⟹ (∼↑φ) :: Δ₁ := ih' (ReduxNat.redux hs this) - exact Derivation.id (by simp [h]) this - · exact ih' (ReduxNat.redux hs $ Redux.idRefl h) - -noncomputable def syntacticMainLemmaTop : (T : Schema L) ⟹ Γ := syntacticMainLemma wf ⊤ - -end WellFounded - -section NotWellFounded - -noncomputable def chainU (T : Theory L) (Γ : Sequent L) : ℕ → SearchTree T Γ := descendingChain (SearchTree.Lt T Γ) ⊤ - -noncomputable def chain (T : Theory L) (Γ : Sequent L) (s : ℕ) : Sequent L := (chainU T Γ s).seq - -def chainSet (T : Theory L) (Γ : Sequent L) : Set (Proposition L) := ⋃ s, {x | x ∈ chain T Γ s} - -local notation "⛓️[" s "]" => chain T Γ s - -local notation "⛓️" => chainSet T Γ - -lemma top_inaccessible (nwf : ¬WellFounded (SearchTree.Lt T Γ)) : ¬Acc (SearchTree.Lt T Γ) ⊤ := by - intro A - have : WellFounded (SearchTree.Lt T Γ) := ⟨by - rintro ⟨s, Δ, a⟩ - induction a - case zero => exact A - case succ s Δ₁ Δ₂ a r ih => exact ih.inv (SearchTree.Lt.intro a r)⟩ - contradiction - -lemma chainU_spec (nwf : ¬WellFounded (SearchTree.Lt T Γ)) : IsInfiniteDescendingChain (SearchTree.Lt T Γ) (chainU T Γ) := - isInfiniteDescendingChain_of_non_acc _ _ (top_inaccessible nwf) - -lemma chainU_val_fst_eq (nwf : ¬WellFounded (SearchTree.Lt T Γ)) (s : ℕ) : (chainU T Γ s).rank = s := by - induction s - case zero => - dsimp [SearchTree.rank] - exact rfl - case succ s ih => - dsimp [SearchTree.rank] - simpa [ih] using SearchTree.rank_of_lt (chainU_spec nwf s) - -lemma chain_spec (nwf : ¬WellFounded (SearchTree.Lt T Γ)) (s) : ⛓️[s + 1] ≺⟨s⟩ ⛓️[s] := - by simpa [chainU_val_fst_eq nwf s] using SearchTree.seq_of_lt (chainU_spec nwf s) - -lemma chain_monotone (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {s u : ℕ} (h : s ≤ u) : ⛓️[s] ⊆ ⛓️[u] := by - suffices ∀ d, ⛓️[s] ⊆ ⛓️[s + d] by - simpa [Nat.add_sub_of_le h] using this (u - s) - intro d; induction' d with d ih - · simp - · simpa only [Nat.add_succ] using subset_trans ih <| ReduxNat.antimonotone (chain_spec nwf (s + d)) - -lemma chain_spec' (nwf : ¬WellFounded (SearchTree.Lt T Γ)) (c : Code L) (i : ℕ) : - ⛓️[(encode c).pair i + 1] ≺[c] ⛓️[(encode c).pair i] := (chain_spec nwf _).toRedux - -lemma chainSet_verum (nwf : ¬WellFounded (SearchTree.Lt T Γ)) : ⊤ ∉ ⛓️ := by - suffices ∀ s, ⊤ ∉ ⛓️[s] by simpa [chainSet] - intro s h - have : ⊤ ∈ ⛓️[(encode (Code.verum : Code L)).pair s] := chain_monotone nwf (Nat.right_le_pair _ _) h - have : ¬⊤ ∈ ⛓️[(encode (Code.verum : Code L)).pair s] := by - have : ⛓️[(encode Code.verum).pair s + 1] ≺[Code.verum] ⛓️[(encode Code.verum).pair s] := chain_spec' nwf _ _ - generalize ⛓️[(encode (Code.verum : Code L)).pair s + 1] = Δ' at this - rcases this; assumption - contradiction - -lemma chainSet_axL (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {k} (r : L.Rel k) (v : Fin k → SyntacticTerm L) : - rel r v ∉ ⛓️ ∨ nrel r v ∉ ⛓️ := by - by_contra h - have : (∃ s₁, rel r v ∈ ⛓️[s₁]) ∧ (∃ s₂, nrel r v ∈ ⛓️[s₂]) := by - have h : rel r v ∈ ⛓️ ∧ nrel r v ∈ ⛓️ := by simpa [not_or] using h - simpa [chainSet] using h - rcases this with ⟨⟨s₁, hs₁⟩, ⟨s₂, hs₂⟩⟩ - have : rel r v ∈ ⛓️[(encode $ Code.axL r v).pair (max s₁ s₂)] ∧ nrel r v ∈ ⛓️[(encode $ Code.axL r v).pair (max s₁ s₂)] := by - exact ⟨chain_monotone nwf (le_trans (by simp) (Nat.right_le_pair _ _)) hs₁, - chain_monotone nwf (le_trans (by simp) (Nat.right_le_pair _ _)) hs₂⟩ - have : ¬(rel r v ∈ ⛓️[(encode $ Code.axL r v).pair (max s₁ s₂)] ∧ nrel r v ∈ ⛓️[(encode $ Code.axL r v).pair (max s₁ s₂)]) := by - rw [not_and_or] - have : ⛓️[(encode $ Code.axL r v).pair (max s₁ s₂) + 1] ≺[Code.axL r v] ⛓️[(encode $ Code.axL r v).pair (max s₁ s₂)] := - chain_spec' nwf _ _ - generalize ⛓️[(encode $ Code.axL r v).pair (max s₁ s₂) + 1] = Δ' at this - rcases this; assumption - contradiction - -lemma chainSet_and (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ ψ : Proposition L} (h : φ ⋏ ψ ∈ ⛓️) : - φ ∈ ⛓️ ∨ ψ ∈ ⛓️ := by - have : ∃ s, φ ⋏ ψ ∈ ⛓️[s] := by simpa [chainSet] using h - rcases this with ⟨s, hs⟩ - have : ⛓️[(encode $ Code.and φ ψ).pair s + 1] ≺[Code.and φ ψ] ⛓️[(encode $ Code.and φ ψ).pair s] := chain_spec' nwf _ _ - generalize hΔ : ⛓️[(encode $ Code.and φ ψ).pair s + 1] = Δ at this - rcases this - case and₁ => - exact Or.inl (Set.mem_iUnion.mpr ⟨(encode $ Code.and φ ψ).pair s + 1, by simp [hΔ]⟩) - case and₂ => - exact Or.inr (Set.mem_iUnion.mpr ⟨(encode $ Code.and φ ψ).pair s + 1, by simp [hΔ]⟩) - case andRefl => - have : φ ⋏ ψ ∈ ⛓️[(encode $ Code.and φ ψ).pair s] := chain_monotone nwf (Nat.right_le_pair _ _) hs - contradiction - -lemma chainSet_or (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ ψ : Proposition L} (h : φ ⋎ ψ ∈ ⛓️) : - φ ∈ ⛓️ ∧ ψ ∈ ⛓️ := by - have : ∃ s, φ ⋎ ψ ∈ ⛓️[s] := by simpa [chainSet] using h - rcases this with ⟨s, hs⟩ - have : ⛓️[(encode $ Code.or φ ψ).pair s + 1] ≺[Code.or φ ψ] ⛓️[(encode $ Code.or φ ψ).pair s] := chain_spec' nwf _ _ - generalize hΔ : ⛓️[(encode $ Code.or φ ψ).pair s + 1] = Δ at this - rcases this - · exact ⟨Set.mem_iUnion.mpr ⟨(encode $ Code.or φ ψ).pair s + 1, by simp [hΔ]⟩, - Set.mem_iUnion.mpr ⟨(encode $ Code.or φ ψ).pair s + 1, by simp [hΔ]⟩⟩ - · have : φ ⋎ ψ ∈ ⛓️[(encode $ Code.or φ ψ).pair s] := chain_monotone nwf (Nat.right_le_pair _ _) hs - contradiction - -lemma chainSet_all (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ : Semiproposition L 1} (h : ∀⁰ φ ∈ ⛓️) : - ∃ t, φ/[t] ∈ ⛓️ := by - have : ∃ s, ∀⁰ φ ∈ ⛓️[s] := by simpa [chainSet] using h - rcases this with ⟨s, hs⟩ - have : ⛓️[(encode $ Code.all φ).pair s + 1] ≺[Code.all φ] ⛓️[(encode $ Code.all φ).pair s] := chain_spec' nwf _ _ - generalize hΔ : ⛓️[(encode $ Code.all φ).pair s + 1] = Δ at this - rcases this - · exact ⟨&(newVar ⛓️[(encode $ Code.all φ).pair s]), Set.mem_iUnion.mpr ⟨(encode $ Code.all φ).pair s + 1, by simp [hΔ]⟩⟩ - · have : ∀⁰ φ ∈ ⛓️[(encode $ Code.all φ).pair s] := chain_monotone nwf (Nat.right_le_pair _ _) hs - contradiction - -lemma chainSet_ex (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ : Semiproposition L 1} (h : ∃⁰ φ ∈ ⛓️) : - ∀ t, φ/[t] ∈ ⛓️ := fun t => by - have : ∃ s, ∃⁰ φ ∈ ⛓️[s] := by simpa [chainSet] using h - rcases this with ⟨s, hs⟩ - have : ⛓️[(encode $ Code.exs φ t).pair s + 1] ≺[Code.exs φ t] ⛓️[(encode $ Code.exs φ t).pair s] := chain_spec' nwf _ _ - generalize hΔ : ⛓️[(encode $ Code.exs φ t).pair s + 1] = Δ at this - rcases this - · exact Set.mem_iUnion.mpr ⟨(encode $ Code.exs φ t).pair s + 1, by simp [hΔ]⟩ - · have : ∃⁰ φ ∈ ⛓️[(encode $ Code.exs φ t).pair s] := chain_monotone nwf (Nat.right_le_pair _ _) hs - contradiction - -lemma chainSet_id (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ : Sentence L} (h : φ ∈ T) : - ∼↑φ ∈ ⛓️ := by - have : ⛓️[(encode $ Code.id φ).pair 0 + 1] ≺[Code.id φ] ⛓️[(encode $ Code.id φ).pair 0] := chain_spec' nwf _ _ - generalize hΔ : ⛓️[(encode $ Code.id φ).pair 0 + 1] = Δ - rw [hΔ] at this; rcases this - · exact Set.mem_iUnion.mpr ⟨(encode $ Code.id φ).pair 0 + 1, by simp [hΔ]⟩ - · contradiction - -set_option linter.unusedVariables false in -abbrev Model (T : Theory L) (Γ : Sequent L) := SyntacticTerm L - -instance : Inhabited (Model T Γ) := ⟨(default : SyntacticTerm L)⟩ - -def Model.equiv : Model T Γ ≃ SyntacticTerm L := Equiv.refl _ - -instance Model.structure (T : Theory L) (Γ : Sequent L) : Structure L (Model T Γ) where - func := fun _ f v => Semiterm.func f v - rel := fun _ r v => nrel r v ∈ chainSet T Γ - -@[simp] lemma Model.val {e : Fin n → SyntacticTerm L} {ε} (t : SyntacticSemiterm L n) : - Semiterm.val (Model.structure T Γ) e ε t = Rew.bind e ε t := by - induction t <;> simp [*, Semiterm.val_func, Rew.func]; rfl - -@[simp] lemma Model.rel {k} (r : L.Rel k) (v : Fin k → SyntacticTerm L) : - (Model.structure T Γ).rel r v ↔ nrel r v ∈ ⛓️ := of_eq rfl - -lemma semanticMainLemma_val (nwf : ¬WellFounded (SearchTree.Lt T Γ)) : - (φ : Proposition L) → φ ∈ ⛓️ → ¬Evalf (Model.structure T Γ) Semiterm.fvar φ - | ⊤, h => by by_contra; exact chainSet_verum nwf h - | ⊥, _ => by simp - | rel r v, h => by rcases chainSet_axL nwf r v with (hr | hr); { contradiction }; { simpa [eval_rel] using hr } - | nrel r v, h => by simpa [eval_nrel] using h - | φ ⋏ ψ, h => by - suffices Evalf (Model.structure T Γ) Semiterm.fvar φ → ¬Evalf (Model.structure T Γ) Semiterm.fvar ψ by simpa - intro _ _ - have : φ ∈ ⛓️ ∨ ψ ∈ ⛓️ := chainSet_and nwf h - rcases this with (h | h) - · have : ¬Evalf (Model.structure T Γ) Semiterm.fvar φ := semanticMainLemma_val nwf φ h - contradiction - · have : ¬Evalf (Model.structure T Γ) Semiterm.fvar ψ := semanticMainLemma_val nwf ψ h - contradiction - | φ ⋎ ψ, h => by - have hpq : φ ∈ ⛓️ ∧ ψ ∈ ⛓️ := chainSet_or nwf h - simp only [LogicalConnective.HomClass.map_or, LogicalConnective.Prop.or_eq] - rintro (h | h) - · exact semanticMainLemma_val nwf φ hpq.1 h - · exact semanticMainLemma_val nwf ψ hpq.2 h - | ∀⁰ φ, h => by - have : ∃ u, φ/[u] ∈ ⛓️ := chainSet_all nwf h - rcases this with ⟨u, hu⟩ - have : ¬Eval (Model.structure T Γ) ![u] Semiterm.fvar φ := by - simpa [eval_substs, Matrix.constant_eq_singleton] using semanticMainLemma_val nwf (φ/[u]) hu - simpa using ⟨u, this⟩ - | ∃⁰ φ, h => by - suffices ∀ u : Model T Γ, ¬Eval (Model.structure T Γ) ![u] Semiterm.fvar φ by simpa - intro u - have : φ/[u] ∈ ⛓️ := chainSet_ex nwf h u - have : ¬Eval (Model.structure T Γ) ![u] Semiterm.fvar φ := by - simpa [eval_substs, Matrix.constant_eq_singleton] using semanticMainLemma_val nwf (φ/[u]) this - assumption - termination_by φ _ => φ.complexity - -lemma Model.models (nwf : ¬WellFounded (SearchTree.Lt T Γ)) : - Model T Γ ⊧ₘ* T := - ⟨fun φ hφ ↦ by simpa [Semiformula.eval_univCl] using semanticMainLemma_val nwf _ (chainSet_id nwf hφ)⟩ - -lemma semanticMainLemmaTop (nwf : ¬WellFounded (SearchTree.Lt T Γ)) {φ : Proposition L} (h : φ ∈ Γ) : - ¬Evalf (Model.structure T Γ) Semiterm.fvar φ := - semanticMainLemma_val nwf φ (Set.mem_iUnion.mpr ⟨0, by simp [chain, chainU, h]⟩) - -end NotWellFounded - -end Completeness - -end FirstOrder - -end LO diff --git a/Foundation/FirstOrder/Completeness/SubLanguage.lean b/Foundation/FirstOrder/Completeness/SubLanguage.lean deleted file mode 100644 index 7477eb4da..000000000 --- a/Foundation/FirstOrder/Completeness/SubLanguage.lean +++ /dev/null @@ -1,251 +0,0 @@ -module - -public import Foundation.FirstOrder.Basic - -@[expose] public section -namespace LO - -namespace FirstOrder - -variable {L : Language.{u}} {L₁ : Language.{u}} {L₂ : Language.{u}} - -namespace Language - -def subLanguage (L : Language) (pfunc : ∀ k, L.Func k → Prop) (prel : ∀ k, L.Rel k → Prop) : - Language where - Func := fun k => Subtype (pfunc k) - Rel := fun k => Subtype (prel k) - -section subLanguage - -variable (L) - -variable {pf : (k : ℕ) → L.Func k → Prop} {pr : (k : ℕ) → L.Rel k → Prop} - -def ofSubLanguage : subLanguage L pf pr →ᵥ L where - func := Subtype.val - rel := Subtype.val - -@[simp] lemma ofSubLanguage_onFunc : - L.ofSubLanguage.func φ = φ.val := rfl - -@[simp] lemma ofSubLanguage_onRel : - L.ofSubLanguage.rel φ = φ.val := rfl - -end subLanguage - -end Language - -namespace Semiterm - -open Language -variable [∀ k, DecidableEq (L.Func k)] - -def lang : Semiterm L ξ n → Finset (Σ k, L.Func k) - | #_ => ∅ - | &_ => ∅ - | func f v => insert ⟨_, f⟩ $ Finset.biUnion Finset.univ (fun i => lang (v i)) - -@[simp] lemma lang_func {k} (f : L.Func k) (v : Fin k → Semiterm L ξ n) : - ⟨k, f⟩ ∈ (func f v).lang := by simp [lang] - -lemma lang_func_ss {k} (f : L.Func k) (v : Fin k → Semiterm L ξ n) (i) : - (v i).lang ⊆ (func f v).lang := by - intros x - simp only [lang, Finset.mem_insert, Finset.mem_biUnion, Finset.mem_univ, true_and] - intros h; exact Or.inr ⟨i, h⟩ - -def toSubLanguage' (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) : ∀ t : Semiterm L ξ n, - (∀ k f, ⟨k, f⟩ ∈ t.lang → pf k f) → Semiterm (subLanguage L pf pr) ξ n - | #x, _ => #x - | &x, _ => &x - | func (arity := k) f v, h => func ⟨f, h k f (by simp)⟩ - (fun i => toSubLanguage' pf pr (v i) (fun k' f' h' => h k' f' (lang_func_ss f v i h'))) - -@[simp] lemma lMap_toSubLanguage' (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) - (t : Semiterm L ξ n) (h : ∀ k f, ⟨k, f⟩ ∈ t.lang → pf k f) : - (t.toSubLanguage' pf pr h).lMap L.ofSubLanguage = t := by - induction t <;> simp [*, toSubLanguage', lMap_func, Function.comp_def] - -end Semiterm - -namespace Semiformula - -variable [L.DecidableEq] - -noncomputable def langFunc {n} : Semiformula L ξ n → Finset (Σ k, L.Func k) - | ⊤ => ∅ - | ⊥ => ∅ - | rel _ v => Finset.biUnion Finset.univ (fun i => (v i).lang) - | nrel _ v => Finset.biUnion Finset.univ (fun i => (v i).lang) - | φ ⋏ ψ => langFunc φ ∪ langFunc ψ - | φ ⋎ ψ => langFunc φ ∪ langFunc ψ - | ∀⁰ φ => langFunc φ - | ∃⁰ φ => langFunc φ - -noncomputable def langRel {n} : Semiformula L ξ n → Finset (Σ k, L.Rel k) - | ⊤ => ∅ - | ⊥ => ∅ - | rel r _ => {⟨_, r⟩} - | nrel r _ => {⟨_, r⟩} - | φ ⋏ ψ => langRel φ ∪ langRel ψ - | φ ⋎ ψ => langRel φ ∪ langRel ψ - | ∀⁰ φ => langRel φ - | ∃⁰ φ => langRel φ - -lemma langFunc_rel_ss {k} (r : L.Rel k) (v : Fin k → Semiterm L ξ n) (i) : - (v i).lang ⊆ (rel r v).langFunc := by - intros x - simp only [langFunc, Finset.mem_biUnion, Finset.mem_univ, true_and] - intros h; exact ⟨i, h⟩ - -def toSubLanguage' (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) {n} : - (φ : Semiformula L ξ n) → - (∀ k f, ⟨k, f⟩ ∈ φ.langFunc → pf k f) → - (∀ k r, ⟨k, r⟩ ∈ φ.langRel → pr k r) → - Semiformula (L.subLanguage pf pr) ξ n - | ⊤, _, _ => ⊤ - | ⊥, _, _ => ⊥ - | rel r v, hf, hr => - rel ⟨r, hr _ r (by simp [langRel])⟩ - (fun i => (v i).toSubLanguage' pf pr (fun k f h => hf k f (langFunc_rel_ss r v i h))) - | nrel r v, hf, hr => - nrel ⟨r, hr _ r (by simp [langRel])⟩ - (fun i => (v i).toSubLanguage' pf pr (fun k f h => hf k f (langFunc_rel_ss r v i h))) - | φ ⋏ ψ, hf, hr => - toSubLanguage' pf pr φ (fun k f h => hf k f (Finset.mem_union_left _ h)) (fun k r h => hr k r (Finset.mem_union_left _ h)) ⋏ - toSubLanguage' pf pr ψ (fun k f h => hf k f (Finset.mem_union_right _ h)) (fun k r h => hr k r (Finset.mem_union_right _ h)) - | φ ⋎ ψ, hf, hr => - toSubLanguage' pf pr φ (fun k f h => hf k f (Finset.mem_union_left _ h)) (fun k r h => hr k r (Finset.mem_union_left _ h)) ⋎ - toSubLanguage' pf pr ψ (fun k f h => hf k f (Finset.mem_union_right _ h)) (fun k r h => hr k r (Finset.mem_union_right _ h)) - | ∀⁰ φ, hf, hr => ∀⁰ toSubLanguage' pf pr φ hf hr - | ∃⁰ φ, hf, hr => ∃⁰ toSubLanguage' pf pr φ hf hr - -@[simp] lemma lMap_toSubLanguage' - (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) {n} (φ : Semiformula L ξ n) - (hf : ∀ k f, ⟨k, f⟩ ∈ φ.langFunc → pf k f) (hr : ∀ k r, ⟨k, r⟩ ∈ φ.langRel → pr k r) : - lMap L.ofSubLanguage (φ.toSubLanguage' pf pr hf hr) = φ := by - induction φ using rec' <;> simp [*, toSubLanguage', lMap_rel, lMap_nrel, Function.comp_def] - -noncomputable def languageFuncIndexed (φ : Semiformula L ξ n) (k) : Finset (L.Func k) := - Finset.preimage (langFunc φ) (Sigma.mk k) (Set.injOn_of_injective sigma_mk_injective) - -noncomputable def languageRelIndexed (φ : Semiformula L ξ n) (k) : Finset (L.Rel k) := - Finset.preimage (langRel φ) (Sigma.mk k) (Set.injOn_of_injective sigma_mk_injective) - -abbrev languageFinset (Γ : Finset (Semiformula L ξ n)) : Language := - Language.subLanguage L (fun k f => ∃ φ ∈ Γ, ⟨k, f⟩ ∈ langFunc φ) (fun k r => ∃ φ ∈ Γ, ⟨k, r⟩ ∈ langRel φ) - -noncomputable instance (Γ : Finset (Semiformula L ξ n)) (k) : Fintype ((languageFinset Γ).Func k) := - Fintype.subtype (Γ.biUnion (languageFuncIndexed · k)) (by simp [languageFuncIndexed]) - -noncomputable instance (Γ : Finset (Semiformula L ξ n)) (k) : Fintype ((languageFinset Γ).Rel k) := - Fintype.subtype (Γ.biUnion (languageRelIndexed · k)) (by simp [languageRelIndexed]) - -def toSubLanguageFinsetSelf {Γ : Finset (Semiformula L ξ n)} {φ} (h : φ ∈ Γ) : Semiformula (languageFinset Γ) ξ n := - φ.toSubLanguage' _ _ (fun _ _ hf => ⟨φ, h, hf⟩) (fun _ _ hr => ⟨φ, h, hr⟩) - -@[simp] lemma lMap_toSubLanguageFinsetSelf {Γ : Finset (Semiformula L ξ n)} {φ} (h : φ ∈ Γ) : - lMap L.ofSubLanguage (toSubLanguageFinsetSelf h) = φ := - lMap_toSubLanguage' _ _ _ _ _ - -end Semiformula - -namespace Structure - -instance subLanguageStructure {pf : ∀ k, L.Func k → Prop} {pr : ∀ k, L.Rel k → Prop} - {M : Type w} (s : Structure L M) : Structure (Language.subLanguage L pf pr) M := - s.lMap (Language.ofSubLanguage L) - -noncomputable def extendStructure (Φ : L₁ →ᵥ L₂) {M : Type w} [Nonempty M] (s : Structure L₁ M) : Structure L₂ M where - func := fun {k} f₂ v => Classical.epsilon (fun y => ∃ f₁ : L₁.Func k, Φ.func f₁ = f₂ ∧ y = s.func f₁ v) - rel := fun {k} r₂ v => ∃ r₁ : L₁.Rel k, Φ.rel r₁ = r₂ ∧ s.rel r₁ v - -namespace extendStructure - -variable {M : Type u} [Nonempty M] (s₁ : Structure L₁ M) - -protected lemma func - (Φ : L₁ →ᵥ L₂) - {k} (injf : Function.Injective (Φ.func : L₁.Func k → L₂.Func k)) (f₁ : L₁.Func k) (v : Fin k → M) : - (s₁.extendStructure Φ).func (Φ.func f₁) v = s₁.func f₁ v := by - have : ∃ y, ∃ f₁' : L₁.Func k, Φ.func f₁' = Φ.func f₁ ∧ y = s₁.func f₁' v := ⟨s₁.func f₁ v, f₁, rfl, rfl⟩ - rcases Classical.epsilon_spec this with ⟨f', f'eq, h⟩ - rcases injf f'eq with rfl; exact h - -protected lemma rel - (Φ : L₁ →ᵥ L₂) - {k} (injr : Function.Injective (Φ.rel : L₁.Rel k → L₂.Rel k)) - (r₁ : L₁.Rel k) (v : Fin k → M) : - (s₁.extendStructure Φ).rel (Φ.rel r₁) v ↔ s₁.rel r₁ v := by - refine ⟨by intros h; rcases h with ⟨r₁', e, h⟩; rcases injr e; exact h, by intros h; refine ⟨r₁, rfl, h⟩⟩ - -lemma val_lMap - (Φ : L₁ →ᵥ L₂) - (injf : ∀ k, Function.Injective (Φ.func : L₁.Func k → L₂.Func k)) - {n} (e : Fin n → M) (ε : ξ → M) - (t : Semiterm L₁ ξ n) : - Semiterm.val (s := s₁.extendStructure Φ) e ε (t.lMap Φ) = Semiterm.val (s := s₁) e ε t := by - induction t - case func k f v ih => - simp only [Semiterm.lMap_func, Semiterm.val_func, Function.comp_def, ih] - exact extendStructure.func s₁ Φ (injf k) f fun i ↦ Semiterm.val (s := s₁) e ε (v i) - case _ => simp [*] - case _ => simp [*] - -open Semiformula - -lemma eval_lMap - (Φ : L₁ →ᵥ L₂) - (injf : ∀ k, Function.Injective (Φ.func : L₁.Func k → L₂.Func k)) - (injr : ∀ k, Function.Injective (Φ.rel : L₁.Rel k → L₂.Rel k)) - {n} (e : Fin n → M) (ε : ξ → M) - {φ : Semiformula L₁ ξ n} : - Eval (s := s₁.extendStructure Φ) e ε (lMap Φ φ) ↔ Eval (s := s₁) e ε φ := by - induction φ using Semiformula.rec' - case hrel k r v => - simp only [Semiformula.lMap_rel, eval_rel, val_lMap s₁ Φ injf e ε, Function.comp_def] - exact extendStructure.rel s₁ Φ (injr k) r (fun i => Semiterm.val (s := s₁) e ε (v i)) - case hnrel k r v => - simp only [lMap_nrel, eval_nrel, val_lMap s₁ Φ injf e ε, Function.comp_def] - simpa [not_iff_not] using - extendStructure.rel s₁ Φ (injr k) r (fun i => Semiterm.val (s := s₁) e ε (v i)) - case _ => simp [*] - case _ => simp [*] - case _ => simp [*] - case _ => simp [*] - case _ => simp [*] - case _ => simp [*] - -lemma models_lMap - (Φ : L₁ →ᵥ L₂) - (injf : ∀ k, Function.Injective (Φ.func : L₁.Func k → L₂.Func k)) - (injr : ∀ k, Function.Injective (Φ.rel : L₁.Rel k → L₂.Rel k)) - (φ : Sentence L₁) : - (s₁.extendStructure Φ).toStruc ⊧ Semiformula.lMap Φ φ ↔ s₁.toStruc ⊧ φ := by - simp [Semantics.Models, eval_lMap s₁ Φ injf injr] - -end extendStructure - -end Structure - -section lMap - -lemma satisfiable_lMap - (Φ : L₁ →ᵥ L₂) - (injf : ∀ k, Function.Injective (Φ.func : L₁.Func k → L₂.Func k)) - (injr : ∀ k, Function.Injective (Φ.rel : L₁.Rel k → L₂.Rel k)) - {T : Theory L₁} (s : Satisfiable T) : - Satisfiable (Semiformula.lMap Φ '' T) := by - rcases s with ⟨⟨M, i, s⟩, hM⟩ - exact ⟨⟨M, i, s.extendStructure Φ⟩, by - simp only [Semantics.modelsSet_iff, Set.mem_image, forall_exists_index, and_imp, - forall_apply_eq_imp_iff₂] - intro φ hp - exact (Structure.extendStructure.models_lMap s Φ injf injr φ).mpr (hM.models _ hp)⟩ - -end lMap - -end FirstOrder - -end LO diff --git a/Foundation/Vorspiel/Order/Preorder.lean b/Foundation/Vorspiel/Order/Preorder.lean deleted file mode 100644 index da4aeb623..000000000 --- a/Foundation/Vorspiel/Order/Preorder.lean +++ /dev/null @@ -1,107 +0,0 @@ -module - -public import Mathlib.Topology.Order.UpperLowerSetTopology -public import Mathlib.Topology.Sets.Opens -public import Mathlib.Order.Heyting.Regular -public import Foundation.Vorspiel.Order.Regular - -@[expose] public section - -variable {α : Type*} [Preorder α] - -namespace LowerSet - -def IsCompatiblePair (a b : α) : Prop := ∃ c, c ≤ a ∧ c ≤ b - -infix:50 " ‖ " => IsCompatiblePair - -@[simp, refl] protected lemma IsCompatiblePair.refl (a : α) : a ‖ a := ⟨a, by simp⟩ - -@[symm] protected lemma IsCompatiblePair.symm_iff {a b : α} : a ‖ b ↔ b ‖ a := by - constructor - · rintro ⟨c, hca, hcb⟩; exact ⟨c, hcb, hca⟩ - · rintro ⟨c, hcb, hca⟩; exact ⟨c, hca, hcb⟩ - -alias ⟨IsCompatiblePair.symm, _⟩ := IsCompatiblePair.symm_iff - -def IsIncompatiblePair (a b : α) : Prop := ¬(a ‖ b) - -infix:50 " ⟂ " => IsIncompatiblePair - -lemma isIncompatiblePair_iff {a b : α} : a ⟂ b ↔ ∀ c ≤ a, ¬c ≤ b := by - simp [IsIncompatiblePair, IsCompatiblePair] - -@[simp] lemma IsIncompatiblePair.antirefl (a : α) : ¬(a ⟂ a) := by simp [IsIncompatiblePair] - -lemma IsIncompatiblePair.symm_iff {a b : α} : a ⟂ b ↔ b ⟂ a := by - contrapose; simpa [IsIncompatiblePair] using IsCompatiblePair.symm_iff - -alias ⟨IsIncompatiblePair.symm, _⟩ := IsIncompatiblePair.symm_iff - -lemma IsIncompatiblePair.lower {a a' b b' : α} (h : a ⟂ b) (ha'a : a' ≤ a) (hb'b : b' ≤ b) : a' ⟂ b' := by - rintro ⟨c, hca, hcb⟩ - exact h ⟨c, le_trans hca ha'a, le_trans hcb hb'b⟩ - -@[simp, grind =] lemma not_isCompatiblePair_iff_isIncompatiblePair {a b : α} : ¬(a ‖ b) ↔ a ⟂ b := by - rfl - -@[simp, grind =] lemma not_isIncompatiblePair_iff_isCompatiblePair {a b : α} : ¬(a ⟂ b) ↔ a ‖ b := by - simp [IsIncompatiblePair, IsCompatiblePair] - -instance : HeytingAlgebra (LowerSet α) := inferInstance - -lemma inf_eq_bot_iff_incompatible {u v : LowerSet α} : u ⊓ v = ⊥ ↔ (∀ x ∈ u, ∀ y ∈ v, x ⟂ y) := by - suffices (u ∩ v : Set α) = ∅ ↔ ∀ x ∈ u, ∀ y ∈ v, x ⟂ y by simpa [LowerSet.ext_iff] - constructor - · rintro e x hx y hy ⟨z, hzx, hzy⟩ - have hzu : z ∈ u := u.lower hzx hx - have hzv : z ∈ v := v.lower hzy hy - have : z ∈ (u ∩ v : Set α) := ⟨hzu, hzv⟩ - simp_all - · rintro h - suffices ∀ x ∈ u, x ∉ v by - apply Set.eq_empty_of_forall_notMem - simpa - intro x hx hx' - simpa using h x hx x hx' - -lemma mem_dual_iff {u : LowerSet α} : x ∈ uᶜ ↔ ∀ y ∈ u, x ⟂ y := by - suffices (∃ i, (∀ y ∈ i, ∀ z ∈ u, y ⟂ z) ∧ x ∈ i) ↔ ∀ y ∈ u, x ⟂ y by simpa [Compl.compl, inf_eq_bot_iff_incompatible] - constructor - · rintro ⟨i, hi, hxi⟩ y hyu - exact hi x hxi y hyu - · intro h - let i : LowerSet α := ⟨{x | ∀ y ∈ u, x ⟂ y}, by - intro a b hba ha y hyu - exact (ha y hyu).lower hba (by rfl)⟩ - refine ⟨i, by simp [i], by simpa [i] using h⟩ - -lemma coe_dual (u : LowerSet α) : uᶜ = {x | ∀ y ∈ u, x ⟂ y} := by - ext x; simp [mem_dual_iff] - -lemma mem_himp_iff {u v : LowerSet α} : x ∈ u ⇨ v ↔ ∀ y ≤ x, y ∈ u → y ∈ v := by - suffices (∃ s, s ⊓ u ≤ v ∧ x ∈ s) ↔ ∀ y ≤ x, y ∈ u → y ∈ v by simpa [HImp.himp] - constructor - · rintro ⟨s, hs, hxs⟩ y hyx hyu - have : y ∈ s := s.lower hyx hxs - have : y ∈ s ⊓ u := ⟨this, hyu⟩ - exact hs this - · intro h - refine ⟨LowerSet.Iic x, ?_, by simp⟩ - intro y; simp; grind - -variable (α) - -abbrev Regular := Heyting.Regular (LowerSet α) - -variable {α} - -namespace Regular - -instance : BooleanAlgebra (Regular α) := inferInstance - -instance : CompleteBooleanAlgebra (Regular α) := inferInstance - -end Regular - -end LowerSet From 5b11d8ca0ae85a4263f6873a5d52787b1244c3de Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sun, 5 Apr 2026 01:23:44 +0900 Subject: [PATCH 29/61] sInf of Ideal --- Foundation/Vorspiel/Order/Heyting.lean | 15 ++++ Foundation/Vorspiel/Order/Ideal.lean | 50 +++++++++++ Foundation/Vorspiel/Order/LowerSet.lean | 107 ++++++++++++++++++++++++ Foundation/Vorspiel/Order/Regular.lean | 8 +- 4 files changed, 176 insertions(+), 4 deletions(-) create mode 100644 Foundation/Vorspiel/Order/Heyting.lean create mode 100644 Foundation/Vorspiel/Order/Ideal.lean create mode 100644 Foundation/Vorspiel/Order/LowerSet.lean diff --git a/Foundation/Vorspiel/Order/Heyting.lean b/Foundation/Vorspiel/Order/Heyting.lean new file mode 100644 index 000000000..60398d77e --- /dev/null +++ b/Foundation/Vorspiel/Order/Heyting.lean @@ -0,0 +1,15 @@ +module + +public import Mathlib.Order.Heyting.Regular +public import Mathlib.Order.CompleteBooleanAlgebra + +public section + +variable {α : Type*} [Order.Frame α] + +/-- https://github.com/leanprover-community/mathlib4/blob/205a0ba54c047cafda226494138ba715ab6bf28c/Mathlib/Order/CompleteBooleanAlgebra.lean#L413-L414-/ +theorem iSup_himp_eq {f : ι → α} : (⨆ x, f x) ⇨ a = ⨅ x, f x ⇨ a := + eq_of_forall_le_iff fun b => by simp [inf_iSup_eq] + +theorem compl_iSup' {a : ι → α} : (⨆ i, a i)ᶜ = ⨅ i, (a i)ᶜ := by + simpa using iSup_himp_eq (f := a) (a := ⊥) diff --git a/Foundation/Vorspiel/Order/Ideal.lean b/Foundation/Vorspiel/Order/Ideal.lean new file mode 100644 index 000000000..2096ef7f3 --- /dev/null +++ b/Foundation/Vorspiel/Order/Ideal.lean @@ -0,0 +1,50 @@ + +module + +public import Mathlib.Order.Ideal +public import Mathlib.Order.PFilter +public import Mathlib.Data.Finset.Lattice.Basic + +@[expose] public section + +namespace Order + +namespace Ideal + +variable {P : Type*} [SemilatticeSup P] [OrderBot P] + +lemma sSup_def (s : Set (Ideal P)) : sSup s = sInf (upperBounds s) := rfl + +lemma iSup_def (I : ι → Ideal P) : ⨆ i, I i = sInf (upperBounds (Set.range I)) := rfl + +lemma mem_iSup_iff [DecidableEq ι] {I : ι → Ideal P} {x : P} : + x ∈ ⨆ i, I i ↔ ∃ u : Finset ι, x ∈ u.sup I := by + revert x + let K : Ideal P := { + carrier := { x | ∃ u : Finset ι, x ∈ u.sup I } + lower' x y hyx := by + rintro ⟨u, hx⟩ + exact ⟨u, (u.sup I).lower hyx hx⟩ + nonempty' := ⟨⊥, ∅, by simp⟩ + directed' := by + rintro x ⟨u, hu⟩ y ⟨v, hv⟩ + refine ⟨x ⊔ y, ⟨u ∪ v, ?_⟩, ?_⟩ + · simpa [Finset.sup_union] + using ⟨⟨x, hu, y, hv, by simp⟩, ⟨x, hu, y, hv, by simp⟩⟩ + · simp } + have mem_K_iff x : x ∈ K ↔ ∃ u : Finset ι, x ∈ u.sup I := by rfl + suffices K = ⨆ i, I i by simp [←this, mem_K_iff] + apply le_antisymm + · intro x hx + rcases hx with ⟨u, hxu⟩ + suffices ∀ J, (∀ i, I i ≤ J) → x ∈ J by simpa [iSup_def, upperBounds] + intro J hJ + have : u.sup I ≤ J := by simp [hJ] + exact this hxu + · suffices ∀ i, I i ≤ K by simpa [upperBounds] + intro i x hx + refine ⟨{i}, by simpa using hx⟩ + +end Ideal + +end Order diff --git a/Foundation/Vorspiel/Order/LowerSet.lean b/Foundation/Vorspiel/Order/LowerSet.lean new file mode 100644 index 000000000..da4aeb623 --- /dev/null +++ b/Foundation/Vorspiel/Order/LowerSet.lean @@ -0,0 +1,107 @@ +module + +public import Mathlib.Topology.Order.UpperLowerSetTopology +public import Mathlib.Topology.Sets.Opens +public import Mathlib.Order.Heyting.Regular +public import Foundation.Vorspiel.Order.Regular + +@[expose] public section + +variable {α : Type*} [Preorder α] + +namespace LowerSet + +def IsCompatiblePair (a b : α) : Prop := ∃ c, c ≤ a ∧ c ≤ b + +infix:50 " ‖ " => IsCompatiblePair + +@[simp, refl] protected lemma IsCompatiblePair.refl (a : α) : a ‖ a := ⟨a, by simp⟩ + +@[symm] protected lemma IsCompatiblePair.symm_iff {a b : α} : a ‖ b ↔ b ‖ a := by + constructor + · rintro ⟨c, hca, hcb⟩; exact ⟨c, hcb, hca⟩ + · rintro ⟨c, hcb, hca⟩; exact ⟨c, hca, hcb⟩ + +alias ⟨IsCompatiblePair.symm, _⟩ := IsCompatiblePair.symm_iff + +def IsIncompatiblePair (a b : α) : Prop := ¬(a ‖ b) + +infix:50 " ⟂ " => IsIncompatiblePair + +lemma isIncompatiblePair_iff {a b : α} : a ⟂ b ↔ ∀ c ≤ a, ¬c ≤ b := by + simp [IsIncompatiblePair, IsCompatiblePair] + +@[simp] lemma IsIncompatiblePair.antirefl (a : α) : ¬(a ⟂ a) := by simp [IsIncompatiblePair] + +lemma IsIncompatiblePair.symm_iff {a b : α} : a ⟂ b ↔ b ⟂ a := by + contrapose; simpa [IsIncompatiblePair] using IsCompatiblePair.symm_iff + +alias ⟨IsIncompatiblePair.symm, _⟩ := IsIncompatiblePair.symm_iff + +lemma IsIncompatiblePair.lower {a a' b b' : α} (h : a ⟂ b) (ha'a : a' ≤ a) (hb'b : b' ≤ b) : a' ⟂ b' := by + rintro ⟨c, hca, hcb⟩ + exact h ⟨c, le_trans hca ha'a, le_trans hcb hb'b⟩ + +@[simp, grind =] lemma not_isCompatiblePair_iff_isIncompatiblePair {a b : α} : ¬(a ‖ b) ↔ a ⟂ b := by + rfl + +@[simp, grind =] lemma not_isIncompatiblePair_iff_isCompatiblePair {a b : α} : ¬(a ⟂ b) ↔ a ‖ b := by + simp [IsIncompatiblePair, IsCompatiblePair] + +instance : HeytingAlgebra (LowerSet α) := inferInstance + +lemma inf_eq_bot_iff_incompatible {u v : LowerSet α} : u ⊓ v = ⊥ ↔ (∀ x ∈ u, ∀ y ∈ v, x ⟂ y) := by + suffices (u ∩ v : Set α) = ∅ ↔ ∀ x ∈ u, ∀ y ∈ v, x ⟂ y by simpa [LowerSet.ext_iff] + constructor + · rintro e x hx y hy ⟨z, hzx, hzy⟩ + have hzu : z ∈ u := u.lower hzx hx + have hzv : z ∈ v := v.lower hzy hy + have : z ∈ (u ∩ v : Set α) := ⟨hzu, hzv⟩ + simp_all + · rintro h + suffices ∀ x ∈ u, x ∉ v by + apply Set.eq_empty_of_forall_notMem + simpa + intro x hx hx' + simpa using h x hx x hx' + +lemma mem_dual_iff {u : LowerSet α} : x ∈ uᶜ ↔ ∀ y ∈ u, x ⟂ y := by + suffices (∃ i, (∀ y ∈ i, ∀ z ∈ u, y ⟂ z) ∧ x ∈ i) ↔ ∀ y ∈ u, x ⟂ y by simpa [Compl.compl, inf_eq_bot_iff_incompatible] + constructor + · rintro ⟨i, hi, hxi⟩ y hyu + exact hi x hxi y hyu + · intro h + let i : LowerSet α := ⟨{x | ∀ y ∈ u, x ⟂ y}, by + intro a b hba ha y hyu + exact (ha y hyu).lower hba (by rfl)⟩ + refine ⟨i, by simp [i], by simpa [i] using h⟩ + +lemma coe_dual (u : LowerSet α) : uᶜ = {x | ∀ y ∈ u, x ⟂ y} := by + ext x; simp [mem_dual_iff] + +lemma mem_himp_iff {u v : LowerSet α} : x ∈ u ⇨ v ↔ ∀ y ≤ x, y ∈ u → y ∈ v := by + suffices (∃ s, s ⊓ u ≤ v ∧ x ∈ s) ↔ ∀ y ≤ x, y ∈ u → y ∈ v by simpa [HImp.himp] + constructor + · rintro ⟨s, hs, hxs⟩ y hyx hyu + have : y ∈ s := s.lower hyx hxs + have : y ∈ s ⊓ u := ⟨this, hyu⟩ + exact hs this + · intro h + refine ⟨LowerSet.Iic x, ?_, by simp⟩ + intro y; simp; grind + +variable (α) + +abbrev Regular := Heyting.Regular (LowerSet α) + +variable {α} + +namespace Regular + +instance : BooleanAlgebra (Regular α) := inferInstance + +instance : CompleteBooleanAlgebra (Regular α) := inferInstance + +end Regular + +end LowerSet diff --git a/Foundation/Vorspiel/Order/Regular.lean b/Foundation/Vorspiel/Order/Regular.lean index da3d9e1e3..aeaf8bba1 100644 --- a/Foundation/Vorspiel/Order/Regular.lean +++ b/Foundation/Vorspiel/Order/Regular.lean @@ -19,17 +19,17 @@ instance : CompleteBooleanAlgebra (Regular α) where __ : BooleanAlgebra (Regular α) := inferInstance __ : CompleteLattice (Regular α) := inferInstance -theorem coe_sSup (s : Set (Regular α)) : (↑(sSup s) : α) = (sSup ((↑) '' s))ᶜᶜ := by +@[simp] theorem coe_sSup (s : Set (Regular α)) : (↑(sSup s) : α) = (sSup ((↑) '' s))ᶜᶜ := by simp [sSup, sSup_image] -theorem coe_iSup (a : ι → Regular α) : (↑(⨆ i, a i) : α) = (⨆ i, (a i : α))ᶜᶜ := calc +@[simp] theorem coe_iSup (a : ι → Regular α) : (↑(⨆ i, a i) : α) = (⨆ i, (a i : α))ᶜᶜ := calc (↑(⨆ i, a i) : α) = (↑(sSup (Set.range a)) : α) := by rfl _ = (⨆ i, (a i : α))ᶜᶜ := by rw [coe_sSup]; congr; grind -theorem coe_sInf (s : Set (Regular α)) : (↑(sInf s) : α) = sInf ((↑) '' s) := by +@[simp] theorem coe_sInf (s : Set (Regular α)) : (↑(sInf s) : α) = sInf ((↑) '' s) := by simp [sInf, sInf_image]; rfl -theorem coe_iInf (a : ι → Regular α) : (↑(⨅ i, a i) : α) = (⨅ i, (a i : α)) := calc +@[simp] theorem coe_iInf (a : ι → Regular α) : (↑(⨅ i, a i) : α) = (⨅ i, (a i : α)) := calc (↑(⨅ i, a i) : α) = (↑(sInf (Set.range a)) : α) := by rfl _ = (⨅ i, (a i : α)) := by rw [coe_sInf]; congr; grind From 13aa74b6c8023509f07ccff028fa03f2ba168104 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sun, 5 Apr 2026 01:23:59 +0900 Subject: [PATCH 30/61] canonical model --- .../FirstOrder/Basic/Semantics/Semantics.lean | 4 + Foundation/FirstOrder/Basic/Soundness.lean | 4 + .../Completeness/BooleanValuedModel.lean | 162 +++++++++++++++++ .../Completeness/CanonicalModel.lean | 170 +++--------------- 4 files changed, 190 insertions(+), 150 deletions(-) create mode 100644 Foundation/FirstOrder/Completeness/BooleanValuedModel.lean diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index 63f814ebd..463338b00 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -39,6 +39,10 @@ instance [n : Nonempty M] : Nonempty (Structure L M) := by rcases n with ⟨x⟩ exact ⟨{ func := fun _ _ _ ↦ x, rel := fun _ _ _ ↦ True }⟩ +instance unit : Structure L Unit where + func := fun _ _ _ ↦ () + rel := fun _ _ _ ↦ True + protected def lMap (φ : L₁ →ᵥ L₂) {M : Type w} (S : Structure L₂ M) : Structure L₁ M where func _ f := S.func (φ.func f) rel _ r := S.rel (φ.rel r) diff --git a/Foundation/FirstOrder/Basic/Soundness.lean b/Foundation/FirstOrder/Basic/Soundness.lean index 136491e92..069870b45 100644 --- a/Foundation/FirstOrder/Basic/Soundness.lean +++ b/Foundation/FirstOrder/Basic/Soundness.lean @@ -63,6 +63,10 @@ lemma sound {M : Type*} [s : Structure L M] [Nonempty M] (f : ℕ → M) {Γ : S · exact ⟨ψ, by simp [hn], hq⟩ · exact ⟨ψ, by simp [h], hq⟩ +@[simp] lemma nil_empty : IsEmpty (⊢ᴷ ([] : Sequent L)) := by + refine ⟨fun b ↦ ?_⟩ + simpa using sound (fun _ ↦ ()) b + end Derivation theorem Provable.sound {M : Type*} [s : Structure L M] [Nonempty M] {φ : Proposition L} (f : ℕ → M) : diff --git a/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean b/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean new file mode 100644 index 000000000..e0ee13839 --- /dev/null +++ b/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean @@ -0,0 +1,162 @@ +module + +public import Foundation.Vorspiel.Order.LowerSet +public import Foundation.Vorspiel.Order.Ideal +public import Foundation.Vorspiel.Order.Heyting +public import Foundation.FirstOrder.Completeness.CanonicalModel +public import Mathlib.Order.PFilter + +@[expose] public section + +/-! +# Heyting and Boolean-valued model associated to the canonical model + +Main reference: Jeremy Avigad, Algebraic proofs of cut elimination [Avi01] + -/ + +namespace LO.FirstOrder.Derivation + +variable {L : Language} + +namespace Canonical + +variable (L) + +def ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴷ ∼Γ)} + +variable {L} + +local notation "ℙ" => Sequent L + +local notation "ℂ" => ConsistentSequent L + +namespace ConsistentSequent + +instance : Preorder ℂ where + le q p := q.val ≤ p.val + le_refl p := by simp + le_trans p q r := le_trans + +instance : Inhabited ℂ := ⟨⟨[], by simp⟩⟩ + +end ConsistentSequent + +/-- ## Heyting-valued model -/ + +local notation "ℍ" => LowerSet ℂ + +instance : Nontrivial ℍ := ⟨⊥, ⊤, fun e ↦ by simpa using SetLike.ext_iff.mp e default⟩ + +def hValue (φ : Propositionᵢ L) : ℍ where + carrier := { p | p.val ⊩ φ } + lower' := fun _ _ hqp hp ↦ IsForced.monotone hqp hp + +scoped prefix:max "♯" => hValue + +lemma hValue_ext {φ ψ : Propositionᵢ L} : (∀ p : ℂ, p.val ⊩ φ ↔ p.val ⊩ ψ) → ♯φ = ♯ψ := by + intro h; ext p; simp [hValue, h] + +@[simp] lemma mem_hValue {p : ℂ} {φ : Propositionᵢ L} : p ∈ ♯φ ↔ p.val ⊩ φ := by simp [hValue] + +@[simp] lemma hValue_and_eq_inf {φ ψ : Propositionᵢ L} : ♯(φ ⋏ ψ) = (♯φ ⊓ ♯ψ) := by + ext p; simp [hValue] + +@[simp] lemma hValue_or_eq_sup {φ ψ : Propositionᵢ L} : ♯(φ ⋎ ψ) = (♯φ ⊔ ♯ψ) := by + ext p; simp [hValue] + +@[simp] lemma hValue_fal_eq_Inf {φ : Semipropositionᵢ L 1} : ♯(∀⁰ φ) = ⨅ t, ♯(φ/[t]) := by + ext p; simp [hValue,] + +@[simp] lemma hValue_exs_eq_Sup {φ : Semipropositionᵢ L 1} : ♯(∃⁰ φ) = ⨆ t, ♯(φ/[t]) := by + ext p; simp [hValue,] + +@[simp] lemma hValue_falsum : ♯(⊥ : Propositionᵢ L) = ⊥ := by + ext p; simp [hValue, IsForced.falsum, p.prop] + +@[simp] lemma hValue_imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ ➝ ψ) = (♯φ ⇨ ♯ψ) := by + ext p + suffices (∀ q ≤ p.val, q ⊩ φ → q ⊩ ψ) ↔ ∀ q ≤ p, q.val ⊩ φ → q.val ⊩ ψ by + simpa [IsForced.imply, LowerSet.mem_himp_iff] + constructor + · intro h q hqp hqφ + exact h q.val hqp hqφ + · intro h q hqp hqφ + by_cases! hq : IsEmpty (⊢ᴷ ∼q) + · exact h ⟨q, hq⟩ hqp hqφ + · exact IsForced.efq (p := q) (by simp [IsForced.falsum, hq]) ψ + +@[simp] lemma hValue_neg_eq_himp_bot (φ : Propositionᵢ L) : ♯(∼φ) = (♯φ)ᶜ := by + simp [Semiformulaᵢ.neg_def] + +lemma hValue_eq_top_iff_provable {φ : Proposition L} : ♯φᴺ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc + ♯φᴺ = ⊤ ↔ ⊤ ≤ ♯φᴺ := by simp only [top_le_iff] + _ ↔ (∀ p : ℂ, p.val ⊩ φᴺ) := by simp [SetLike.le_def] + _ ↔ ℙ ∀⊩ φᴺ := by + constructor + · intro h p + by_cases! hp : IsEmpty (⊢ᴷ ∼p) + · exact h ⟨p, hp⟩ + · exact IsForced.efq (p := p) (by simp [IsForced.falsum, hp]) φᴺ + · intro h p; exact h p.val + _ ↔ 𝐋𝐊¹ ⊢ φ := IsForced.complete + +lemma hValue_lt_top_iff_provable {φ : Proposition L} : ♯φᴺ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by + simp [Entailment.Unprovable, ←hValue_eq_top_iff_provable, lt_top_iff_ne_top] + +lemma hValue_dn_neg (φ : Proposition L) : ♯(∼φ)ᴺ = (♯φᴺ)ᶜ := calc + ♯(∼φ)ᴺ = ♯(∼φᴺ) := hValue_ext <| by simp [←IsForced.dn_neg_iff] + _ = (♯φᴺ)ᶜ := by simp + +@[simp] lemma dn_isRegular (φ : Proposition L) : Heyting.IsRegular ♯φᴺ := by + have : ♯φᴺ = (♯(∼φ)ᴺ)ᶜ := by simp [←hValue_dn_neg] + simpa [this] using Heyting.isRegular_compl ♯(∼φ)ᴺ + +/-- ## Boolean-valued model -/ + +local notation "𝔹" => Heyting.Regular ℍ + +instance : Nontrivial 𝔹 := + ⟨⊥, ⊤, fun e ↦ by simpa using Heyting.Regular.coe_inj.mpr e⟩ + +/-- Boolean value -/ +def bValue (φ : Proposition L) : 𝔹 := ⟨♯φᴺ, by simp⟩ + +scoped prefix:max "♭" => bValue + +@[simp] lemma coe_bValue (φ : Proposition L) : (♭φ : ℍ) = ♯φᴺ := rfl + +@[simp] lemma bValue_and_eq_inf : ♭(φ ⋏ ψ) = ♭φ ⊓ ♭ψ := Heyting.Regular.coe_inj.mp <| by simp + +@[simp] lemma bValue_or_eq_sup : ♭(φ ⋎ ψ) = ♭φ ⊔ ♭ψ := Heyting.Regular.coe_inj.mp <| by simp + +@[simp] lemma bValue_fal_eq_Inf : ♭(∀⁰ φ) = ⨅ t, ♭(φ/[t]) := Heyting.Regular.coe_inj.mp <| by + simp [Semiformula.subst_doubleNegation] + +@[simp] lemma bValue_exs_eq_Sup : ♭(∃⁰ φ) = ⨆ t, ♭(φ/[t]) := Heyting.Regular.coe_inj.mp <| by + simp [Semiformula.subst_doubleNegation, compl_iSup'] + +@[simp] lemma bValue_neg_eq_himp : ♭(∼φ) = (♭φ)ᶜ := Heyting.Regular.coe_inj.mp <| by + simp [hValue_dn_neg] + +@[simp] lemma bValue_falsum : ♭(⊥ : Proposition L) = ⊥ := Heyting.Regular.coe_inj.mp <| by simp + +lemma bValue_eq_top_iff_provable : ♭φ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc + ♭φ = ⊤ ↔ ♯φᴺ = ⊤ := by rw [←Heyting.Regular.coe_inj]; simp + _ ↔ 𝐋𝐊¹ ⊢ φ := hValue_eq_top_iff_provable + +lemma bValue_lt_top_iff_provable : ♭φ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by + simp [Entailment.Unprovable, ←bValue_eq_top_iff_provable, lt_top_iff_ne_top] + +/-- Filter induced by a schema -/ +def _root_.LO.FirstOrder.Schema.filter (𝔖 : Schema L) : Order.PFilter 𝔹 := + ⟨⨆ φ ∈ 𝔖, Order.Ideal.principal ♭φ⟩ + +@[simp] lemma mem_filter_iff {𝔖 : Schema L} {x} : + x ∈ 𝔖.filter ↔ ∃ u : Finset (Proposition L), (∀ φ ∈ u, φ ∈ 𝔖) ∧ ⨅ φ ∈ u, ♭φ ≤ x := by sorry + +lemma bValue_mem_filter_iff_provable {𝔖 : Schema L} {φ : Proposition L} : + ♭φ ∈ 𝔖.filter ↔ 𝔖 ⊢ φ := by sorry + +end Canonical + +end LO.FirstOrder.Derivation diff --git a/Foundation/FirstOrder/Completeness/CanonicalModel.lean b/Foundation/FirstOrder/Completeness/CanonicalModel.lean index 7610e13ba..51fac6854 100644 --- a/Foundation/FirstOrder/Completeness/CanonicalModel.lean +++ b/Foundation/FirstOrder/Completeness/CanonicalModel.lean @@ -2,84 +2,28 @@ module public import Foundation.FirstOrder.NegationTranslation.GoedelGentzen public import Foundation.Logic.ForcingRelation -public import Foundation.Vorspiel.Order.Preorder @[expose] public section + /-! # Canonical model of classical first-order logic Main reference: Jeremy Avigad, Algebraic proofs of cut elimination [Avi01] -/ -namespace LO.FirstOrder - -variable {L : Language.{u}} - -namespace Derivation - -inductive IsCutFree : {Γ : Sequent L} → ⊢ᴷ Γ → Prop -| axL (r : L.Rel k) (v) : IsCutFree (identity r v) -| verum : IsCutFree verum -| or {d : ⊢ᴷ φ :: ψ :: Γ} : IsCutFree d → IsCutFree d.or -| and {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) -| all {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all -| exs (t) {d : ⊢ᴷ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs -| wk {d : ⊢ᴷ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) - -attribute [simp] IsCutFree.axL IsCutFree.verum - -variable {Γ Δ : Sequent L} - -@[simp] lemma isCutFree_or_iff {d : ⊢ᴷ φ :: ψ :: Γ} : - IsCutFree d.or ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .or⟩ - -@[simp] lemma isCutFree_and_iff {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : - IsCutFree (dφ.and dψ) ↔ IsCutFree dφ ∧ IsCutFree dψ := - ⟨by rintro ⟨⟩; constructor <;> assumption, by intro ⟨hφ, hψ⟩; exact hφ.and hψ⟩ - -@[simp] lemma isCutFree_all_iff {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : - IsCutFree d.all ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .all⟩ - -@[simp] lemma isCutFree_exs_iff {d : ⊢ᴷ φ/[t] :: Γ} : - IsCutFree d.exs ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .exs t⟩ +namespace LO.FirstOrder.Derivation -@[simp] lemma isCutFree_wk_iff {d : ⊢ᴷ Δ} {ss : Δ ⊆ Γ} : - IsCutFree (d.wk ss) ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .wk _⟩ +variable {L : Language} -@[simp] lemma IsCutFree.cast {d : ⊢ᴷ Γ} {e : Γ = Δ} : - IsCutFree (.cast d e) ↔ IsCutFree d := by rcases e; rfl +inductive Positive (Ξ : Sequent L) : Sequent L → Type _ +| or : Positive Ξ (φ :: ψ :: Γ) → Positive Ξ (φ ⋎ ψ :: Γ) +| exs : Positive Ξ (φ/[t] :: Γ) → Positive Ξ ((∃⁰ φ) :: Γ) +| wk : Positive Ξ Δ → Δ ⊆ Γ → Positive Ξ Γ +| protected id : Positive Ξ Ξ -@[simp] lemma IsCutFree.not_cut (dp : ⊢ᴷ φ :: Γ) (dn : ⊢ᴷ ∼φ :: Δ) : ¬IsCutFree (dp.cut dn) := by - intro h - refine h.rec - (motive := fun {_} d _ => - match d with - | .cut _ _ => False - | _ => True) - ?_ ?_ ?_ ?_ ?_ ?_ ?_ - all_goals simp +infix:45 " ⟶⁺ " => Positive -@[simp] lemma isCutFree_rewrite_iff_isCutFree {f : ℕ → SyntacticTerm L} {d : ⊢ᴷ Γ} : - IsCutFree (rewrite f d) ↔ IsCutFree d := by - induction d generalizing f <;> simp [rewrite, *] - -@[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᴷ Γ} : - IsCutFree (Derivation.map d f) ↔ IsCutFree d := isCutFree_rewrite_iff_isCutFree - -@[simp] lemma IsCutFree.genelalizeByNewver_isCutFree {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) - (d : ⊢ᴷ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] - -end Derivation - -inductive PositiveDerivationFrom (Ξ : Sequent L) : Sequent L → Type _ -| or : PositiveDerivationFrom Ξ (φ :: ψ :: Γ) → PositiveDerivationFrom Ξ (φ ⋎ ψ :: Γ) -| exs : PositiveDerivationFrom Ξ (φ/[t] :: Γ) → PositiveDerivationFrom Ξ ((∃⁰ φ) :: Γ) -| wk : PositiveDerivationFrom Ξ Δ → Δ ⊆ Γ → PositiveDerivationFrom Ξ Γ -| protected id : PositiveDerivationFrom Ξ Ξ - -infix:45 " ⟶⁺ " => PositiveDerivationFrom - -namespace PositiveDerivationFrom +namespace Positive variable {Ξ Γ Δ : Sequent L} @@ -120,9 +64,9 @@ def graft {Ξ Γ : Sequent L} (b : ⊢ᴷ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴷ Γ lemma graft_isCutFree_of_isCutFree {b : ⊢ᴷ Ξ} {d : Ξ ⟶⁺ Γ} (hb : Derivation.IsCutFree b) : Derivation.IsCutFree (d.graft b) := by induction d <;> simp [graft, *] -end PositiveDerivationFrom +end Positive -namespace Hauptsatz +namespace Canonical open Semiformulaᵢ @@ -227,10 +171,10 @@ def cast {p : ℙ} (f : p ⊩ φ) (s : φ = ψ) : p ⊩ ψ := s ▸ f def monotone {q p : ℙ} (s : q ≼ p) : {φ : Propositionᵢ L} → p ⊩ φ → q ⊩ φ | ⊥, b => let ⟨d, hd⟩ := b.falsumEquiv - falsumEquiv.symm ⟨s.val.graft d, PositiveDerivationFrom.graft_isCutFree_of_isCutFree hd⟩ + falsumEquiv.symm ⟨s.val.graft d, Positive.graft_isCutFree_of_isCutFree hd⟩ | .rel R v, b => let ⟨d, hd⟩ := b.relEquiv - relEquiv.symm ⟨s.val.cons (.rel R v) |>.graft d, PositiveDerivationFrom.graft_isCutFree_of_isCutFree hd⟩ + relEquiv.symm ⟨s.val.cons (.rel R v) |>.graft d, Positive.graft_isCutFree_of_isCutFree hd⟩ | φ ⋏ ψ, b => andEquiv.symm ⟨monotone s b.andEquiv.1, monotone s b.andEquiv.2⟩ | φ ⋎ ψ, b => orEquiv.symm <| b.orEquiv.rec (fun b ↦ .inl <| b.monotone s) (fun b ↦ .inr <| b.monotone s) | φ ➝ ψ, b => implyEquiv.symm fun r srq bφ ↦ b.implyEquiv r (srq.trans s) bφ @@ -386,7 +330,8 @@ def conj' : {Γ : Sequent L} → (b : (φ : Proposition L) → φ ∈ Γ → p end Forces -def main [L.DecidableEq] {Γ : Sequent L} : ⊢ᴷ Γ → {d : ⊢ᴷ Γ // Derivation.IsCutFree d} := fun d ↦ +/-- Cut elimination theorem of $\mathbf{LK}$. -/ +def hauptsatz [L.DecidableEq] {Γ : Sequent L} : ⊢ᴷ Γ → {d : ⊢ᴷ Γ // Derivation.IsCutFree d} := fun d ↦ let d : 𝗠𝗶𝗻¹ ⊢! ⋀(∼Γ)ᴺ ➝ ⊥ := Entailment.FiniteContext.toDef (Derivation.gödelGentzen d) let ff : Forces (∼Γ) (⋀(∼Γ)ᴺ ➝ ⊥) := Forces.sound d (∼Γ) let fc : Forces (∼Γ) (⋀(∼Γ)ᴺ) := Forces.conj' fun φ hφ ↦ @@ -395,8 +340,6 @@ def main [L.DecidableEq] {Γ : Sequent L} : ⊢ᴷ Γ → {d : ⊢ᴷ Γ // Deri let ⟨b, hb⟩ := b.falsumEquiv ⟨Derivation.cast b (by simp), by simp [hb]⟩ - - instance : LE ℙ := ⟨fun q p ↦ Nonempty (q ≼ p)⟩ instance : Preorder ℙ where @@ -420,7 +363,7 @@ open Classical have ⟨d, hd⟩ := b.relEquiv exact ⟨d⟩ · rintro ⟨d⟩ - let ⟨b, hb⟩ := main d + let ⟨b, hb⟩ := hauptsatz d exact ⟨Forces.relEquiv.symm ⟨b, hb⟩⟩ @[simp] lemma fal {p : ℙ} : p ⊩ ∀⁰ φ ↔ ∀ t, p ⊩ φ/[t] := by @@ -468,7 +411,7 @@ lemma falsum {p : ℙ} : p ⊩ ⊥ ↔ Nonempty (⊢ᴷ ∼p) := by have ⟨d, hd⟩ := b.falsumEquiv exact ⟨d⟩ · rintro ⟨d⟩ - let ⟨b, hb⟩ := main d + let ⟨b, hb⟩ := hauptsatz d exact ⟨Forces.falsumEquiv.symm ⟨b, hb⟩⟩ lemma neg {p : ℙ} {φ : Propositionᵢ L} : p ⊩ ∼φ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ⊥) := by @@ -509,79 +452,6 @@ lemma complete {φ : Proposition L} : ℙ ∀⊩ φᴺ ↔ 𝐋𝐊¹ ⊢ φ := end IsForced -variable (L) - -def ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴷ ∼Γ)} - -local notation "ℂ" => ConsistentSequent L - -variable {L} - -namespace ConsistentSequent - -instance : Preorder ℂ where - le q p := q.val ≤ p.val - le_refl p := by simp - le_trans p q r := le_trans - -end ConsistentSequent - -def hValue (φ : Propositionᵢ L) : LowerSet ℂ where - carrier := { p | p.val ⊩ φ } - lower' := fun _ _ hqp hp ↦ IsForced.monotone hqp hp - -scoped prefix:max "♯" => hValue - -@[simp] lemma mem_hValue {p : ℂ} {φ : Propositionᵢ L} : p ∈ ♯φ ↔ p.val ⊩ φ := by simp [hValue] - -@[simp] lemma hValue_and_eq_inf {φ ψ : Propositionᵢ L} : ♯(φ ⋏ ψ) = (♯φ ⊓ ♯ψ) := by - ext p; simp [hValue] - -@[simp] lemma hValue_or_eq_sup {φ ψ : Propositionᵢ L} : ♯(φ ⋎ ψ) = (♯φ ⊔ ♯ψ) := by - ext p; simp [hValue] - -@[simp] lemma hValue_fal_eq_Inf {φ : Semipropositionᵢ L 1} : ♯(∀⁰ φ) = ⨅ t, ♯(φ/[t]) := by - ext p; simp [hValue,] - -@[simp] lemma hValue_exs_eq_Sup {φ : Semipropositionᵢ L 1} : ♯(∃⁰ φ) = ⨆ t, ♯(φ/[t]) := by - ext p; simp [hValue,] - -@[simp] lemma hValue_falsum : ♯(⊥ : Propositionᵢ L) = ⊥ := by - ext p; simp [hValue, IsForced.falsum, p.prop] - -@[simp] lemma hValue_imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ ➝ ψ) = (♯φ ⇨ ♯ψ) := by - ext p - suffices (∀ q ≤ p.val, q ⊩ φ → q ⊩ ψ) ↔ ∀ q ≤ p, q.val ⊩ φ → q.val ⊩ ψ by - simpa [IsForced.imply, LowerSet.mem_himp_iff] - constructor - · intro h q hqp hqφ - exact h q.val hqp hqφ - · intro h q hqp hqφ - by_cases! hq : IsEmpty (⊢ᴷ ∼q) - · exact h ⟨q, hq⟩ hqp hqφ - · exact IsForced.efq (p := q) (by simp [IsForced.falsum, hq]) ψ - -@[simp] lemma hValue_neg_eq_himp_bot (φ : Propositionᵢ L) : ♯(∼φ) = (♯φ)ᶜ := by - simp [Semiformulaᵢ.neg_def] - -lemma eq_top_iff_provable {φ : Proposition L} : ♯φᴺ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc - ♯φᴺ = ⊤ ↔ ⊤ ≤ ♯φᴺ := by simp only [top_le_iff] - _ ↔ (∀ p : ℂ, p.val ⊩ φᴺ) := by simp [SetLike.le_def] - _ ↔ ℙ ∀⊩ φᴺ := by - constructor - · intro h p - by_cases! hp : IsEmpty (⊢ᴷ ∼p) - · exact h ⟨p, hp⟩ - · exact IsForced.efq (p := p) (by simp [IsForced.falsum, hp]) φᴺ - · intro h p; exact h p.val - _ ↔ 𝐋𝐊¹ ⊢ φ := IsForced.complete - -lemma lt_top_iff_provable {φ : Proposition L} : ♯φᴺ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by - simp [Entailment.Unprovable, ←eq_top_iff_provable, lt_top_iff_ne_top] - - -end Hauptsatz - -alias hauptsatz := Hauptsatz.main +end Canonical -end LO.FirstOrder +end LO.FirstOrder.Derivation From e48715a10f0ea1d78fb91f86191b99703d8e130a Mon Sep 17 00:00:00 2001 From: palalansouki Date: Mon, 6 Apr 2026 00:28:44 +0900 Subject: [PATCH 31/61] fix --- Foundation/FirstOrder/Basic/Calculus.lean | 6 +- Foundation/FirstOrder/Basic/CutFree.lean | 2 + Foundation/FirstOrder/Basic/Eq.lean | 32 +++---- Foundation/FirstOrder/Basic/Operator.lean | 10 +-- .../FirstOrder/Basic/Semantics/Semantics.lean | 14 +-- .../FirstOrder/Basic/Syntax/Schema.lean | 89 +++++-------------- .../FirstOrder/Intuitionistic/Deduction.lean | 24 +++-- .../NegationTranslation/GoedelGentzen.lean | 26 +++--- Foundation/Logic/Calculus.lean | 6 +- 9 files changed, 86 insertions(+), 123 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index 95f3f4e1e..c8ad8a760 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -279,7 +279,7 @@ def equiv (𝔖 : Schema L) (φ) : invFun := fun ⟨⟨Γ, hΓ⟩, d⟩ ↦ ⟨Γ, hΓ, d⟩ instance : Entailment.Compact (Schema L) where - core b := ⟨fun φ ↦ φ ∈ b.axioms⟩ + core b := {φ | φ ∈ b.axioms} corePrf b := ⟨b.axioms, by simp, b.derivation⟩ core_finite b := by simp [AdjunctiveSet.Finite, AdjunctiveSet.set] core_subset b := by simpa [AdjunctiveSet.subset_iff] using b.axioms_mem @@ -372,7 +372,7 @@ open Entailment Derivation lemma iff_context {𝔖 : Schema L} : 𝔖 ⊢ φ ↔ 𝔖 *⊢[𝐋𝐊¹] φ := by constructor · rintro ⟨d⟩ - have : 𝐋𝐊¹ ⊢! ⋀d.axioms ➝ φ := + have : 𝐋𝐊¹ ⊢! ⋀d.axioms 🡒 φ := have : ⊢ᴷ ∼d.axioms ++ [φ] := d.derivation.weakening this.disj₂.or.cast <| by simp [Semiformula.imp_eq] refine ⟨⟨d.axioms, by simpa using d.axioms_mem, this⟩⟩ @@ -388,7 +388,7 @@ open Classical in noncomputable instance : Entailment.Deduction (Schema L) where ofInsert {φ ψ 𝔖 b} := have : insert φ ↑𝔖 *⊢[𝐋𝐊¹] ψ := iff_context.mp ⟨b⟩ - have : ↑𝔖 *⊢[𝐋𝐊¹] φ ➝ ψ := Context.deduct! this + have : ↑𝔖 *⊢[𝐋𝐊¹] φ 🡒 ψ := Context.deduct! this (iff_context.mpr this).get inv {φ ψ 𝔖 b} := have : ↑(adjoin φ 𝔖) *⊢[𝐋𝐊¹] ψ := Context.deductInv! (iff_context.mp ⟨b⟩) diff --git a/Foundation/FirstOrder/Basic/CutFree.lean b/Foundation/FirstOrder/Basic/CutFree.lean index 9d71afcf2..803b9bfc7 100644 --- a/Foundation/FirstOrder/Basic/CutFree.lean +++ b/Foundation/FirstOrder/Basic/CutFree.lean @@ -57,6 +57,7 @@ variable {Γ Δ : Sequent L} ?_ ?_ ?_ ?_ ?_ ?_ ?_ all_goals simp +set_option backward.isDefEq.respectTransparency false in @[simp] lemma isCutFree_rewrite_iff_isCutFree {f : ℕ → SyntacticTerm L} {d : ⊢ᴷ Γ} : IsCutFree (rewrite f d) ↔ IsCutFree d := by induction d generalizing f <;> simp [rewrite, *] @@ -64,6 +65,7 @@ variable {Γ Δ : Sequent L} @[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᴷ Γ} : IsCutFree (Derivation.map d f) ↔ IsCutFree d := isCutFree_rewrite_iff_isCutFree +set_option backward.isDefEq.respectTransparency false in @[simp] lemma IsCutFree.genelalizeByNewver_isCutFree {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) (d : ⊢ᴷ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] diff --git a/Foundation/FirstOrder/Basic/Eq.lean b/Foundation/FirstOrder/Basic/Eq.lean index 0fd0ac8e8..97f223238 100644 --- a/Foundation/FirstOrder/Basic/Eq.lean +++ b/Foundation/FirstOrder/Basic/Eq.lean @@ -25,12 +25,12 @@ namespace Eq protected abbrev refl (t : Term L ℕ) : Proposition L := op(=).operator ![t, t] -protected abbrev symm (t u : Term L ℕ) : Proposition L := op(=).operator ![t, u] ➝ op(=).operator ![u, t] +protected abbrev symm (t u : Term L ℕ) : Proposition L := op(=).operator ![t, u] 🡒 op(=).operator ![u, t] -protected abbrev trans (t u v : Term L ℕ) : Proposition L := op(=).operator ![t, u] ➝ op(=).operator ![u, v] ➝ op(=).operator ![t, v] +protected abbrev trans (t u v : Term L ℕ) : Proposition L := op(=).operator ![t, u] 🡒 op(=).operator ![u, v] 🡒 op(=).operator ![t, v] def funcExt {k} (f : L.Func k) (v w : Fin k → Term L ℕ) : Proposition L := - (Matrix.conj fun i ↦ op(=).operator ![v i, w i]) ➝ op(=).operator ![Semiterm.func f v, Semiterm.func f w] + (Matrix.conj fun i ↦ op(=).operator ![v i, w i]) 🡒 op(=).operator ![Semiterm.func f v, Semiterm.func f w] @[simp] lemma rew_funcExt (ω : Rew L ℕ 0 ℕ 0) {k} (f : L.Func k) (v w : Fin k → Term L ℕ) : ω ▹ funcExt f v w = funcExt f (ω ∘ v) (ω ∘ w) := by @@ -73,7 +73,7 @@ variable (L) (M : Type*) [Nonempty M] [Structure L M] intro σ h have : ∃ φ, Eq.EqSchema φ ∧ Semiformula.univCl φ = σ := by simpa using h rcases this with ⟨φ, (_ | _ | _ | _ | _), rfl⟩ <;> simp [models_iff, Eq.funcExt, Eq.relExt] - · simp at h; grind + · grind · grind · simp [Function.comp_def]; grind · simp [Function.comp_def]; grind⟩ @@ -84,7 +84,7 @@ def eqv (a b : M) : Prop := (@Semiformula.Operator.Eq.eq L _).val ![a, b] variable {L} -variable [H : M↓[L] ⊧* 𝗘𝗤 L] +variable [H : M↓[L] ⊧* ↑↑(𝗘𝗤 L)] open Semiterm Theory Semiformula @@ -212,40 +212,40 @@ end Eq end Structure lemma consequence_iff_eq {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] {σ : Sentence L} : - 𝔖 ⊨[Struc.{v, u} L] σ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [Structure.Eq L M], M↓[L] ⊧* 𝔖 → M↓[L] ⊧ σ) := by + ↑↑𝔖 ⊨[Struc.{v, u} L] σ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [Structure.Eq L M], M↓[L] ⊧* ↑↑𝔖 → M↓[L] ⊧ σ) := by simp only [consequence_iff, Nonempty.forall] constructor · intro h M x s _ hM; exact h M x hM · intro h M x s hM have : Nonempty M := ⟨x⟩ - have H : M↓[L] ⊧* 𝗘𝗤 L := models_of_subtheory hM + have H : M↓[L] ⊧* ↑↑(𝗘𝗤 L) := models_of_subtheory hM have e : Structure.Eq.QuotEq L M ≡ₑ[L] M := Structure.Eq.QuotEq.elementaryEquiv L M exact e.models.mp <| h (Structure.Eq.QuotEq L M) ⟦x⟧ (e.modelsTheory.mpr hM) lemma consequence_iff_eq' {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] {σ : Sentence L} : - 𝔖 ⊨[Struc.{v, u} L] σ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [Structure.Eq L M] [M↓[L] ⊧* 𝔖], M↓[L] ⊧ σ) := by + ↑↑𝔖 ⊨[Struc.{v, u} L] σ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [Structure.Eq L M] [M↓[L] ⊧* ↑↑𝔖], M↓[L] ⊧ σ) := by rw [consequence_iff_eq] lemma satisfiable_iff_eq {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] : - Semantics.Satisfiable (Struc.{v, u} L) 𝔖 ↔ (∃ (M : Type v) (_ : Nonempty M) (_ : Structure L M) (_ : Structure.Eq L M), M↓[L] ⊧* 𝔖) := by + Semantics.Satisfiable (Struc.{v, u} L) ↑↑𝔖 ↔ (∃ (M : Type v) (_ : Nonempty M) (_ : Structure L M) (_ : Structure.Eq L M), M↓[L] ⊧* ↑↑𝔖) := by simp only [satisfiable_iff, Nonempty.exists, exists_prop] constructor · intro ⟨M, x, s, hM⟩; have : Nonempty M := ⟨x⟩ - have H : M↓[L] ⊧* 𝗘𝗤 L := models_of_subtheory hM + have H : M↓[L] ⊧* ↑↑(𝗘𝗤 L) := models_of_subtheory hM have e : Structure.Eq.QuotEq L M ≡ₑ[L] M := Structure.Eq.QuotEq.elementaryEquiv L M exact ⟨Structure.Eq.QuotEq L M, ⟦x⟧, inferInstance, inferInstance, e.modelsTheory.mpr hM⟩ · intro ⟨M, i, s, _, hM⟩; exact ⟨M, i, s, hM⟩ -instance {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] (sat : Semantics.Satisfiable (Struc.{v, u} L) 𝔖) : - (ModelOfSat sat)↓[L] ⊧* 𝗘𝗤 L := models_of_subtheory (ModelOfSat.models sat) +instance {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] (sat : Semantics.Satisfiable (Struc.{v, u} L) ↑↑𝔖) : + (ModelOfSat sat)↓[L] ⊧* ↑↑(𝗘𝗤 L) := models_of_subtheory (ModelOfSat.models sat) -def ModelOfSatEq {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] (sat : Semantics.Satisfiable (Struc.{v, u} L) 𝔖) : Type _ := +def ModelOfSatEq {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] (sat : Semantics.Satisfiable (Struc.{v, u} L) ↑↑𝔖) : Type _ := Structure.Eq.QuotEq L (ModelOfSat sat) namespace ModelOfSatEq -variable {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] (sat : Semantics.Satisfiable (Struc.{v, u} L) 𝔖) +variable {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] (sat : Semantics.Satisfiable (Struc.{v, u} L) ↑↑𝔖) noncomputable instance : Nonempty (ModelOfSatEq sat) := Structure.Eq.QuotEq.inhabited @@ -253,11 +253,11 @@ noncomputable instance struc : Structure L (ModelOfSatEq sat) := Structure.Eq.Qu noncomputable instance : Structure.Eq L (ModelOfSatEq sat) := Structure.Eq.QuotEq.structureEq -lemma models : (ModelOfSatEq sat)↓[L] ⊧* 𝔖 := +lemma models : (ModelOfSatEq sat)↓[L] ⊧* ↑↑𝔖 := have e : ModelOfSatEq sat ≡ₑ[L] ModelOfSat sat := Structure.Eq.QuotEq.elementaryEquiv L (ModelOfSat sat) e.modelsTheory.mpr (ModelOfSat.models _) -instance mod : (ModelOfSatEq sat)↓[L] ⊧* 𝔖 := models sat +instance mod : (ModelOfSatEq sat)↓[L] ⊧* ↑↑𝔖 := models sat open Semiterm Semiformula diff --git a/Foundation/FirstOrder/Basic/Operator.lean b/Foundation/FirstOrder/Basic/Operator.lean index 3ce5a9f81..9b89376e4 100644 --- a/Foundation/FirstOrder/Basic/Operator.lean +++ b/Foundation/FirstOrder/Basic/Operator.lean @@ -222,7 +222,7 @@ abbrev gödelNumber' (a : α) : Semiterm L ξ n := const (gödelNumber a) instance : GödelQuote α (Semiterm L ξ n) := ⟨gödelNumber'⟩ -def ofEncodable [Operator.Zero L] [Operator.One L] [Operator.Add L] {α : Type*} [Encodable α] : GödelNumber L α := ⟨Operator.encode L⟩ +abbrev ofEncodable [Operator.Zero L] [Operator.One L] [Operator.Add L] {α : Type*} [Encodable α] : GödelNumber L α := ⟨Operator.encode L⟩ end GödelNumber @@ -379,19 +379,19 @@ lemma LE.def_of_Eq_of_LT [Operator.Eq L] [Operator.LT L] : lemma lt_def [L.LT] (t u : Semiterm L ξ n) : LT.lt.operator ![t, u] = Semiformula.rel Language.LT.lt ![t, u] := by - simp [operator, LT.sentence_eq, Matrix.fun_eq_vec_two'] + simp [operator, LT.sentence_eq, Matrix.fun_eq_vec_two] lemma eq_def [L.Eq] (t u : Semiterm L ξ n) : Eq.eq.operator ![t, u] = Semiformula.rel Language.Eq.eq ![t, u] := by - simp [operator, Eq.sentence_eq, Matrix.fun_eq_vec_two'] + simp [operator, Eq.sentence_eq, Matrix.fun_eq_vec_two] lemma mem_def [L.Mem] (t u : Semiterm L ξ n) : Mem.mem.operator ![t, u] = Semiformula.rel Language.Mem.mem ![t, u] := by - simp [operator, Mem.sentence_eq, Matrix.fun_eq_vec_two'] + simp [operator, Mem.sentence_eq, Matrix.fun_eq_vec_two] lemma le_def [L.Eq] [L.LT] (t u : Semiterm L ξ n) : LE.le.operator ![t, u] = Semiformula.rel Language.Eq.eq ![t, u] ⋎ Semiformula.rel Language.LT.lt ![t, u] := by - simp [operator, Eq.sentence_eq, LT.sentence_eq, LE.sentence_eq, Matrix.fun_eq_vec_two'] + simp [operator, Eq.sentence_eq, LT.sentence_eq, LE.sentence_eq, Matrix.fun_eq_vec_two] variable {L : Language} diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index 463338b00..cf49f9386 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -43,7 +43,7 @@ instance unit : Structure L Unit where func := fun _ _ _ ↦ () rel := fun _ _ _ ↦ True -protected def lMap (φ : L₁ →ᵥ L₂) {M : Type w} (S : Structure L₂ M) : Structure L₁ M where +protected abbrev lMap (φ : L₁ →ᵥ L₂) {M : Type w} (S : Structure L₂ M) : Structure L₁ M where func _ f := S.func (φ.func f) rel _ r := S.rel (φ.rel r) @@ -53,7 +53,7 @@ variable (φ : L₁ →ᵥ L₂) {M : Type w} (s₂ : Structure L₂ M) @[simp] lemma lMap_rel {k} {r : L₁.Rel k} {v : Fin k → M} : (s₂.lMap φ).rel r v ↔ s₂.rel (φ.rel r) v := of_eq rfl -def ofEquiv {M : Type w} [Structure L M] {N : Type w'} (Θ : M ≃ N) : Structure L N where +abbrev ofEquiv {M : Type w} [Structure L M] {N : Type w'} (Θ : M ≃ N) : Structure L N where func := fun _ f v ↦ Θ (func f (Θ.symm ∘ v)) rel := fun _ r v ↦ rel r (Θ.symm ∘ v) @@ -527,7 +527,7 @@ lemma models_iff_proposition {φ : Proposition L} : M↓[L] ⊧ φ.univCl ↔ lemma models_theory_iff : M↓[L] ⊧* T ↔ (∀ {φ}, φ ∈ T → M↓[L] ⊧ φ) := Semantics.modelsSet_iff -lemma models_schema_iff {𝔖 : Schema L} : M↓[L] ⊧* 𝔖 ↔ (∀ {φ : Proposition L}, φ ∈ 𝔖 → ∀ f : ℕ → M, φ.Evalf f) := by +lemma models_schema_iff {𝔖 : Schema L} : M↓[L] ⊧* (𝔖 : Theory L) ↔ (∀ {φ : Proposition L}, φ ∈ 𝔖 → ∀ f : ℕ → M, φ.Evalf f) := by simp [models_theory_iff, models_iff] lemma models_of_mem {T : Theory L} [M↓[L] ⊧* T] {φ} (h : φ ∈ T) : M↓[L] ⊧ φ := Semantics.ModelsSet.models _ h @@ -627,16 +627,16 @@ variable {M} lemma models_of_ss {T U : Theory L} (h : M↓[L] ⊧* U) (ss : T ⊆ U) : M↓[L] ⊧* T := Semantics.ModelsSet.of_subset h ss -lemma models_of_le {𝓢₁ 𝓢₂ : Schema L} (h : M↓[L] ⊧* 𝓢₂) (le : 𝓢₁ ≤ 𝓢₂) : M↓[L] ⊧* 𝓢₁ := +lemma models_of_le {𝔖₁ 𝔖₂ : Schema L} (h : M↓[L] ⊧* ↑↑𝔖₂) (le : 𝔖₁ ≤ 𝔖₂) : M↓[L] ⊧* ↑↑𝔖₁ := Semantics.ModelsSet.of_subset h (Schema.coe_subset_coe_of_le le) -instance models_schema_sup (𝓢₁ 𝓢₂ : Schema L) [M↓[L] ⊧* 𝓢₁] [M↓[L] ⊧* 𝓢₂] : M↓[L] ⊧* 𝓢₁ ⊔ 𝓢₂ := by - simp only [Set.sup_eq_union, Semantics.ModelsSet.union_iff] +instance models_schema_sup (𝔖₁ 𝔖₂ : Schema L) [M↓[L] ⊧* ↑↑𝔖₁] [M↓[L] ⊧* ↑↑𝔖₂] : M↓[L] ⊧* ↑↑(𝔖₁ ∪ 𝔖₂) := by + simp only [Schema.coe_sup, Semantics.ModelsSet.union_iff] constructor · infer_instance · infer_instance -lemma modelsUnivCl_of_mem_schema {𝔖 : Schema L} [h : M↓[L] ⊧* 𝔖] (hf : φ ∈ 𝔖) : M↓[L] ⊧ φ.univCl := +lemma modelsUnivCl_of_mem_schema {𝔖 : Schema L} [h : M↓[L] ⊧* ↑↑𝔖] (hf : φ ∈ 𝔖) : M↓[L] ⊧ φ.univCl := h.models _ <| by simp; grind end schema diff --git a/Foundation/FirstOrder/Basic/Syntax/Schema.lean b/Foundation/FirstOrder/Basic/Syntax/Schema.lean index 92c423c60..45c1a4b46 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Schema.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Schema.lean @@ -13,8 +13,7 @@ First-order schema `Schema L` is defined as a set of propositions, which may con namespace LO.FirstOrder -structure Schema (L : Language) where - Mem : Proposition L → Prop +abbrev Schema (L : Language) := Set (Proposition L) abbrev Theory (L : Language) := Set (Sentence L) @@ -22,66 +21,22 @@ namespace Schema variable {L : Language} -instance : SetLike (Schema L) (Proposition L) where - coe 𝓢 := { φ | 𝓢.Mem φ } - coe_injective' := by - rintro ⟨⟩ ⟨⟩ _ - congr - -lemma mem_def (𝓢 : Schema L) (φ : Proposition L) : 𝓢.Mem φ ↔ φ ∈ 𝓢 := Iff.rfl - -@[simp] lemma mem_mk_iff (φ : Proposition L) (P : Proposition L → Prop) : φ ∈ Schema.mk P ↔ P φ := Iff.rfl - -lemma le_def (𝓢₁ 𝓢₂ : Schema L) : 𝓢₁ ≤ 𝓢₂ ↔ ∀ φ, φ ∈ 𝓢₁ → φ ∈ 𝓢₂ := Iff.rfl - -instance : CompleteLattice (Schema L) where - sup 𝓢₁ 𝓢₂ := ⟨fun φ ↦ φ ∈ 𝓢₁ ∨ φ ∈ 𝓢₂⟩ - le_sup_left _ _ := by simp [le_def]; grind - le_sup_right _ _ := by simp [le_def]; grind - sup_le _ _ _ := by simp [le_def]; grind - inf 𝓢₁ 𝓢₂ := ⟨fun φ ↦ φ ∈ 𝓢₁ ∧ φ ∈ 𝓢₂⟩ - inf_le_left _ _ := by simp [le_def]; grind - inf_le_right _ _ := by simp [le_def] - le_inf _ _ _ := by simp [le_def]; grind - sSup s := ⟨fun φ ↦ ∃ 𝓢 ∈ s, φ ∈ 𝓢⟩ - le_sSup _ _ := by simp [le_def]; grind - sSup_le _ _ := by simp [le_def]; grind - sInf s := ⟨fun φ ↦ ∀ 𝓢 ∈ s, φ ∈ 𝓢⟩ - sInf_le _ _ := by simp [le_def]; grind - le_sInf _ _ := by simp [le_def]; grind - top := ⟨fun _ ↦ True⟩ - le_top _ _ := by simp - bot := ⟨fun _ ↦ False⟩ - bot_le _ _ := by simp - -@[simp] lemma mem_sup_iff (𝓢₁ 𝓢₂ : Schema L) (φ : Proposition L) : φ ∈ 𝓢₁ ⊔ 𝓢₂ ↔ φ ∈ 𝓢₁ ∨ φ ∈ 𝓢₂ := Iff.rfl - -@[simp] lemma mem_inf_iff (𝓢₁ 𝓢₂ : Schema L) (φ : Proposition L) : φ ∈ 𝓢₁ ⊓ 𝓢₂ ↔ φ ∈ 𝓢₁ ∧ φ ∈ 𝓢₂ := Iff.rfl - -@[simp] lemma mem_sSup_iff (s : Set (Schema L)) (φ : Proposition L) : φ ∈ sSup s ↔ ∃ 𝓢 ∈ s, φ ∈ 𝓢 := Iff.rfl - -@[simp] lemma mem_sInf_iff (s : Set (Schema L)) (φ : Proposition L) : φ ∈ sInf s ↔ ∀ 𝓢 ∈ s, φ ∈ 𝓢 := Iff.rfl - -@[simp] lemma mem_top (φ : Proposition L) : φ ∈ (⊤ : Schema L) := by trivial - -@[simp] lemma not_mem_bot (φ : Proposition L) : φ ∉ (⊥ : Schema L) := by rintro ⟨⟩ - -@[coe] def ofProposition (φ : Proposition L) : Schema L := ⟨(· = φ)⟩ +@[coe] def ofProposition (φ : Proposition L) : Schema L := {φ} instance : Coe (Proposition L) (Schema L) := ⟨fun φ ↦ ofProposition φ⟩ @[simp] lemma mem_coe (φ ψ : Proposition L) : ψ ∈ (φ : Schema L) ↔ ψ = φ := by rfl instance : AdjunctiveSet (Proposition L) (Schema L) where - Subset 𝓢₁ 𝓢₂ := 𝓢₁ ≤ 𝓢₂ + Subset 𝔖₁ 𝔖₂ := 𝔖₁ ≤ 𝔖₂ emptyCollection := ⊥ - adjoin φ 𝓢 := φ ⊔ 𝓢 - subset_iff := by simp [le_def] + adjoin φ 𝔖 := φ ⊔ 𝔖 + subset_iff := by simp [Set.subset_def] not_mem_empty _ := by simp mem_cons_iff := by simp -class IsClosed (𝓢 : Schema L) : Prop where - closed : ∀ ω : Rew L ℕ 0 ℕ 0, ∀ φ ∈ 𝓢, ω ▹ φ ∈ 𝓢 +class IsClosed (𝔖 : Schema L) : Prop where + closed : ∀ ω : Rew L ℕ 0 ℕ 0, ∀ φ ∈ 𝔖, ω ▹ φ ∈ 𝔖 namespace IsClosed @@ -91,27 +46,27 @@ instance : IsClosed (⊤ : Schema L) where instance : IsClosed (⊥ : Schema L) where closed _ _ := by rintro ⟨⟩ -instance sup (𝓢₁ 𝓢₂ : Schema L) [IsClosed 𝓢₁] [IsClosed 𝓢₂] : IsClosed (𝓢₁ ⊔ 𝓢₂) where +instance sup (𝔖₁ 𝔖₂ : Schema L) [IsClosed 𝔖₁] [IsClosed 𝔖₂] : IsClosed (𝔖₁ ∪ 𝔖₂) where closed ω φ h := by - have : φ ∈ 𝓢₁ ∨ φ ∈ 𝓢₂ := by simpa using h + have : φ ∈ 𝔖₁ ∨ φ ∈ 𝔖₂ := by simpa using h rcases this with (h |h ) · left; apply IsClosed.closed ω φ h · right; apply IsClosed.closed ω φ h -instance inf (𝓢₁ 𝓢₂ : Schema L) [IsClosed 𝓢₁] [IsClosed 𝓢₂] : IsClosed (𝓢₁ ⊓ 𝓢₂) where +instance inf (𝔖₁ 𝔖₂ : Schema L) [IsClosed 𝔖₁] [IsClosed 𝔖₂] : IsClosed (𝔖₁ ∩ 𝔖₂) where closed ω φ h := by - have : φ ∈ 𝓢₁ ∧ φ ∈ 𝓢₂ := by simpa using h + have : φ ∈ 𝔖₁ ∧ φ ∈ 𝔖₂ := by simpa using h rcases this with ⟨h₁, h₂⟩ constructor · apply IsClosed.closed ω φ h₁ · apply IsClosed.closed ω φ h₂ -lemma sSup (s : Set (Schema L)) (H : ∀ 𝓢 ∈ s, IsClosed 𝓢) : IsClosed (sSup s) where +lemma sSup (s : Set (Schema L)) (H : ∀ 𝔖 ∈ s, IsClosed 𝔖) : IsClosed (sSup s) where closed ω φ h := by - have : ∃ 𝓢 ∈ s, φ ∈ 𝓢 := by simpa using h - rcases this with ⟨𝓢, hs, hφ⟩ - have : IsClosed 𝓢 := H 𝓢 hs - exact ⟨𝓢, hs, IsClosed.closed _ _ hφ⟩ + have : ∃ 𝔖 ∈ s, φ ∈ 𝔖 := by simpa using h + rcases this with ⟨𝔖, hs, hφ⟩ + have : IsClosed 𝔖 := H 𝔖 hs + exact ⟨𝔖, hs, IsClosed.closed _ _ hφ⟩ instance sentence (σ : Sentence L) : IsClosed (σ : Schema L) where closed _ φ h := by @@ -121,25 +76,25 @@ instance sentence (σ : Sentence L) : IsClosed (σ : Schema L) where end IsClosed -@[coe] def uniClosure (𝓢 : Schema L) : Theory L := Set.image Semiformula.univCl {φ | φ ∈ 𝓢} +@[coe] def uniClosure (𝔖 : Schema L) : Theory L := Set.image Semiformula.univCl {φ | φ ∈ 𝔖} instance : Coe (Schema L) (Theory L) := ⟨uniClosure⟩ -variable {𝓢 : Schema L} +variable {𝔖 : Schema L} @[simp] lemma mem_uniClosure : - σ ∈ (𝓢 : Theory L) ↔ ∃ φ ∈ 𝓢, Semiformula.univCl φ = σ := by simp [uniClosure] + σ ∈ (𝔖 : Theory L) ↔ ∃ φ ∈ 𝔖, Semiformula.univCl φ = σ := by simp [uniClosure] -@[simp] lemma coe_sup (𝓢₁ 𝓢₂ : Schema L) : ((𝓢₁ ⊔ 𝓢₂ : Schema L) : Theory L) = (𝓢₁ : Theory L) ∪ (𝓢₂ : Theory L) := by +@[simp] lemma coe_sup (𝔖₁ 𝔖₂ : Schema L) : ((𝔖₁ ∪ 𝔖₂ : Schema L) : Theory L) = (𝔖₁ : Theory L) ∪ (𝔖₂ : Theory L) := by ext σ; simp [uniClosure]; grind -@[simp] lemma coe_sSup (s : Set (Schema L)) : ((sSup s : Schema L) : Theory L) = ⋃ 𝓢 ∈ s, (𝓢 : Theory L) := by +@[simp] lemma coe_sSup (s : Set (Schema L)) : ((sSup s : Schema L) : Theory L) = ⋃ 𝔖 ∈ s, (𝔖 : Theory L) := by ext σ; simp [uniClosure, sSup]; grind @[simp] lemma coe_coe_proposition (φ : Proposition L) : ((φ : Schema L) : Theory L) = {φ.univCl} := by ext σ; simp [uniClosure] -@[grind <-] lemma coe_subset_coe_of_le {𝓢₁ 𝓢₂ : Schema L} (h : 𝓢₁ ≤ 𝓢₂) : (𝓢₁ : Theory L) ⊆ (𝓢₂ : Theory L) := +@[grind <-] lemma coe_subset_coe_of_le {𝔖₁ 𝔖₂ : Schema L} (h : 𝔖₁ ≤ 𝔖₂) : (𝔖₁ : Theory L) ⊆ (𝔖₂ : Theory L) := Set.image_mono h end Schema diff --git a/Foundation/FirstOrder/Intuitionistic/Deduction.lean b/Foundation/FirstOrder/Intuitionistic/Deduction.lean index 7d4fbd0c0..065091726 100644 --- a/Foundation/FirstOrder/Intuitionistic/Deduction.lean +++ b/Foundation/FirstOrder/Intuitionistic/Deduction.lean @@ -24,6 +24,12 @@ instance : SetLike (Hilbertᵢ L) (Propositionᵢ L) where coe := Hilbertᵢ.axiomSet coe_injective' := by rintro ⟨T, _⟩ ⟨U, _⟩; simp + +instance : LE (Hilbertᵢ L) where + le Λ₁ Λ₂ := (Λ₁ : Set (Propositionᵢ L)) ⊆ (Λ₂ : Set (Propositionᵢ L)) + +instance : IsConcreteLE (Hilbertᵢ L) (Propositionᵢ L) := ⟨by intros; rfl⟩ + @[simp] lemma mem_mk (s : Set (Propositionᵢ L)) (h) : φ ∈ Hilbertᵢ.mk s h ↔ φ ∈ s := by rfl def Minimal : Hilbertᵢ L := ⟨∅, by simp⟩ @@ -145,18 +151,18 @@ def allImplyAllOfAllImply (φ ψ) : Λ ⊢! ∀⁰ (φ 🡒 ψ) 🡒 ∀⁰ φ apply deduct' apply deduct apply geNOverFiniteContext - have b₁ : [∀⁰ shift φ, ∀⁰ (shift φ ➝ shift ψ)] ⊢[Λ]! free φ ➝ free ψ := + have b₁ : [∀⁰ shift φ, ∀⁰ (shift φ 🡒 shift ψ)] ⊢[Λ]! free φ 🡒 free ψ := Entailment.cast (specializeOverContext (nthAxm 1) &0) - have b₂ : [∀⁰ shift φ, ∀⁰ (shift φ ➝ shift ψ)] ⊢[Λ]! free φ := + have b₂ : [∀⁰ shift φ, ∀⁰ (shift φ 🡒 shift ψ)] ⊢[Λ]! free φ := Entailment.cast (specializeOverContext (nthAxm 0) &0) - have : [∀⁰ φ, ∀⁰ (φ ➝ ψ)]⁺ ⊢[Λ]! free ψ := cast (by simp) (b₁ ⨀ b₂) + have : [∀⁰ φ, ∀⁰ (φ 🡒 ψ)]⁺ ⊢[Λ]! free ψ := cast (by simp) (b₁ ⨀ b₂) exact this -def allIffAllOfIff {φ ψ} (b : Λ ⊢! free φ ⭤ free ψ) : Λ ⊢! ∀⁰ φ ⭤ ∀⁰ ψ := Entailment.K_intro +def allIffAllOfIff {φ ψ} (b : Λ ⊢! free φ 🡘 free ψ) : Λ ⊢! ∀⁰ φ 🡘 ∀⁰ ψ := Entailment.K_intro (allImplyAllOfAllImply φ ψ ⨀ gen (Entailment.cast (Entailment.K_left b))) (allImplyAllOfAllImply ψ φ ⨀ gen (Entailment.cast (Entailment.K_right b))) -def dneOfNegative [L.DecidableEq] : {φ : Propositionᵢ L} → φ.IsNegative → Λ ⊢! ∼∼φ ➝ φ +def dneOfNegative [L.DecidableEq] : {φ : Propositionᵢ L} → φ.IsNegative → Λ ⊢! ∼∼φ 🡒 φ | ⊥, _ => Entailment.CNNOO | φ ⋏ ψ, h => have ihφ : Λ ⊢! ∼∼φ 🡒 φ := dneOfNegative (by simp [by simpa using h]) @@ -184,10 +190,10 @@ def dneOfNegative [L.DecidableEq] : {φ : Propositionᵢ L} → φ.IsNegative def ofDNOfNegative [L.DecidableEq] {φ : Propositionᵢ L} {Γ} (b : Γ ⊢[Λ]! ∼∼φ) (h : φ.IsNegative) : Γ ⊢[Λ]! φ := Entailment.C_trans (toDef b) (dneOfNegative h) -def DN_of_isNegative [L.DecidableEq] {φ : Propositionᵢ L} (h : φ.IsNegative) : Λ ⊢! ∼∼φ ⭤ φ := +def DN_of_isNegative [L.DecidableEq] {φ : Propositionᵢ L} (h : φ.IsNegative) : Λ ⊢! ∼∼φ 🡘 φ := Entailment.K_intro (dneOfNegative h) Entailment.dni -def efqOfNegative : {φ : Propositionᵢ L} → φ.IsNegative → Λ ⊢! ⊥ ➝ φ +def efqOfNegative : {φ : Propositionᵢ L} → φ.IsNegative → Λ ⊢! ⊥ 🡒 φ | ⊥, _ => Entailment.C_id | φ ⋏ ψ, h => have ihφ : Λ ⊢! ⊥ 🡒 φ := efqOfNegative (by simp [by simpa using h]) @@ -197,11 +203,11 @@ def efqOfNegative : {φ : Propositionᵢ L} → φ.IsNegative → Λ ⊢! ⊥ have ihψ : Λ ⊢! ⊥ 🡒 ψ := efqOfNegative (by simp [by simpa using h]) Entailment.C_trans ihψ Entailment.implyK | ∀⁰ φ, h => - have ihφ : Λ ⊢! ⊥ ➝ free φ := efqOfNegative (by simp [by simpa using h]) + have ihφ : Λ ⊢! ⊥ 🡒 free φ := efqOfNegative (by simp [by simpa using h]) implyAll <| Entailment.cast ihφ termination_by φ _ => φ.complexity -def iffnegOfNegIff [L.DecidableEq] {φ ψ : Propositionᵢ L} (h : φ.IsNegative) (b : Λ ⊢! ∼φ ⭤ ψ) : Λ ⊢! φ ⭤ ∼ψ := +def iffnegOfNegIff [L.DecidableEq] {φ ψ : Propositionᵢ L} (h : φ.IsNegative) (b : Λ ⊢! ∼φ 🡘 ψ) : Λ ⊢! φ 🡘 ∼ψ := Entailment.E_trans (Entailment.E_symm <| DN_of_isNegative h) (Entailment.ENN_of_E b) def rewrite (f : ℕ → SyntacticTerm L) : Λ ⊢! φ → Λ ⊢! Rew.rewrite f ▹ φ diff --git a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean index 95e855174..9d51ebb4f 100644 --- a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean +++ b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean @@ -94,7 +94,7 @@ variable {L : Language} [L.DecidableEq] {T : Theory L} {Λ : Hilbertᵢ L} open Rewriting LO.Entailment Entailment.FiniteContext HilbertProofᵢ -def negDoubleNegation : (φ : Proposition L) → Λ ⊢! ∼φᴺ ⭤ (∼φ)ᴺ +def negDoubleNegation : (φ : Proposition L) → Λ ⊢! ∼φᴺ 🡘 (∼φ)ᴺ | .rel r v => Entailment.tneIff (φ := Semiformulaᵢ.rel r v) | .nrel r v => Entailment.E_Id (φ := ∼∼(Semiformulaᵢ.rel r v)) | ⊤ => Entailment.ENNOO @@ -112,29 +112,29 @@ def negDoubleNegation : (φ : Proposition L) → Λ ⊢! ∼φᴺ ⭤ (∼φ)ᴺ have : Λ ⊢! ∼∼(∼φᴺ ⋏ ∼ψᴺ) 🡘 (∼φ)ᴺ ⋏ (∼ψ)ᴺ := Entailment.E_trans (DN_of_isNegative (by simp)) this this | ∀⁰ φ => - have ihφ : Λ ⊢! ∼(free φ)ᴺ ⭤ (∼(free φ))ᴺ := negDoubleNegation (free φ) - have : Λ ⊢! (free φ)ᴺ ⭤ (∼(∼(free φ))ᴺ) := iffnegOfNegIff (by simp) ihφ - have : Λ ⊢! ∀⁰ φᴺ ⭤ ∀⁰ ∼(∼φ)ᴺ := + have ihφ : Λ ⊢! ∼(free φ)ᴺ 🡘 (∼(free φ))ᴺ := negDoubleNegation (free φ) + have : Λ ⊢! (free φ)ᴺ 🡘 (∼(∼(free φ))ᴺ) := iffnegOfNegIff (by simp) ihφ + have : Λ ⊢! ∀⁰ φᴺ 🡘 ∀⁰ ∼(∼φ)ᴺ := allIffAllOfIff <| Entailment.cast this (by simp [Semiformula.rew_doubleNegation]) Entailment.ENN_of_E this | ∃⁰ φ => - have ihφ : Λ ⊢! ∼(free φ)ᴺ ⭤ (∼(free φ))ᴺ := negDoubleNegation (free φ) - have : Λ ⊢! ∀⁰ ∼φᴺ ⭤ ∀⁰ (∼φ)ᴺ := + have ihφ : Λ ⊢! ∼(free φ)ᴺ 🡘 (∼(free φ))ᴺ := negDoubleNegation (free φ) + have : Λ ⊢! ∀⁰ ∼φᴺ 🡘 ∀⁰ (∼φ)ᴺ := allIffAllOfIff <| Entailment.cast ihφ (by simp [Semiformula.rew_doubleNegation]) - have : Λ ⊢! ∼∼(∀⁰ ∼φᴺ) ⭤ ∀⁰ (∼φ)ᴺ := Entailment.E_trans (DN_of_isNegative (by simp)) this + have : Λ ⊢! ∼∼(∀⁰ ∼φᴺ) 🡘 ∀⁰ (∼φ)ᴺ := Entailment.E_trans (DN_of_isNegative (by simp)) this this termination_by φ => φ.complexity -lemma neg_doubleNegation (φ : Proposition L) : Λ ⊢ ∼φᴺ ⭤ (∼φ)ᴺ := ⟨negDoubleNegation φ⟩ +lemma neg_doubleNegation (φ : Proposition L) : Λ ⊢ ∼φᴺ 🡘 (∼φ)ᴺ := ⟨negDoubleNegation φ⟩ -lemma neg_doubleNegation' (φ : Proposition L) : Λ ⊢ ∼(∼φ)ᴺ ⭤ φᴺ := by simpa using neg_doubleNegation (∼φ) +lemma neg_doubleNegation' (φ : Proposition L) : Λ ⊢ ∼(∼φ)ᴺ 🡘 φᴺ := by simpa using neg_doubleNegation (∼φ) open FiniteContext -lemma imply_doubleNegation (φ ψ : Proposition L) : Λ ⊢ (φᴺ ➝ ψᴺ) ⭤ (φ ➝ ψ)ᴺ := by - suffices Λ ⊢ (φᴺ ➝ ψᴺ) ⭤ ∼(∼(∼φ)ᴺ ⋏ ∼ψᴺ) by simpa [Semiformula.doubleNegation_imply] - have hφ₀ : Λ ⊢ ∼(∼φ)ᴺ ⭤ φᴺ := by simpa using neg_doubleNegation (∼φ) - have hψ : Λ ⊢ ∼∼ψᴺ ⭤ ψᴺ := ⟨DN_of_isNegative (by simp)⟩ +lemma imply_doubleNegation (φ ψ : Proposition L) : Λ ⊢ (φᴺ 🡒 ψᴺ) 🡘 (φ 🡒 ψ)ᴺ := by + suffices Λ ⊢ (φᴺ 🡒 ψᴺ) 🡘 ∼(∼(∼φ)ᴺ ⋏ ∼ψᴺ) by simpa [Semiformula.doubleNegation_imply] + have hφ₀ : Λ ⊢ ∼(∼φ)ᴺ 🡘 φᴺ := by simpa using neg_doubleNegation (∼φ) + have hψ : Λ ⊢ ∼∼ψᴺ 🡘 ψᴺ := ⟨DN_of_isNegative (by simp)⟩ apply Entailment.E!_intro · apply FiniteContext.deduct'! apply FiniteContext.deduct! diff --git a/Foundation/Logic/Calculus.lean b/Foundation/Logic/Calculus.lean index 8ef2b25b8..43a8ee044 100644 --- a/Foundation/Logic/Calculus.lean +++ b/Foundation/Logic/Calculus.lean @@ -72,7 +72,7 @@ instance : Entailment.ModusPonens 𝓔 where mdp {φ ψ} b₁ b₂ := let b₁ := equiv b₁ let b₂ := equiv b₂ - have : 𝔇 [∼(φ ➝ ψ), ∼φ, ψ] := cast (tensor (𝔇 := 𝔇) (identity φ) (identity (∼ψ))) (by simp [DeMorgan.imply]) + have : 𝔇 [∼(φ 🡒 ψ), ∼φ, ψ] := cast (tensor (𝔇 := 𝔇) (identity φ) (identity (∼ψ))) (by simp [DeMorgan.imply]) have : 𝔇 [∼φ, ψ] := wk (cut b₁ this) (by simp) have : 𝔇 [ψ] := wk (cut b₂ this) (by simp) equiv.symm <| cast this @@ -151,7 +151,7 @@ instance (𝓢 : S) : Entailment.ModusPonens 𝓢 where mdp {φ ψ} b₁ b₂ := let ⟨Γ₁, b₁⟩ := equiv b₁ let ⟨Γ₂, b₂⟩ := equiv b₂ - have : 𝔇 [∼(φ ➝ ψ), ∼φ, ψ] := cast (tensor (𝔇 := 𝔇) (identity φ) (identity (∼ψ))) (by simp [DeMorgan.imply]) + have : 𝔇 [∼(φ 🡒 ψ), ∼φ, ψ] := cast (tensor (𝔇 := 𝔇) (identity φ) (identity (∼ψ))) (by simp [DeMorgan.imply]) have : 𝔇 (∼φ :: ψ :: ∼↑Γ₁) := wk (cut b₁ this) (by simp) have : 𝔇 (ψ :: ∼↑Γ₁ ++ ∼↑Γ₂) := wk (cut b₂ this) (by simp) equiv.symm ⟨⟨Γ₁ ++ Γ₂, by simp; grind⟩, cast this⟩ @@ -162,7 +162,7 @@ instance : Entailment.StrongCut S S where match l with | [] => equiv.symm ⟨⟨[], by simp⟩, d⟩ | ψ :: l => - have bχ : T ⊢! ψ ➝ χ := + have bχ : T ⊢! ψ 🡒 χ := Entailment.cast (bl l (by simp at hl; grind) (∼ψ ⋎ χ) (OneSidedLK.or <| OneSidedLK.swap₁ d)) (by simp [DeMorgan.imply]) have bψ : T ⊢! ψ := bs (show ψ ∈ U by simp at hl; grind) From d078f1346e61349714c3bc53034e64384d5ffb54 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Mon, 6 Apr 2026 05:47:29 +0900 Subject: [PATCH 32/61] commentout --- Foundation.lean | 253 +++++------ .../Completeness/BooleanValuedModel.lean | 3 +- .../Completeness/CanonicalModel.lean | 32 +- Foundation/FirstOrder/Hauptsatz.lean | 6 +- .../FirstOrder/Intuitionistic/Deduction.lean | 2 + Foundation/FirstOrder/Skolemization/Hull.lean | 28 +- .../Modal/VanBentham/StandardTranslation.lean | 11 +- Foundation/Propositional/Decidable.lean | 428 ------------------ Foundation/Propositional/Hilbert/F/Basic.lean | 2 +- .../Propositional/Hilbert/Minimal/Basic.lean | 2 +- .../Propositional/Hilbert/VF/Basic.lean | 2 +- .../Propositional/Hilbert/WF/Basic.lean | 2 +- Foundation/Vorspiel/Order/Heyting.lean | 4 - 13 files changed, 170 insertions(+), 605 deletions(-) delete mode 100644 Foundation/Propositional/Decidable.lean diff --git a/Foundation.lean b/Foundation.lean index 4a35549aa..7f69277f3 100644 --- a/Foundation.lean +++ b/Foundation.lean @@ -1,47 +1,48 @@ module -- shake: keep-all -public import Foundation.FirstOrder.Arithmetic.Basic -public import Foundation.FirstOrder.Arithmetic.Basic.Hierarchy -public import Foundation.FirstOrder.Arithmetic.Basic.Misc -public import Foundation.FirstOrder.Arithmetic.Basic.Model -public import Foundation.FirstOrder.Arithmetic.Basic.Monotone -public import Foundation.FirstOrder.Arithmetic.Definability -public import Foundation.FirstOrder.Arithmetic.Definability.Absoluteness -public import Foundation.FirstOrder.Arithmetic.Definability.BoundedDefinable -public import Foundation.FirstOrder.Arithmetic.Definability.Definable -public import Foundation.FirstOrder.Arithmetic.Definability.Hierarchy -public import Foundation.FirstOrder.Arithmetic.Exponential -public import Foundation.FirstOrder.Arithmetic.Exponential.Bit -public import Foundation.FirstOrder.Arithmetic.Exponential.Exp -public import Foundation.FirstOrder.Arithmetic.Exponential.Log -public import Foundation.FirstOrder.Arithmetic.Exponential.PPow2 -public import Foundation.FirstOrder.Arithmetic.Exponential.Pow2 -public import Foundation.FirstOrder.Arithmetic.HFS -public import Foundation.FirstOrder.Arithmetic.HFS.Basic -public import Foundation.FirstOrder.Arithmetic.HFS.Coding -public import Foundation.FirstOrder.Arithmetic.HFS.Fixpoint -public import Foundation.FirstOrder.Arithmetic.HFS.PRF -public import Foundation.FirstOrder.Arithmetic.HFS.Seq -public import Foundation.FirstOrder.Arithmetic.HFS.Vec -public import Foundation.FirstOrder.Arithmetic.IOpen.Basic -public import Foundation.FirstOrder.Arithmetic.Induction -public import Foundation.FirstOrder.Arithmetic.Omega1.Basic -public import Foundation.FirstOrder.Arithmetic.Omega1.Nuon -public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Basic -public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Functions -public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Q -public import Foundation.FirstOrder.Arithmetic.Q.Basic -public import Foundation.FirstOrder.Arithmetic.R0.Basic -public import Foundation.FirstOrder.Arithmetic.R0.Representation -public import Foundation.FirstOrder.Arithmetic.Schemata -public import Foundation.FirstOrder.Arithmetic.TA.Basic -public import Foundation.FirstOrder.Arithmetic.TA.Nonstandard +-- public import Foundation.FirstOrder.Arithmetic.Basic +-- public import Foundation.FirstOrder.Arithmetic.Basic.Hierarchy +-- public import Foundation.FirstOrder.Arithmetic.Basic.Misc +-- public import Foundation.FirstOrder.Arithmetic.Basic.Model +-- public import Foundation.FirstOrder.Arithmetic.Basic.Monotone +-- public import Foundation.FirstOrder.Arithmetic.Definability +-- public import Foundation.FirstOrder.Arithmetic.Definability.Absoluteness +-- public import Foundation.FirstOrder.Arithmetic.Definability.BoundedDefinable +-- public import Foundation.FirstOrder.Arithmetic.Definability.Definable +-- public import Foundation.FirstOrder.Arithmetic.Definability.Hierarchy +-- public import Foundation.FirstOrder.Arithmetic.Exponential +-- public import Foundation.FirstOrder.Arithmetic.Exponential.Bit +-- public import Foundation.FirstOrder.Arithmetic.Exponential.Exp +-- public import Foundation.FirstOrder.Arithmetic.Exponential.Log +-- public import Foundation.FirstOrder.Arithmetic.Exponential.PPow2 +-- public import Foundation.FirstOrder.Arithmetic.Exponential.Pow2 +-- public import Foundation.FirstOrder.Arithmetic.HFS +-- public import Foundation.FirstOrder.Arithmetic.HFS.Basic +-- public import Foundation.FirstOrder.Arithmetic.HFS.Coding +-- public import Foundation.FirstOrder.Arithmetic.HFS.Fixpoint +-- public import Foundation.FirstOrder.Arithmetic.HFS.PRF +-- public import Foundation.FirstOrder.Arithmetic.HFS.Seq +-- public import Foundation.FirstOrder.Arithmetic.HFS.Vec +-- public import Foundation.FirstOrder.Arithmetic.IOpen.Basic +-- public import Foundation.FirstOrder.Arithmetic.Induction +-- public import Foundation.FirstOrder.Arithmetic.Omega1.Basic +-- public import Foundation.FirstOrder.Arithmetic.Omega1.Nuon +-- public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Basic +-- public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Functions +-- public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Q +-- public import Foundation.FirstOrder.Arithmetic.Q.Basic +-- public import Foundation.FirstOrder.Arithmetic.R0.Basic +-- public import Foundation.FirstOrder.Arithmetic.R0.Representation +-- public import Foundation.FirstOrder.Arithmetic.Schemata +-- public import Foundation.FirstOrder.Arithmetic.TA.Basic +-- public import Foundation.FirstOrder.Arithmetic.TA.Nonstandard public import Foundation.FirstOrder.Basic public import Foundation.FirstOrder.Basic.AesopInit public import Foundation.FirstOrder.Basic.BinderNotation public import Foundation.FirstOrder.Basic.Calculus public import Foundation.FirstOrder.Basic.Calculus2 public import Foundation.FirstOrder.Basic.Coding +public import Foundation.FirstOrder.Basic.CutFree public import Foundation.FirstOrder.Basic.Definability public import Foundation.FirstOrder.Basic.Eq public import Foundation.FirstOrder.Basic.Model @@ -53,71 +54,68 @@ public import Foundation.FirstOrder.Basic.Soundness public import Foundation.FirstOrder.Basic.Syntax.Formula public import Foundation.FirstOrder.Basic.Syntax.Rew public import Foundation.FirstOrder.Basic.Syntax.Schema -public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D1 -public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D2 -public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D3 -public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.EquationalTheory -public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.PeanoMinus -public import Foundation.FirstOrder.Bootstrapping.FixedPoint -public import Foundation.FirstOrder.Bootstrapping.Syntax -public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Basic -public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Coding -public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Functions -public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Iteration -public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Typed -public import Foundation.FirstOrder.Bootstrapping.Syntax.Language -public import Foundation.FirstOrder.Bootstrapping.Syntax.Proof.Basic -public import Foundation.FirstOrder.Bootstrapping.Syntax.Proof.Coding -public import Foundation.FirstOrder.Bootstrapping.Syntax.Proof.Typed -public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Basic -public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Coding -public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Functions -public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Typed -public import Foundation.FirstOrder.Bootstrapping.Syntax.Theory -public import Foundation.FirstOrder.Completeness.Coding -public import Foundation.FirstOrder.Completeness.Completeness -public import Foundation.FirstOrder.Completeness.Corollaries -public import Foundation.FirstOrder.Completeness.SearchTree -public import Foundation.FirstOrder.Completeness.SubLanguage -public import Foundation.FirstOrder.Hauptsatz -public import Foundation.FirstOrder.Incompleteness.Consistency -public import Foundation.FirstOrder.Incompleteness.Dense -public import Foundation.FirstOrder.Incompleteness.Examples -public import Foundation.FirstOrder.Incompleteness.First -public import Foundation.FirstOrder.Incompleteness.GödelRosser -public import Foundation.FirstOrder.Incompleteness.Halting -public import Foundation.FirstOrder.Incompleteness.Jeroslow -public import Foundation.FirstOrder.Incompleteness.Löb -public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Basic -public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Height -public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Refutability -public import Foundation.FirstOrder.Incompleteness.RestrictedProvability -public import Foundation.FirstOrder.Incompleteness.RosserProvability -public import Foundation.FirstOrder.Incompleteness.Second -public import Foundation.FirstOrder.Incompleteness.StandardProvability -public import Foundation.FirstOrder.Incompleteness.Tarski -public import Foundation.FirstOrder.Incompleteness.WitnessComparison -public import Foundation.FirstOrder.Incompleteness.Yablo -public import Foundation.FirstOrder.Interpretation +-- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D1 +-- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D2 +-- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D3 +-- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.EquationalTheory +-- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.PeanoMinus +-- public import Foundation.FirstOrder.Bootstrapping.FixedPoint +-- public import Foundation.FirstOrder.Bootstrapping.Syntax +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Basic +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Coding +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Functions +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Iteration +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Typed +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Language +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Proof.Basic +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Proof.Coding +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Proof.Typed +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Basic +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Coding +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Functions +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Typed +-- public import Foundation.FirstOrder.Bootstrapping.Syntax.Theory +public import Foundation.FirstOrder.Completeness.BooleanValuedModel +public import Foundation.FirstOrder.Completeness.CanonicalModel +-- public import Foundation.FirstOrder.Hauptsatz +-- public import Foundation.FirstOrder.Incompleteness.Consistency +-- public import Foundation.FirstOrder.Incompleteness.Dense +-- public import Foundation.FirstOrder.Incompleteness.Examples +-- public import Foundation.FirstOrder.Incompleteness.First +-- public import Foundation.FirstOrder.Incompleteness.GödelRosser +-- public import Foundation.FirstOrder.Incompleteness.Halting +-- public import Foundation.FirstOrder.Incompleteness.Jeroslow +-- public import Foundation.FirstOrder.Incompleteness.Löb +-- public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Basic +-- public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Height +-- public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Refutability +-- public import Foundation.FirstOrder.Incompleteness.RestrictedProvability +-- public import Foundation.FirstOrder.Incompleteness.RosserProvability +-- public import Foundation.FirstOrder.Incompleteness.Second +-- public import Foundation.FirstOrder.Incompleteness.StandardProvability +-- public import Foundation.FirstOrder.Incompleteness.Tarski +-- public import Foundation.FirstOrder.Incompleteness.WitnessComparison +-- public import Foundation.FirstOrder.Incompleteness.Yablo +-- public import Foundation.FirstOrder.Interpretation public import Foundation.FirstOrder.Intuitionistic.Deduction public import Foundation.FirstOrder.Intuitionistic.Formula public import Foundation.FirstOrder.Intuitionistic.Rew public import Foundation.FirstOrder.Kripke.Basic public import Foundation.FirstOrder.Kripke.Intuitionistic -public import Foundation.FirstOrder.Kripke.WeakForcing +-- public import Foundation.FirstOrder.Kripke.WeakForcing public import Foundation.FirstOrder.NegationTranslation.GoedelGentzen -public import Foundation.FirstOrder.Order.Le +-- public import Foundation.FirstOrder.Order.Le public import Foundation.FirstOrder.Polarity -public import Foundation.FirstOrder.SetTheory.Basic -public import Foundation.FirstOrder.SetTheory.Basic.Axioms -public import Foundation.FirstOrder.SetTheory.Basic.Misc -public import Foundation.FirstOrder.SetTheory.Basic.Model -public import Foundation.FirstOrder.SetTheory.Function -public import Foundation.FirstOrder.SetTheory.LoewenheimSkolem -public import Foundation.FirstOrder.SetTheory.Ordinal -public import Foundation.FirstOrder.SetTheory.TransitiveModel -public import Foundation.FirstOrder.SetTheory.Universe -public import Foundation.FirstOrder.SetTheory.Z +-- public import Foundation.FirstOrder.SetTheory.Basic +-- public import Foundation.FirstOrder.SetTheory.Basic.Axioms +-- public import Foundation.FirstOrder.SetTheory.Basic.Misc +-- public import Foundation.FirstOrder.SetTheory.Basic.Model +-- public import Foundation.FirstOrder.SetTheory.Function +-- public import Foundation.FirstOrder.SetTheory.LoewenheimSkolem +-- public import Foundation.FirstOrder.SetTheory.Ordinal +-- public import Foundation.FirstOrder.SetTheory.TransitiveModel +-- public import Foundation.FirstOrder.SetTheory.Universe +-- public import Foundation.FirstOrder.SetTheory.Z public import Foundation.FirstOrder.Skolemization.Hull public import Foundation.FirstOrder.Ultraproduct public import Foundation.Init @@ -187,12 +185,12 @@ public import Foundation.InterpretabilityLogic.Veltman.Logic.IL_P₀ public import Foundation.InterpretabilityLogic.Veltman.Logic.IL_R public import Foundation.InterpretabilityLogic.Veltman.Logic.IL_R_W public import Foundation.InterpretabilityLogic.Veltman.Logic.IL_W -public import Foundation.LinearLogic.FirstOrder.Calculus -public import Foundation.LinearLogic.FirstOrder.ClassicalEmbedding -public import Foundation.LinearLogic.FirstOrder.Formula -public import Foundation.LinearLogic.FirstOrder.Rew -public import Foundation.LinearLogic.LogicSymbol -public import Foundation.LinearLogic.MLL +-- public import Foundation.LinearLogic.FirstOrder.Calculus +-- public import Foundation.LinearLogic.FirstOrder.ClassicalEmbedding +-- public import Foundation.LinearLogic.FirstOrder.Formula +-- public import Foundation.LinearLogic.FirstOrder.Rew +-- public import Foundation.LinearLogic.LogicSymbol +-- public import Foundation.LinearLogic.MLL public import Foundation.Logic.Calculus public import Foundation.Logic.Decidability public import Foundation.Logic.Disjunctive @@ -210,14 +208,14 @@ public import Foundation.Meta.Test public import Foundation.Meta.TwoSided public import Foundation.Modal.Algebra.Basic public import Foundation.Modal.Axioms -public import Foundation.Modal.Boxdot.Basic -public import Foundation.Modal.Boxdot.GLPoint3_GrzPoint3 -public import Foundation.Modal.Boxdot.GL_Grz -public import Foundation.Modal.Boxdot.GL_S -public import Foundation.Modal.Boxdot.Grz_S -public import Foundation.Modal.Boxdot.Jerabek -public import Foundation.Modal.Boxdot.K4_S4 -public import Foundation.Modal.Boxdot.Ver_Triv +-- public import Foundation.Modal.Boxdot.Basic +-- public import Foundation.Modal.Boxdot.GLPoint3_GrzPoint3 +-- public import Foundation.Modal.Boxdot.GL_Grz +-- public import Foundation.Modal.Boxdot.GL_S +-- public import Foundation.Modal.Boxdot.Grz_S +-- public import Foundation.Modal.Boxdot.Jerabek +-- public import Foundation.Modal.Boxdot.K4_S4 +-- public import Foundation.Modal.Boxdot.Ver_Triv public import Foundation.Modal.ComplementClosedConsistentFinset public import Foundation.Modal.Entailment.AxiomGeach public import Foundation.Modal.Entailment.Basic @@ -350,7 +348,7 @@ public import Foundation.Modal.Logic.GLPlusBoxBot.Basic public import Foundation.Modal.Logic.GLPoint3OplusBoxBot.Basic public import Foundation.Modal.Logic.Global public import Foundation.Modal.Logic.S.Basic -public import Foundation.Modal.Logic.S.Consistent +-- public import Foundation.Modal.Logic.S.Consistent public import Foundation.Modal.Logic.SumNormal public import Foundation.Modal.Logic.SumQuasiNormal public import Foundation.Modal.LogicSymbol @@ -380,7 +378,6 @@ public import Foundation.Propositional.Boolean.NNFormula public import Foundation.Propositional.Boolean.Tait public import Foundation.Propositional.Boolean.ZeroSubst public import Foundation.Propositional.ConsistentTableau -public import Foundation.Propositional.Decidable public import Foundation.Propositional.Dialectica.Basic public import Foundation.Propositional.Entailment.AxiomDNE public import Foundation.Propositional.Entailment.AxiomEFQ @@ -463,24 +460,24 @@ public import Foundation.Propositional.Neighborhood.NB.Hilbert.WF public import Foundation.Propositional.Slash public import Foundation.Propositional.Tait.Calculus public import Foundation.Propositional.Translation -public import Foundation.ProvabilityLogic.Arithmetic -public import Foundation.ProvabilityLogic.Classification.LetterlessTrace -public import Foundation.ProvabilityLogic.Classification.Result -public import Foundation.ProvabilityLogic.Classification.Trace -public import Foundation.ProvabilityLogic.GL.Completeness -public import Foundation.ProvabilityLogic.GL.Soundness -public import Foundation.ProvabilityLogic.GL.Uniform -public import Foundation.ProvabilityLogic.GL.Unprovability -public import Foundation.ProvabilityLogic.Grz.Completeness -public import Foundation.ProvabilityLogic.N.Soundness -public import Foundation.ProvabilityLogic.Realization -public import Foundation.ProvabilityLogic.S.Completeness -public import Foundation.ProvabilityLogic.S.Soundness -public import Foundation.ProvabilityLogic.SolovaySentences -public import Foundation.SecondOrder.Derivation -public import Foundation.SecondOrder.Semantics -public import Foundation.SecondOrder.Syntax.Formula -public import Foundation.SecondOrder.Syntax.Rew +-- public import Foundation.ProvabilityLogic.Arithmetic +-- public import Foundation.ProvabilityLogic.Classification.LetterlessTrace +-- public import Foundation.ProvabilityLogic.Classification.Result +-- public import Foundation.ProvabilityLogic.Classification.Trace +-- public import Foundation.ProvabilityLogic.GL.Completeness +-- public import Foundation.ProvabilityLogic.GL.Soundness +-- public import Foundation.ProvabilityLogic.GL.Uniform +-- public import Foundation.ProvabilityLogic.GL.Unprovability +-- public import Foundation.ProvabilityLogic.Grz.Completeness +-- public import Foundation.ProvabilityLogic.N.Soundness +-- public import Foundation.ProvabilityLogic.Realization +-- public import Foundation.ProvabilityLogic.S.Completeness +-- public import Foundation.ProvabilityLogic.S.Soundness +-- public import Foundation.ProvabilityLogic.SolovaySentences +-- public import Foundation.SecondOrder.Derivation +-- public import Foundation.SecondOrder.Semantics +-- public import Foundation.SecondOrder.Syntax.Formula +-- public import Foundation.SecondOrder.Syntax.Rew public import Foundation.Semantics.Algebra.Modal.Basic public import Foundation.Semantics.Algebra.Modal.Magari public import Foundation.Semantics.CoherenceSpace.Basic diff --git a/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean b/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean index e0ee13839..1c16a63b1 100644 --- a/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean +++ b/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean @@ -73,7 +73,7 @@ lemma hValue_ext {φ ψ : Propositionᵢ L} : (∀ p : ℂ, p.val ⊩ φ ↔ p.v @[simp] lemma hValue_falsum : ♯(⊥ : Propositionᵢ L) = ⊥ := by ext p; simp [hValue, IsForced.falsum, p.prop] -@[simp] lemma hValue_imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ ➝ ψ) = (♯φ ⇨ ♯ψ) := by +@[simp] lemma hValue_imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ 🡒 ψ) = (♯φ ⇨ ♯ψ) := by ext p suffices (∀ q ≤ p.val, q ⊩ φ → q ⊩ ψ) ↔ ∀ q ≤ p, q.val ⊩ φ → q.val ⊩ ψ by simpa [IsForced.imply, LowerSet.mem_himp_iff] @@ -88,6 +88,7 @@ lemma hValue_ext {φ ψ : Propositionᵢ L} : (∀ p : ℂ, p.val ⊩ φ ↔ p.v @[simp] lemma hValue_neg_eq_himp_bot (φ : Propositionᵢ L) : ♯(∼φ) = (♯φ)ᶜ := by simp [Semiformulaᵢ.neg_def] +set_option backward.isDefEq.respectTransparency false in lemma hValue_eq_top_iff_provable {φ : Proposition L} : ♯φᴺ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc ♯φᴺ = ⊤ ↔ ⊤ ≤ ♯φᴺ := by simp only [top_le_iff] _ ↔ (∀ p : ℂ, p.val ⊩ φᴺ) := by simp [SetLike.le_def] diff --git a/Foundation/FirstOrder/Completeness/CanonicalModel.lean b/Foundation/FirstOrder/Completeness/CanonicalModel.lean index 51fac6854..8e086e36b 100644 --- a/Foundation/FirstOrder/Completeness/CanonicalModel.lean +++ b/Foundation/FirstOrder/Completeness/CanonicalModel.lean @@ -116,7 +116,7 @@ def Forces (p : ℙ) : Propositionᵢ L → Type u | .rel R v => { b : ⊢ᴷ .rel R v :: ∼p // Derivation.IsCutFree b } | φ ⋏ ψ => Forces p φ × Forces p ψ | φ ⋎ ψ => Forces p φ ⊕ Forces p ψ - | φ ➝ ψ => (q : ℙ) → q ≼ p → Forces q φ → Forces q ψ + | φ 🡒 ψ => (q : ℙ) → q ≼ p → Forces q φ → Forces q ψ | ∀⁰ φ => (t : SyntacticTerm L) → Forces p (φ/[t]) | ∃⁰ φ => (t : SyntacticTerm L) × Forces p (φ/[t]) termination_by φ => φ.complexity @@ -148,7 +148,7 @@ def orEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ ⋎ ψ ≃ (p ⊩ φ) ⊕ (p unfold Forces exact .refl _ -def implyEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ ➝ ψ ≃ ((q : ℙ) → q ≼ p → q ⊩ φ → q ⊩ ψ) := by +def implyEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ 🡒 ψ ≃ ((q : ℙ) → q ≼ p → q ⊩ φ → q ⊩ ψ) := by conv => lhs unfold Forces @@ -177,7 +177,7 @@ def monotone {q p : ℙ} (s : q ≼ p) : {φ : Propositionᵢ L} → p ⊩ φ relEquiv.symm ⟨s.val.cons (.rel R v) |>.graft d, Positive.graft_isCutFree_of_isCutFree hd⟩ | φ ⋏ ψ, b => andEquiv.symm ⟨monotone s b.andEquiv.1, monotone s b.andEquiv.2⟩ | φ ⋎ ψ, b => orEquiv.symm <| b.orEquiv.rec (fun b ↦ .inl <| b.monotone s) (fun b ↦ .inr <| b.monotone s) - | φ ➝ ψ, b => implyEquiv.symm fun r srq bφ ↦ b.implyEquiv r (srq.trans s) bφ + | φ 🡒 ψ, b => implyEquiv.symm fun r srq bφ ↦ b.implyEquiv r (srq.trans s) bφ | ∀⁰ φ, b => allEquiv.symm fun t ↦ (b.allEquiv t).monotone s | ∃⁰ φ, b => let ⟨t, d⟩ : (t : SyntacticTerm L) × p ⊩ φ/[t] := b.exsEquiv @@ -191,26 +191,26 @@ def explosion {p : ℙ} (b : p ⊩ ⊥) : (φ : Propositionᵢ L) → p ⊩ φ relEquiv.symm ⟨.wk d (by simp), by simp [hd]⟩ | φ ⋏ ψ => andEquiv.symm ⟨b.explosion φ, b.explosion ψ⟩ | φ ⋎ ψ => orEquiv.symm <| .inl <| b.explosion φ - | φ ➝ ψ => implyEquiv.symm fun q sqp dφ ↦ (b.monotone sqp).explosion ψ + | φ 🡒 ψ => implyEquiv.symm fun q sqp dφ ↦ (b.monotone sqp).explosion ψ | ∀⁰ φ => allEquiv.symm fun t ↦ b.explosion (φ/[t]) | ∃⁰ φ => exsEquiv.symm ⟨default, b.explosion (φ/[default])⟩ termination_by φ => φ.complexity -def efq (φ : Propositionᵢ L) : ⊩ ⊥ ➝ φ := fun _ ↦ implyEquiv.symm fun _ _ d ↦ d.explosion φ +def efq (φ : Propositionᵢ L) : ⊩ ⊥ 🡒 φ := fun _ ↦ implyEquiv.symm fun _ _ d ↦ d.explosion φ def implyOf {φ ψ : Propositionᵢ L} (b : (q : ℙ) → q ⊩ φ → p ⊓ q ⊩ ψ) : - p ⊩ φ ➝ ψ := implyEquiv.symm fun q sqp fφ ↦ + p ⊩ φ 🡒 ψ := implyEquiv.symm fun q sqp fφ ↦ let fψ : p ⊓ q ⊩ ψ := b q fφ fψ.monotone (StrongerThan.leMinRightOfLe sqp) open LawfulSyntacticRewriting -def modusPonens {φ ψ : Propositionᵢ L} (f : p ⊩ φ ➝ ψ) (g : p ⊩ φ) : p ⊩ ψ := +def modusPonens {φ ψ : Propositionᵢ L} (f : p ⊩ φ 🡒 ψ) (g : p ⊩ φ) : p ⊩ ψ := f.implyEquiv p (StrongerThan.refl p) g def sound {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢! φ → ⊩ φ | .mdp (φ := ψ) b d => fun p ↦ - let b : p ⊩ ψ ➝ φ := sound b p + let b : p ⊩ ψ 🡒 φ := sound b p let d : p ⊩ ψ := sound d p b.implyEquiv p (StrongerThan.refl p) d | .gen (φ := φ) b => fun p ↦ allEquiv.symm fun t ↦ @@ -223,7 +223,7 @@ def sound {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢! φ → ⊩ φ implyEquiv.symm fun q sqp b₁ ↦ implyEquiv.symm fun r srq b₂ ↦ implyEquiv.symm fun s ssr b₃ ↦ - let d₁ : s ⊩ ψ ➝ χ := b₁.implyEquiv s (ssr.trans srq) b₃ + let d₁ : s ⊩ ψ 🡒 χ := b₁.implyEquiv s (ssr.trans srq) b₃ let d₂ : s ⊩ ψ := b₂.implyEquiv s ssr b₃ d₁.implyEquiv s (StrongerThan.refl s) d₂ | .and₁ φ ψ => fun p ↦ @@ -255,7 +255,7 @@ def sound {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢! φ → ⊩ φ implyEquiv.symm fun q sqp b ↦ implyEquiv.symm fun r srq bφ ↦ allEquiv.symm fun t ↦ - let d : q ⊩ φ ➝ ψ/[t] := by simpa using (b.allEquiv t) + let d : q ⊩ φ 🡒 ψ/[t] := by simpa using (b.allEquiv t) d.implyEquiv r srq bφ | .ex₁ t φ => fun p ↦ implyEquiv.symm fun q sqp bφ ↦ exsEquiv.symm ⟨t, bφ⟩ @@ -263,7 +263,7 @@ def sound {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢! φ → ⊩ φ implyEquiv.symm fun q sqp b ↦ implyEquiv.symm fun r srq bφ ↦ let ⟨t, dt⟩ : (t : SyntacticTerm L) × r ⊩ φ/[t] := bφ.exsEquiv - let d : q ⊩ φ/[t] ➝ ψ := by simpa using b.allEquiv t + let d : q ⊩ φ/[t] 🡒 ψ := by simpa using b.allEquiv t d.implyEquiv r srq dt termination_by b => HilbertProofᵢ.depth b @@ -283,6 +283,7 @@ protected def refl.or (ihφ : [φ] ⊩ φᴺ) (ihψ : [ψ] ⊩ ψᴺ) : [φ ⋎ (Derivation.cast bbφ (by simp [inf_def])) (Derivation.cast bbψ (by simp [inf_def])) falsumEquiv.symm ⟨Derivation.cast band (by simp [inf_def]), by simp [band, hbbφ, hbbψ]⟩ +set_option backward.isDefEq.respectTransparency false in protected def refl.exs (d : ∀ x, [φ/[&x]] ⊩ (φ/[&x])ᴺ) : [∃⁰ φ] ⊩ (∃⁰ φ)ᴺ := implyOf fun q f ↦ let x := Sequent.newVar ((∀⁰ ∼φ) :: ∼q) @@ -298,6 +299,7 @@ protected def refl.exs (d : ∀ x, [φ/[&x]] ⊩ (φ/[&x])ᴺ) : [∃⁰ φ] ⊩ (Derivation.cast b (by simp [inf_def])) falsumEquiv.symm ⟨ba, by simp [ba, hb]⟩ +set_option backward.isDefEq.respectTransparency false in protected def refl : (φ : Proposition L) → [φ] ⊩ φᴺ | ⊤ => implyEquiv.symm fun q sqp dφ ↦ dφ | ⊥ => falsumEquiv.symm ⟨Derivation.verum, by simp⟩ @@ -332,8 +334,8 @@ end Forces /-- Cut elimination theorem of $\mathbf{LK}$. -/ def hauptsatz [L.DecidableEq] {Γ : Sequent L} : ⊢ᴷ Γ → {d : ⊢ᴷ Γ // Derivation.IsCutFree d} := fun d ↦ - let d : 𝗠𝗶𝗻¹ ⊢! ⋀(∼Γ)ᴺ ➝ ⊥ := Entailment.FiniteContext.toDef (Derivation.gödelGentzen d) - let ff : Forces (∼Γ) (⋀(∼Γ)ᴺ ➝ ⊥) := Forces.sound d (∼Γ) + let d : 𝗠𝗶𝗻¹ ⊢! ⋀(∼Γ)ᴺ 🡒 ⊥ := Entailment.FiniteContext.toDef (Derivation.gödelGentzen d) + let ff : Forces (∼Γ) (⋀(∼Γ)ᴺ 🡒 ⊥) := Forces.sound d (∼Γ) let fc : Forces (∼Γ) (⋀(∼Γ)ᴺ) := Forces.conj' fun φ hφ ↦ (Forces.refl φ).monotone (StrongerThan.ofSubset <| List.cons_subset.mpr ⟨hφ, by simp⟩) let b : Forces (∼Γ) ⊥ := ff.modusPonens fc @@ -390,7 +392,7 @@ open Classical · exact ⟨Forces.orEquiv.symm <| .inl hφ⟩ · exact ⟨Forces.orEquiv.symm <| .inr hψ⟩ -lemma imply {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ ➝ ψ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ψ) := by +lemma imply {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ 🡒 ψ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ψ) := by constructor · rintro ⟨b⟩ q ⟨sqp⟩ ⟨bφ⟩ exact ⟨b.implyEquiv _ sqp bφ⟩ @@ -428,7 +430,7 @@ instance : ForcingRelation.PreIntKripke ℙ (· ≥ ·) where monotone hφ _ hpq := hφ.monotone hpq lemma efq {p : ℙ} (h : p ⊩ ⊥) (φ : Propositionᵢ L) : p ⊩ φ := by - have : p ⊩ ⊥ ➝ φ := ⟨Forces.efq φ p⟩ + have : p ⊩ ⊥ 🡒 φ := ⟨Forces.efq φ p⟩ exact imply.mp this p (by simp) h lemma sound_minimal {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢ φ → ℙ ∀⊩ φ := by diff --git a/Foundation/FirstOrder/Hauptsatz.lean b/Foundation/FirstOrder/Hauptsatz.lean index ed13aae24..ed27a02af 100644 --- a/Foundation/FirstOrder/Hauptsatz.lean +++ b/Foundation/FirstOrder/Hauptsatz.lean @@ -451,7 +451,7 @@ open Classical · exact ⟨Forces.orEquiv.symm <| .inl hφ⟩ · exact ⟨Forces.orEquiv.symm <| .inr hψ⟩ -lemma imply {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ ➝ ψ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ψ) := by +lemma imply {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ 🡒 ψ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ψ) := by constructor · rintro ⟨b⟩ q ⟨sqp⟩ ⟨bφ⟩ exact ⟨b.implyEquiv _ sqp bφ⟩ @@ -489,7 +489,7 @@ instance : ForcingRelation.PreIntKripke ℙ (· ≥ ·) where monotone hφ _ hpq := hφ.monotone hpq lemma efq {p : ℙ} (h : p ⊩ ⊥) (φ : Propositionᵢ L) : p ⊩ φ := by - have : p ⊩ ⊥ ➝ φ := ⟨Forces.efq φ p⟩ + have : p ⊩ ⊥ 🡒 φ := ⟨Forces.efq φ p⟩ exact imply.mp this p (by simp) h lemma sound_minimal {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢ φ → ℙ ∀⊩ φ := by @@ -553,7 +553,7 @@ scoped prefix:max "♯" => hValue @[simp] lemma hValue_falsum : ♯(⊥ : Propositionᵢ L) = ⊥ := by ext p; simp [hValue, IsForced.falsum, p.prop] -@[simp] lemma hValue_imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ ➝ ψ) = (♯φ ⇨ ♯ψ) := by +@[simp] lemma hValue_imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ 🡒 ψ) = (♯φ ⇨ ♯ψ) := by ext p suffices (∀ q ≤ p.val, q ⊩ φ → q ⊩ ψ) ↔ ∀ q ≤ p, q.val ⊩ φ → q.val ⊩ ψ by simpa [IsForced.imply, LowerSet.mem_himp_iff] diff --git a/Foundation/FirstOrder/Intuitionistic/Deduction.lean b/Foundation/FirstOrder/Intuitionistic/Deduction.lean index 065091726..8d5d193be 100644 --- a/Foundation/FirstOrder/Intuitionistic/Deduction.lean +++ b/Foundation/FirstOrder/Intuitionistic/Deduction.lean @@ -14,6 +14,8 @@ open Semiformulaᵢ variable {L : Language.{u}} {T : Theory L} +abbrev Schemaᵢ (L : Language) := Set (Propositionᵢ L) + structure Hilbertᵢ (L : Language) where axiomSet : Set (Propositionᵢ L) rewrite_closed {φ : Propositionᵢ L} : φ ∈ axiomSet → ∀ f : ℕ → SyntacticTerm L, Rew.rewrite f ▹ φ ∈ axiomSet diff --git a/Foundation/FirstOrder/Skolemization/Hull.lean b/Foundation/FirstOrder/Skolemization/Hull.lean index 253779cfb..5d5867845 100644 --- a/Foundation/FirstOrder/Skolemization/Hull.lean +++ b/Foundation/FirstOrder/Skolemization/Hull.lean @@ -26,18 +26,18 @@ variable (L : Language.{u}) variable (M : Type v) [Nonempty M] [𝓼 : Structure L M] noncomputable instance skolem : Structure L.skolemFunction₁ M where - func _ φ v := Classical.epsilon fun z ↦ Semiformula.Evalb 𝓼 (z :> v) φ + func _ φ v := Classical.epsilon fun z ↦ φ.Evalb M (z :> v) rel _ r _ := PEmpty.elim r variable {L M} @[simp] lemma val_skolem_func (φ : Semisentence L (k + 1)) : - (skolem L M).func φ.skolem₁ v = Classical.epsilon fun z ↦ φ.Evalb 𝓼 (z :> v) := rfl + (skolem L M).func φ.skolem₁ v = Classical.epsilon fun z ↦ φ.Evalb M (z :> v) := rfl variable (L) /-- The Skolem hull of subset of structure. -/ -def SkolemHull (s : Set M) : Set M := Set.range fun t : Term L.skolemFunction₁ s ↦ t.valm M ![] (↑) +def SkolemHull (s : Set M) : Set M := Set.range fun t : Term L.skolemFunction₁ s ↦ t.val ![] (↑) variable (M) @@ -52,14 +52,14 @@ open Semiformula variable {s : Set M} lemma mem_iff : - x ∈ SkolemHull L s ↔ ∃ t : Term L.skolemFunction₁ s, t.valm M ![] (↑) = x := by + x ∈ SkolemHull L s ↔ ∃ t : Term L.skolemFunction₁ s, t.val ![] (↑) = x := by simp [SkolemHull] -@[simp] lemma val_mem (t : Term L.skolemFunction₁ s) : t.valm M ![] (↑) ∈ SkolemHull L s := by simp [SkolemHull] +@[simp] lemma val_mem (t : Term L.skolemFunction₁ s) : t.val ![] (↑) ∈ SkolemHull L s := by simp [SkolemHull] lemma subset : s ⊆ SkolemHull L s := fun x hx ↦ by let t : Term L.skolemFunction₁ s := &⟨x, hx⟩ - have : x = t.valm M ![] (↑) := by simp [t] + have : x = t.val ![] (↑) := by simp [t] simp [this] lemma closed {v : Fin k → M} (hv : ∀ i, v i ∈ SkolemHull L s) @@ -67,9 +67,9 @@ lemma closed {v : Fin k → M} (hv : ∀ i, v i ∈ SkolemHull L s) ∃ z ∈ SkolemHull L s, M ⊧/(z :> v) φ := by choose u hu using fun i ↦ mem_iff.mp (hv i) let t : Term L.skolemFunction₁ s := .func φ.skolem₁ u - refine ⟨t.valm M ![] (↑), by simp, ?_⟩ + refine ⟨t.val ![] (↑), by simp, ?_⟩ suffices M ⊧/((Classical.epsilon fun z ↦ M ⊧/(z :> v) φ) :> v) φ by - simpa [t, Semiterm.val_func, hu] + simpa [t, Semiterm.val_func, Function.comp_def, hu] exact Classical.epsilon_spec H variable [L.Eq] [Structure.Eq L M] @@ -78,7 +78,7 @@ lemma closed_func {v : Fin k → M} (hv : ∀ i, v i ∈ SkolemHull L s) {f : L.Func k} : Structure.func f v ∈ SkolemHull L s := by have : ∃ z ∈ SkolemHull L s, M ⊧/(z :> v) “#0 = !!(Semiterm.func f fun i ↦ #i.succ)” := closed hv (φ := “#0 = !!(Semiterm.func f fun i ↦ #i.succ)”) - (by simp [Semiterm.val_func]) + (by simp [Semiterm.val_func]; simp [Function.comp_def]) rcases this with ⟨z, hz, e⟩ have : z = func f v := by simpa [Semiterm.val_func] using e rcases this; assumption @@ -107,21 +107,21 @@ variable {𝓼 s} (str 𝓼 s).rel R v ↔ 𝓼.rel R fun i ↦ (v i : M) := by rfl @[simp] lemma str_val (t : Semiterm L ξ n) (b : Fin n → SkolemHull L s) (f : ξ → SkolemHull L s) : - (t.val (M := SkolemHull L s) (str 𝓼 s) b f : M) = t.val 𝓼 (b ·) (f ·) := + (t.val (M := SkolemHull L s) (s := str 𝓼 s) b f : M) = t.val (s := 𝓼) (b ·) (f ·) := match t with | #x => by simp | &x => by simp - | .func F v => by simp [Semiterm.val_func, str_val] + | .func F v => by simp [Semiterm.val_func, str_val, Function.comp_def] @[simp] lemma str_eval {φ : Semisentence L n} : (SkolemHull L s) ⊧/b φ ↔ M ⊧/(b ·) φ := match φ with - | .rel R v | .nrel R v => by simp [Semiformula.eval_rel, Semiformula.eval_nrel, Empty.eq_elim] + | .rel R v | .nrel R v => by simp [Semiformula.eval_rel, Semiformula.eval_nrel, Empty.eq_elim, Function.comp_def] | ⊤ | ⊥ => by simp | φ ⋏ ψ | φ ⋎ ψ => by simp [str_eval (φ := φ), str_eval (φ := ψ)] | ∀⁰ φ => by suffices - (∃ x ∈ SkolemHull L s, (∼φ).Evalb 𝓼 (x :> (b ·))) ↔ (∃ x, (∼φ).Evalb 𝓼 (x :> (b ·))) by + (∃ x ∈ SkolemHull L s, (∼φ).Evalb M (x :> (b ·))) ↔ (∃ x, (∼φ).Evalb M (x :> (b ·))) by apply not_iff_not.mp simpa [str_eval (φ := φ), Matrix.comp_vecCons'] constructor @@ -131,7 +131,7 @@ variable {𝓼 s} exact closed (s := s) (by simp) h | ∃⁰ φ => by suffices - (∃ x ∈ SkolemHull L s, φ.Evalb 𝓼 (x :> (b ·))) ↔ (∃ x, φ.Evalb 𝓼 (x :> (b ·))) by + (∃ x ∈ SkolemHull L s, φ.Evalb M (x :> (b ·))) ↔ (∃ x, φ.Evalb M (x :> (b ·))) by simpa [str_eval (φ := φ), Matrix.comp_vecCons'] constructor · rintro ⟨x, _, H⟩ diff --git a/Foundation/Modal/VanBentham/StandardTranslation.lean b/Foundation/Modal/VanBentham/StandardTranslation.lean index 41ce8bf32..a5a5fdc2a 100644 --- a/Foundation/Modal/VanBentham/StandardTranslation.lean +++ b/Foundation/Modal/VanBentham/StandardTranslation.lean @@ -69,7 +69,6 @@ def standardTranslation : NNFormula ℕ → FirstOrder.Semisentence 𝓛𝓕 1 postfix:max "¹" => standardTranslation - namespace Kripke.FirstOrder open FirstOrder.Frame (forces) @@ -93,9 +92,7 @@ lemma correspondence_satisfies : x ⊧ φ ↔ M ⊧/![x] φ¹ := by induction φ using NNFormula.rec' generalizing x with | hBox φ ihφ => suffices x ⊧ □φ ↔ ∀ y, x ≺ y → M ⊧/![y] (φ¹) by - simp [standardTranslation]; - convert this; - simp; + simpa [standardTranslation] constructor; . intro h y Rxy; exact ihφ.mp $ h y Rxy; @@ -103,9 +100,7 @@ lemma correspondence_satisfies : x ⊧ φ ↔ M ⊧/![x] φ¹ := by exact ihφ.mpr $ h y Rxy; | hDia φ ihφ => suffices x ⊧ ◇φ ↔ ∃ y, x ≺ y ∧ M ⊧/![y] (φ¹) by - simp [standardTranslation]; - convert this; - simp; + simpa [standardTranslation] constructor; . rintro ⟨y, Rxy, hy⟩; use y; @@ -120,7 +115,7 @@ lemma correspondence_satisfies : x ⊧ φ ↔ M ⊧/![x] φ¹ := by | _ => simp_all [standardTranslation]; /-- BdRV Prop 2.47 (ii) -/ -lemma correspondence_validOnModel : M ⊧ φ ↔ M ⊧ₘ ∀⁰ φ¹ := by +lemma correspondence_validOnModel : M ⊧ φ ↔ M↓[𝓛𝓕] ⊧ ∀⁰ φ¹ := by suffices M ⊧ φ ↔ ∀ x : M.World, M ⊧/![x] φ¹ by simpa [FirstOrder.models_iff]; constructor; . intro h x; apply correspondence_satisfies.mp $ h x; diff --git a/Foundation/Propositional/Decidable.lean b/Foundation/Propositional/Decidable.lean deleted file mode 100644 index bb42611df..000000000 --- a/Foundation/Propositional/Decidable.lean +++ /dev/null @@ -1,428 +0,0 @@ -module - -public import Foundation.Propositional.Boolean.Tait -public import Mathlib.Algebra.Order.BigOperators.Group.List - -@[expose] public section - -namespace LO.Propositional - -variable {α : Type*} - -namespace NNFormula - -@[simp] lemma ne_neg (φ : NNFormula α) : ∼φ ≠ φ := by - induction φ using NNFormula.rec' <;> simp - -inductive IsAtomic : NNFormula α → Prop - | atom (a : α) : IsAtomic (.atom a) - | natom (a : α) : IsAtomic (.natom a) - -attribute [simp] IsAtomic.atom IsAtomic.natom - -@[simp] lemma IsAtomic.not_cons_verum : ¬IsAtomic (⊤ : NNFormula α) := by rintro ⟨⟩ -@[simp] lemma IsAtomic.not_cons_falsum : ¬IsAtomic (⊥ : NNFormula α) := by rintro ⟨⟩ -@[simp] lemma IsAtomic.not_cons_and {φ ψ : NNFormula α} : ¬IsAtomic (φ ⋏ ψ) := by rintro ⟨⟩ -@[simp] lemma IsAtomic.not_cons_or {φ ψ : NNFormula α} : ¬IsAtomic (φ ⋎ ψ) := by rintro ⟨⟩ - -instance : DecidablePred (IsAtomic (α := α)) := fun φ ↦ - match φ with - | .atom a => .isTrue (by simp) - | .natom a => .isTrue (by simp) - | ⊤ => .isFalse (by simp) - | ⊥ => .isFalse (by simp) - | _ ⋏ _ => .isFalse (by simp) - | _ ⋎ _ => .isFalse (by simp) - -def weight : NNFormula α → ℕ -| atom _ => 0 -| natom _ => 0 -| ⊤ => 1 -| ⊥ => 1 -| φ ⋏ ψ => φ.weight + ψ.weight + 1 -| φ ⋎ ψ => φ.weight + ψ.weight + 1 - -@[simp] lemma weight_atom (a : α) : complexity (atom a) = 0 := rfl -@[simp] lemma weight_natom (a : α) : complexity (natom a) = 0 := rfl -@[simp] lemma weight_verum : weight (⊤ : NNFormula α) = 1 := rfl -@[simp] lemma weight_falsum : weight (⊥ : NNFormula α) = 1 := rfl -@[simp] lemma weight_and (φ ψ : NNFormula α) : weight (φ ⋏ ψ) = φ.weight + ψ.weight + 1 := rfl -@[simp] lemma weight_or (φ ψ : NNFormula α) : weight (φ ⋎ ψ) = φ.weight + ψ.weight + 1 := rfl - -end NNFormula - -variable {Γ Δ : Sequent α} - -namespace Sequent - -def weight (Γ : Sequent α) : ℕ := (Γ.map NNFormula.weight).sum - -@[simp] lemma weight_nil : weight ([] : Sequent α) = 0 := rfl - -@[simp] lemma weight_cons (φ) (Γ : Sequent α) : weight (φ :: Γ) = φ.weight + Γ.weight := rfl - -@[simp] lemma weight_append (Γ Δ : Sequent α) : weight (Γ ++ Δ) = Γ.weight + Δ.weight := by - unfold weight; simp - -lemma weight_le_weight_of_mem {φ : NNFormula α} {Γ : Sequent α} (h : φ ∈ Γ) : φ.weight ≤ Γ.weight := - List.le_sum_of_mem (List.mem_map_of_mem h) - -lemma weight_remove [DecidableEq α] (Γ : Sequent α) (φ) : - weight (Γ.remove φ) = Γ.weight - Γ.count φ * φ.weight := by - suffices weight (Γ.remove φ) + Γ.count φ * φ.weight = Γ.weight from Nat.eq_sub_of_add_eq this - induction Γ - case nil => simp - case cons ψ Γ ih => - by_cases e : φ = ψ - · rcases e - simp [add_mul, ←add_assoc, add_comm φ.weight, ih] - · simp [Γ.remove_cons_of_ne (Ne.symm e), add_assoc, ih, List.count_cons_of_ne (Ne.symm e)] - -lemma weight_remove_le_of_mem [DecidableEq α] {φ} {Γ : Sequent α} (h : φ ∈ Γ) : - weight (Γ.remove φ) ≤ Γ.weight - φ.weight := calc - weight (Γ.remove φ) = Γ.weight - Γ.count φ * φ.weight := weight_remove Γ φ - _ ≤ Γ.weight - φ.weight := - Nat.sub_le_sub_left (Nat.le_mul_of_pos_left φ.weight (List.count_pos_iff.mpr h)) Γ.weight - -def IsAtomic (Γ : Sequent α) : Prop := ∀ φ ∈ Γ, φ.IsAtomic - -@[simp] lemma IsAtomic.nil : IsAtomic ([] : Sequent α) := by intro _; simp - -instance : DecidablePred (IsAtomic (α := α)) := List.decidableBAll NNFormula.IsAtomic - -@[simp] lemma IsAtomic.cons_atom_iff : IsAtomic (φ :: Γ) ↔ φ.IsAtomic ∧ IsAtomic Γ := by - simp [IsAtomic] - -def chooseNonAtomic (Γ : Sequent α) (H : ¬Γ.IsAtomic) : NNFormula α := - Γ.choose (fun φ ↦ ¬φ.IsAtomic) (by simpa [IsAtomic] using H) - -@[simp] lemma chooseNonAtomic_mem {Γ : Sequent α} (h : ¬Γ.IsAtomic) : Γ.chooseNonAtomic h ∈ Γ := List.choose_mem _ _ _ - -@[simp] lemma chooseNonAtomic_property (Γ : Sequent α) (h : ¬Γ.IsAtomic) : ¬(Γ.chooseNonAtomic h).IsAtomic := - List.choose_property (fun φ : NNFormula α ↦ ¬φ.IsAtomic) _ _ - -end Sequent - -abbrev Sequents (α : Type*) := List (Sequent α) - -namespace Sequents - -def weight (S : Sequents α) : ℕ := (S.map Sequent.weight).max?.casesOn 0 .succ - -variable {S S₁ S₂ : Sequents α} - -@[simp] lemma weight_nil : weight ([] : Sequents α) = 0 := rfl - -@[simp] lemma weight_eq_zero_iff_eq_nil : weight S = 0 ↔ S = [] := by - cases h : (List.map Sequent.weight S).max? <;> simp [weight, h] - · simpa using h - · rintro rfl; simp at h - -lemma weight_eq_succ_iff {S : Sequents α} : - S.weight = n + 1 ↔ ∃ Γ ∈ S, Γ.weight = n ∧ ∀ Δ ∈ S, Δ.weight ≤ n := by - match h : (List.map Sequent.weight S).max? with - | .none => simp [show S = [] by simpa using h] - | .some a => - have : (∃ Γ ∈ S, Γ.weight = a) ∧ ∀ Δ ∈ S, Δ.weight ≤ a := by simpa using List.max?_eq_some_iff'.mp h - rcases this with ⟨⟨Γ, hΓS, rfl⟩, hS⟩ - have : S.weight = Γ.weight + 1 := by simp [Sequents.weight, h] - constructor - · intro e - have : n = Γ.weight := by simp [e] at this; simp_all - rcases this - exact ⟨Γ, by assumption, rfl, hS⟩ - · rintro ⟨Γ', _, rfl, H⟩ - have : Γ.weight ≤ Γ'.weight := H Γ (by assumption) - have : Γ'.weight ≤ Γ.weight := hS Γ' (by assumption) - simp [weight, h]; exact Nat.le_antisymm (by assumption) (by assumption) - -lemma weight_eq_of_mem_max (hm : m ∈ (S.map Sequent.weight).max?) : - S.weight = m + 1 := by simp [weight, show (S.map Sequent.weight).max? = .some m from hm] - -lemma weight_lt_weight_of {Γ} (hΓ : Γ ∈ S₂) (h : ∀ Δ ∈ S₁, Δ.weight < Γ.weight) : S₁.weight < S₂.weight := by - match hS₁ : S₁.weight, hS₂ : S₂.weight with - | _, 0 => rcases weight_eq_zero_iff_eq_nil.mp hS₂; simp_all - | 0, _ + 1 => simp - | n₁ + 1, n₂ + 1 => - rcases weight_eq_succ_iff.mp hS₁ with ⟨Γ₁, hΓS₁, rfl, H₁⟩ - rcases weight_eq_succ_iff.mp hS₂ with ⟨Γ₂, hΓS₂, rfl, H₂⟩ - have : Γ₁.weight < Γ₂.weight := lt_of_lt_of_le (h Γ₁ hΓS₁) (H₂ Γ hΓ) - simpa - -end Sequents - -abbrev Derivations (T : Theory α) (S : Sequents α) := ∀ Γ ∈ S, T ⟹ Γ - -abbrev Derivations! (T : Theory α) (S : Sequents α) : Prop := ∀ Γ ∈ S, T ⟹! Γ - -namespace Derivations - -variable {T : Theory α} {S₁ S₂ : Sequents α} - -def ofSubset (ss : S₁ ⊆ S₂) : Derivations T S₂ → Derivations T S₁ := fun d Γ hΓ ↦ d Γ (ss hΓ) - -def nil : Derivations T [] := fun _ h ↦ False.elim <| by simp at h - -end Derivations - -namespace Derivations! - -@[simp] lemma nil : Derivations! T [] := fun _ h ↦ False.elim <| by simp at h - -end Derivations! - -def Sequent.IsClosed (Γ : Sequent α) : Prop := ∃ φ ∈ Γ, ∼φ ∈ Γ - -lemma Sequent.IsClosed.cons_iff {Γ : Sequent α} : - IsClosed (φ :: Γ) ↔ ∼φ ∈ Γ ∨ Γ.IsClosed := by - simp [IsClosed] - constructor - · rintro (h | ⟨ψ, h, (rfl | hn)⟩) - · simp [*] - · simp [*] - · right; exact ⟨ψ, by simp [*]⟩ - · rintro (h | ⟨ψ, h, hn⟩) - · simp [*] - · right; exact ⟨ψ, h, by simp [*]⟩ - -instance [DecidableEq α] : DecidablePred (Sequent.IsClosed (α := α)) := - List.rec - (.isFalse <| by simp [Sequent.IsClosed]) - fun φ Γ d ↦ - if h : ∼φ ∈ Γ then .isTrue ⟨φ, by simp [h]⟩ else - match d with - | .isFalse hΓ => .isFalse <| by simp [Sequent.IsClosed.cons_iff, *] - | .isTrue hΓ => .isTrue <| by simp [Sequent.IsClosed.cons_iff, hΓ] - -def Sequent.IsClosed.choose [DecidableEq α] : (Γ : Sequent α) → Γ.IsClosed → {φ // φ ∈ Γ ∧ ∼φ ∈ Γ} - | [], h => False.elim (by rcases h; simp_all) - | φ :: Γ, h => - if hn : ∼φ ∈ Γ then ⟨φ, by simp [hn]⟩ else - have : IsClosed Γ := by simpa [Sequent.IsClosed.cons_iff, hn] using h - let ⟨ψ, hψ⟩ := this.choose - ⟨ψ, by simp [hψ]⟩ - -def Derivation.ofIsClosed [DecidableEq α] {T : Theory α} {Γ : Sequent α} (h : Γ.IsClosed) : T ⟹ Γ := - let ⟨φ, h, hn⟩ := h.choose - em (φ := φ) h hn - -abbrev Sequent.IsOpen (Γ : Sequent α) : Prop := Γ.IsAtomic ∧ ¬Γ.IsClosed - -instance [DecidableEq α] : DecidablePred (Sequent.IsOpen (α := α)) := inferInstance - -lemma Sequent.IsOpen.not_tautology (h : Γ.IsOpen) : ¬Γ.IsTautology := - Sequent.notTautology_iff.mpr ⟨fun a ↦ .atom a ∉ Γ, fun φ hφ ↦ by - rcases show φ.IsAtomic from h.1 φ hφ - case atom a => - simp [hφ] - case natom a => - suffices NNFormula.atom a ∉ Γ by simpa - intro ha - exact h.2 ⟨.atom a, by simp [*]⟩⟩ - -def Sequents.IsClosed (S : Sequents α) : Prop := ∀ Γ ∈ S, Γ.IsClosed - -instance [DecidableEq α] : DecidablePred (Sequents.IsClosed (α := α)) := List.decidableBAll Sequent.IsClosed - -def Sequent.reduction [DecidableEq α] {Γ : Sequent α} (h : ¬Γ.IsAtomic) : Sequents α := - match H : Γ.chooseNonAtomic h with - | .atom a => by have := Γ.chooseNonAtomic_property h; simp_all - | .natom a => by have := Γ.chooseNonAtomic_property h; simp_all - | ⊤ => [] - | ⊥ => [Γ.remove ⊥] - | φ ⋏ ψ => [Γ.remove (φ ⋏ ψ) |>.concat φ, Γ.remove (φ ⋏ ψ) |>.concat ψ] - | φ ⋎ ψ => [Γ.remove (φ ⋎ ψ) |>.concat φ |>.concat ψ] - -section - -variable [DecidableEq α] - -lemma Sequent.reduction_verum {h : ¬Γ.IsAtomic} (H : Γ.chooseNonAtomic h = ⊤) : Γ.reduction h = [] := by - unfold Sequent.reduction; split <;> simp_all - -lemma Sequent.reduction_falsum {h : ¬Γ.IsAtomic} (H : Γ.chooseNonAtomic h = ⊥) : Γ.reduction h = [Γ.remove ⊥] := by - unfold Sequent.reduction; split <;> simp_all - -lemma Sequent.reduction_and {h : ¬Γ.IsAtomic} (H : Γ.chooseNonAtomic h = φ ⋏ ψ) : - Γ.reduction h = [Γ.remove (φ ⋏ ψ) |>.concat φ, Γ.remove (φ ⋏ ψ) |>.concat ψ] := by - unfold Sequent.reduction; split <;> simp_all - · rcases H; simp - -lemma Sequent.reduction_or {h : ¬Γ.IsAtomic} (H : Γ.chooseNonAtomic h = φ ⋎ ψ) : - Γ.reduction h = [Γ.remove (φ ⋎ ψ) |>.concat φ |>.concat ψ] := by - unfold Sequent.reduction; split <;> simp_all - · rcases H; simp - -lemma Sequent.weight_lt_weight_of_mem_reduction {h : ¬Γ.IsAtomic} : Δ ∈ Γ.reduction h → Δ.weight < Γ.weight := by - match H : Γ.chooseNonAtomic h with - | .atom a => have := Γ.chooseNonAtomic_property h; simp_all - | .natom a => have := Γ.chooseNonAtomic_property h; simp_all - | ⊤ => simp [Sequent.reduction_verum H] - | ⊥ => - suffices weight (List.remove ⊥ Γ) < Γ.weight by simp [Sequent.reduction_falsum H]; rintro rfl; exact this - have : ⊥ ∈ Γ := by simpa [*] using Sequent.chooseNonAtomic_mem h - calc weight (List.remove ⊥ Γ) ≤ Γ.weight - NNFormula.weight ⊥ := Sequent.weight_remove_le_of_mem this - _ < Γ.weight := Nat.sub_lt_of_pos_le (by simp) (weight_le_weight_of_mem this) - | φ ⋏ ψ => - have : φ ⋏ ψ ∈ Γ := by simpa [*] using Sequent.chooseNonAtomic_mem h - suffices - weight (List.remove (φ ⋏ ψ) Γ ++ [φ]) < Γ.weight ∧ - weight (List.remove (φ ⋏ ψ) Γ ++ [ψ]) < Γ.weight by - simp [Sequent.reduction_and H]; rintro (rfl | rfl); { exact this.1 }; { exact this.2 } - constructor - · calc - weight (List.remove (φ ⋏ ψ) Γ ++ [φ]) = weight (List.remove (φ ⋏ ψ) Γ) + φ.weight := by simp - _ ≤ Γ.weight - (φ ⋏ ψ).weight + φ.weight := - (add_le_add_iff_right _).mpr (Sequent.weight_remove_le_of_mem this) - _ = Γ.weight + φ.weight - (φ ⋏ ψ).weight := - Eq.symm <| Nat.sub_add_comm <| weight_le_weight_of_mem this - _ < Γ.weight := - Nat.sub_lt_left_of_lt_add (Nat.le_add_right_of_le (weight_le_weight_of_mem this)) (by simp; omega) - · calc - weight (List.remove (φ ⋏ ψ) Γ ++ [ψ]) = weight (List.remove (φ ⋏ ψ) Γ) + ψ.weight := by simp - _ ≤ Γ.weight - (φ ⋏ ψ).weight + ψ.weight := - (add_le_add_iff_right _).mpr (Sequent.weight_remove_le_of_mem this) - _ = Γ.weight + ψ.weight - (φ ⋏ ψ).weight := - Eq.symm <| Nat.sub_add_comm <| weight_le_weight_of_mem this - _ < Γ.weight := - Nat.sub_lt_left_of_lt_add (Nat.le_add_right_of_le (weight_le_weight_of_mem this)) (by simp; omega) - | φ ⋎ ψ => - have : φ ⋎ ψ ∈ Γ := by simpa [*] using Sequent.chooseNonAtomic_mem h - suffices weight (List.remove (φ ⋎ ψ) Γ ++ [φ, ψ]) < Γ.weight by simp [Sequent.reduction_or H]; rintro rfl; exact this - calc weight (List.remove (φ ⋎ ψ) Γ ++ [φ, ψ]) = weight (List.remove (φ ⋎ ψ) Γ) + (φ.weight + ψ.weight) := by simp - _ ≤ Γ.weight - (φ ⋎ ψ).weight + (φ.weight + ψ.weight) := - (add_le_add_iff_right _).mpr (Sequent.weight_remove_le_of_mem this) - _ = Γ.weight + (φ.weight + ψ.weight) - (φ ⋎ ψ).weight := - Eq.symm <| Nat.sub_add_comm <| weight_le_weight_of_mem this - _ < Γ.weight := - Nat.sub_lt_left_of_lt_add (Nat.le_add_right_of_le (weight_le_weight_of_mem this)) (by simp; omega) - -def Derivation.ofReduction {Γ : Sequent α} {hΓ : ¬Γ.IsAtomic} - (d : Derivations T (Γ.reduction hΓ)) : T ⟹ Γ := - match H : Γ.chooseNonAtomic hΓ with - | .atom a => by have := Γ.chooseNonAtomic_property hΓ; simp_all - | .natom a => by have := Γ.chooseNonAtomic_property hΓ; simp_all - | ⊤ => verum' (by simpa [H] using Sequent.chooseNonAtomic_mem hΓ) - | ⊥ => - have : T ⟹ Γ.remove ⊥ := d (Γ.remove ⊥) (by simp [Sequent.reduction_falsum H]) - this.wk (by simp) - | φ ⋏ ψ => - have : T ⟹ (Γ.remove (φ ⋏ ψ)).concat φ := d _ (by simp [Sequent.reduction_and H]) - have dφ : T ⟹ φ :: Γ.remove (φ ⋏ ψ) := this.wk (by simp) - have : T ⟹ (Γ.remove (φ ⋏ ψ)).concat ψ := d _ (by simp [Sequent.reduction_and H]) - have dψ : T ⟹ ψ :: Γ.remove (φ ⋏ ψ) := this.wk (by simp) - dφ.and dψ |>.wk (by simpa [H] using Sequent.chooseNonAtomic_mem hΓ) - | φ ⋎ ψ => - have : T ⟹ ((Γ.remove (φ ⋎ ψ)).concat φ).concat ψ := d _ (by simp [Sequent.reduction_or H]) - have : T ⟹ φ :: ψ :: Γ.remove (φ ⋎ ψ) := this.wk <| by simp - this.or |>.wk (by simpa [H] using Sequent.chooseNonAtomic_mem hΓ) - -lemma Derivation.toReduction {Γ : Sequent α} (hΓ : ¬Γ.IsAtomic) - (d : T ⟹! Γ) : Derivations! T (Γ.reduction hΓ) := by - match H : Γ.chooseNonAtomic hΓ with - | .atom a => have := Γ.chooseNonAtomic_property hΓ; simp_all - | .natom a => have := Γ.chooseNonAtomic_property hΓ; simp_all - | ⊤ => simpa [Sequent.reduction_verum H] using Derivations!.nil - | ⊥ => - suffices T ⟹! List.remove ⊥ Γ by - simp only [Sequent.reduction_falsum H] - intro Γ; simp; rintro rfl; assumption - exact ⟨Tait.cutFalsum <| (d.get).wk <| by simp⟩ - | φ ⋏ ψ => - suffices T ⟹! φ :: List.remove (φ ⋏ ψ) Γ ∧ T ⟹! ψ :: List.remove (φ ⋏ ψ) Γ by - simp [Sequent.reduction_and H] - intro Γ; simp - rintro (rfl | rfl); { exact Tait.wk! this.1 (by simp) }; { exact Tait.wk! this.2 (by simp) } - have : T ⟹! φ ⋏ ψ :: List.remove (φ ⋏ ψ) Γ := Tait.wk! d - constructor - · exact Tait.modusPonens! Entailment.and₁! this - · exact Tait.modusPonens! Entailment.and₂! this - | φ ⋎ ψ => - suffices T ⟹! φ :: ψ :: List.remove (φ ⋎ ψ) Γ by - simp [Sequent.reduction_or H] - intro Γ; simp; rintro rfl - exact Tait.wk! (by assumption) - exact ⟨Tait.orReversion <| (d.get).wk <| by simp⟩ - -end - -abbrev Sequents.Refuted (S : Sequents α) : Prop := ∃ Γ ∈ S, Γ.IsOpen - -lemma Sequents.Refuted.not_iff {S : Sequents α} : ¬S.Refuted ↔ ∀ Γ ∈ S, Γ.IsAtomic → Γ.IsClosed := by - simp [Refuted] - -instance [DecidableEq α] : DecidablePred (Sequents.Refuted (α := α)) := List.decidableBEx _ - -def Sequents.reduction [DecidableEq α] (S : Sequents α) : Sequents α := - S.flatMap fun Γ ↦ if h : Γ.IsAtomic then [] else Γ.reduction h - -lemma Sequent.reduction_sublist [DecidableEq α] {Γ : Sequent α} (hΓ : ¬Γ.IsAtomic) {S : Sequents α} - (h : Γ ∈ S) : (Γ.reduction hΓ).Sublist S.reduction := - List.sublist_flatten_of_mem <| List.mem_map.mpr ⟨Γ, h, by simp_all⟩ - -def Derivations.ofReduction [DecidableEq α] {S : Sequents α} (hS : ¬S.Refuted) - (d : Derivations T S.reduction) : Derivations T S := fun Γ h ↦ - if hΓ : Γ.IsAtomic then - have : Γ.IsClosed := Sequents.Refuted.not_iff.mp hS Γ h hΓ - Derivation.ofIsClosed this - else - Derivation.ofReduction <| d.ofSubset <| (Sequent.reduction_sublist hΓ h).subset - -lemma Derivations.toReduction [DecidableEq α] {S : Sequents α} - (d : Derivations! T S) : Derivations! T S.reduction := fun Γ h ↦ by - have : ∃ Δ ∈ S, ∃ (h : ¬Δ.IsAtomic), Γ ∈ Sequent.reduction h := by simpa [Sequents.reduction] using h - rcases this with ⟨Δ, hΔS, hΔ, H⟩ - exact Derivation.toReduction hΔ (d Δ hΔS) Γ H - -lemma Sequents.reduction_weight_lt_weight [DecidableEq α] (S : Sequents α) (h : S ≠ []) : S.reduction.weight < S.weight := by - match hS : S.weight with - | 0 => simp at hS; contradiction - | n + 1 => - rcases Sequents.weight_eq_succ_iff.mp hS with ⟨Γ, hΓS, rfl, HΓ⟩ - have : S.reduction.weight < S.weight := - Sequents.weight_lt_weight_of hΓS (S₁ := S.reduction) <| by - intro Δ hΔ - have : ∃ Ξ ∈ S, ∃ (h : ¬Ξ.IsAtomic), Δ ∈ Sequent.reduction h := by simpa [reduction] using hΔ - rcases this with ⟨Ξ, hΞS, hΞ, hΔΞ⟩ - have : Δ.weight < Ξ.weight := Sequent.weight_lt_weight_of_mem_reduction hΔΞ - exact lt_of_lt_of_le this (HΓ Ξ hΞS) - simpa [hS] using this - -inductive Derivations.Dec : Sequents α → Type _ where - | provable : Derivations ∅ S → Derivations.Dec S - | unprovable (Γ : Sequent α) : Γ ∈ S → ¬Sequent.IsTautology Γ → Derivations.Dec S - -def Derivations.Dec.ofReduction [DecidableEq α] {S : Sequents α} (hS : ¬S.Refuted) : Derivations.Dec S.reduction → Derivations.Dec S - | .provable d => .provable <| LO.Propositional.Derivations.ofReduction hS d - | .unprovable Γ hΓSr hΓNT => - let Δ := S.choose (fun Δ ↦ ∃ h : ¬Δ.IsAtomic, Γ ∈ Sequent.reduction h) (by simpa [Sequents.reduction] using hΓSr) - .unprovable Δ (S.choose_mem _ _) (by - intro hΔT - have : ∃ h : ¬Δ.IsAtomic, Γ ∈ Sequent.reduction h := S.choose_property (fun Δ ↦ ∃ h : ¬Δ.IsAtomic, Γ ∈ Sequent.reduction h) _ - rcases this with ⟨hΔ, hΓr⟩ - have : Γ.IsTautology := Derivation.toReduction hΔ hΔT Γ hΓr - contradiction) - -def Sequents.dec [DecidableEq α] : (S : Sequents α) → Derivations.Dec S := fun S ↦ - if hS : S = [] then - .provable (by rw [hS]; exact Derivations.nil) - else if h : S.Refuted then - let ⟨Γ, hΓS, hΓ⟩ := S.chooseX Sequent.IsOpen h - .unprovable Γ hΓS (Sequent.IsOpen.not_tautology hΓ) - else - S.reduction.dec.ofReduction h - termination_by S => S.weight - decreasing_by - exact S.reduction_weight_lt_weight hS - -instance [DecidableEq α] : DecidablePred fun Γ : Sequent α ↦ Γ.IsTautology := fun Γ ↦ - match Sequents.dec [Γ] with - | .provable d => .isTrue ⟨d Γ (by simp)⟩ - | .unprovable Δ hΔ hΔNT => .isFalse <| by - have : Δ = Γ := by simpa using hΔ - rcases this; assumption - -instance [DecidableEq α] : DecidablePred fun φ : NNFormula α ↦ φ.IsTautology := fun _ ↦ inferInstance - -end LO.Propositional -end diff --git a/Foundation/Propositional/Hilbert/F/Basic.lean b/Foundation/Propositional/Hilbert/F/Basic.lean index 4573a76bd..e94725cba 100644 --- a/Foundation/Propositional/Hilbert/F/Basic.lean +++ b/Foundation/Propositional/Hilbert/F/Basic.lean @@ -161,7 +161,7 @@ def ofProofSchema (h : H₂ ⊢!* H₁.schema) : H₁ ⊢! φ → H₂ ⊢! φ | andIR h₁ h₂ => andIR (ofProofSchema h h₁) (ofProofSchema h h₂) lemma of_proof_schema (h : H₂ ⊢* H₁.schema) : H₁ ⊢ φ → H₂ ⊢ φ := - λ ⟨hφ⟩ => ⟨ofProofSchema (h · |>.get) hφ⟩ + λ ⟨hφ⟩ => ⟨ofProofSchema (fun _ hφ ↦ (h hφ).get) hφ⟩ lemma weakerThan_of_provable_schema (h : H₂ ⊢* H₁.schema) : H₁ ⪯ H₂ := Entailment.weakerThan_iff.mpr $ of_proof_schema h diff --git a/Foundation/Propositional/Hilbert/Minimal/Basic.lean b/Foundation/Propositional/Hilbert/Minimal/Basic.lean index 5bd48ed41..1b9e748ad 100644 --- a/Foundation/Propositional/Hilbert/Minimal/Basic.lean +++ b/Foundation/Propositional/Hilbert/Minimal/Basic.lean @@ -133,7 +133,7 @@ def ofProofSchema (h : H₂ ⊢!* H₁.schema) : H₁ ⊢! φ → H₂ ⊢! φ | orIntroR => orIntroR | orElim => orElim -lemma of_proof_schema (h : H₂ ⊢* H₁.schema) : H₁ ⊢ φ → H₂ ⊢ φ := λ ⟨hφ⟩ => ⟨ofProofSchema (h · |>.get) hφ⟩ +lemma of_proof_schema (h : H₂ ⊢* H₁.schema) : H₁ ⊢ φ → H₂ ⊢ φ := λ ⟨hφ⟩ => ⟨ofProofSchema (fun _ hφ ↦ (h hφ).get) hφ⟩ lemma weakerThan_of_provable_schema (h : H₂ ⊢* H₁.schema) : H₁ ⪯ H₂ := Entailment.weakerThan_iff.mpr $ of_proof_schema h diff --git a/Foundation/Propositional/Hilbert/VF/Basic.lean b/Foundation/Propositional/Hilbert/VF/Basic.lean index 36a08722e..2e8175dfd 100644 --- a/Foundation/Propositional/Hilbert/VF/Basic.lean +++ b/Foundation/Propositional/Hilbert/VF/Basic.lean @@ -126,7 +126,7 @@ def ofProofSchema (h : H₂ ⊢!* H₁.schema) : H₁ ⊢! φ → H₂ ⊢! φ | ruleI h₁ h₂ => ruleI (ofProofSchema h h₁) (ofProofSchema h h₂) lemma of_proof_schema (h : H₂ ⊢* H₁.schema) : H₁ ⊢ φ → H₂ ⊢ φ := - λ ⟨hφ⟩ => ⟨ofProofSchema (h · |>.get) hφ⟩ + λ ⟨hφ⟩ => ⟨ofProofSchema (fun _ hφ ↦ (h hφ).get) hφ⟩ lemma weakerThan_of_provable_schema (h : H₂ ⊢* H₁.schema) : H₁ ⪯ H₂ := Entailment.weakerThan_iff.mpr $ of_proof_schema h diff --git a/Foundation/Propositional/Hilbert/WF/Basic.lean b/Foundation/Propositional/Hilbert/WF/Basic.lean index 821ecb209..05f090218 100644 --- a/Foundation/Propositional/Hilbert/WF/Basic.lean +++ b/Foundation/Propositional/Hilbert/WF/Basic.lean @@ -131,7 +131,7 @@ def ofProofSchema (h : H₂ ⊢!* H₁.schema) : H₁ ⊢! φ → H₂ ⊢! φ | ruleE h₁ h₂ => ruleE (ofProofSchema h h₁) (ofProofSchema h h₂) lemma of_proof_schema (h : H₂ ⊢* H₁.schema) : H₁ ⊢ φ → H₂ ⊢ φ := - λ ⟨hφ⟩ => ⟨ofProofSchema (h · |>.get) hφ⟩ + λ ⟨hφ⟩ => ⟨ofProofSchema (fun _ hφ ↦ (h hφ).get) hφ⟩ lemma weakerThan_of_provable_schema (h : H₂ ⊢* H₁.schema) : H₁ ⪯ H₂ := Entailment.weakerThan_iff.mpr $ of_proof_schema h diff --git a/Foundation/Vorspiel/Order/Heyting.lean b/Foundation/Vorspiel/Order/Heyting.lean index 60398d77e..948310be2 100644 --- a/Foundation/Vorspiel/Order/Heyting.lean +++ b/Foundation/Vorspiel/Order/Heyting.lean @@ -7,9 +7,5 @@ public section variable {α : Type*} [Order.Frame α] -/-- https://github.com/leanprover-community/mathlib4/blob/205a0ba54c047cafda226494138ba715ab6bf28c/Mathlib/Order/CompleteBooleanAlgebra.lean#L413-L414-/ -theorem iSup_himp_eq {f : ι → α} : (⨆ x, f x) ⇨ a = ⨅ x, f x ⇨ a := - eq_of_forall_le_iff fun b => by simp [inf_iSup_eq] - theorem compl_iSup' {a : ι → α} : (⨆ i, a i)ᶜ = ⨅ i, (a i)ᶜ := by simpa using iSup_himp_eq (f := a) (a := ⊥) From 46d2bf5c3c60e15ce70b8b39e969dce19d4de7d6 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Mon, 6 Apr 2026 06:06:23 +0900 Subject: [PATCH 33/61] fix Vorspiel --- Foundation.lean | 7 +- Foundation/FirstOrder/Kripke/Basic.lean | 2 +- Foundation/Modal/Algebra/Basic.lean | 2 +- .../Propositional/Heyting/Semantics.lean | 4 +- Foundation/Vorspiel/Order.lean | 67 ------------------- .../{Preorder.lean => Order/Dense.lean} | 1 - Foundation/Vorspiel/Order/Heyting.lean | 31 +++++++++ 7 files changed, 40 insertions(+), 74 deletions(-) delete mode 100644 Foundation/Vorspiel/Order.lean rename Foundation/Vorspiel/{Preorder.lean => Order/Dense.lean} (98%) diff --git a/Foundation.lean b/Foundation.lean index 7f69277f3..88e505493 100644 --- a/Foundation.lean +++ b/Foundation.lean @@ -512,9 +512,12 @@ public import Foundation.Vorspiel.Nat.Basic public import Foundation.Vorspiel.Nat.Matrix public import Foundation.Vorspiel.NotationClass public import Foundation.Vorspiel.Option -public import Foundation.Vorspiel.Order +public import Foundation.Vorspiel.Order.Dense +public import Foundation.Vorspiel.Order.Heyting +public import Foundation.Vorspiel.Order.Ideal +public import Foundation.Vorspiel.Order.LowerSet +public import Foundation.Vorspiel.Order.Regular public import Foundation.Vorspiel.Part -public import Foundation.Vorspiel.Preorder public import Foundation.Vorspiel.Quotient public import Foundation.Vorspiel.Rel.Basic public import Foundation.Vorspiel.Rel.CWF diff --git a/Foundation/FirstOrder/Kripke/Basic.lean b/Foundation/FirstOrder/Kripke/Basic.lean index bea1e0618..d76f33ccb 100644 --- a/Foundation/FirstOrder/Kripke/Basic.lean +++ b/Foundation/FirstOrder/Kripke/Basic.lean @@ -3,7 +3,7 @@ module public import Foundation.FirstOrder.Basic public import Foundation.Syntax.Predicate.Relational public import Foundation.Logic.ForcingRelation -public import Foundation.Vorspiel.Preorder +public import Foundation.Vorspiel.Order.Dense @[expose] public section namespace LO.FirstOrder diff --git a/Foundation/Modal/Algebra/Basic.lean b/Foundation/Modal/Algebra/Basic.lean index 33a1f197d..55a3b01db 100644 --- a/Foundation/Modal/Algebra/Basic.lean +++ b/Foundation/Modal/Algebra/Basic.lean @@ -2,7 +2,7 @@ module public import Foundation.Modal.Kripke.Logic.K public import Foundation.Semantics.Algebra.Modal.Basic -public import Foundation.Vorspiel.Order +public import Foundation.Vorspiel.Order.Heyting @[expose] public section diff --git a/Foundation/Propositional/Heyting/Semantics.lean b/Foundation/Propositional/Heyting/Semantics.lean index b46526d1b..c5612dcc8 100644 --- a/Foundation/Propositional/Heyting/Semantics.lean +++ b/Foundation/Propositional/Heyting/Semantics.lean @@ -2,7 +2,7 @@ module public import Foundation.Propositional.Hilbert.Minimal.Basic public import Foundation.Logic.LindenbaumAlgebra -public import Foundation.Vorspiel.Order +public import Foundation.Vorspiel.Order.Heyting @[expose] public section @@ -79,7 +79,7 @@ lemma val_def' {ℍ : HeytingSemantics α} {φ : Formula α} : ℍ ⊧ φ ↔ ( instance : Semantics.Top (HeytingSemantics α) := ⟨fun ℍ ↦ by simp [val_def]⟩ -instance : Semantics.Bot (HeytingSemantics α) := ⟨fun ℍ ↦ by simp [Semantics.NotModels, val_def]⟩ +instance : Semantics.Bot (HeytingSemantics α) := ⟨fun ℍ ↦ by simp [val_def]⟩ instance : Semantics.And (HeytingSemantics α) := ⟨fun {ℍ φ ψ} ↦ by simp [val_def]⟩ diff --git a/Foundation/Vorspiel/Order.lean b/Foundation/Vorspiel/Order.lean deleted file mode 100644 index b541e934c..000000000 --- a/Foundation/Vorspiel/Order.lean +++ /dev/null @@ -1,67 +0,0 @@ -module - -public import Mathlib.Tactic.Cases -public import Mathlib.Tactic.TautoSet -public import Mathlib.Algebra.GroupWithZero.Nat -public import Mathlib.Algebra.Order.Group.Nat - -@[expose] -public section - -section - -variable {α : Sort u} (r : α → α → Prop) - -local infix:50 " ≺ " => r - -def IsInfiniteDescendingChain (c : ℕ → α) : Prop := ∀ i, c (i + 1) ≺ c i - -noncomputable def descendingChain (z : α) : ℕ → α - | 0 => z - | (i + 1) => @Classical.epsilon α ⟨z⟩ (fun y => y ≺ descendingChain z i ∧ ¬Acc r y) - -lemma not_acc_iff {x : α} : ¬Acc r x ↔ ∃ y, y ≺ x ∧ ¬Acc r y := - ⟨by contrapose; simp; exact Acc.intro x, by contrapose; simp; rintro ⟨h⟩; assumption⟩ - -@[simp] lemma descending_chain_zero (z : α) : descendingChain r z 0 = z := rfl - -lemma isInfiniteDescendingChain_of_non_acc (z : α) (hz : ¬Acc r z) : - IsInfiniteDescendingChain r (descendingChain r z) := by - have : ∀ i, (i ≠ 0 → descendingChain r z i ≺ descendingChain r z i.pred) ∧ ¬Acc r (descendingChain r z i) := by - intro i; induction' i with i ih - · simpa using hz - · simp [descendingChain] - have : ∃ y, y ≺ (descendingChain r z i) ∧ ¬Acc r y := (not_acc_iff r).mp ih.2 - exact Classical.epsilon_spec this - intro i; simpa using (this (i + 1)).1 - -end - -section HeytingAlgebra - -variable {α : Type*} [HeytingAlgebra α] - -@[simp, grind .] -lemma himp_himp_inf_himp_inf_le (a b c : α) : (a ⇨ b ⇨ c) ⊓ (a ⇨ b) ⊓ a ≤ c := calc - (a ⇨ b ⇨ c) ⊓ (a ⇨ b) ⊓ a = (a ⇨ b ⇨ c) ⊓ b ⊓ a := by simp only [inf_assoc, himp_inf_self] - _ = (a ⇨ b ⇨ c) ⊓ a ⊓ b := by simp only [inf_assoc, inf_comm a b] - _ ≤ (b ⇨ c) ⊓ b := by simp only [himp_inf_self a (b ⇨ c), le_inf_iff] - constructor - · simp only [inf_assoc, inf_le_left] - · exact inf_le_right - _ ≤ c := by simp - -@[simp, grind .] -lemma himp_inf_himp_inf_sup_le (a b c : α) : (a ⇨ c) ⊓ (b ⇨ c) ⊓ (a ⊔ b) ≤ c := by - have ha : a ≤ (a ⇨ c) ⊓ (b ⇨ c) ⇨ c := by - simp only [le_himp_iff, ← inf_assoc, inf_himp] - refine inf_le_of_left_le (by simp) - have hb : b ≤ (a ⇨ c) ⊓ (b ⇨ c) ⇨ c := by - simp only [le_himp_iff, inf_comm (a ⇨ c) (b ⇨ c), ← inf_assoc, inf_himp] - refine inf_le_of_left_le (by simp) - have : a ⊔ b ≤ (a ⇨ c) ⊓ (b ⇨ c) ⇨ c := sup_le_iff.mpr ⟨ha, hb⟩ - simpa only [GeneralizedHeytingAlgebra.le_himp_iff, inf_comm (a ⊔ b)] using this - -end HeytingAlgebra - -end diff --git a/Foundation/Vorspiel/Preorder.lean b/Foundation/Vorspiel/Order/Dense.lean similarity index 98% rename from Foundation/Vorspiel/Preorder.lean rename to Foundation/Vorspiel/Order/Dense.lean index b272be346..2ae08b808 100644 --- a/Foundation/Vorspiel/Preorder.lean +++ b/Foundation/Vorspiel/Order/Dense.lean @@ -1,7 +1,6 @@ module public import Mathlib.Order.PFilter -public import Foundation.Vorspiel.Finset.Card public import Mathlib.Data.Set.Countable @[expose] public section diff --git a/Foundation/Vorspiel/Order/Heyting.lean b/Foundation/Vorspiel/Order/Heyting.lean index 948310be2..70c1f6bcd 100644 --- a/Foundation/Vorspiel/Order/Heyting.lean +++ b/Foundation/Vorspiel/Order/Heyting.lean @@ -5,7 +5,38 @@ public import Mathlib.Order.CompleteBooleanAlgebra public section +section frame + variable {α : Type*} [Order.Frame α] theorem compl_iSup' {a : ι → α} : (⨆ i, a i)ᶜ = ⨅ i, (a i)ᶜ := by simpa using iSup_himp_eq (f := a) (a := ⊥) + +end frame + +section HeytingAlgebra + +variable {α : Type*} [HeytingAlgebra α] + +@[simp, grind .] +lemma himp_himp_inf_himp_inf_le (a b c : α) : (a ⇨ b ⇨ c) ⊓ (a ⇨ b) ⊓ a ≤ c := calc + (a ⇨ b ⇨ c) ⊓ (a ⇨ b) ⊓ a = (a ⇨ b ⇨ c) ⊓ b ⊓ a := by simp only [inf_assoc, himp_inf_self] + _ = (a ⇨ b ⇨ c) ⊓ a ⊓ b := by simp only [inf_assoc, inf_comm a b] + _ ≤ (b ⇨ c) ⊓ b := by simp only [himp_inf_self a (b ⇨ c), le_inf_iff] + constructor + · simp only [inf_assoc, inf_le_left] + · exact inf_le_right + _ ≤ c := by simp + +@[simp, grind .] +lemma himp_inf_himp_inf_sup_le (a b c : α) : (a ⇨ c) ⊓ (b ⇨ c) ⊓ (a ⊔ b) ≤ c := by + have ha : a ≤ (a ⇨ c) ⊓ (b ⇨ c) ⇨ c := by + simp only [le_himp_iff, ← inf_assoc, inf_himp] + refine inf_le_of_left_le (by simp) + have hb : b ≤ (a ⇨ c) ⊓ (b ⇨ c) ⇨ c := by + simp only [le_himp_iff, inf_comm (a ⇨ c) (b ⇨ c), ← inf_assoc, inf_himp] + refine inf_le_of_left_le (by simp) + have : a ⊔ b ≤ (a ⇨ c) ⊓ (b ⇨ c) ⇨ c := sup_le_iff.mpr ⟨ha, hb⟩ + simpa only [GeneralizedHeytingAlgebra.le_himp_iff, inf_comm (a ⊔ b)] using this + +end HeytingAlgebra From 2cfe1be255196fa63e505112637be5f0ff1e3986 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Mon, 6 Apr 2026 06:18:55 +0900 Subject: [PATCH 34/61] rename --- Foundation/FirstOrder/Basic/Calculus.lean | 138 +++++++++--------- Foundation/FirstOrder/Basic/CutFree.lean | 32 ++-- Foundation/FirstOrder/Basic/Soundness.lean | 4 +- .../Completeness/BooleanValuedModel.lean | 6 +- .../Completeness/CanonicalModel.lean | 22 +-- Foundation/FirstOrder/Hauptsatz.lean | 60 ++++---- Foundation/FirstOrder/Kripke/WeakForcing.lean | 4 +- .../NegationTranslation/GoedelGentzen.lean | 2 +- Foundation/Propositional/Tait/Calculus.lean | 26 ++-- Foundation/SecondOrder/Derivation.lean | 6 +- 10 files changed, 150 insertions(+), 150 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index c8ad8a760..c4f8f62b7 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -47,13 +47,13 @@ inductive Derivation : Sequent L → Type _ | all : Derivation (φ.free :: Γ⁺) → Derivation ((∀⁰ φ) :: Γ) | exs : Derivation (φ/[t] :: Γ) → Derivation ((∃⁰ φ) :: Γ) -scoped prefix:45 "⊢ᴷ " => Derivation +prefix:45 "⊢ᴸᴷ¹ " => Derivation namespace Derivation open Rewriting LawfulSyntacticRewriting -def height {Δ : Sequent L} : ⊢ᴷ Δ → ℕ +def height {Δ : Sequent L} : ⊢ᴸᴷ¹ Δ → ℕ | identity _ _ => 0 | cut dp dn => max dp.height dn.height + 1 | wk d _ => d.height + 1 @@ -68,59 +68,59 @@ section height @[simp] lemma height_id {k} {r : L.Rel k} {v} : height (identity r v) = 0 := rfl -@[simp] lemma height_cut {φ} (dp : ⊢ᴷ φ :: Δ) (dn : ⊢ᴷ (∼φ) :: Δ) : +@[simp] lemma height_cut {φ} (dp : ⊢ᴸᴷ¹ φ :: Δ) (dn : ⊢ᴸᴷ¹ (∼φ) :: Δ) : height (cut dp dn) = (max (height dp) (height dn)).succ := rfl -@[simp] lemma height_wk (d : ⊢ᴷ Δ) (h : Δ ⊆ Γ) : height (wk d h) = d.height.succ := rfl +@[simp] lemma height_wk (d : ⊢ᴸᴷ¹ Δ) (h : Δ ⊆ Γ) : height (wk d h) = d.height.succ := rfl -@[simp] lemma height_verum : height (verum : ⊢ᴷ ([⊤] : Sequent L)) = 0 := rfl +@[simp] lemma height_verum : height (verum : ⊢ᴸᴷ¹ ([⊤] : Sequent L)) = 0 := rfl -@[simp] lemma height_and {φ ψ} (dp : ⊢ᴷ φ :: Δ) (dq : ⊢ᴷ ψ :: Δ) : +@[simp] lemma height_and {φ ψ} (dp : ⊢ᴸᴷ¹ φ :: Δ) (dq : ⊢ᴸᴷ¹ ψ :: Δ) : height (and dp dq) = (max (height dp) (height dq)).succ := rfl -@[simp] lemma height_or {φ ψ} (d : ⊢ᴷ φ :: ψ :: Δ) : height (or d) = d.height.succ := rfl +@[simp] lemma height_or {φ ψ} (d : ⊢ᴸᴷ¹ φ :: ψ :: Δ) : height (or d) = d.height.succ := rfl -@[simp] lemma height_all {φ : Semiproposition L 1} (d : ⊢ᴷ φ.free :: Δ⁺) : height (all d) = d.height.succ := rfl +@[simp] lemma height_all {φ : Semiproposition L 1} (d : ⊢ᴸᴷ¹ φ.free :: Δ⁺) : height (all d) = d.height.succ := rfl -@[simp] lemma height_exs {t} {φ} (d : ⊢ᴷ φ/[t] :: Δ) : height (exs d) = d.height.succ := rfl +@[simp] lemma height_exs {t} {φ} (d : ⊢ᴸᴷ¹ φ/[t] :: Δ) : height (exs d) = d.height.succ := rfl end height -protected abbrev cast (d : ⊢ᴷ Δ) (e : Δ = Γ := by simp) : ⊢ᴷ Γ := e ▸ d +protected abbrev cast (d : ⊢ᴸᴷ¹ Δ) (e : Δ = Γ := by simp) : ⊢ᴸᴷ¹ Γ := e ▸ d -@[simp] lemma height_cast (d : ⊢ᴷ Δ) (e : Δ = Γ) : +@[simp] lemma height_cast (d : ⊢ᴸᴷ¹ Δ) (e : Δ = Γ) : height (Derivation.cast d e) = height d := by rcases e with rfl; simp [Derivation.cast] -def weakening (d : ⊢ᴷ Δ) (h : Δ ⊆ Γ := by simp) : ⊢ᴷ Γ := wk d h +def weakening (d : ⊢ᴸᴷ¹ Δ) (h : Δ ⊆ Γ := by simp) : ⊢ᴸᴷ¹ Γ := wk d h -def top (h : ⊤ ∈ Δ := by simp) : ⊢ᴷ Δ := verum.wk (by simp [h]) +def top (h : ⊤ ∈ Δ := by simp) : ⊢ᴸᴷ¹ Δ := verum.wk (by simp [h]) -def identity' (r : L.Rel k) (v) (hpos : Semiformula.rel r v ∈ Δ := by simp) (hneg : Semiformula.nrel r v ∈ Δ := by simp) : ⊢ᴷ Δ := +def identity' (r : L.Rel k) (v) (hpos : Semiformula.rel r v ∈ Δ := by simp) (hneg : Semiformula.nrel r v ∈ Δ := by simp) : ⊢ᴸᴷ¹ Δ := (identity r v).wk (by simp [hpos, hneg]) -def tensor {φ ψ} (dφ : ⊢ᴷ φ :: Γ) (dψ : ⊢ᴷ ψ :: Δ) : ⊢ᴷ φ ⋏ ψ :: (Γ ++ Δ) := and dφ.weakening dψ.weakening +def tensor {φ ψ} (dφ : ⊢ᴸᴷ¹ φ :: Γ) (dψ : ⊢ᴸᴷ¹ ψ :: Δ) : ⊢ᴸᴷ¹ φ ⋏ ψ :: (Γ ++ Δ) := and dφ.weakening dψ.weakening -def rotate (d : ⊢ᴷ φ :: Γ) : ⊢ᴷ Γ ++ [φ] := d.weakening +def rotate (d : ⊢ᴸᴷ¹ φ :: Γ) : ⊢ᴸᴷ¹ Γ ++ [φ] := d.weakening -def eta : (φ : Proposition L) → ⊢ᴷ [φ, ∼φ] +def eta : (φ : Proposition L) → ⊢ᴸᴷ¹ [φ, ∼φ] | .rel R v | .nrel R v => identity' R v | ⊤ | ⊥ => top | φ ⋏ ψ => ((eta φ).tensor (eta ψ)).rotate.or.rotate | φ ⋎ ψ => ((eta φ).rotate.tensor (eta ψ).rotate).rotate.or | ∀⁰ φ => - have : ⊢ᴷ [(∼φ.shift)/[&0], φ.free] := (eta φ.free).rotate.cast - have : ⊢ᴷ φ.free :: [∃⁰ ∼φ]⁺ := this.exs.rotate.cast + have : ⊢ᴸᴷ¹ [(∼φ.shift)/[&0], φ.free] := (eta φ.free).rotate.cast + have : ⊢ᴸᴷ¹ φ.free :: [∃⁰ ∼φ]⁺ := this.exs.rotate.cast this.all | ∃⁰ φ => - have : ⊢ᴷ [(φ.shift)/[&0], (∼φ).free] := (eta φ.free).cast - have : ⊢ᴷ (∼φ).free :: [∃⁰ φ]⁺ := this.exs.rotate.cast + have : ⊢ᴸᴷ¹ [(φ.shift)/[&0], (∼φ).free] := (eta φ.free).cast + have : ⊢ᴸᴷ¹ (∼φ).free :: [∃⁰ φ]⁺ := this.exs.rotate.cast this.all.rotate termination_by φ => φ.complexity -def close (φ : Proposition L) (hp : φ ∈ Δ := by simp) (hn : ∼φ ∈ Δ := by simp) : ⊢ᴷ Δ := +def close (φ : Proposition L) (hp : φ ∈ Δ := by simp) (hn : ∼φ ∈ Δ := by simp) : ⊢ᴸᴷ¹ Δ := eta φ |>.weakening (by simp [hp, hn]) -lemma of_isClosed {Γ : Sequent L} (h : Γ.IsClosed) : Nonempty (⊢ᴷ Γ) := by +lemma of_isClosed {Γ : Sequent L} (h : Γ.IsClosed) : Nonempty (⊢ᴸᴷ¹ Γ) := by rcases h with ⟨φ, hp, hn⟩ exact ⟨close φ hp hn⟩ @@ -134,11 +134,11 @@ instance : OneSidedLK (Derivation (L := L)) where instance : OneSidedLK.Cut (Derivation (L := L)) where cut dp dn := cut dp dn -def rewrite {Γ} (f : ℕ → SyntacticTerm L) : ⊢ᴷ Γ → ⊢ᴷ Γ.map (Rew.rewrite f ▹ ·) +def rewrite {Γ} (f : ℕ → SyntacticTerm L) : ⊢ᴸᴷ¹ Γ → ⊢ᴸᴷ¹ Γ.map (Rew.rewrite f ▹ ·) | identity R v => identity R (Rew.rewrite f ∘ v) | cut (φ := φ) (Γ := Γ) (Δ := Δ) d₁ d₂ => - have d₁ : ⊢ᴷ Rew.rewrite f ▹ φ :: Γ.map (app (Rew.rewrite f)) := (d₁.rewrite f).cast - have d₂ : ⊢ᴷ ∼(Rew.rewrite f ▹ φ) :: Δ.map (app (Rew.rewrite f)) := (d₂.rewrite f).cast + have d₁ : ⊢ᴸᴷ¹ Rew.rewrite f ▹ φ :: Γ.map (app (Rew.rewrite f)) := (d₁.rewrite f).cast + have d₂ : ⊢ᴸᴷ¹ ∼(Rew.rewrite f ▹ φ) :: Δ.map (app (Rew.rewrite f)) := (d₂.rewrite f).cast d₁.cut d₂ |>.cast | wk d ss => d.rewrite f |>.wk (List.map_subset _ ss) | verum => verum @@ -146,20 +146,20 @@ def rewrite {Γ} (f : ℕ → SyntacticTerm L) : ⊢ᴷ Γ → ⊢ᴷ Γ.map (Re | and d₁ d₂ => (d₁.rewrite f).and (d₂.rewrite f) | all (φ := φ) (Γ := Γ) d => let g : ℕ → SyntacticTerm L := &0 :>ₙ fun x ↦ Rew.shift (f x) - have : ⊢ᴷ (φ.free :: Γ⁺).map (Rew.rewrite g ▹ ·) := d.rewrite g - have : ⊢ᴷ (∀⁰ Rew.rewrite (Rew.bShift ∘ f) ▹ φ) :: Γ.map (Rew.rewrite f ▹ ·) := + have : ⊢ᴸᴷ¹ (φ.free :: Γ⁺).map (Rew.rewrite g ▹ ·) := d.rewrite g + have : ⊢ᴸᴷ¹ (∀⁰ Rew.rewrite (Rew.bShift ∘ f) ▹ φ) :: Γ.map (Rew.rewrite f ▹ ·) := all (Derivation.cast this (by simp [g, free_rewrite_eq, Rewriting.shifts, shift_rewrite_eq, Function.comp_def])) Derivation.cast this (by simp [Rew.q_rewrite]) | exs (φ := φ) (Γ := Γ) (t := t) d => - have : ⊢ᴷ (φ/[t] :: Γ).map (Rew.rewrite f ▹ ·) := d.rewrite f - have : ⊢ᴷ (∃⁰ Rew.rewrite (Rew.bShift ∘ f) ▹ φ) :: Γ.map (Rew.rewrite f ▹ ·) := + have : ⊢ᴸᴷ¹ (φ/[t] :: Γ).map (Rew.rewrite f ▹ ·) := d.rewrite f + have : ⊢ᴸᴷ¹ (∃⁰ Rew.rewrite (Rew.bShift ∘ f) ▹ φ) :: Γ.map (Rew.rewrite f ▹ ·) := exs (t := Rew.rewrite f t) (Derivation.cast this (by simp [rewrite_subst_eq])) Derivation.cast this (by simp [Rew.q_rewrite]) -protected def map {Δ : Sequent L} (d : ⊢ᴷ Δ) (f : ℕ → ℕ) : - ⊢ᴷ Δ.map (Rew.rewriteMap f ▹ ·) := d.rewrite (fun x ↦ &(f x)) +protected def map {Δ : Sequent L} (d : ⊢ᴸᴷ¹ Δ) (f : ℕ → ℕ) : + ⊢ᴸᴷ¹ Δ.map (Rew.rewriteMap f ▹ ·) := d.rewrite (fun x ↦ &(f x)) -protected def shift {Δ : Sequent L} (d : ⊢ᴷ Δ) : ⊢ᴷ Δ⁺ := +protected def shift {Δ : Sequent L} (d : ⊢ᴸᴷ¹ Δ) : ⊢ᴸᴷ¹ Δ⁺ := Derivation.cast (Derivation.map d Nat.succ) (by rfl) section Hom @@ -170,30 +170,30 @@ lemma shifts_image (Φ : L₁ →ᵥ L₂) {Δ : List (Proposition L₁)} : (Δ.map <| Semiformula.lMap Φ)⁺ = (Δ⁺.map <| Semiformula.lMap Φ) := by simp [Rewriting.shifts, Function.comp_def, Semiformula.lMap_shift] -def lMap (Φ : L₁ →ᵥ L₂) {Γ} : ⊢ᴷ Γ → ⊢ᴷ Γ.map (.lMap Φ) +def lMap (Φ : L₁ →ᵥ L₂) {Γ} : ⊢ᴸᴷ¹ Γ → ⊢ᴸᴷ¹ Γ.map (.lMap Φ) | identity r v => .cast (identity (Φ.rel r) (fun i ↦ .lMap Φ (v i))) (by simp [Function.comp_def]) | cut (Γ := Γ) (Δ := Δ) (φ := φ) d dn => - have : ⊢ᴷ (Γ.map (.lMap Φ) ++ Δ.map (.lMap Φ) : Sequent L₂) := + have : ⊢ᴸᴷ¹ (Γ.map (.lMap Φ) ++ Δ.map (.lMap Φ) : Sequent L₂) := cut (φ := .lMap Φ φ) (Derivation.cast (lMap Φ d) (by simp)) (Derivation.cast (lMap Φ dn) (by simp)) Derivation.cast this (by simp) | wk (Δ := Δ) (Γ := Γ) d ss => (lMap Φ d).wk (List.map_subset _ ss) | verum => by simpa using verum | or (Γ := Γ) (φ := φ) (ψ := ψ) d => by - have : ⊢ᴷ (.lMap Φ φ ⋎ .lMap Φ ψ :: Γ.map (.lMap Φ) : Sequent L₂) := + have : ⊢ᴸᴷ¹ (.lMap Φ φ ⋎ .lMap Φ ψ :: Γ.map (.lMap Φ) : Sequent L₂) := or (by simpa using lMap Φ d) exact Derivation.cast this (by simp) | and (Γ := Γ) (φ := φ) (ψ := ψ) dp dq => - have : ⊢ᴷ (.lMap Φ φ ⋏ .lMap Φ ψ :: (Γ.map (.lMap Φ)) : Sequent L₂) := + have : ⊢ᴸᴷ¹ (.lMap Φ φ ⋏ .lMap Φ ψ :: (Γ.map (.lMap Φ)) : Sequent L₂) := and (Derivation.cast (lMap Φ dp) (by simp)) (Derivation.cast (lMap Φ dq) (by simp)) Derivation.cast this (by simp) | all (Γ := Γ) (φ := φ) d => - have : ⊢ᴷ ((∀⁰ .lMap Φ φ) :: (Γ.map (.lMap Φ)) : Sequent L₂) := + have : ⊢ᴸᴷ¹ ((∀⁰ .lMap Φ φ) :: (Γ.map (.lMap Φ)) : Sequent L₂) := all (Derivation.cast (lMap Φ d) (by simp [←Semiformula.lMap_free, shifts_image])) Derivation.cast this (by simp) | exs (Γ := Γ) (φ := φ) (t := t) d => - have : ⊢ᴷ ((∃⁰ .lMap Φ φ) :: (Γ.map (.lMap Φ)) : Sequent L₂) := + have : ⊢ᴸᴷ¹ ((∃⁰ .lMap Φ φ) :: (Γ.map (.lMap Φ)) : Sequent L₂) := exs (t := Semiterm.lMap Φ t) (.cast (lMap Φ d) (by simp [Semiformula.lMap_subst])) Derivation.cast this (by simp) @@ -213,24 +213,24 @@ private lemma map_rewriteMap_eq_shifts (Δ : Sequent L) (h : ∀ φ ∈ Δ, ¬φ (by intro x hx; simp [ne_of_mem_of_not_mem hx (h φ hp)]) def genelalizeByNewver {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) - (d : ⊢ᴷ φ/[&m] :: Δ) : ⊢ᴷ (∀⁰ φ) :: Δ := by - have : ⊢ᴷ φ.free :: Δ⁺ := + (d : ⊢ᴸᴷ¹ φ/[&m] :: Δ) : ⊢ᴸᴷ¹ (∀⁰ φ) :: Δ := by + have : ⊢ᴸᴷ¹ φ.free :: Δ⁺ := Derivation.cast (Derivation.map d (fun x ↦ if x = m then 0 else x + 1)) (by simp [map_subst_eq_free φ hp, map_rewriteMap_eq_shifts Δ hΔ]) exact all this def exOfInstances (v : List (SyntacticTerm L)) (φ : Semiproposition L 1) - (h : ⊢ᴷ v.map (φ/[·]) ++ Γ) : ⊢ᴷ (∃⁰ φ) :: Γ := by + (h : ⊢ᴸᴷ¹ v.map (φ/[·]) ++ Γ) : ⊢ᴸᴷ¹ (∃⁰ φ) :: Γ := by induction' v with t v ih generalizing Γ · exact weakening h (List.subset_cons_self _ _) · exact (ih (Γ := (∃⁰ φ) :: Γ) ((exs h).wk (by simp))).wk (by simp) def exOfInstances' (v : List (SyntacticTerm L)) (φ : Semiproposition L 1) - (h : ⊢ᴷ (∃⁰ φ) :: v.map (φ/[·]) ++ Γ) : ⊢ᴷ (∃⁰ φ) :: Γ := + (h : ⊢ᴸᴷ¹ (∃⁰ φ) :: v.map (φ/[·]) ++ Γ) : ⊢ᴸᴷ¹ (∃⁰ φ) :: Γ := (exOfInstances (Γ := (∃⁰ φ) :: Γ) v φ (h.wk <| by simp)).wk (by simp) -def allNvar {Δ : Sequent L} {φ} (h : ∀⁰ φ ∈ Δ) : ⊢ᴷ φ/[&Δ.newVar] :: Δ → ⊢ᴷ Δ := fun b ↦ - let b : ⊢ᴷ (∀⁰ φ) :: Δ := +def allNvar {Δ : Sequent L} {φ} (h : ∀⁰ φ ∈ Δ) : ⊢ᴸᴷ¹ φ/[&Δ.newVar] :: Δ → ⊢ᴸᴷ¹ Δ := fun b ↦ + let b : ⊢ᴸᴷ¹ (∀⁰ φ) :: Δ := b.genelalizeByNewver (by simpa [Semiformula.FVar?] using Sequent.not_fvar?_newVar h) (fun _ ↦ Sequent.not_fvar?_newVar) b.wk (by simp [h]) @@ -243,14 +243,14 @@ inductive Proof.Symbol (L : Language) notation "𝐋𝐊¹" => Proof.Symbol.symbol -abbrev Proof (φ : Proposition L) := ⊢ᴷ [φ] +abbrev Proof (φ : Proposition L) := ⊢ᴸᴷ¹ [φ] instance : Entailment (Proof.Symbol L) (Proposition L) where Prf _ := Proof namespace Proof -lemma def_eq (φ : Proposition L) : (𝐋𝐊¹ ⊢! φ) = (⊢ᴷ [φ]) := rfl +lemma def_eq (φ : Proposition L) : (𝐋𝐊¹ ⊢! φ) = (⊢ᴸᴷ¹ [φ]) := rfl instance : OneSidedLK.EmptyEntailment (Derivation (L := L)) (𝐋𝐊¹ : Proof.Symbol L) where equiv := Equiv.refl _ @@ -262,7 +262,7 @@ end Proof structure Schema.Proof (𝔖 : Schema L) (φ : Proposition L) where axioms : List (Proposition L) axioms_mem : ∀ ψ ∈ axioms, ψ ∈ 𝔖 - derivation : ⊢ᴷ φ :: ∼axioms + derivation : ⊢ᴸᴷ¹ φ :: ∼axioms namespace Schema @@ -274,7 +274,7 @@ variable {𝔖 : Schema L} attribute [simp] Proof.axioms_mem def equiv (𝔖 : Schema L) (φ) : - (𝔖 ⊢! φ) ≃ (Γ : {Γ : Sequent L // ∀ ψ ∈ Γ, ψ ∈ 𝔖}) × ⊢ᴷ φ :: ∼Γ where + (𝔖 ⊢! φ) ≃ (Γ : {Γ : Sequent L // ∀ ψ ∈ Γ, ψ ∈ 𝔖}) × ⊢ᴸᴷ¹ φ :: ∼Γ where toFun b := ⟨⟨b.axioms, b.axioms_mem⟩, b.derivation⟩ invFun := fun ⟨⟨Γ, hΓ⟩, d⟩ ↦ ⟨Γ, hΓ, d⟩ @@ -296,11 +296,11 @@ instance (𝔖 𝔘 : Schema L) : 𝔖 ⪯ 𝔖 ⊔ 𝔘 := weakerThan_of_le (by instance (𝔖 𝔘 : Schema L) : 𝔘 ⪯ 𝔖 ⊔ 𝔘 := weakerThan_of_le (by simp) lemma provable_iff : - 𝔖 ⊢ φ ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝔖) ∧ Nonempty (⊢ᴷ φ :: ∼Γ) := + 𝔖 ⊢ φ ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝔖) ∧ Nonempty (⊢ᴸᴷ¹ φ :: ∼Γ) := OneSidedLK.Entailment.provable_iff lemma inconsistent_iff : - Entailment.Inconsistent 𝔖 ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝔖) ∧ Nonempty (⊢ᴷ ∼Γ) := + Entailment.Inconsistent 𝔖 ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝔖) ∧ Nonempty (⊢ᴸᴷ¹ ∼Γ) := OneSidedLK.Entailment.inconsistent_iff def rewrite [𝔖.IsClosed] (b : 𝔖 ⊢! φ) (f : ℕ → SyntacticTerm L) : @@ -324,43 +324,43 @@ open Entailment variable {Γ Δ : Sequent L} -def eCut (d₁ : ⊢ᴷ φ :: Γ) (d₂ : ⊢ᴷ ψ :: Δ) (e : ∼φ = ψ := by simp) : ⊢ᴷ Γ ++ Δ := cut d₁ (d₂.cast (by simp [e])) +def eCut (d₁ : ⊢ᴸᴷ¹ φ :: Γ) (d₂ : ⊢ᴸᴷ¹ ψ :: Δ) (e : ∼φ = ψ := by simp) : ⊢ᴸᴷ¹ Γ ++ Δ := cut d₁ (d₂.cast (by simp [e])) -def disj₂ {Γ Δ : Sequent L} : ⊢ᴷ Γ ++ Δ → ⊢ᴷ ⋁Γ :: Δ := fun d ↦ +def disj₂ {Γ Δ : Sequent L} : ⊢ᴸᴷ¹ Γ ++ Δ → ⊢ᴸᴷ¹ ⋁Γ :: Δ := fun d ↦ match Γ with | [] => d.weakening | [φ] => d | [φ, ψ] => d.or | φ :: ψ :: χ :: Γ => let Φ := ⋁(χ :: Γ) - have : ⊢ᴷ (φ ⋎ ψ :: χ :: Γ) ++ Δ := d.or - have d₁ : ⊢ᴷ (φ ⋎ ψ) ⋎ Φ :: Δ := this.disj₂ - have d₂ : ⊢ᴷ [(∼φ ⋏ ∼ψ) ⋏ ∼Φ, φ ⋎ ψ ⋎ Φ] := - have : ⊢ᴷ [φ, ψ ⋎ Φ, (∼φ ⋏ ∼ψ) ⋏ ∼Φ] := + have : ⊢ᴸᴷ¹ (φ ⋎ ψ :: χ :: Γ) ++ Δ := d.or + have d₁ : ⊢ᴸᴷ¹ (φ ⋎ ψ) ⋎ Φ :: Δ := this.disj₂ + have d₂ : ⊢ᴸᴷ¹ [(∼φ ⋏ ∼ψ) ⋏ ∼Φ, φ ⋎ ψ ⋎ Φ] := + have : ⊢ᴸᴷ¹ [φ, ψ ⋎ Φ, (∼φ ⋏ ∼ψ) ⋏ ∼Φ] := ((eta φ).rotate.tensor (eta ψ).rotate).tensor (eta Φ).rotate |>.rotate.rotate.or.weakening this.or.rotate d₂.eCut d₁ termination_by _ => Γ.length -def conj₂ {Γ Δ : Sequent L} (d : (φ : Proposition L) → φ ∈ Γ → ⊢ᴷ φ :: Δ) : ⊢ᴷ ⋀Γ :: Δ := +def conj₂ {Γ Δ : Sequent L} (d : (φ : Proposition L) → φ ∈ Γ → ⊢ᴸᴷ¹ φ :: Δ) : ⊢ᴸᴷ¹ ⋀Γ :: Δ := match Γ with | [] => verum.weakening | [φ] => d φ (by simp) | φ :: ψ :: Γ => - have : ⊢ᴷ ⋀(ψ :: Γ) :: Δ := conj₂ (Γ := ψ :: Γ) (fun χ h ↦ d χ (by simp_all)) + have : ⊢ᴸᴷ¹ ⋀(ψ :: Γ) :: Δ := conj₂ (Γ := ψ :: Γ) (fun χ h ↦ d χ (by simp_all)) (d φ (by simp)).and this -def disjClosure : ⊢ᴷ Γ → 𝐋𝐊¹ ⊢! ⋁Γ := fun d ↦ - have : ⊢ᴷ Γ ++ [] := d.cast +def disjClosure : ⊢ᴸᴷ¹ Γ → 𝐋𝐊¹ ⊢! ⋁Γ := fun d ↦ + have : ⊢ᴸᴷ¹ Γ ++ [] := d.cast this.disj₂ -def disjClosureInv : 𝐋𝐊¹ ⊢! ⋁Γ → ⊢ᴷ Γ := fun d ↦ - have d₁ : ⊢ᴷ [⋁Γ] := d - have d₂ : ⊢ᴷ ⋀(∼Γ) :: Γ := conj₂ fun φ h ↦ close φ (by simp) (by simp_all) +def disjClosureInv : 𝐋𝐊¹ ⊢! ⋁Γ → ⊢ᴸᴷ¹ Γ := fun d ↦ + have d₁ : ⊢ᴸᴷ¹ [⋁Γ] := d + have d₂ : ⊢ᴸᴷ¹ ⋀(∼Γ) :: Γ := conj₂ fun φ h ↦ close φ (by simp) (by simp_all) d₁.eCut d₂ -lemma nonempty_iff_provable_disj : Nonempty (⊢ᴷ Γ) ↔ 𝐋𝐊¹ ⊢ ⋁Γ := +lemma nonempty_iff_provable_disj : Nonempty (⊢ᴸᴷ¹ Γ) ↔ 𝐋𝐊¹ ⊢ ⋁Γ := ⟨by rintro ⟨d⟩; exact ⟨d.disjClosure⟩, by rintro ⟨d⟩; exact ⟨d.disjClosureInv⟩⟩ end Derivation @@ -373,13 +373,13 @@ lemma iff_context {𝔖 : Schema L} : 𝔖 ⊢ φ ↔ 𝔖 *⊢[𝐋𝐊¹] φ : constructor · rintro ⟨d⟩ have : 𝐋𝐊¹ ⊢! ⋀d.axioms 🡒 φ := - have : ⊢ᴷ ∼d.axioms ++ [φ] := d.derivation.weakening + have : ⊢ᴸᴷ¹ ∼d.axioms ++ [φ] := d.derivation.weakening this.disj₂.or.cast <| by simp [Semiformula.imp_eq] refine ⟨⟨d.axioms, by simpa using d.axioms_mem, this⟩⟩ · rintro ⟨Γ, h, d⟩ - have d : ⊢ᴷ [⋁(∼Γ) ⋎ φ] := d.cast (by simp [Semiformula.imp_eq]) - have : ⊢ᴷ ⋀Γ ⋏ ∼φ :: φ :: ∼Γ := - have : ⊢ᴷ ⋀Γ :: ∼Γ := Derivation.conj₂ fun φ h ↦ close φ (by simp) (by simp [h]) + have d : ⊢ᴸᴷ¹ [⋁(∼Γ) ⋎ φ] := d.cast (by simp [Semiformula.imp_eq]) + have : ⊢ᴸᴷ¹ ⋀Γ ⋏ ∼φ :: φ :: ∼Γ := + have : ⊢ᴸᴷ¹ ⋀Γ :: ∼Γ := Derivation.conj₂ fun φ h ↦ close φ (by simp) (by simp [h]) this.tensor (eta φ).rotate |>.weakening refine ⟨⟨Γ, h, (d.eCut this).cast⟩⟩ diff --git a/Foundation/FirstOrder/Basic/CutFree.lean b/Foundation/FirstOrder/Basic/CutFree.lean index 803b9bfc7..4b200bdcb 100644 --- a/Foundation/FirstOrder/Basic/CutFree.lean +++ b/Foundation/FirstOrder/Basic/CutFree.lean @@ -15,39 +15,39 @@ variable {L : Language.{u}} namespace Derivation -inductive IsCutFree : {Γ : Sequent L} → ⊢ᴷ Γ → Prop +inductive IsCutFree : {Γ : Sequent L} → ⊢ᴸᴷ¹ Γ → Prop | identity (r : L.Rel k) (v) : IsCutFree (identity r v) | verum : IsCutFree verum -| or {d : ⊢ᴷ φ :: ψ :: Γ} : IsCutFree d → IsCutFree d.or -| and {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) -| all {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all -| exs (t) {d : ⊢ᴷ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs -| wk {d : ⊢ᴷ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) +| or {d : ⊢ᴸᴷ¹ φ :: ψ :: Γ} : IsCutFree d → IsCutFree d.or +| and {dφ : ⊢ᴸᴷ¹ φ :: Γ} {dψ : ⊢ᴸᴷ¹ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) +| all {d : ⊢ᴸᴷ¹ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all +| exs (t) {d : ⊢ᴸᴷ¹ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs +| wk {d : ⊢ᴸᴷ¹ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) attribute [simp] IsCutFree.identity IsCutFree.verum variable {Γ Δ : Sequent L} -@[simp] lemma isCutFree_or_iff {d : ⊢ᴷ φ :: ψ :: Γ} : +@[simp] lemma isCutFree_or_iff {d : ⊢ᴸᴷ¹ φ :: ψ :: Γ} : IsCutFree d.or ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .or⟩ -@[simp] lemma isCutFree_and_iff {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : +@[simp] lemma isCutFree_and_iff {dφ : ⊢ᴸᴷ¹ φ :: Γ} {dψ : ⊢ᴸᴷ¹ ψ :: Γ} : IsCutFree (dφ.and dψ) ↔ IsCutFree dφ ∧ IsCutFree dψ := ⟨by rintro ⟨⟩; constructor <;> assumption, by intro ⟨hφ, hψ⟩; exact hφ.and hψ⟩ -@[simp] lemma isCutFree_all_iff {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : +@[simp] lemma isCutFree_all_iff {d : ⊢ᴸᴷ¹ Rewriting.free φ :: Γ⁺} : IsCutFree d.all ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .all⟩ -@[simp] lemma isCutFree_exs_iff {d : ⊢ᴷ φ/[t] :: Γ} : +@[simp] lemma isCutFree_exs_iff {d : ⊢ᴸᴷ¹ φ/[t] :: Γ} : IsCutFree d.exs ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .exs t⟩ -@[simp] lemma isCutFree_wk_iff {d : ⊢ᴷ Δ} {ss : Δ ⊆ Γ} : +@[simp] lemma isCutFree_wk_iff {d : ⊢ᴸᴷ¹ Δ} {ss : Δ ⊆ Γ} : IsCutFree (d.wk ss) ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .wk _⟩ -@[simp] lemma IsCutFree.cast {d : ⊢ᴷ Γ} {e : Γ = Δ} : +@[simp] lemma IsCutFree.cast {d : ⊢ᴸᴷ¹ Γ} {e : Γ = Δ} : IsCutFree (.cast d e) ↔ IsCutFree d := by rcases e; rfl -@[simp] lemma IsCutFree.not_cut (dp : ⊢ᴷ φ :: Γ) (dn : ⊢ᴷ ∼φ :: Δ) : ¬IsCutFree (dp.cut dn) := by +@[simp] lemma IsCutFree.not_cut (dp : ⊢ᴸᴷ¹ φ :: Γ) (dn : ⊢ᴸᴷ¹ ∼φ :: Δ) : ¬IsCutFree (dp.cut dn) := by intro h refine h.rec (motive := fun {_} d _ => @@ -58,15 +58,15 @@ variable {Γ Δ : Sequent L} all_goals simp set_option backward.isDefEq.respectTransparency false in -@[simp] lemma isCutFree_rewrite_iff_isCutFree {f : ℕ → SyntacticTerm L} {d : ⊢ᴷ Γ} : +@[simp] lemma isCutFree_rewrite_iff_isCutFree {f : ℕ → SyntacticTerm L} {d : ⊢ᴸᴷ¹ Γ} : IsCutFree (rewrite f d) ↔ IsCutFree d := by induction d generalizing f <;> simp [rewrite, *] -@[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᴷ Γ} : +@[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᴸᴷ¹ Γ} : IsCutFree (Derivation.map d f) ↔ IsCutFree d := isCutFree_rewrite_iff_isCutFree set_option backward.isDefEq.respectTransparency false in @[simp] lemma IsCutFree.genelalizeByNewver_isCutFree {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) - (d : ⊢ᴷ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] + (d : ⊢ᴸᴷ¹ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] end Derivation diff --git a/Foundation/FirstOrder/Basic/Soundness.lean b/Foundation/FirstOrder/Basic/Soundness.lean index 6f342f21a..e34bdbe99 100644 --- a/Foundation/FirstOrder/Basic/Soundness.lean +++ b/Foundation/FirstOrder/Basic/Soundness.lean @@ -17,7 +17,7 @@ variable {L : Language} namespace Derivation lemma sound {M : Type*} [s : Structure L M] [Nonempty M] (f : ℕ → M) {Γ : Sequent L} : - ⊢ᴷ Γ → ∃ φ ∈ Γ, φ.Evalf f + ⊢ᴸᴷ¹ Γ → ∃ φ ∈ Γ, φ.Evalf f | identity r v => by by_cases h : s.rel r (Semiterm.val ![] f ∘ v) · exact ⟨rel r v, by simp, h⟩ @@ -63,7 +63,7 @@ lemma sound {M : Type*} [s : Structure L M] [Nonempty M] (f : ℕ → M) {Γ : S · exact ⟨ψ, by simp [hn], hq⟩ · exact ⟨ψ, by simp [h], hq⟩ -@[simp] lemma nil_empty : IsEmpty (⊢ᴷ ([] : Sequent L)) := by +@[simp] lemma nil_empty : IsEmpty (⊢ᴸᴷ¹ ([] : Sequent L)) := by refine ⟨fun b ↦ ?_⟩ simpa using sound (fun _ ↦ ()) b diff --git a/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean b/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean index 1c16a63b1..b3365055f 100644 --- a/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean +++ b/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean @@ -22,7 +22,7 @@ namespace Canonical variable (L) -def ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴷ ∼Γ)} +def ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴸᴷ¹ ∼Γ)} variable {L} @@ -81,7 +81,7 @@ lemma hValue_ext {φ ψ : Propositionᵢ L} : (∀ p : ℂ, p.val ⊩ φ ↔ p.v · intro h q hqp hqφ exact h q.val hqp hqφ · intro h q hqp hqφ - by_cases! hq : IsEmpty (⊢ᴷ ∼q) + by_cases! hq : IsEmpty (⊢ᴸᴷ¹ ∼q) · exact h ⟨q, hq⟩ hqp hqφ · exact IsForced.efq (p := q) (by simp [IsForced.falsum, hq]) ψ @@ -95,7 +95,7 @@ lemma hValue_eq_top_iff_provable {φ : Proposition L} : ♯φᴺ = ⊤ ↔ 𝐋 _ ↔ ℙ ∀⊩ φᴺ := by constructor · intro h p - by_cases! hp : IsEmpty (⊢ᴷ ∼p) + by_cases! hp : IsEmpty (⊢ᴸᴷ¹ ∼p) · exact h ⟨p, hp⟩ · exact IsForced.efq (p := p) (by simp [IsForced.falsum, hp]) φᴺ · intro h p; exact h p.val diff --git a/Foundation/FirstOrder/Completeness/CanonicalModel.lean b/Foundation/FirstOrder/Completeness/CanonicalModel.lean index 8e086e36b..617a348c8 100644 --- a/Foundation/FirstOrder/Completeness/CanonicalModel.lean +++ b/Foundation/FirstOrder/Completeness/CanonicalModel.lean @@ -55,13 +55,13 @@ def add {Γ Δ Ξ Θ : Sequent L} : Γ ⟶⁺ Δ → Ξ ⟶⁺ Θ → Γ ++ Ξ | wk d h, b => wk (d.add b) (by simp [h]) | .id, b => b.append Γ -def graft {Ξ Γ : Sequent L} (b : ⊢ᴷ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴷ Γ +def graft {Ξ Γ : Sequent L} (b : ⊢ᴸᴷ¹ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴸᴷ¹ Γ | or d => .or (d.graft b) | exs d => .exs (d.graft b) | wk d h => .wk (d.graft b) h | .id => b -lemma graft_isCutFree_of_isCutFree {b : ⊢ᴷ Ξ} {d : Ξ ⟶⁺ Γ} (hb : Derivation.IsCutFree b) : Derivation.IsCutFree (d.graft b) := by +lemma graft_isCutFree_of_isCutFree {b : ⊢ᴸᴷ¹ Ξ} {d : Ξ ⟶⁺ Γ} (hb : Derivation.IsCutFree b) : Derivation.IsCutFree (d.graft b) := by induction d <;> simp [graft, *] end Positive @@ -112,8 +112,8 @@ def leMinRightOfLe (s : q ≼ p) : q ≼ p ⊓ q := leMinOfle s (.refl q) end StrongerThan def Forces (p : ℙ) : Propositionᵢ L → Type u - | ⊥ => { b : ⊢ᴷ ∼p // Derivation.IsCutFree b } - | .rel R v => { b : ⊢ᴷ .rel R v :: ∼p // Derivation.IsCutFree b } + | ⊥ => { b : ⊢ᴸᴷ¹ ∼p // Derivation.IsCutFree b } + | .rel R v => { b : ⊢ᴸᴷ¹ .rel R v :: ∼p // Derivation.IsCutFree b } | φ ⋏ ψ => Forces p φ × Forces p ψ | φ ⋎ ψ => Forces p φ ⊕ Forces p ψ | φ 🡒 ψ => (q : ℙ) → q ≼ p → Forces q φ → Forces q ψ @@ -131,9 +131,9 @@ scoped infix:45 " ⊩ " => Forces scoped prefix:45 "⊩ " => allForces -def falsumEquiv : p ⊩ ⊥ ≃ { b : ⊢ᴷ ∼p // Derivation.IsCutFree b} := by unfold Forces; exact .refl _ +def falsumEquiv : p ⊩ ⊥ ≃ { b : ⊢ᴸᴷ¹ ∼p // Derivation.IsCutFree b} := by unfold Forces; exact .refl _ -def relEquiv {k} {R : L.Rel k} {v} : p ⊩ .rel R v ≃ { b : ⊢ᴷ .rel R v :: ∼p // Derivation.IsCutFree b } := by +def relEquiv {k} {R : L.Rel k} {v} : p ⊩ .rel R v ≃ { b : ⊢ᴸᴷ¹ .rel R v :: ∼p // Derivation.IsCutFree b } := by unfold Forces; exact .refl _ def andEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ ⋏ ψ ≃ (p ⊩ φ) × (p ⊩ ψ) := by @@ -279,7 +279,7 @@ protected def refl.or (ihφ : [φ] ⊩ φᴺ) (ihψ : [ψ] ⊩ ψᴺ) : [φ ⋎ let bψ : [ψ] ⊓ q ⊩ ⊥ := dψ.implyEquiv ([ψ] ⊓ q) (.minLeRight _ _) (ihψ.monotone (.minLeLeft _ _)) let ⟨bbφ, hbbφ⟩ := bφ.falsumEquiv let ⟨bbψ, hbbψ⟩ := bψ.falsumEquiv - let band : ⊢ᴷ ∼φ ⋏ ∼ψ :: ∼q := Derivation.and + let band : ⊢ᴸᴷ¹ ∼φ ⋏ ∼ψ :: ∼q := Derivation.and (Derivation.cast bbφ (by simp [inf_def])) (Derivation.cast bbψ (by simp [inf_def])) falsumEquiv.symm ⟨Derivation.cast band (by simp [inf_def]), by simp [band, hbbφ, hbbψ]⟩ @@ -291,7 +291,7 @@ protected def refl.exs (d : ∀ x, [φ/[&x]] ⊩ (φ/[&x])ᴺ) : [∃⁰ φ] ⊩ let b : [φ/[&x]] ⊓ q ⊩ ⊥ := (f.allEquiv &x).implyEquiv ([φ/[&x]] ⊓ q) (StrongerThan.minLeRight _ _) (ih.monotone (StrongerThan.minLeLeft _ _)) let ⟨b, hb⟩ := b.falsumEquiv - let ba : ⊢ᴷ (∀⁰ ∼φ) :: ∼q := + let ba : ⊢ᴸᴷ¹ (∀⁰ ∼φ) :: ∼q := Derivation.genelalizeByNewver (m := x) (by have : ¬Semiformula.FVar? (∀⁰ ∼φ) x := Sequent.not_fvar?_newVar (by simp) simpa using this) @@ -333,7 +333,7 @@ def conj' : {Γ : Sequent L} → (b : (φ : Proposition L) → φ ∈ Γ → p end Forces /-- Cut elimination theorem of $\mathbf{LK}$. -/ -def hauptsatz [L.DecidableEq] {Γ : Sequent L} : ⊢ᴷ Γ → {d : ⊢ᴷ Γ // Derivation.IsCutFree d} := fun d ↦ +def hauptsatz [L.DecidableEq] {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → {d : ⊢ᴸᴷ¹ Γ // Derivation.IsCutFree d} := fun d ↦ let d : 𝗠𝗶𝗻¹ ⊢! ⋀(∼Γ)ᴺ 🡒 ⊥ := Entailment.FiniteContext.toDef (Derivation.gödelGentzen d) let ff : Forces (∼Γ) (⋀(∼Γ)ᴺ 🡒 ⊥) := Forces.sound d (∼Γ) let fc : Forces (∼Γ) (⋀(∼Γ)ᴺ) := Forces.conj' fun φ hφ ↦ @@ -359,7 +359,7 @@ namespace IsForced open Classical -@[simp] lemma rel {p : ℙ} {k} {R : L.Rel k} {v} : p ⊩ .rel R v ↔ Nonempty (⊢ᴷ .rel R v :: ∼p) := by +@[simp] lemma rel {p : ℙ} {k} {R : L.Rel k} {v} : p ⊩ .rel R v ↔ Nonempty (⊢ᴸᴷ¹ .rel R v :: ∼p) := by constructor · rintro ⟨b⟩ have ⟨d, hd⟩ := b.relEquiv @@ -407,7 +407,7 @@ lemma imply {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ 🡒 ψ ↔ (∀ q · rintro ⟨t, h⟩ exact ⟨Forces.exsEquiv.symm ⟨t, h.some⟩⟩ -lemma falsum {p : ℙ} : p ⊩ ⊥ ↔ Nonempty (⊢ᴷ ∼p) := by +lemma falsum {p : ℙ} : p ⊩ ⊥ ↔ Nonempty (⊢ᴸᴷ¹ ∼p) := by constructor · rintro ⟨b⟩ have ⟨d, hd⟩ := b.falsumEquiv diff --git a/Foundation/FirstOrder/Hauptsatz.lean b/Foundation/FirstOrder/Hauptsatz.lean index ed27a02af..70b8c3d6c 100644 --- a/Foundation/FirstOrder/Hauptsatz.lean +++ b/Foundation/FirstOrder/Hauptsatz.lean @@ -17,39 +17,39 @@ variable {L : Language.{u}} namespace Derivation -inductive IsCutFree : {Γ : Sequent L} → ⊢ᴷ Γ → Prop +inductive IsCutFree : {Γ : Sequent L} → ⊢ᴸᴷ¹ Γ → Prop | axL (r : L.Rel k) (v) : IsCutFree (identity r v) | verum : IsCutFree verum -| or {d : ⊢ᴷ φ :: ψ :: Γ} : IsCutFree d → IsCutFree d.or -| and {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) -| all {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all -| exs (t) {d : ⊢ᴷ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs -| wk {d : ⊢ᴷ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) +| or {d : ⊢ᴸᴷ¹ φ :: ψ :: Γ} : IsCutFree d → IsCutFree d.or +| and {dφ : ⊢ᴸᴷ¹ φ :: Γ} {dψ : ⊢ᴸᴷ¹ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) +| all {d : ⊢ᴸᴷ¹ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all +| exs (t) {d : ⊢ᴸᴷ¹ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs +| wk {d : ⊢ᴸᴷ¹ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) attribute [simp] IsCutFree.axL IsCutFree.verum variable {Γ Δ : Sequent L} -@[simp] lemma isCutFree_or_iff {d : ⊢ᴷ φ :: ψ :: Γ} : +@[simp] lemma isCutFree_or_iff {d : ⊢ᴸᴷ¹ φ :: ψ :: Γ} : IsCutFree d.or ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .or⟩ -@[simp] lemma isCutFree_and_iff {dφ : ⊢ᴷ φ :: Γ} {dψ : ⊢ᴷ ψ :: Γ} : +@[simp] lemma isCutFree_and_iff {dφ : ⊢ᴸᴷ¹ φ :: Γ} {dψ : ⊢ᴸᴷ¹ ψ :: Γ} : IsCutFree (dφ.and dψ) ↔ IsCutFree dφ ∧ IsCutFree dψ := ⟨by rintro ⟨⟩; constructor <;> assumption, by intro ⟨hφ, hψ⟩; exact hφ.and hψ⟩ -@[simp] lemma isCutFree_all_iff {d : ⊢ᴷ Rewriting.free φ :: Γ⁺} : +@[simp] lemma isCutFree_all_iff {d : ⊢ᴸᴷ¹ Rewriting.free φ :: Γ⁺} : IsCutFree d.all ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .all⟩ -@[simp] lemma isCutFree_exs_iff {d : ⊢ᴷ φ/[t] :: Γ} : +@[simp] lemma isCutFree_exs_iff {d : ⊢ᴸᴷ¹ φ/[t] :: Γ} : IsCutFree d.exs ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .exs t⟩ -@[simp] lemma isCutFree_wk_iff {d : ⊢ᴷ Δ} {ss : Δ ⊆ Γ} : +@[simp] lemma isCutFree_wk_iff {d : ⊢ᴸᴷ¹ Δ} {ss : Δ ⊆ Γ} : IsCutFree (d.wk ss) ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .wk _⟩ -@[simp] lemma IsCutFree.cast {d : ⊢ᴷ Γ} {e : Γ = Δ} : +@[simp] lemma IsCutFree.cast {d : ⊢ᴸᴷ¹ Γ} {e : Γ = Δ} : IsCutFree (.cast d e) ↔ IsCutFree d := by rcases e; rfl -@[simp] lemma IsCutFree.not_cut (dp : ⊢ᴷ φ :: Γ) (dn : ⊢ᴷ ∼φ :: Δ) : ¬IsCutFree (dp.cut dn) := by +@[simp] lemma IsCutFree.not_cut (dp : ⊢ᴸᴷ¹ φ :: Γ) (dn : ⊢ᴸᴷ¹ ∼φ :: Δ) : ¬IsCutFree (dp.cut dn) := by intro h refine h.rec (motive := fun {_} d _ => @@ -60,16 +60,16 @@ variable {Γ Δ : Sequent L} all_goals simp set_option backward.isDefEq.respectTransparency false in -@[simp] lemma isCutFree_rewrite_iff_isCutFree {f : ℕ → SyntacticTerm L} {d : ⊢ᴷ Γ} : +@[simp] lemma isCutFree_rewrite_iff_isCutFree {f : ℕ → SyntacticTerm L} {d : ⊢ᴸᴷ¹ Γ} : IsCutFree (rewrite f d) ↔ IsCutFree d := by induction d generalizing f <;> simp [rewrite, *] -@[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᴷ Γ} : +@[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᴸᴷ¹ Γ} : IsCutFree (Derivation.map d f) ↔ IsCutFree d := isCutFree_rewrite_iff_isCutFree set_option backward.isDefEq.respectTransparency false in @[simp] lemma IsCutFree.genelalizeByNewver_isCutFree {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) - (d : ⊢ᴷ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] + (d : ⊢ᴸᴷ¹ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] end Derivation @@ -113,13 +113,13 @@ def add {Γ Δ Ξ Θ : Sequent L} : Γ ⟶⁺ Δ → Ξ ⟶⁺ Θ → Γ ++ Ξ | wk d h, b => wk (d.add b) (by simp [h]) | .id, b => b.append Γ -def graft {Ξ Γ : Sequent L} (b : ⊢ᴷ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴷ Γ +def graft {Ξ Γ : Sequent L} (b : ⊢ᴸᴷ¹ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴸᴷ¹ Γ | or d => .or (d.graft b) | exs d => .exs (d.graft b) | wk d h => .wk (d.graft b) h | .id => b -lemma graft_isCutFree_of_isCutFree {b : ⊢ᴷ Ξ} {d : Ξ ⟶⁺ Γ} (hb : Derivation.IsCutFree b) : Derivation.IsCutFree (d.graft b) := by +lemma graft_isCutFree_of_isCutFree {b : ⊢ᴸᴷ¹ Ξ} {d : Ξ ⟶⁺ Γ} (hb : Derivation.IsCutFree b) : Derivation.IsCutFree (d.graft b) := by induction d <;> simp [graft, *] end PositiveDerivationFrom @@ -170,8 +170,8 @@ def leMinRightOfLe (s : q ≼ p) : q ≼ p ⊓ q := leMinOfle s (.refl q) end StrongerThan def Forces (p : ℙ) : Propositionᵢ L → Type u - | ⊥ => { b : ⊢ᴷ ∼p // Derivation.IsCutFree b } - | .rel R v => { b : ⊢ᴷ .rel R v :: ∼p // Derivation.IsCutFree b } + | ⊥ => { b : ⊢ᴸᴷ¹ ∼p // Derivation.IsCutFree b } + | .rel R v => { b : ⊢ᴸᴷ¹ .rel R v :: ∼p // Derivation.IsCutFree b } | φ ⋏ ψ => Forces p φ × Forces p ψ | φ ⋎ ψ => Forces p φ ⊕ Forces p ψ | φ 🡒 ψ => (q : ℙ) → q ≼ p → Forces q φ → Forces q ψ @@ -189,9 +189,9 @@ scoped infix:45 " ⊩ " => Forces scoped prefix:45 "⊩ " => allForces -def falsumEquiv : p ⊩ ⊥ ≃ { b : ⊢ᴷ ∼p // Derivation.IsCutFree b} := by unfold Forces; exact .refl _ +def falsumEquiv : p ⊩ ⊥ ≃ { b : ⊢ᴸᴷ¹ ∼p // Derivation.IsCutFree b} := by unfold Forces; exact .refl _ -def relEquiv {k} {R : L.Rel k} {v} : p ⊩ .rel R v ≃ { b : ⊢ᴷ .rel R v :: ∼p // Derivation.IsCutFree b } := by +def relEquiv {k} {R : L.Rel k} {v} : p ⊩ .rel R v ≃ { b : ⊢ᴸᴷ¹ .rel R v :: ∼p // Derivation.IsCutFree b } := by unfold Forces; exact .refl _ def andEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ ⋏ ψ ≃ (p ⊩ φ) × (p ⊩ ψ) := by @@ -337,7 +337,7 @@ protected def refl.or (ihφ : [φ] ⊩ φᴺ) (ihψ : [ψ] ⊩ ψᴺ) : [φ ⋎ let bψ : [ψ] ⊓ q ⊩ ⊥ := dψ.implyEquiv ([ψ] ⊓ q) (.minLeRight _ _) (ihψ.monotone (.minLeLeft _ _)) let ⟨bbφ, hbbφ⟩ := bφ.falsumEquiv let ⟨bbψ, hbbψ⟩ := bψ.falsumEquiv - let band : ⊢ᴷ ∼φ ⋏ ∼ψ :: ∼q := Derivation.and + let band : ⊢ᴸᴷ¹ ∼φ ⋏ ∼ψ :: ∼q := Derivation.and (Derivation.cast bbφ (by simp [inf_def])) (Derivation.cast bbψ (by simp [inf_def])) falsumEquiv.symm ⟨Derivation.cast band (by simp [inf_def]), by simp [band, hbbφ, hbbψ]⟩ @@ -349,7 +349,7 @@ protected def refl.exs (d : ∀ x, [φ/[&x]] ⊩ (φ/[&x])ᴺ) : [∃⁰ φ] ⊩ let b : [φ/[&x]] ⊓ q ⊩ ⊥ := (f.allEquiv &x).implyEquiv ([φ/[&x]] ⊓ q) (StrongerThan.minLeRight _ _) (ih.monotone (StrongerThan.minLeLeft _ _)) let ⟨b, hb⟩ := b.falsumEquiv - let ba : ⊢ᴷ (∀⁰ ∼φ) :: ∼q := + let ba : ⊢ᴸᴷ¹ (∀⁰ ∼φ) :: ∼q := Derivation.genelalizeByNewver (m := x) (by have : ¬Semiformula.FVar? (∀⁰ ∼φ) x := Sequent.not_fvar?_newVar (by simp) simpa using this) @@ -390,7 +390,7 @@ def conj' : {Γ : Sequent L} → (b : (φ : Proposition L) → φ ∈ Γ → p end Forces -def main [L.DecidableEq] {Γ : Sequent L} : ⊢ᴷ Γ → {d : ⊢ᴷ Γ // Derivation.IsCutFree d} := fun d ↦ +def main [L.DecidableEq] {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → {d : ⊢ᴸᴷ¹ Γ // Derivation.IsCutFree d} := fun d ↦ let d : 𝗠𝗶𝗻¹ ⊢! ⋀(∼Γ)ᴺ 🡒 ⊥ := Entailment.FiniteContext.toDef (Derivation.gödelGentzen d) let ff : Forces (∼Γ) (⋀(∼Γ)ᴺ 🡒 ⊥) := Forces.sound d (∼Γ) let fc : Forces (∼Γ) (⋀(∼Γ)ᴺ) := Forces.conj' fun φ hφ ↦ @@ -418,7 +418,7 @@ namespace IsForced open Classical -@[simp] lemma rel {p : ℙ} {k} {R : L.Rel k} {v} : p ⊩ .rel R v ↔ Nonempty (⊢ᴷ .rel R v :: ∼p) := by +@[simp] lemma rel {p : ℙ} {k} {R : L.Rel k} {v} : p ⊩ .rel R v ↔ Nonempty (⊢ᴸᴷ¹ .rel R v :: ∼p) := by constructor · rintro ⟨b⟩ have ⟨d, hd⟩ := b.relEquiv @@ -466,7 +466,7 @@ lemma imply {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ 🡒 ψ ↔ (∀ q · rintro ⟨t, h⟩ exact ⟨Forces.exsEquiv.symm ⟨t, h.some⟩⟩ -lemma falsum {p : ℙ} : p ⊩ ⊥ ↔ Nonempty (⊢ᴷ ∼p) := by +lemma falsum {p : ℙ} : p ⊩ ⊥ ↔ Nonempty (⊢ᴸᴷ¹ ∼p) := by constructor · rintro ⟨b⟩ have ⟨d, hd⟩ := b.falsumEquiv @@ -515,7 +515,7 @@ end IsForced variable (L) -def ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴷ ∼Γ)} +def ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴸᴷ¹ ∼Γ)} local notation "ℂ" => ConsistentSequent L @@ -561,7 +561,7 @@ scoped prefix:max "♯" => hValue · intro h q hqp hqφ exact h q.val hqp hqφ · intro h q hqp hqφ - by_cases! hq : IsEmpty (⊢ᴷ ∼q) + by_cases! hq : IsEmpty (⊢ᴸᴷ¹ ∼q) · exact h ⟨q, hq⟩ hqp hqφ · exact IsForced.efq (p := q) (by simp [IsForced.falsum, hq]) ψ @@ -574,7 +574,7 @@ lemma eq_top_iff_provable {φ : Proposition L} : ♯φᴺ = ⊤ ↔ 𝐋𝐊¹ _ ↔ ℙ ∀⊩ φᴺ := by constructor · intro h p - by_cases! hp : IsEmpty (⊢ᴷ ∼p) + by_cases! hp : IsEmpty (⊢ᴸᴷ¹ ∼p) · exact h ⟨p, hp⟩ · exact IsForced.efq (p := p) (by simp [IsForced.falsum, hp]) φᴺ · intro h p; exact h p.val diff --git a/Foundation/FirstOrder/Kripke/WeakForcing.lean b/Foundation/FirstOrder/Kripke/WeakForcing.lean index 2e578bcf4..c9e9b8c00 100644 --- a/Foundation/FirstOrder/Kripke/WeakForcing.lean +++ b/Foundation/FirstOrder/Kripke/WeakForcing.lean @@ -378,7 +378,7 @@ def add {Γ Δ Ξ Θ : Sequent L} : Γ ⟶⁺ Δ → Ξ ⟶⁺ Θ → Γ ++ Ξ | wk d h, b => wk (d.add b) (by simp [h]) | .id, b => b.append Γ -def graft {Ξ Γ : Sequent L} (b : ⊢ᴷ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴷ Γ +def graft {Ξ Γ : Sequent L} (b : ⊢ᴸᴷ¹ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴸᴷ¹ Γ | or d => .or (d.graft b) | exs d => .exs (d.graft b) | wk d h => .wk (d.graft b) h @@ -388,7 +388,7 @@ end PositiveDerivationFrom variable (L) -abbrev ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴷ ∼Γ)} +abbrev ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴸᴷ¹ ∼Γ)} variable {L} diff --git a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean index 9d51ebb4f..f2c064447 100644 --- a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean +++ b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean @@ -152,7 +152,7 @@ lemma imply_doubleNegation (φ ψ : Proposition L) : Λ ⊢ (φᴺ 🡒 ψᴺ) open Entailment -def gödelGentzen {Γ : Sequent L} : ⊢ᴷ Γ → (∼Γ)ᴺ ⊢[Λ]! ⊥ +def gödelGentzen {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → (∼Γ)ᴺ ⊢[Λ]! ⊥ | identity r v => nthAxm 1 ⨀ nthAxm 0 | verum => nthAxm 0 | and (Γ := Γ) (φ := φ) (ψ := ψ) dφ dψ => diff --git a/Foundation/Propositional/Tait/Calculus.lean b/Foundation/Propositional/Tait/Calculus.lean index eda8ba5fc..181fe58c3 100644 --- a/Foundation/Propositional/Tait/Calculus.lean +++ b/Foundation/Propositional/Tait/Calculus.lean @@ -17,13 +17,13 @@ inductive Derivation : Sequent α → Type _ | or : Derivation (φ :: ψ :: Γ) → Derivation (φ ⋎ ψ :: Γ) | and : Derivation (φ :: Γ) → Derivation (ψ :: Γ) → Derivation (φ ⋏ ψ :: Γ) -scoped prefix:45 "⊢ᴷ " => Derivation +prefix:45 "⊢ᴸᴷ⁰ " => Derivation namespace Derivation variable {T U : Theory α} {Δ Δ₁ Δ₂ Γ : Sequent α} -def height {Δ : Sequent α} : ⊢ᴷ Δ → ℕ +def height {Δ : Sequent α} : ⊢ᴸᴷ⁰ Δ → ℕ |identity _ => 0 | cut dp dn => max dp.height dn.height + 1 | wk d _ => d.height + 1 @@ -31,29 +31,29 @@ def height {Δ : Sequent α} : ⊢ᴷ Δ → ℕ | or d => d.height + 1 | and dp dq => max (height dp) (height dq) + 1 -protected def cast (d : ⊢ᴷ Δ) (e : Δ = Γ) : ⊢ᴷ Γ := cast (by simp [e]) d +protected def cast (d : ⊢ᴸᴷ⁰ Δ) (e : Δ = Γ) : ⊢ᴸᴷ⁰ Γ := cast (by simp [e]) d -@[simp] lemma height_cast (d : ⊢ᴷ Δ) (e : Δ = Γ) : height (Derivation.cast d e) = height d := by +@[simp] lemma height_cast (d : ⊢ᴸᴷ⁰ Δ) (e : Δ = Γ) : height (Derivation.cast d e) = height d := by rcases e with rfl; simp [Derivation.cast] -def weakening (d : ⊢ᴷ Δ) (h : Δ ⊆ Γ := by simp) : ⊢ᴷ Γ := wk d h +def weakening (d : ⊢ᴸᴷ⁰ Δ) (h : Δ ⊆ Γ := by simp) : ⊢ᴸᴷ⁰ Γ := wk d h -def top (h : ⊤ ∈ Δ := by simp) : ⊢ᴷ Δ := verum.wk (by simp [h]) +def top (h : ⊤ ∈ Δ := by simp) : ⊢ᴸᴷ⁰ Δ := verum.wk (by simp [h]) -def identity' (a : α) (hpos : .atom a ∈ Δ := by simp) (hneg : .natom a ∈ Δ := by simp) : ⊢ᴷ Δ := +def identity' (a : α) (hpos : .atom a ∈ Δ := by simp) (hneg : .natom a ∈ Δ := by simp) : ⊢ᴸᴷ⁰ Δ := (identity a).wk (by simp [hpos, hneg]) -def tensor {φ ψ} (dφ : ⊢ᴷ φ :: Γ) (dψ : ⊢ᴷ ψ :: Δ) : ⊢ᴷ φ ⋏ ψ :: (Γ ++ Δ) := and dφ.weakening dψ.weakening +def tensor {φ ψ} (dφ : ⊢ᴸᴷ⁰ φ :: Γ) (dψ : ⊢ᴸᴷ⁰ ψ :: Δ) : ⊢ᴸᴷ⁰ φ ⋏ ψ :: (Γ ++ Δ) := and dφ.weakening dψ.weakening -def rotate (d : ⊢ᴷ φ :: Γ) : ⊢ᴷ Γ ++ [φ] := d.weakening +def rotate (d : ⊢ᴸᴷ⁰ φ :: Γ) : ⊢ᴸᴷ⁰ Γ ++ [φ] := d.weakening -def eta : (φ : NNFormula α) → ⊢ᴷ [φ, ∼φ] +def eta : (φ : NNFormula α) → ⊢ᴸᴷ⁰ [φ, ∼φ] | .atom a | .natom a => identity' a | ⊤ | ⊥ => top | φ ⋏ ψ => ((eta φ).tensor (eta ψ)).rotate.or.rotate | φ ⋎ ψ => ((eta φ).rotate.tensor (eta ψ).rotate).rotate.or -def close (φ : NNFormula α) (hp : φ ∈ Δ := by simp) (hn : ∼φ ∈ Δ := by simp) : ⊢ᴷ Δ := +def close (φ : NNFormula α) (hp : φ ∈ Δ := by simp) (hn : ∼φ ∈ Δ := by simp) : ⊢ᴸᴷ⁰ Δ := eta φ |>.weakening (by simp [hp, hn]) instance : OneSidedLK (Derivation (α := α)) where @@ -75,14 +75,14 @@ inductive Proof.Symbol (α : Type*) : Type notation "𝐋𝐊⁰" => Proof.Symbol.symbol -abbrev Proof (φ : NNFormula α) := ⊢ᴷ [φ] +abbrev Proof (φ : NNFormula α) := ⊢ᴸᴷ⁰ [φ] instance : Entailment (Proof.Symbol α) (NNFormula α) where Prf _ := Proof namespace Proof -lemma def_eq (φ : NNFormula α) : (𝐋𝐊⁰ ⊢! φ) = (⊢ᴷ [φ]) := rfl +lemma def_eq (φ : NNFormula α) : (𝐋𝐊⁰ ⊢! φ) = (⊢ᴸᴷ⁰ [φ]) := rfl instance : OneSidedLK.EmptyEntailment (Derivation (α := α)) (𝐋𝐊⁰ : Proof.Symbol α) where equiv := Equiv.refl _ diff --git a/Foundation/SecondOrder/Derivation.lean b/Foundation/SecondOrder/Derivation.lean index f9a7eac9d..d2fe326d0 100644 --- a/Foundation/SecondOrder/Derivation.lean +++ b/Foundation/SecondOrder/Derivation.lean @@ -54,15 +54,15 @@ inductive Derivation : Sequent L → Type _ | all₁ {φ : Semiproposition L 1 0} : Derivation (φ.free₁ :: Sequent.shift₁ Γ) → Derivation ((∀¹ φ) :: Γ) | exs₁ {φ : Semiproposition L 1 0} : Derivation (φ/⟦ψ⟧ :: Γ) → Derivation ((∃¹ φ) :: Γ) -scoped prefix:45 "⊢ᴷ " => Derivation +scoped prefix:45 "⊢ᴸᴷ¹ " => Derivation namespace Derivation -def cast {Γ Δ : Sequent L} (d : ⊢ᴷ Γ) (h : Γ = Δ) : ⊢ᴷ Δ := h ▸ d +def cast {Γ Δ : Sequent L} (d : ⊢ᴸᴷ¹ Γ) (h : Γ = Δ) : ⊢ᴸᴷ¹ Δ := h ▸ d end Derivation -abbrev Proof (φ : Sentence L) := ⊢ᴷ [(φ : Proposition L)] +abbrev Proof (φ : Sentence L) := ⊢ᴸᴷ¹ [(φ : Proposition L)] inductive Proof.Symbol (L : Language) : Type | symbol From 9e14b0b70564a71e2b3f6518b682196284eb18be Mon Sep 17 00:00:00 2001 From: palalansouki Date: Tue, 7 Apr 2026 00:55:09 +0900 Subject: [PATCH 35/61] filter completeness --- Foundation/FirstOrder/Basic/Definability.lean | 8 +-- Foundation/FirstOrder/Basic/Model.lean | 2 +- .../FirstOrder/Basic/Semantics/Semantics.lean | 27 +++++---- .../Completeness/BooleanValuedModel.lean | 60 +++++++++++++++++-- Foundation/FirstOrder/Skolemization/Hull.lean | 20 +++---- .../Modal/VanBentham/StandardTranslation.lean | 8 +-- .../Entailment/Minimal/Basic.lean | 13 ++-- Foundation/Vorspiel/Order/Ideal.lean | 15 +++++ Foundation/Vorspiel/Order/Lattice.lean | 34 +++++++++++ 9 files changed, 145 insertions(+), 42 deletions(-) create mode 100644 Foundation/Vorspiel/Order/Lattice.lean diff --git a/Foundation/FirstOrder/Basic/Definability.lean b/Foundation/FirstOrder/Basic/Definability.lean index cbef448f0..b422d7b66 100644 --- a/Foundation/FirstOrder/Basic/Definability.lean +++ b/Foundation/FirstOrder/Basic/Definability.lean @@ -17,19 +17,19 @@ namespace LO.FirstOrder variable {L : Language} {M : Type*} [Structure L M] abbrev IsDefinedBy (R : (Fin k → M) → Prop) (φ : Semisentence L k) : Prop := - ∀ v, Semiformula.Evalb M v φ ↔ R v + ∀ v, Semiformula.Evalb v φ ↔ R v class Defined (R : outParam ((Fin k → M) → Prop)) (φ : Semisentence L k) : Prop where iff : IsDefinedBy R φ abbrev IsDefinedByWithParam (R : (Fin k → M) → Prop) (φ : Semiformula L M k) : Prop := - ∀ v, Semiformula.Eval v id φ ↔ R v + ∀ v, φ.Eval v id ↔ R v @[simp] lemma Defined.eval_iff {R : (Fin k → M) → Prop} {φ : Semisentence L k} [h : Defined R φ] (v) : - Semiformula.Evalb M v φ ↔ R v := h.iff v + φ.Evalb v ↔ R v := h.iff v lemma IsDefinedByWithParam.iff {R : (Fin k → M) → Prop} {φ : Semiformula L M k} (h : IsDefinedByWithParam R φ) (v) : - Semiformula.Eval v id φ ↔ R v := h v + φ.Eval v id ↔ R v := h v abbrev DefinedFunction (f : (Fin k → M) → M) (φ : Semisentence L (k + 1)) : Prop := Defined (fun v ↦ v 0 = f (v ·.succ)) φ diff --git a/Foundation/FirstOrder/Basic/Model.lean b/Foundation/FirstOrder/Basic/Model.lean index 94267cedf..22c1517ed 100644 --- a/Foundation/FirstOrder/Basic/Model.lean +++ b/Foundation/FirstOrder/Basic/Model.lean @@ -78,7 +78,7 @@ section ofFunc variable (F : ℕ → Type*) {M : Type*} (fF : {k : ℕ} → (f : F k) → (Fin k → M) → M) -def ofFunc : Structure (Language.ofFunc F) M where +abbrev ofFunc : Structure (Language.ofFunc F) M where func := fun _ f v => fF f v rel := fun _ r _ => r.elim diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index cf49f9386..65f8afc48 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -86,7 +86,7 @@ def val [s : Structure L M] (b : Fin n → M) (f : ξ → M) : Semiterm L ξ n | &x => f x | func F v => s.func F fun i ↦ (v i).val b f -abbrev valb (M : Type w) [s : Structure L M] (b : Fin n → M) (t : ClosedSemiterm L n) : M := t.val b Empty.elim +abbrev valb [s : Structure L M] (b : Fin n → M) (t : ClosedSemiterm L n) : M := t.val b Empty.elim abbrev valf [s : Structure L M] {n} (b : Fin n → M) : Semiterm L Empty n → M := val b Empty.elim @@ -131,7 +131,7 @@ lemma val_bShift' (b : Fin (n + 1) → M) (t : Semiterm L ξ n) : simp [val_rew]; congr lemma val_embSubsts (w : Fin k → Semiterm L ξ n) (t : Semiterm L Empty k) : - (Rew.embSubsts w t).val b f = t.valb M (val b f ∘ w) := by + (Rew.embSubsts w t).val b f = t.valb (val b f ∘ w) := by simp [val_rew, Empty.eq_elim]; congr section Language @@ -174,7 +174,7 @@ lemma val_eq_of_funEqOn [DecidableEq ξ] (t : Semiterm L ξ n) (h : Function.fun simp only [val_func, Function.comp_def] congr; funext i; exact ih i (by intro x hx; exact h x (by simpa using ⟨i, hx⟩)) -lemma val_toEmpty [DecidableEq ξ] (t : Semiterm L ξ n) (h : t.freeVariables = ∅) : t.val b f = (t.toEmpty h).valb M b := by +lemma val_toEmpty [DecidableEq ξ] (t : Semiterm L ξ n) (h : t.freeVariables = ∅) : t.val b f = (t.toEmpty h).valb b := by induction t case bvar => simp [Semiterm.toEmpty] case fvar => simp at h @@ -235,10 +235,11 @@ def Eval [s : Structure L M] (b : Fin n → M) (f : ξ → M) : Semiformula L ξ abbrev Evalf [s : Structure L M] (f : ξ → M) : Formula L ξ →ˡᶜ Prop := Eval (s := s) ![] f -abbrev Evalb (M : Type w) [s : Structure L M] (b : Fin n → M) : +abbrev Evalb [s : Structure L M] (b : Fin n → M) : Semiformula L Empty n →ˡᶜ Prop := Eval b Empty.elim -notation:max M:90 " ⊧/" b:max => Evalb M b +abbrev Eval₀ (M : Type*) [s : Structure L M] : + Sentence L →ˡᶜ Prop := Eval (s := s) ![] Empty.elim abbrev Models (s : Structure L M) : Formula L M →ˡᶜ Prop := Eval ![] id @@ -363,7 +364,7 @@ lemma eval_bShift' (φ : Semiformula L ξ n) : simp [IsEmpty.eq_elim] @[simp] lemma eval_embSubsts {ξ} {f : ξ → M} {k} (w : Fin k → Semiterm L ξ n) (σ : Semisentence L k) : - Eval b f ((@Rew.embSubsts L ξ n k w) ▹ σ) ↔ σ.Evalb M (Semiterm.val b f ∘ w) := by + Eval b f ((@Rew.embSubsts L ξ n k w) ▹ σ) ↔ σ.Evalb (Semiterm.val b f ∘ w) := by simp [eval_rew, Function.comp_def, Empty.eq_elim] section Syntactic @@ -412,7 +413,7 @@ lemma eval_iff_of_funEqOn [DecidableEq ξ] {n b} (φ : Semiformula L ξ n) (h : apply exists_congr; intro x exact eval_iff_of_funEqOn φ fun x hx ↦ h _ (by simpa [FVar?]) -lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeVariables = ∅) {b} : Eval b f φ ↔ Evalb M b (φ.toEmpty hp) := by +lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeVariables = ∅) {b} : Eval b f φ ↔ Evalb b (φ.toEmpty hp) := by match φ with | .rel r v => simp only [eval_rel] @@ -426,11 +427,11 @@ lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeV simp [eval_toEmpty (φ := φ) (by simp [by simpa [Finset.union_eq_empty] using hp]), eval_toEmpty (φ := ψ) (by simp [by simpa [Finset.union_eq_empty] using hp])] | ∀⁰ φ => - have : ∀ x, Eval (x :> b) f φ ↔ Evalb M (x :> b) (φ.toEmpty hp) := + have : ∀ x, Eval (x :> b) f φ ↔ Evalb (x :> b) (φ.toEmpty hp) := fun x ↦ eval_toEmpty (φ := φ) (b := (x :> b)) (by simpa using hp) simp [this] | ∃⁰ φ => - have : ∀ x, Eval (x :> b) f φ ↔ Evalb M (x :> b) (φ.toEmpty hp) := + have : ∀ x, Eval (x :> b) f φ ↔ Evalb (x :> b) (φ.toEmpty hp) := fun x ↦ eval_toEmpty (φ := φ) (b := (x :> b)) (by simpa using hp) simp [this] @@ -446,7 +447,7 @@ lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeV intro x hx; simp [Rew.fixitr_fvar, lt_fvSup_of_fvar? hx] @[simp] lemma eval_univCl [Nonempty M] (φ : Proposition L) : - Evalb M ![] φ.univCl ↔ ∀ f : ℕ → M, Evalf f φ := by + Eval₀ M φ.univCl ↔ ∀ f : ℕ → M, Evalf f φ := by haveI : Inhabited M := Classical.inhabited_of_nonempty inferInstance simp [Semiformula.univCl, ←eval_toEmpty (f := default)] @@ -490,7 +491,7 @@ end end Structure instance : Semantics (Struc L) (Sentence L) where - Models := fun str ↦ Semiformula.Evalb str.Dom ![] + Models := fun str ↦ Semiformula.Eval₀ str.Dom instance : Semantics.Tarski (Struc L) where models_verum := by simp [Semantics.Models] @@ -520,7 +521,7 @@ variable {M} lemma struc_models_iff_models {s : Struc L} : s ⊧ σ ↔ s.Dom↓[L] ⊧ σ := by rfl -lemma models_iff : M↓[L] ⊧ σ ↔ M ⊧/![] σ := by rfl +lemma models_iff : M↓[L] ⊧ σ ↔ σ.Eval₀ M := by rfl lemma models_iff_proposition {φ : Proposition L} : M↓[L] ⊧ φ.univCl ↔ ∀ f : ℕ → M, φ.Evalf f := by simp [models_iff] @@ -591,7 +592,7 @@ lemma consequence_iff_unsatisfiable {σ : Sentence L} : intro hT; simpa using models_iff.mp (h hT) · intro h; apply consequence_iff.mpr intro M _ s hT - have : σ.Evalb M ![] := by + have : σ.Eval₀ M := by have := by simpa only [Semantics.ModelsSet.insert_iff, not_and', models_iff] using unsatisfiable_iff.mp h M inferInstance s simpa using this hT apply models_iff.mpr (by simpa using this) diff --git a/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean b/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean index b3365055f..874f42437 100644 --- a/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean +++ b/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean @@ -3,6 +3,7 @@ module public import Foundation.Vorspiel.Order.LowerSet public import Foundation.Vorspiel.Order.Ideal public import Foundation.Vorspiel.Order.Heyting +public import Foundation.Vorspiel.Order.Lattice public import Foundation.FirstOrder.Completeness.CanonicalModel public import Mathlib.Order.PFilter @@ -20,6 +21,8 @@ variable {L : Language} namespace Canonical +open Classical + variable (L) def ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴸᴷ¹ ∼Γ)} @@ -126,8 +129,22 @@ scoped prefix:max "♭" => bValue @[simp] lemma coe_bValue (φ : Proposition L) : (♭φ : ℍ) = ♯φᴺ := rfl +@[simp] lemma bValue_falsum : ♭(⊥ : Proposition L) = ⊥ := Heyting.Regular.coe_inj.mp <| by simp + +@[simp] lemma bValue_verum : ♭(⊤ : Proposition L) = ⊤ := Heyting.Regular.coe_inj.mp <| by simp + @[simp] lemma bValue_and_eq_inf : ♭(φ ⋏ ψ) = ♭φ ⊓ ♭ψ := Heyting.Regular.coe_inj.mp <| by simp +@[simp] lemma bValue_lConj_eq_inf (Γ : List (Proposition L)) : ♭(⋀Γ) = Γ.toFinset.inf bValue := + match Γ with + | [] => by simp + | [φ] => by simp + | φ :: ψ :: Γ => by + simp [bValue_lConj_eq_inf (ψ :: Γ),]; rfl + +@[simp] lemma bValue_fConj_eq_inf (Γ : Finset (Proposition L)) : ♭(Γ.conj) = Γ.inf bValue := by + simp [Finset.conj] + @[simp] lemma bValue_or_eq_sup : ♭(φ ⋎ ψ) = ♭φ ⊔ ♭ψ := Heyting.Regular.coe_inj.mp <| by simp @[simp] lemma bValue_fal_eq_Inf : ♭(∀⁰ φ) = ⨅ t, ♭(φ/[t]) := Heyting.Regular.coe_inj.mp <| by @@ -136,10 +153,11 @@ scoped prefix:max "♭" => bValue @[simp] lemma bValue_exs_eq_Sup : ♭(∃⁰ φ) = ⨆ t, ♭(φ/[t]) := Heyting.Regular.coe_inj.mp <| by simp [Semiformula.subst_doubleNegation, compl_iSup'] -@[simp] lemma bValue_neg_eq_himp : ♭(∼φ) = (♭φ)ᶜ := Heyting.Regular.coe_inj.mp <| by +@[simp] lemma bValue_neg_eq_compl : ♭(∼φ) = (♭φ)ᶜ := Heyting.Regular.coe_inj.mp <| by simp [hValue_dn_neg] -@[simp] lemma bValue_falsum : ♭(⊥ : Proposition L) = ⊥ := Heyting.Regular.coe_inj.mp <| by simp +@[simp] lemma bValue_imply_eq_himp : ♭(φ 🡒 ψ) = (♭φ ⇨ ♭ψ) := by + simp [Semiformula.imp_eq, BooleanAlgebra.himp_eq]; grind lemma bValue_eq_top_iff_provable : ♭φ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc ♭φ = ⊤ ↔ ♯φᴺ = ⊤ := by rw [←Heyting.Regular.coe_inj]; simp @@ -148,15 +166,47 @@ lemma bValue_eq_top_iff_provable : ♭φ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc lemma bValue_lt_top_iff_provable : ♭φ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by simp [Entailment.Unprovable, ←bValue_eq_top_iff_provable, lt_top_iff_ne_top] +open Order OrderDual + /-- Filter induced by a schema -/ def _root_.LO.FirstOrder.Schema.filter (𝔖 : Schema L) : Order.PFilter 𝔹 := - ⟨⨆ φ ∈ 𝔖, Order.Ideal.principal ♭φ⟩ + ⟨⨆ φ : 𝔖, Ideal.principal (toDual ♭φ)⟩ + +open Classical @[simp] lemma mem_filter_iff {𝔖 : Schema L} {x} : - x ∈ 𝔖.filter ↔ ∃ u : Finset (Proposition L), (∀ φ ∈ u, φ ∈ 𝔖) ∧ ⨅ φ ∈ u, ♭φ ≤ x := by sorry + x ∈ 𝔖.filter ↔ ∃ Γ : Finset (Proposition L), ↑Γ ⊆ 𝔖 ∧ Γ.inf bValue ≤ x := calc + x ∈ 𝔖.filter ↔ toDual x ∈ ⨆ φ : 𝔖, Ideal.principal (P := 𝔹ᵒᵈ) (toDual ♭φ) := Order.PFilter.mem_mk _ _ + _ ↔ ∃ Γ : Finset 𝔖, toDual x ∈ Γ.sup (Ideal.principal ∘ toDual ∘ bValue ∘ Subtype.val) := by rw [Ideal.mem_iSup_iff]; rfl + _ ↔ ∃ Γ : Finset 𝔖, toDual x ≤ Γ.sup (toDual ∘ bValue ∘ Subtype.val) := by simp [Ideal.mem_finsup_principal] + _ ↔ ∃ Γ : Finset 𝔖, Γ.inf (bValue ∘ Subtype.val) ≤ x := exists_congr fun Γ ↦ by simp [OrderDual.toDual_le, Function.comp_def] + _ ↔ ∃ Γ : Finset (Proposition L), ↑Γ ⊆ 𝔖 ∧ Γ.inf bValue ≤ x := by + constructor + · rintro ⟨Γ, hΓ⟩ + exact ⟨Γ.map (Function.Embedding.subtype _), fun x ↦ by simp; tauto, by simpa [Function.comp_def]⟩ + · rintro ⟨Γ, hΓ⟩ + refine ⟨Γ.subtype _, ?_⟩ + rw [Finset.subtype_inf_val_of] + · exact hΓ.2 + · intro i hi; exact hΓ.1 hi lemma bValue_mem_filter_iff_provable {𝔖 : Schema L} {φ : Proposition L} : - ♭φ ∈ 𝔖.filter ↔ 𝔖 ⊢ φ := by sorry + ♭φ ∈ 𝔖.filter ↔ 𝔖 ⊢ φ := calc + ♭φ ∈ 𝔖.filter ↔ ∃ Γ : Finset (Proposition L), ↑Γ ⊆ 𝔖 ∧ Γ.inf bValue ≤ ♭φ := mem_filter_iff + _ ↔ ∃ Γ : List (Proposition L), ↑Γ.toFinset ⊆ 𝔖 ∧ Γ.toFinset.inf bValue ≤ ♭φ := by + constructor + · rintro ⟨Γ, hΓ⟩ + exact ⟨Γ.toList, by simpa using hΓ⟩ + · rintro ⟨Γ, hΓ⟩ + exact ⟨Γ.toFinset, by simpa using hΓ⟩ + _ ↔ ∃ Γ : List (Proposition L), ↑Γ.toFinset ⊆ 𝔖 ∧ 𝐋𝐊¹ ⊢ ⋀Γ 🡒 φ := by simp [←bValue_eq_top_iff_provable] + _ ↔ 𝔖 *⊢[𝐋𝐊¹] φ := by + constructor + · rintro ⟨Γ, hΓ, ⟨b⟩⟩ + exact ⟨Γ, fun ψ hψ ↦ hΓ (by simpa using hψ), b⟩ + · intro ⟨b⟩ + exact ⟨b.ctx, fun ψ ↦ by simpa using b.subset ψ, ⟨b.prf⟩⟩ + _ ↔ 𝔖 ⊢ φ := Schema.iff_context.symm end Canonical diff --git a/Foundation/FirstOrder/Skolemization/Hull.lean b/Foundation/FirstOrder/Skolemization/Hull.lean index 5d5867845..cba3b6dc5 100644 --- a/Foundation/FirstOrder/Skolemization/Hull.lean +++ b/Foundation/FirstOrder/Skolemization/Hull.lean @@ -26,13 +26,13 @@ variable (L : Language.{u}) variable (M : Type v) [Nonempty M] [𝓼 : Structure L M] noncomputable instance skolem : Structure L.skolemFunction₁ M where - func _ φ v := Classical.epsilon fun z ↦ φ.Evalb M (z :> v) + func _ φ v := Classical.epsilon fun z ↦ φ.Evalb (z :> v) rel _ r _ := PEmpty.elim r variable {L M} @[simp] lemma val_skolem_func (φ : Semisentence L (k + 1)) : - (skolem L M).func φ.skolem₁ v = Classical.epsilon fun z ↦ φ.Evalb M (z :> v) := rfl + (skolem L M).func φ.skolem₁ v = Classical.epsilon fun z ↦ φ.Evalb (z :> v) := rfl variable (L) @@ -63,12 +63,12 @@ lemma subset : s ⊆ SkolemHull L s := fun x hx ↦ by simp [this] lemma closed {v : Fin k → M} (hv : ∀ i, v i ∈ SkolemHull L s) - {φ : Semisentence L (k + 1)} (H : ∃ z, M ⊧/(z :> v) φ) : - ∃ z ∈ SkolemHull L s, M ⊧/(z :> v) φ := by + {φ : Semisentence L (k + 1)} (H : ∃ z, φ.Evalb (z :> v)) : + ∃ z ∈ SkolemHull L s, φ.Evalb (z :> v) := by choose u hu using fun i ↦ mem_iff.mp (hv i) let t : Term L.skolemFunction₁ s := .func φ.skolem₁ u refine ⟨t.val ![] (↑), by simp, ?_⟩ - suffices M ⊧/((Classical.epsilon fun z ↦ M ⊧/(z :> v) φ) :> v) φ by + suffices φ.Evalb ((Classical.epsilon fun z ↦ φ.Evalb (z :> v)) :> v) by simpa [t, Semiterm.val_func, Function.comp_def, hu] exact Classical.epsilon_spec H @@ -76,7 +76,7 @@ variable [L.Eq] [Structure.Eq L M] lemma closed_func {v : Fin k → M} (hv : ∀ i, v i ∈ SkolemHull L s) {f : L.Func k} : Structure.func f v ∈ SkolemHull L s := by - have : ∃ z ∈ SkolemHull L s, M ⊧/(z :> v) “#0 = !!(Semiterm.func f fun i ↦ #i.succ)” := + have : ∃ z ∈ SkolemHull L s, “#0 = !!(Semiterm.func f fun i ↦ #i.succ)”.Evalb (z :> v) := closed hv (φ := “#0 = !!(Semiterm.func f fun i ↦ #i.succ)”) (by simp [Semiterm.val_func]; simp [Function.comp_def]) rcases this with ⟨z, hz, e⟩ @@ -90,7 +90,7 @@ instance (priority := 50) str : Structure L (SkolemHull L s) where rel k R v := Structure.rel R fun i ↦ (v i : M) instance set_nonempty : (SkolemHull L s).Nonempty := by - have : ∃ z, M ⊧/![z] (⊤ : Semisentence L 1) := by simp + have : ∃ z : M, (⊤ : Semisentence L 1).Evalb ![z] := by simp have : ∃ z, z ∈ SkolemHull L s := by simpa using closed (s := s) (by simp) this exact this @@ -114,14 +114,14 @@ variable {𝓼 s} | .func F v => by simp [Semiterm.val_func, str_val, Function.comp_def] @[simp] lemma str_eval {φ : Semisentence L n} : - (SkolemHull L s) ⊧/b φ ↔ M ⊧/(b ·) φ := + φ.Evalb (M := SkolemHull L s) b ↔ φ.Evalb (M := M) (b ·) := match φ with | .rel R v | .nrel R v => by simp [Semiformula.eval_rel, Semiformula.eval_nrel, Empty.eq_elim, Function.comp_def] | ⊤ | ⊥ => by simp | φ ⋏ ψ | φ ⋎ ψ => by simp [str_eval (φ := φ), str_eval (φ := ψ)] | ∀⁰ φ => by suffices - (∃ x ∈ SkolemHull L s, (∼φ).Evalb M (x :> (b ·))) ↔ (∃ x, (∼φ).Evalb M (x :> (b ·))) by + (∃ x ∈ SkolemHull L s, (∼φ).Evalb (x :> (b ·))) ↔ (∃ x : M, (∼φ).Evalb (x :> (b ·))) by apply not_iff_not.mp simpa [str_eval (φ := φ), Matrix.comp_vecCons'] constructor @@ -131,7 +131,7 @@ variable {𝓼 s} exact closed (s := s) (by simp) h | ∃⁰ φ => by suffices - (∃ x ∈ SkolemHull L s, φ.Evalb M (x :> (b ·))) ↔ (∃ x, φ.Evalb M (x :> (b ·))) by + (∃ x ∈ SkolemHull L s, φ.Evalb (x :> (b ·))) ↔ (∃ x : M, φ.Evalb (x :> (b ·))) by simpa [str_eval (φ := φ), Matrix.comp_vecCons'] constructor · rintro ⟨x, _, H⟩ diff --git a/Foundation/Modal/VanBentham/StandardTranslation.lean b/Foundation/Modal/VanBentham/StandardTranslation.lean index a5a5fdc2a..77b460b7d 100644 --- a/Foundation/Modal/VanBentham/StandardTranslation.lean +++ b/Foundation/Modal/VanBentham/StandardTranslation.lean @@ -88,10 +88,10 @@ instance {M : Model} : FirstOrder.Structure 𝓛𝓕 M.World where @[simp] lemma lt_iff_rel : (@Operator.LT.lt 𝓛𝓕 _).val ![x, y] ↔ x ≺ y := by rfl /-- BdRV Prop 2.47 (i) -/ -lemma correspondence_satisfies : x ⊧ φ ↔ M ⊧/![x] φ¹ := by +lemma correspondence_satisfies : x ⊧ φ ↔ φ¹.Evalb ![x] := by induction φ using NNFormula.rec' generalizing x with | hBox φ ihφ => - suffices x ⊧ □φ ↔ ∀ y, x ≺ y → M ⊧/![y] (φ¹) by + suffices x ⊧ □φ ↔ ∀ y, x ≺ y → (φ¹).Evalb ![y] by simpa [standardTranslation] constructor; . intro h y Rxy; @@ -99,7 +99,7 @@ lemma correspondence_satisfies : x ⊧ φ ↔ M ⊧/![x] φ¹ := by . intro h y Rxy; exact ihφ.mpr $ h y Rxy; | hDia φ ihφ => - suffices x ⊧ ◇φ ↔ ∃ y, x ≺ y ∧ M ⊧/![y] (φ¹) by + suffices x ⊧ ◇φ ↔ ∃ y, x ≺ y ∧ (φ¹).Evalb ![y] by simpa [standardTranslation] constructor; . rintro ⟨y, Rxy, hy⟩; @@ -116,7 +116,7 @@ lemma correspondence_satisfies : x ⊧ φ ↔ M ⊧/![x] φ¹ := by /-- BdRV Prop 2.47 (ii) -/ lemma correspondence_validOnModel : M ⊧ φ ↔ M↓[𝓛𝓕] ⊧ ∀⁰ φ¹ := by - suffices M ⊧ φ ↔ ∀ x : M.World, M ⊧/![x] φ¹ by simpa [FirstOrder.models_iff]; + suffices M ⊧ φ ↔ ∀ x : M.World, (φ¹).Evalb ![x] by simpa [FirstOrder.models_iff]; constructor; . intro h x; apply correspondence_satisfies.mp $ h x; . intro h x; exact correspondence_satisfies.mpr $ h x; diff --git a/Foundation/Propositional/Entailment/Minimal/Basic.lean b/Foundation/Propositional/Entailment/Minimal/Basic.lean index a13b9bf99..4d1429947 100644 --- a/Foundation/Propositional/Entailment/Minimal/Basic.lean +++ b/Foundation/Propositional/Entailment/Minimal/Basic.lean @@ -380,7 +380,8 @@ section variable {G T : Type*} [Entailment T G] [LogicalConnective G] {𝓣 : T} -def Minimal.ofEquiv (𝓢 : S) [Entailment.Minimal 𝓢] (𝓣 : T) (f : G →ˡᶜ F) (e : (φ : G) → 𝓢 ⊢! f φ ≃ 𝓣 ⊢! φ) : Entailment.Minimal 𝓣 where +abbrev Minimal.ofEquiv (𝓢 : S) [Entailment.Minimal 𝓢] (𝓣 : T) + (f : G →ˡᶜ F) (e : (φ : G) → 𝓢 ⊢! f φ ≃ 𝓣 ⊢! φ) : Entailment.Minimal 𝓣 where mdp {φ ψ dpq dp} := (e ψ) ( let d : 𝓢 ⊢! f φ 🡒 f ψ := by simpa using (e (φ 🡒 ψ)).symm dpq d ⨀ ((e φ).symm dp)) @@ -661,7 +662,7 @@ section minimal variable [Entailment.Minimal 𝓢] instance [DecidableEq F] : Axiomatized (Context F 𝓢) where - prfAxm := fun {Γ φ} hp ↦ ⟨[φ], by simpa using hp, byAxm (by simp [AdjunctiveSet.set])⟩ + prfAxm := fun {Γ φ} hp ↦ ⟨[φ], by simpa using hp, byAxm (by simp)⟩ weakening := fun h b ↦ ⟨b.ctx, fun φ hp ↦ AdjunctiveSet.subset_iff.mp h φ (b.subset φ hp), b.prf⟩ def byAxm [DecidableEq F] {Γ : Set F} {φ : F} (h : φ ∈ Γ) : Γ *⊢[𝓢]! φ := Axiomatized.prfAxm (by simpa) @@ -684,7 +685,8 @@ def deduct [DecidableEq F] {φ ψ : F} {Γ : Set F} : (insert φ Γ) *⊢[𝓢]! (by simp [List.subset_def, List.mem_filter]; grind) b ⟨ Δ.filter (· ≠ φ), by - intro ψ; simp [List.mem_filter] + intro ψ + suffices ψ ∈ Δ → ψ ≠ φ → ψ ∈ Γ by simpa [List.mem_filter] intro hq ne rcases h ψ hq · contradiction @@ -693,7 +695,7 @@ def deduct [DecidableEq F] {φ ψ : F} {Γ : Set F} : (insert φ Γ) *⊢[𝓢]! lemma deduct! [DecidableEq F] (h : (insert φ Γ) *⊢[𝓢] ψ) : Γ *⊢[𝓢] φ 🡒 ψ := ⟨Context.deduct h.some⟩ def deductInv {φ ψ : F} {Γ : Set F} : Γ *⊢[𝓢]! φ 🡒 ψ → (insert φ Γ) *⊢[𝓢]! ψ - | ⟨Δ, h, b⟩ => ⟨φ :: Δ, by simp; intro χ hr; exact Or.inr (h χ hr), FiniteContext.deductInv b⟩ + | ⟨Δ, h, b⟩ => ⟨φ :: Δ, by simpa using fun χ hr ↦ Or.inr (h χ hr), FiniteContext.deductInv b⟩ lemma deductInv! [DecidableEq F] (h : Γ *⊢[𝓢] φ 🡒 ψ) : (insert φ Γ) *⊢[𝓢] ψ := ⟨Context.deductInv h.some⟩ instance deduction [DecidableEq F] : Deduction (Context F 𝓢) where @@ -709,7 +711,8 @@ lemma of! (b : 𝓢 ⊢ φ) : Γ *⊢[𝓢] φ := ⟨Context.of b.some⟩ def mdp [DecidableEq F] {Γ : Set F} (bpq : Γ *⊢[𝓢]! φ 🡒 ψ) (bp : Γ *⊢[𝓢]! φ) : Γ *⊢[𝓢]! ψ := ⟨ bpq.ctx ++ bp.ctx, by - simp; rintro χ (hr | hr) + simp only [List.mem_append, mem_coe_iff] + rintro χ (hr | hr) · exact bpq.subset χ hr · exact bp.subset χ hr, FiniteContext.mdp' bpq.prf bp.prf ⟩ diff --git a/Foundation/Vorspiel/Order/Ideal.lean b/Foundation/Vorspiel/Order/Ideal.lean index 2096ef7f3..d10f93f41 100644 --- a/Foundation/Vorspiel/Order/Ideal.lean +++ b/Foundation/Vorspiel/Order/Ideal.lean @@ -17,6 +17,21 @@ lemma sSup_def (s : Set (Ideal P)) : sSup s = sInf (upperBounds s) := rfl lemma iSup_def (I : ι → Ideal P) : ⨆ i, I i = sInf (upperBounds (Set.range I)) := rfl +@[simp] lemma mem_bot {x : P} : x ∈ (⊥ : Ideal P) ↔ x = ⊥ := le_bot_iff + +theorem mem_finsup_principal [DecidableEq ι] {s : Finset ι} {f : ι → P} : + x ∈ s.sup (principal ∘ f) ↔ x ≤ s.sup f := by + induction s using Finset.induction generalizing x + · simp + case insert i s hi ih => + suffices (∃ y ≤ f i, ∃ z ≤ s.sup f, x ≤ y ⊔ z) ↔ x ≤ f i ⊔ s.sup f by + simpa [ih] + constructor + · rintro ⟨y, hy, z, hz, h⟩ + refine le_trans h (sup_le_sup hy hz) + · intro h + exact ⟨f i, le_refl _, s.sup f, le_refl _, h⟩ + lemma mem_iSup_iff [DecidableEq ι] {I : ι → Ideal P} {x : P} : x ∈ ⨆ i, I i ↔ ∃ u : Finset ι, x ∈ u.sup I := by revert x diff --git a/Foundation/Vorspiel/Order/Lattice.lean b/Foundation/Vorspiel/Order/Lattice.lean new file mode 100644 index 000000000..bc7882d4e --- /dev/null +++ b/Foundation/Vorspiel/Order/Lattice.lean @@ -0,0 +1,34 @@ +module + +public import Mathlib.Data.Finset.Lattice.Fold +public import Mathlib.Data.Finset.Image + +@[expose] public section + +variable {α : Type*} + +namespace Finset + +section sup + +variable [SemilatticeSup α] [OrderBot α] + +lemma subtype_sup_val_of (s : Finset ι) (p : ι → Prop) [DecidablePred p] (f : ι → α) (h : ∀ i ∈ s, p i) : + (s.subtype p).sup (f ∘ Subtype.val) = s.sup f := by + have : s.filter p = s := by ext i; simpa using h i + simp only [Finset.subtype, Function.comp_def, sup_map, Function.Embedding.coeFn_mk, sup_attach, this] + +end sup + +section inf + +variable [SemilatticeInf α] [OrderTop α] + +lemma subtype_inf_val_of (s : Finset ι) (p : ι → Prop) [DecidablePred p] (f : ι → α) (h : ∀ i ∈ s, p i) : + (s.subtype p).inf (f ∘ Subtype.val) = s.inf f := by + have : s.filter p = s := by ext i; simpa using h i + simp only [Finset.subtype, Function.comp_def, inf_map, Function.Embedding.coeFn_mk, inf_attach, this] + +end inf + +end Finset From 0a1e6fd85c9f3d5144d3f71639cbb9c1b9749cf1 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Tue, 7 Apr 2026 02:03:34 +0900 Subject: [PATCH 36/61] primeIdeal --- .../Completeness/BooleanValuedModel.lean | 131 ++++++++++++------ 1 file changed, 85 insertions(+), 46 deletions(-) diff --git a/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean b/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean index 874f42437..0c6f2e260 100644 --- a/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean +++ b/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean @@ -6,6 +6,7 @@ public import Foundation.Vorspiel.Order.Heyting public import Foundation.Vorspiel.Order.Lattice public import Foundation.FirstOrder.Completeness.CanonicalModel public import Mathlib.Order.PFilter +public import Mathlib.Order.PrimeSeparator @[expose] public section @@ -44,39 +45,32 @@ instance : Inhabited ℂ := ⟨⟨[], by simp⟩⟩ end ConsistentSequent -/-- ## Heyting-valued model -/ +/-! ## Heyting-valued model -/ -local notation "ℍ" => LowerSet ℂ +namespace HeytingValuedModel + +scoped notation "ℍ" => LowerSet ℂ + +instance : Order.Frame ℍ := inferInstance instance : Nontrivial ℍ := ⟨⊥, ⊤, fun e ↦ by simpa using SetLike.ext_iff.mp e default⟩ +/-- Heyting value of a proposition -/ def hValue (φ : Propositionᵢ L) : ℍ where carrier := { p | p.val ⊩ φ } lower' := fun _ _ hqp hp ↦ IsForced.monotone hqp hp scoped prefix:max "♯" => hValue -lemma hValue_ext {φ ψ : Propositionᵢ L} : (∀ p : ℂ, p.val ⊩ φ ↔ p.val ⊩ ψ) → ♯φ = ♯ψ := by +protected lemma ext {φ ψ : Propositionᵢ L} : (∀ p : ℂ, p.val ⊩ φ ↔ p.val ⊩ ψ) → ♯φ = ♯ψ := by intro h; ext p; simp [hValue, h] @[simp] lemma mem_hValue {p : ℂ} {φ : Propositionᵢ L} : p ∈ ♯φ ↔ p.val ⊩ φ := by simp [hValue] -@[simp] lemma hValue_and_eq_inf {φ ψ : Propositionᵢ L} : ♯(φ ⋏ ψ) = (♯φ ⊓ ♯ψ) := by - ext p; simp [hValue] - -@[simp] lemma hValue_or_eq_sup {φ ψ : Propositionᵢ L} : ♯(φ ⋎ ψ) = (♯φ ⊔ ♯ψ) := by - ext p; simp [hValue] - -@[simp] lemma hValue_fal_eq_Inf {φ : Semipropositionᵢ L 1} : ♯(∀⁰ φ) = ⨅ t, ♯(φ/[t]) := by - ext p; simp [hValue,] - -@[simp] lemma hValue_exs_eq_Sup {φ : Semipropositionᵢ L 1} : ♯(∃⁰ φ) = ⨆ t, ♯(φ/[t]) := by - ext p; simp [hValue,] - -@[simp] lemma hValue_falsum : ♯(⊥ : Propositionᵢ L) = ⊥ := by +@[simp] lemma falsum : ♯(⊥ : Propositionᵢ L) = ⊥ := by ext p; simp [hValue, IsForced.falsum, p.prop] -@[simp] lemma hValue_imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ 🡒 ψ) = (♯φ ⇨ ♯ψ) := by +@[simp] lemma imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ 🡒 ψ) = (♯φ ⇨ ♯ψ) := by ext p suffices (∀ q ≤ p.val, q ⊩ φ → q ⊩ ψ) ↔ ∀ q ≤ p, q.val ⊩ φ → q.val ⊩ ψ by simpa [IsForced.imply, LowerSet.mem_himp_iff] @@ -88,11 +82,24 @@ lemma hValue_ext {φ ψ : Propositionᵢ L} : (∀ p : ℂ, p.val ⊩ φ ↔ p.v · exact h ⟨q, hq⟩ hqp hqφ · exact IsForced.efq (p := q) (by simp [IsForced.falsum, hq]) ψ -@[simp] lemma hValue_neg_eq_himp_bot (φ : Propositionᵢ L) : ♯(∼φ) = (♯φ)ᶜ := by +@[simp] lemma and_eq_inf {φ ψ : Propositionᵢ L} : ♯(φ ⋏ ψ) = (♯φ ⊓ ♯ψ) := by + ext p; simp [hValue] + +@[simp] lemma or_eq_sup {φ ψ : Propositionᵢ L} : ♯(φ ⋎ ψ) = (♯φ ⊔ ♯ψ) := by + ext p; simp [hValue] + +@[simp] lemma fal_eq_Inf {φ : Semipropositionᵢ L 1} : ♯(∀⁰ φ) = ⨅ t, ♯(φ/[t]) := by + ext p; simp [hValue,] + +@[simp] lemma exs_eq_Sup {φ : Semipropositionᵢ L 1} : ♯(∃⁰ φ) = ⨆ t, ♯(φ/[t]) := by + ext p; simp [hValue,] + +@[simp] lemma neg_eq_himp_bot (φ : Propositionᵢ L) : ♯(∼φ) = (♯φ)ᶜ := by simp [Semiformulaᵢ.neg_def] set_option backward.isDefEq.respectTransparency false in -lemma hValue_eq_top_iff_provable {φ : Proposition L} : ♯φᴺ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc +/-- Completeness of the Heyting-valued model `ℍ` -/ +lemma complete {φ : Proposition L} : ♯φᴺ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc ♯φᴺ = ⊤ ↔ ⊤ ≤ ♯φᴺ := by simp only [top_le_iff] _ ↔ (∀ p : ℂ, p.val ⊩ φᴺ) := by simp [SetLike.le_def] _ ↔ ℙ ∀⊩ φᴺ := by @@ -104,77 +111,85 @@ lemma hValue_eq_top_iff_provable {φ : Proposition L} : ♯φᴺ = ⊤ ↔ 𝐋 · intro h p; exact h p.val _ ↔ 𝐋𝐊¹ ⊢ φ := IsForced.complete -lemma hValue_lt_top_iff_provable {φ : Proposition L} : ♯φᴺ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by - simp [Entailment.Unprovable, ←hValue_eq_top_iff_provable, lt_top_iff_ne_top] +lemma cocomplete {φ : Proposition L} : ♯φᴺ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by + simp [Entailment.Unprovable, ←complete, lt_top_iff_ne_top] lemma hValue_dn_neg (φ : Proposition L) : ♯(∼φ)ᴺ = (♯φᴺ)ᶜ := calc - ♯(∼φ)ᴺ = ♯(∼φᴺ) := hValue_ext <| by simp [←IsForced.dn_neg_iff] + ♯(∼φ)ᴺ = ♯(∼φᴺ) := HeytingValuedModel.ext <| by simp [←IsForced.dn_neg_iff] _ = (♯φᴺ)ᶜ := by simp @[simp] lemma dn_isRegular (φ : Proposition L) : Heyting.IsRegular ♯φᴺ := by have : ♯φᴺ = (♯(∼φ)ᴺ)ᶜ := by simp [←hValue_dn_neg] simpa [this] using Heyting.isRegular_compl ♯(∼φ)ᴺ -/-- ## Boolean-valued model -/ +end HeytingValuedModel + +/-! ## Boolean-valued model -/ -local notation "𝔹" => Heyting.Regular ℍ +namespace BooleanValuedModel + +open HeytingValuedModel + +scoped notation "𝔹" => Heyting.Regular ℍ + +instance : CompleteBooleanAlgebra 𝔹 := inferInstance instance : Nontrivial 𝔹 := ⟨⊥, ⊤, fun e ↦ by simpa using Heyting.Regular.coe_inj.mpr e⟩ -/-- Boolean value -/ +/-- Boolean value of a proposition -/ def bValue (φ : Proposition L) : 𝔹 := ⟨♯φᴺ, by simp⟩ scoped prefix:max "♭" => bValue @[simp] lemma coe_bValue (φ : Proposition L) : (♭φ : ℍ) = ♯φᴺ := rfl -@[simp] lemma bValue_falsum : ♭(⊥ : Proposition L) = ⊥ := Heyting.Regular.coe_inj.mp <| by simp +@[simp] lemma falsum : ♭(⊥ : Proposition L) = ⊥ := Heyting.Regular.coe_inj.mp <| by simp -@[simp] lemma bValue_verum : ♭(⊤ : Proposition L) = ⊤ := Heyting.Regular.coe_inj.mp <| by simp +@[simp] lemma verum : ♭(⊤ : Proposition L) = ⊤ := Heyting.Regular.coe_inj.mp <| by simp -@[simp] lemma bValue_and_eq_inf : ♭(φ ⋏ ψ) = ♭φ ⊓ ♭ψ := Heyting.Regular.coe_inj.mp <| by simp +@[simp] lemma and_eq_inf : ♭(φ ⋏ ψ) = ♭φ ⊓ ♭ψ := Heyting.Regular.coe_inj.mp <| by simp -@[simp] lemma bValue_lConj_eq_inf (Γ : List (Proposition L)) : ♭(⋀Γ) = Γ.toFinset.inf bValue := +@[simp] lemma lConj_eq_inf (Γ : List (Proposition L)) : ♭(⋀Γ) = Γ.toFinset.inf bValue := match Γ with | [] => by simp | [φ] => by simp | φ :: ψ :: Γ => by - simp [bValue_lConj_eq_inf (ψ :: Γ),]; rfl - -@[simp] lemma bValue_fConj_eq_inf (Γ : Finset (Proposition L)) : ♭(Γ.conj) = Γ.inf bValue := by - simp [Finset.conj] + simp [lConj_eq_inf (ψ :: Γ),]; rfl -@[simp] lemma bValue_or_eq_sup : ♭(φ ⋎ ψ) = ♭φ ⊔ ♭ψ := Heyting.Regular.coe_inj.mp <| by simp +@[simp] lemma or_eq_sup : ♭(φ ⋎ ψ) = ♭φ ⊔ ♭ψ := Heyting.Regular.coe_inj.mp <| by simp -@[simp] lemma bValue_fal_eq_Inf : ♭(∀⁰ φ) = ⨅ t, ♭(φ/[t]) := Heyting.Regular.coe_inj.mp <| by +@[simp] lemma fal_eq_Inf : ♭(∀⁰ φ) = ⨅ t, ♭(φ/[t]) := Heyting.Regular.coe_inj.mp <| by simp [Semiformula.subst_doubleNegation] -@[simp] lemma bValue_exs_eq_Sup : ♭(∃⁰ φ) = ⨆ t, ♭(φ/[t]) := Heyting.Regular.coe_inj.mp <| by +@[simp] lemma exs_eq_Sup : ♭(∃⁰ φ) = ⨆ t, ♭(φ/[t]) := Heyting.Regular.coe_inj.mp <| by simp [Semiformula.subst_doubleNegation, compl_iSup'] -@[simp] lemma bValue_neg_eq_compl : ♭(∼φ) = (♭φ)ᶜ := Heyting.Regular.coe_inj.mp <| by +@[simp] lemma neg_eq_compl (φ : Proposition L) : ♭(∼φ) = (♭φ)ᶜ := Heyting.Regular.coe_inj.mp <| by simp [hValue_dn_neg] -@[simp] lemma bValue_imply_eq_himp : ♭(φ 🡒 ψ) = (♭φ ⇨ ♭ψ) := by +@[simp] lemma imply_eq_himp (φ ψ : Proposition L) : ♭(φ 🡒 ψ) = (♭φ ⇨ ♭ψ) := by simp [Semiformula.imp_eq, BooleanAlgebra.himp_eq]; grind -lemma bValue_eq_top_iff_provable : ♭φ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc +/-- Completeness of the Boolean-valued model `𝔹` -/ +lemma complete : ♭φ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc ♭φ = ⊤ ↔ ♯φᴺ = ⊤ := by rw [←Heyting.Regular.coe_inj]; simp - _ ↔ 𝐋𝐊¹ ⊢ φ := hValue_eq_top_iff_provable + _ ↔ 𝐋𝐊¹ ⊢ φ := HeytingValuedModel.complete -lemma bValue_lt_top_iff_provable : ♭φ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by - simp [Entailment.Unprovable, ←bValue_eq_top_iff_provable, lt_top_iff_ne_top] +lemma cocomplete : ♭φ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by + simp [Entailment.Unprovable, ←complete, lt_top_iff_ne_top] open Order OrderDual -/-- Filter induced by a schema -/ +/-- Filter induced by a schema `𝔖` -/ def _root_.LO.FirstOrder.Schema.filter (𝔖 : Schema L) : Order.PFilter 𝔹 := ⟨⨆ φ : 𝔖, Ideal.principal (toDual ♭φ)⟩ open Classical -@[simp] lemma mem_filter_iff {𝔖 : Schema L} {x} : +variable {𝔖 : Schema L} + +lemma mem_filter_iff : x ∈ 𝔖.filter ↔ ∃ Γ : Finset (Proposition L), ↑Γ ⊆ 𝔖 ∧ Γ.inf bValue ≤ x := calc x ∈ 𝔖.filter ↔ toDual x ∈ ⨆ φ : 𝔖, Ideal.principal (P := 𝔹ᵒᵈ) (toDual ♭φ) := Order.PFilter.mem_mk _ _ _ ↔ ∃ Γ : Finset 𝔖, toDual x ∈ Γ.sup (Ideal.principal ∘ toDual ∘ bValue ∘ Subtype.val) := by rw [Ideal.mem_iSup_iff]; rfl @@ -190,7 +205,8 @@ open Classical · exact hΓ.2 · intro i hi; exact hΓ.1 hi -lemma bValue_mem_filter_iff_provable {𝔖 : Schema L} {φ : Proposition L} : +/-- Completeness of a filter induced by a schema `𝔖` -/ +lemma filter_complete : ♭φ ∈ 𝔖.filter ↔ 𝔖 ⊢ φ := calc ♭φ ∈ 𝔖.filter ↔ ∃ Γ : Finset (Proposition L), ↑Γ ⊆ 𝔖 ∧ Γ.inf bValue ≤ ♭φ := mem_filter_iff _ ↔ ∃ Γ : List (Proposition L), ↑Γ.toFinset ⊆ 𝔖 ∧ Γ.toFinset.inf bValue ≤ ♭φ := by @@ -199,7 +215,7 @@ lemma bValue_mem_filter_iff_provable {𝔖 : Schema L} {φ : Proposition L} : exact ⟨Γ.toList, by simpa using hΓ⟩ · rintro ⟨Γ, hΓ⟩ exact ⟨Γ.toFinset, by simpa using hΓ⟩ - _ ↔ ∃ Γ : List (Proposition L), ↑Γ.toFinset ⊆ 𝔖 ∧ 𝐋𝐊¹ ⊢ ⋀Γ 🡒 φ := by simp [←bValue_eq_top_iff_provable] + _ ↔ ∃ Γ : List (Proposition L), ↑Γ.toFinset ⊆ 𝔖 ∧ 𝐋𝐊¹ ⊢ ⋀Γ 🡒 φ := by simp [←complete] _ ↔ 𝔖 *⊢[𝐋𝐊¹] φ := by constructor · rintro ⟨Γ, hΓ, ⟨b⟩⟩ @@ -208,6 +224,29 @@ lemma bValue_mem_filter_iff_provable {𝔖 : Schema L} {φ : Proposition L} : exact ⟨b.ctx, fun ψ ↦ by simpa using b.subset ψ, ⟨b.prf⟩⟩ _ ↔ 𝔖 ⊢ φ := Schema.iff_context.symm +lemma bot_not_mem_iff_consistent : ⊥ ∉ 𝔖.filter ↔ Entailment.Consistent 𝔖 := by + simpa [←Entailment.inconsistent_iff_provable_bot] using Iff.not <| filter_complete (φ := ⊥) (𝔖 := 𝔖) + +lemma primeIdeal_exists (𝔖 : Schema L) (con : Entailment.Consistent 𝔖) : + ∃ J : Order.Ideal 𝔹, J.IsPrime ∧ Disjoint (𝔖.filter : Set 𝔹) J := by + have : Disjoint (𝔖.filter : Set 𝔹) (⊥ : Ideal 𝔹) := Set.disjoint_iff.mpr <| by + intro x + have := bot_not_mem_iff_consistent.mpr con + simp; grind + simpa using DistribLattice.prime_ideal_of_disjoint_filter_ideal this + +noncomputable def primeIdealOf (𝔖 : Schema L) (con : Entailment.Consistent 𝔖) : Ideal 𝔹 := + Classical.choose <| primeIdeal_exists 𝔖 con + +lemma primeIdealOf_isPrime (𝔖 : Schema L) (con : Entailment.Consistent 𝔖) : (primeIdealOf 𝔖 con).IsPrime := + Classical.choose_spec (primeIdeal_exists 𝔖 con) |>.1 + +lemma primeIdealOf_disjoint (𝔖 : Schema L) (con : Entailment.Consistent 𝔖) : + Disjoint (𝔖.filter : Set 𝔹) (primeIdealOf 𝔖 con) := + Classical.choose_spec (primeIdeal_exists 𝔖 con) |>.2 + +end BooleanValuedModel + end Canonical end LO.FirstOrder.Derivation From f5ac7089b110b37f3e3690e5c9555a116d48b1fe Mon Sep 17 00:00:00 2001 From: palalansouki Date: Tue, 14 Apr 2026 02:34:24 +0900 Subject: [PATCH 37/61] wip --- Foundation/Vorspiel/Order/Heyting.lean | 8 ++ Foundation/Vorspiel/Order/Ideal.lean | 146 ++++++++++++++++++++++++- 2 files changed, 153 insertions(+), 1 deletion(-) diff --git a/Foundation/Vorspiel/Order/Heyting.lean b/Foundation/Vorspiel/Order/Heyting.lean index 70c1f6bcd..ff27e08cf 100644 --- a/Foundation/Vorspiel/Order/Heyting.lean +++ b/Foundation/Vorspiel/Order/Heyting.lean @@ -40,3 +40,11 @@ lemma himp_inf_himp_inf_sup_le (a b c : α) : (a ⇨ c) ⊓ (b ⇨ c) ⊓ (a ⊔ simpa only [GeneralizedHeytingAlgebra.le_himp_iff, inf_comm (a ⊔ b)] using this end HeytingAlgebra + +namespace CompleteBooleanAlgebra + +variable {α : Type*} [CompleteBooleanAlgebra α] + + + +end CompleteBooleanAlgebra diff --git a/Foundation/Vorspiel/Order/Ideal.lean b/Foundation/Vorspiel/Order/Ideal.lean index d10f93f41..1f238a659 100644 --- a/Foundation/Vorspiel/Order/Ideal.lean +++ b/Foundation/Vorspiel/Order/Ideal.lean @@ -4,6 +4,7 @@ module public import Mathlib.Order.Ideal public import Mathlib.Order.PFilter public import Mathlib.Data.Finset.Lattice.Basic +public import Mathlib.Order.PrimeIdeal @[expose] public section @@ -11,7 +12,11 @@ namespace Order namespace Ideal -variable {P : Type*} [SemilatticeSup P] [OrderBot P] +variable {P : Type*} + +section semilatticeSup + +variable [SemilatticeSup P] [OrderBot P] lemma sSup_def (s : Set (Ideal P)) : sSup s = sInf (upperBounds s) := rfl @@ -60,6 +65,145 @@ lemma mem_iSup_iff [DecidableEq ι] {I : ι → Ideal P} {x : P} : intro i x hx refine ⟨{i}, by simpa using hx⟩ +end semilatticeSup + +section completeSemilatticeSup + +variable [CompleteSemilatticeSup P] + +theorem sSup_mem {s : Set P} {I : Ideal P} : + sSup s ∈ I → ∀ x ∈ s, x ∈ I := fun h _ hx ↦ + I.lower (le_sSup_iff.mpr fun _ a ↦ a hx) h + +end completeSemilatticeSup + end Ideal +namespace Ideal.IsProper + +variable {P : Type*} [SemilatticeSup P] + +lemma iff_top_not_mem [OrderTop P] {I : Ideal P} : I.IsProper ↔ ⊤ ∉ I := by + constructor + · intro h ht + have : (I : Set P) = Set.univ := by + ext x + suffices x ∈ I by simpa + exact I.lower (show x ≤ ⊤ by simp) ht + exact h.ne_univ this + · intro hn + refine ⟨?_⟩ + intro e + have : ⊤ ∈ I := + SetLike.mem_coe.mp <| by rw [e]; simp + contradiction + +@[simp] lemma top_not_mem [OrderTop P] (I : Ideal P) [I.IsProper] : ⊤ ∉ I := + iff_top_not_mem.mp inferInstance + +end Ideal.IsProper + +namespace Ideal.PrimePair + +variable {P : Type*} + +open IsPrime + +section booleanAlgebra + +section basic + +variable [Preorder P] (IF : PrimePair P) + +lemma not_mem_F_iff_mem_I {x : P} : + x ∉ IF.F ↔ x ∈ IF.I := by + have : x ∈ IF.I ∨ x ∈ IF.F := by simpa using Set.ext_iff.mp IF.I_union_F x + have : x ∈ IF.I → x ∉ IF.F := @Set.disjoint_left.mp IF.disjoint x + tauto + +lemma not_mem_I_iff_mem_F {x : P} : + x ∉ IF.I ↔ x ∈ IF.F := by + have : x ∈ IF.I ∨ x ∈ IF.F := by simpa using Set.ext_iff.mp IF.I_union_F x + have : x ∈ IF.F → x ∉ IF.I := @Set.disjoint_right.mp IF.disjoint x + tauto + +abbrev IsProper : Prop := IF.I.IsProper + +instance i_isProper (IF : PrimePair P) [IF.IsProper] : IF.I.IsProper := inferInstance + +instance : IF.I.IsPrime := I_isPrime IF + +end basic + +variable [BooleanAlgebra P] {IF : PrimePair P} + +lemma mem_or_compl_mem_I (x : P) : x ∈ IF.I ∨ xᶜ ∈ IF.I := + IF.I_isPrime.mem_or_compl_mem + +lemma mem_or_compl_mem_F (x : P) : x ∈ IF.F ∨ xᶜ ∈ IF.F := by + by_contra! + have hx : x ∈ IF.I := by simpa [not_mem_F_iff_mem_I] using this.1 + have hxc : xᶜ ∈ IF.I := by simpa [not_mem_F_iff_mem_I] using this.2 + have : ⊤ ∈ IF.I := by simpa using Order.Ideal.sup_mem hx hxc + have : ⊤ ∉ IF.I := Ideal.IsProper.top_not_mem IF.I + contradiction + +lemma compl_mem_I_iff_mem_F : + xᶜ ∈ IF.I ↔ x ∈ IF.F := by + constructor + · have : x ∈ IF.F ∨ xᶜ ∉ IF.I := by simpa [not_mem_I_iff_mem_F] using mem_or_compl_mem_F x + tauto + · have : x ∉ IF.F ∨ xᶜ ∈ IF.I := by simpa [not_mem_F_iff_mem_I] using mem_or_compl_mem_I x + tauto + +lemma compl_mem_F_iff_mem_I : + xᶜ ∈ IF.F ↔ x ∈ IF.I := by + simpa using (compl_mem_I_iff_mem_F (x := xᶜ)).symm + +@[simp] lemma inf_mem_I_iff {x y : P} : + x ⊓ y ∈ IF.I ↔ x ∈ IF.I ∨ y ∈ IF.I := by + constructor + · exact mem_or_mem (I_isPrime IF) + · rintro (h | h) + · exact IF.I.lower (by simp) h + · exact IF.I.lower (by simp) h + +@[simp] lemma sup_mem_F_iff {x y : P} : + x ⊔ y ∈ IF.F ↔ x ∈ IF.F ∨ y ∈ IF.F := by + simp [←compl_mem_I_iff_mem_F] + +@[simp] lemma himp_mem_F_iff {x y : P} : + x ⇨ y ∈ IF.F ↔ (x ∈ IF.F → y ∈ IF.F) := by + simp [himp_eq, compl_mem_F_iff_mem_I, ←not_mem_F_iff_mem_I] + tauto + +end booleanAlgebra + +section completeBooleanAlgebra + +variable [CompleteBooleanAlgebra P] {IF : PrimePair P} + +lemma iSup_mem_iff {f : ι → P} : + ⨆ i, f i ∈ IF.I ↔ ∀ i, f i ∈ IF.I := by + constructor + · intro h i + exact IF.I.lower (le_iSup f i) h + · intro h + by_contra! hf + + +lemma iInf_mem_iff {f : ι → P} : + ⨅ i, f i ∈ IF.I ↔ ∃ i, f i ∈ IF.I := by + constructor + · intro h + by_contra! hf + + +end completeBooleanAlgebra + +end Ideal.IsPrime + + + + end Order From 829c51071140b50ae29538b5c6c6c5d65d68d532 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 16 Apr 2026 20:17:55 +0900 Subject: [PATCH 38/61] canonical --- .../Completeness/CanonicalModel.lean | 120 ++++++++++++------ Foundation/Logic/ForcingRelation.lean | 10 +- Foundation/Vorspiel/Order/Ideal.lean | 29 +---- 3 files changed, 88 insertions(+), 71 deletions(-) diff --git a/Foundation/FirstOrder/Completeness/CanonicalModel.lean b/Foundation/FirstOrder/Completeness/CanonicalModel.lean index 617a348c8..d6f0802ab 100644 --- a/Foundation/FirstOrder/Completeness/CanonicalModel.lean +++ b/Foundation/FirstOrder/Completeness/CanonicalModel.lean @@ -350,16 +350,36 @@ instance : Preorder ℙ where rintro ⟨hqp⟩ ⟨hrq⟩ exact ⟨StrongerThan.trans hqp hrq⟩ -abbrev IsForced (p : ℙ) (φ : Propositionᵢ L) := Nonempty (Forces p φ) +variable (L) -instance : ForcingRelation ℙ (Propositionᵢ L) where - Forces := IsForced +def ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴸᴷ¹ ∼Γ)} -namespace IsForced +variable {L} + +local notation "ℙ⁻" => ConsistentSequent L + +namespace ConsistentSequent + +instance : Preorder ℙ⁻ where + le q p := q.val ≤ p.val + le_refl p := by simp + le_trans p q r := le_trans + +instance : Inhabited ℙ⁻ := ⟨⟨[], by simp⟩⟩ + +end ConsistentSequent + +abbrev IsForced (p : ℙ⁻) (φ : Propositionᵢ L) := Nonempty (Forces p.val φ) + +instance : ForcingRelation ℙ⁻ (Propositionᵢ L) := ⟨IsForced⟩ + +instance : WeakForcingRelation ℙ⁻ (Proposition L) := ⟨fun p φ ↦ p ⊩ φᴺ⟩ open Classical -@[simp] lemma rel {p : ℙ} {k} {R : L.Rel k} {v} : p ⊩ .rel R v ↔ Nonempty (⊢ᴸᴷ¹ .rel R v :: ∼p) := by +namespace IsForced + +@[simp] lemma rel {p : ℙ⁻} {k} {R : L.Rel k} {v} : p ⊩ .rel R v ↔ Nonempty (⊢ᴸᴷ¹ .rel R v :: ∼p.val) := by constructor · rintro ⟨b⟩ have ⟨d, hd⟩ := b.relEquiv @@ -368,14 +388,14 @@ open Classical let ⟨b, hb⟩ := hauptsatz d exact ⟨Forces.relEquiv.symm ⟨b, hb⟩⟩ -@[simp] lemma fal {p : ℙ} : p ⊩ ∀⁰ φ ↔ ∀ t, p ⊩ φ/[t] := by +@[simp] lemma fal {p : ℙ⁻} : p ⊩ ∀⁰ φ ↔ ∀ t, p ⊩ φ/[t] := by constructor · rintro ⟨b⟩ t exact ⟨b.allEquiv t⟩ · rintro h exact ⟨Forces.allEquiv.symm fun t ↦ (h t).some⟩ -@[simp] lemma and {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ ⋏ ψ ↔ p ⊩ φ ∧ p ⊩ ψ := by +@[simp] lemma and {p : ℙ⁻} {φ ψ : Propositionᵢ L} : p ⊩ φ ⋏ ψ ↔ p ⊩ φ ∧ p ⊩ ψ := by constructor · rintro ⟨b⟩ have ⟨bφ, bψ⟩ := b.andEquiv @@ -383,7 +403,7 @@ open Classical · rintro ⟨⟨bφ⟩, ⟨bψ⟩⟩ exact ⟨Forces.andEquiv.symm ⟨bφ, bψ⟩⟩ -@[simp] lemma or {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ ⋎ ψ ↔ p ⊩ φ ∨ p ⊩ ψ := by +@[simp] lemma or {p : ℙ⁻} {φ ψ : Propositionᵢ L} : p ⊩ φ ⋎ ψ ↔ p ⊩ φ ∨ p ⊩ ψ := by constructor · rintro ⟨b⟩ have b' := b.orEquiv @@ -392,14 +412,28 @@ open Classical · exact ⟨Forces.orEquiv.symm <| .inl hφ⟩ · exact ⟨Forces.orEquiv.symm <| .inr hψ⟩ -lemma imply {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ 🡒 ψ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ψ) := by +@[simp] lemma not_falsum (p : ℙ⁻) : ¬p ⊩ ⊥ := by + rintro ⟨b⟩ + have ⟨d, hd⟩ := b.falsumEquiv + exact p.prop.false d + +lemma imply {p : ℙ⁻} {φ ψ : Propositionᵢ L} : p ⊩ φ 🡒 ψ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ψ) := by constructor · rintro ⟨b⟩ q ⟨sqp⟩ ⟨bφ⟩ exact ⟨b.implyEquiv _ sqp bφ⟩ · rintro h - refine ⟨Forces.implyEquiv.symm fun q sqp hφ ↦ (h q ⟨sqp⟩ ⟨hφ⟩).some⟩ + refine ⟨Forces.implyEquiv.symm fun q sqp hφ ↦ ?_⟩ + by_cases hq : IsEmpty (⊢ᴸᴷ¹ ∼q) + · exact (h ⟨q, hq⟩ ⟨sqp⟩ ⟨hφ⟩).some + · have : Nonempty (⊢ᴸᴷ¹ ∼q) := by simpa using hq + have d : ⊢ᴸᴷ¹ ∼q := this.some + let ⟨b, hb⟩ := hauptsatz d + exact Forces.implyEquiv (Forces.efq ψ p.val) q sqp (Forces.falsumEquiv.symm ⟨b, hb⟩) + +lemma not {p : ℙ⁻} {φ : Propositionᵢ L} : p ⊩ ∼φ ↔ (∀ q ≤ p, ¬q ⊩ φ) := by + simp [Semiformulaᵢ.neg_def, imply] -@[simp] lemma exs {p : ℙ} : p ⊩ ∃⁰ φ ↔ ∃ t, p ⊩ φ/[t] := by +@[simp] lemma exs {p : ℙ⁻} : p ⊩ ∃⁰ φ ↔ ∃ t, p ⊩ φ/[t] := by constructor · rintro ⟨b⟩ have ⟨t, f⟩ := b.exsEquiv @@ -407,52 +441,62 @@ lemma imply {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ 🡒 ψ ↔ (∀ q · rintro ⟨t, h⟩ exact ⟨Forces.exsEquiv.symm ⟨t, h.some⟩⟩ -lemma falsum {p : ℙ} : p ⊩ ⊥ ↔ Nonempty (⊢ᴸᴷ¹ ∼p) := by - constructor - · rintro ⟨b⟩ - have ⟨d, hd⟩ := b.falsumEquiv - exact ⟨d⟩ - · rintro ⟨d⟩ - let ⟨b, hb⟩ := hauptsatz d - exact ⟨Forces.falsumEquiv.symm ⟨b, hb⟩⟩ - -lemma neg {p : ℙ} {φ : Propositionᵢ L} : p ⊩ ∼φ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ⊥) := by - simp [Semiformulaᵢ.neg_def, imply] - -lemma monotone {p q : ℙ} (hqp : q ≤ p) {φ : Propositionᵢ L} (hφ : p ⊩ φ) : q ⊩ φ := +lemma monotone {p q : ℙ⁻} (hqp : q ≤ p) {φ : Propositionᵢ L} (hφ : p ⊩ φ) : q ⊩ φ := ⟨Forces.monotone hqp.some hφ.some⟩ -instance : ForcingRelation.PreIntKripke ℙ (· ≥ ·) where +instance : ForcingRelation.IntKripke ℙ⁻ (· ≥ ·) where verum _ := ⟨Forces.implyEquiv.symm fun _ _ d ↦ d⟩ + falsum _ := by simp and _ := and or _ := or imply _ := imply + not _ := not monotone hφ _ hpq := hφ.monotone hpq -lemma efq {p : ℙ} (h : p ⊩ ⊥) (φ : Propositionᵢ L) : p ⊩ φ := by - have : p ⊩ ⊥ 🡒 φ := ⟨Forces.efq φ p⟩ - exact imply.mp this p (by simp) h +lemma sound_minimal {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢ φ → ℙ⁻ ∀⊩ φ := by + rintro ⟨d⟩ p; exact ⟨Forces.sound d p.val⟩ + +end IsForced -lemma sound_minimal {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢ φ → ℙ ∀⊩ φ := by - rintro ⟨d⟩ p; exact ⟨Forces.sound d p⟩ +namespace IsWeaklyForced -lemma dn_neg_iff {φ : Proposition L} {p : ℙ} : p ⊩ (∼φ)ᴺ ↔ p ⊩ ∼(φᴺ) := by +open IsForced + +lemma iff_isForced {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ φ ↔ p ⊩ φᴺ := by rfl + +lemma dn_neg_iff {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ ∼φ ↔ p ⊩ ∼φᴺ := by have := by simpa using (sound_minimal (Derivation.neg_doubleNegation φ) p) exact (this p (by simp)).symm -protected lemma refl (φ : Proposition L) : [φ] ⊩ φᴺ := ⟨Forces.refl φ⟩ +lemma not {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ ∼φ ↔ ∀ q ≤ p, ¬q ⊩ᶜ φ := by + simp [IsForced.not, dn_neg_iff,]; rfl + +@[simp] lemma and {φ ψ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ φ ⋏ ψ ↔ p ⊩ᶜ φ ∧ p ⊩ᶜ ψ := by + simp [iff_isForced, ] + +@[simp] lemma or {φ ψ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ φ ⋎ ψ ↔ ∀ q ≤ p, ∃ r ≤ q, r ⊩ᶜ φ ∨ r ⊩ᶜ ψ := by + simp [iff_isForced, IsForced.not, ]; grind -lemma complete {φ : Proposition L} : ℙ ∀⊩ φᴺ ↔ 𝐋𝐊¹ ⊢ φ := by +@[simp] lemma all {φ : Semiproposition L 1} {p : ℙ⁻} : p ⊩ᶜ ∀⁰ φ ↔ ∀ t, p ⊩ᶜ φ/[t] := by + simp [iff_isForced, Semiformula.subst_doubleNegation] + +@[simp] lemma exs {φ : Semiproposition L 1} {p : ℙ⁻} : p ⊩ᶜ ∃⁰ φ ↔ ∀ q ≤ p, ∃ r ≤ q, ∃ t, r ⊩ᶜ φ/[t] := by + simp [iff_isForced, IsForced.not, Semiformula.subst_doubleNegation]; grind + +lemma complete {φ : Proposition L} : ℙ⁻ ∀⊩ᶜ φ ↔ 𝐋𝐊¹ ⊢ φ := by constructor · intro h - have hn : [∼φ] ⊩ ∼(φᴺ) := by simpa [dn_neg_iff] using (IsForced.refl (∼φ)) - have hp : [∼φ] ⊩ φᴺ := h [∼φ] - have : 𝐋𝐊¹ ⊢ φ := by simpa using falsum.mp <| neg.mp hn [∼φ] (by simp) hp - exact this + by_contra b + let p : ℙ⁻ := ⟨[∼φ], ⟨fun bφ ↦ b ⟨by simpa using bφ⟩⟩⟩ + have hp : p ⊩ φᴺ := h p + have hn : p ⊩ᶜ ∼φ := ⟨Forces.refl (∼φ)⟩ + have : ∀ q ≤ p, ¬q ⊩ φᴺ := by simpa [not] using hn + have : ¬p ⊩ φᴺ := this p (by simp) + contradiction · intro b exact sound_minimal <| Provable.gödel_gentzen b -end IsForced +end IsWeaklyForced end Canonical diff --git a/Foundation/Logic/ForcingRelation.lean b/Foundation/Logic/ForcingRelation.lean index e055e3761..22c8fa14e 100644 --- a/Foundation/Logic/ForcingRelation.lean +++ b/Foundation/Logic/ForcingRelation.lean @@ -37,10 +37,8 @@ class BasicSemantics where class Monotone (R : outParam (W → W → Prop)) where monotone {w : W} : w ⊩ φ → ∀ v, R w v → v ⊩ φ -class PreIntKripke (R : outParam (W → W → Prop)) extends BasicSemantics W, Monotone W R where +class IntKripke (R : outParam (W → W → Prop)) extends BasicSemantics W, Monotone W R where imply (w : W) : w ⊩ φ 🡒 ψ ↔ (∀ v, R w v → v ⊩ φ → v ⊩ ψ) - -class IntKripke (R : outParam (W → W → Prop)) extends BasicSemantics W, PreIntKripke W R where falsum (w : W) : ¬w ⊩ ⊥ not (w : W) : w ⊩ ∼φ ↔ (∀ v, R w v → ¬v ⊩ φ) @@ -52,12 +50,12 @@ attribute [simp, grind .] IntKripke.falsum attribute [grind .] - PreIntKripke.imply + IntKripke.imply IntKripke.not @[simp, grind =] -lemma iff (R : W → W → Prop) [PreIntKripke W R] : w ⊩ (φ 🡘 ψ) ↔ (∀ v, R w v → (v ⊩ φ ↔ v ⊩ ψ)) := by - simp [LogicalConnective.iff, PreIntKripke.imply]; grind +lemma iff (R : W → W → Prop) [IntKripke W R] : w ⊩ (φ 🡘 ψ) ↔ (∀ v, R w v → (v ⊩ φ ↔ v ⊩ ψ)) := by + simp [LogicalConnective.iff, IntKripke.imply]; grind variable (W) diff --git a/Foundation/Vorspiel/Order/Ideal.lean b/Foundation/Vorspiel/Order/Ideal.lean index 1f238a659..ff88ffa3d 100644 --- a/Foundation/Vorspiel/Order/Ideal.lean +++ b/Foundation/Vorspiel/Order/Ideal.lean @@ -179,31 +179,6 @@ lemma compl_mem_F_iff_mem_I : end booleanAlgebra -section completeBooleanAlgebra +end PrimePair -variable [CompleteBooleanAlgebra P] {IF : PrimePair P} - -lemma iSup_mem_iff {f : ι → P} : - ⨆ i, f i ∈ IF.I ↔ ∀ i, f i ∈ IF.I := by - constructor - · intro h i - exact IF.I.lower (le_iSup f i) h - · intro h - by_contra! hf - - -lemma iInf_mem_iff {f : ι → P} : - ⨅ i, f i ∈ IF.I ↔ ∃ i, f i ∈ IF.I := by - constructor - · intro h - by_contra! hf - - -end completeBooleanAlgebra - -end Ideal.IsPrime - - - - -end Order +end Order.Ideal From f070958604af237cc2e72ef174eba4b28d5634f3 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 16 Apr 2026 21:51:04 +0900 Subject: [PATCH 39/61] genericFillter --- .../Completeness/CanonicalModel.lean | 10 +++ .../FirstOrder/Completeness/CounterModel.lean | 68 +++++++++++++++++++ Foundation/Vorspiel/Order/Dense.lean | 30 ++++---- 3 files changed, 94 insertions(+), 14 deletions(-) create mode 100644 Foundation/FirstOrder/Completeness/CounterModel.lean diff --git a/Foundation/FirstOrder/Completeness/CanonicalModel.lean b/Foundation/FirstOrder/Completeness/CanonicalModel.lean index d6f0802ab..0853fe948 100644 --- a/Foundation/FirstOrder/Completeness/CanonicalModel.lean +++ b/Foundation/FirstOrder/Completeness/CanonicalModel.lean @@ -468,6 +468,10 @@ lemma dn_neg_iff {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ ∼φ ↔ p ⊩ have := by simpa using (sound_minimal (Derivation.neg_doubleNegation φ) p) exact (this p (by simp)).symm +@[simp] lemma verum (p : ℙ⁻) : p ⊩ᶜ ⊤ := by simp [iff_isForced, IsForced.not] + +@[simp] lemma falsum (p : ℙ⁻) : ¬p ⊩ᶜ ⊥ := by simp [iff_isForced] + lemma not {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ ∼φ ↔ ∀ q ≤ p, ¬q ⊩ᶜ φ := by simp [IsForced.not, dn_neg_iff,]; rfl @@ -483,6 +487,12 @@ lemma not {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ ∼φ ↔ ∀ q ≤ p, ¬ @[simp] lemma exs {φ : Semiproposition L 1} {p : ℙ⁻} : p ⊩ᶜ ∃⁰ φ ↔ ∀ q ≤ p, ∃ r ≤ q, ∃ t, r ⊩ᶜ φ/[t] := by simp [iff_isForced, IsForced.not, Semiformula.subst_doubleNegation]; grind +lemma monotone {φ : Proposition L} {p q : ℙ⁻} (h : q ≤ p) : p ⊩ᶜ φ → q ⊩ᶜ φ := IsForced.monotone h + +lemma gnericity {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ φ ↔ ∀ q ≤ p, ∃ r ≤ q, r ⊩ᶜ φ := calc + p ⊩ᶜ φ ↔ p ⊩ᶜ ∼∼φ := by simp + _ ↔ ∀ q ≤ p, ∃ r ≤ q, r ⊩ᶜ φ := by rw [not]; simp [not] + lemma complete {φ : Proposition L} : ℙ⁻ ∀⊩ᶜ φ ↔ 𝐋𝐊¹ ⊢ φ := by constructor · intro h diff --git a/Foundation/FirstOrder/Completeness/CounterModel.lean b/Foundation/FirstOrder/Completeness/CounterModel.lean new file mode 100644 index 000000000..481f8a2b1 --- /dev/null +++ b/Foundation/FirstOrder/Completeness/CounterModel.lean @@ -0,0 +1,68 @@ +module + +public import Foundation.FirstOrder.Completeness.CanonicalModel +public import Foundation.Vorspiel.Order.Dense +public import Mathlib.Logic.Equiv.List +public import Mathlib.Logic.Encodable.Basic + +@[expose] public section + +namespace LO.FirstOrder.Derivation.Canonical + +open Order + +variable {L : Language} + +local notation "ℙ" => Sequent L +local notation "ℙ⁻" => ConsistentSequent L + +scoped notation "ℍ" => LowerSet ℙ⁻ + +instance [L.Encodable] [L.DecidableEq] : Encodable (Sequent L) := List.encodable + +open Classical in +noncomputable instance [L.Encodable] : Encodable ℙ⁻ := Subtype.encodable + +def value (φ : Proposition L) : ℍ where + carrier := { p | p ⊩ᶜ φ } + lower' _ _ hqp hp := IsWeaklyForced.monotone hqp hp + +notation "‖" φ "‖" => value φ + +lemma provable_iff_dense {φ : Proposition L} : + 𝐋𝐊¹ ⊢ φ ↔ IsDense (‖φ‖ : Set ℙ⁻) := calc + 𝐋𝐊¹ ⊢ φ ↔ ℙ⁻ ∀⊩ᶜ φ := IsWeaklyForced.complete.symm + _ ↔ IsDense (‖φ‖ : Set ℙ⁻) := by + constructor + · intro h p + suffices ∃ q ≤ p, q ⊩ᶜ φ by simpa [value] + refine ⟨p, by simp, h p⟩ + · intro h p + apply IsWeaklyForced.gnericity.mpr + intro q hqp + simpa [value] using h q + +open Classical +def decidablePoints (φ : Proposition L) : DenseSet ℙ⁻ where + set := {p | p ⊩ᶜ φ ∨ p ⊩ᶜ ∼φ} + is_dense := by + intro p + have : p ⊩ᶜ φ ⋎ ∼φ := IsWeaklyForced.complete.mpr Entailment.lem! p + have : ∀ q ≤ p, ∃ r ≤ q, r ⊩ᶜ φ ∨ r ⊩ᶜ ∼φ := by simpa using this + simpa using this p (by rfl) + +variable [L.Encodable] + +theorem genericFIlter_exists (p : ℙ⁻) : + ∃ G : PFilter ℙ⁻, G.IsGeneric (Set.range decidablePoints) ∧ p ∈ G := + PFilter.countable_isGeneric (Set.range decidablePoints) (Set.countable_range decidablePoints) p + +noncomputable def genericFilter (p : ℙ⁻) : PFilter ℙ⁻ := Classical.choose (genericFIlter_exists p) + +instance genericFilter_isGeneric (p : ℙ⁻) : (genericFilter p).IsGeneric (Set.range decidablePoints) := + Classical.choose_spec (genericFIlter_exists p) |>.1 + +@[simp] lemma mem_genericFilter (p : ℙ⁻) : p ∈ genericFilter p := + Classical.choose_spec (genericFIlter_exists p) |>.2 + +end LO.FirstOrder.Derivation.Canonical diff --git a/Foundation/Vorspiel/Order/Dense.lean b/Foundation/Vorspiel/Order/Dense.lean index 2ae08b808..d4a108586 100644 --- a/Foundation/Vorspiel/Order/Dense.lean +++ b/Foundation/Vorspiel/Order/Dense.lean @@ -99,30 +99,32 @@ def ofDescendingChain (s : ℕ → α) (hs : ∀ i j, i ≤ j → s i ≥ s j) : @[simp] lemma mem_descendingChain_iff (s : ℕ → α) (hs : ∀ i j, i ≤ j → s i ≥ s j) : x ∈ ofDescendingChain s hs ↔ ∃ i, s i ≤ x := by rfl -class Generic (F : PFilter α) (𝓓 : Set (DenseSet α)) where - generic : ∀ d ∈ 𝓓, ∃ a ∈ F, a ∈ d +class IsGeneric (F : PFilter α) (𝓓 : Set (DenseSet α)) where + isGeneric : ∀ d ∈ 𝓓, ∃ a ∈ F, a ∈ d -@[simp] instance Generic.empty (F : PFilter α) : F.Generic ∅ := ⟨by simp⟩ +@[simp] instance IsGeneric.empty (F : PFilter α) : F.IsGeneric ∅ := ⟨by simp⟩ -theorem countable_generic [Inhabited α] (𝓓 : Set (DenseSet α)) (ctb : Set.Countable 𝓓) : - ∃ G, Generic G 𝓓 := by +theorem countable_isGeneric (𝓓 : Set (DenseSet α)) (ctb : Set.Countable 𝓓) (a : α) : + ∃ G : PFilter α, G.IsGeneric 𝓓 ∧ a ∈ G := by by_cases emp : 𝓓.Nonempty - case neg => exact ⟨default, by simp [Set.not_nonempty_iff_eq_empty.mp emp]⟩ + case neg => exact ⟨principal a, by simp [Set.not_nonempty_iff_eq_empty.mp emp]⟩ have : ∃ D : ℕ → 𝓓, Function.Surjective D := ctb.exists_surjective emp rcases this with ⟨D, hD⟩ - let s (n : ℕ) : α := n.rec default fun i ↦ (D i).val.choose + let s (n : ℕ) : α := n.rec a fun i ↦ (D i).val.choose have hs : ∀ i j, i ≤ j → s i ≥ s j := fun i j hij ↦ Nat.monotone_of_succ_monotone (r := fun i j ↦ s i ≥ s j) (fun _ ↦ le_refl _) ⟨fun _ _ _ ↦ ge_trans⟩ (by simp [s]) hij - refine ⟨ofDescendingChain s hs, ⟨?_⟩⟩ - intro d hd - rcases show ∃ i, D i = ⟨d, hd⟩ from hD ⟨d, hd⟩ with ⟨i, hi⟩ - refine ⟨s (i + 1), ?_, ?_⟩ - · simp only [mem_descendingChain_iff] - exact ⟨i + 1, by rfl⟩ - · simp [s, hi] + refine ⟨ofDescendingChain s hs, ⟨?_⟩, ?_⟩ + · intro d hd + rcases show ∃ i, D i = ⟨d, hd⟩ from hD ⟨d, hd⟩ with ⟨i, hi⟩ + refine ⟨s (i + 1), ?_, ?_⟩ + · simp only [mem_descendingChain_iff] + exact ⟨i + 1, by rfl⟩ + · simp [s, hi] + · suffices ∃ i, s i ≤ a by simpa + refine ⟨0, by simp [s]⟩ end Order.PFilter From 2a2fbd652eed3421127ab9f635749c65027be2ec Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 16 Apr 2026 21:51:04 +0900 Subject: [PATCH 40/61] genericFillter --- .../Completeness/CanonicalModel.lean | 10 +++ .../FirstOrder/Completeness/CounterModel.lean | 70 +++++++++++++++++++ Foundation/Vorspiel/Order/Dense.lean | 30 ++++---- 3 files changed, 96 insertions(+), 14 deletions(-) create mode 100644 Foundation/FirstOrder/Completeness/CounterModel.lean diff --git a/Foundation/FirstOrder/Completeness/CanonicalModel.lean b/Foundation/FirstOrder/Completeness/CanonicalModel.lean index d6f0802ab..0853fe948 100644 --- a/Foundation/FirstOrder/Completeness/CanonicalModel.lean +++ b/Foundation/FirstOrder/Completeness/CanonicalModel.lean @@ -468,6 +468,10 @@ lemma dn_neg_iff {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ ∼φ ↔ p ⊩ have := by simpa using (sound_minimal (Derivation.neg_doubleNegation φ) p) exact (this p (by simp)).symm +@[simp] lemma verum (p : ℙ⁻) : p ⊩ᶜ ⊤ := by simp [iff_isForced, IsForced.not] + +@[simp] lemma falsum (p : ℙ⁻) : ¬p ⊩ᶜ ⊥ := by simp [iff_isForced] + lemma not {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ ∼φ ↔ ∀ q ≤ p, ¬q ⊩ᶜ φ := by simp [IsForced.not, dn_neg_iff,]; rfl @@ -483,6 +487,12 @@ lemma not {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ ∼φ ↔ ∀ q ≤ p, ¬ @[simp] lemma exs {φ : Semiproposition L 1} {p : ℙ⁻} : p ⊩ᶜ ∃⁰ φ ↔ ∀ q ≤ p, ∃ r ≤ q, ∃ t, r ⊩ᶜ φ/[t] := by simp [iff_isForced, IsForced.not, Semiformula.subst_doubleNegation]; grind +lemma monotone {φ : Proposition L} {p q : ℙ⁻} (h : q ≤ p) : p ⊩ᶜ φ → q ⊩ᶜ φ := IsForced.monotone h + +lemma gnericity {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ φ ↔ ∀ q ≤ p, ∃ r ≤ q, r ⊩ᶜ φ := calc + p ⊩ᶜ φ ↔ p ⊩ᶜ ∼∼φ := by simp + _ ↔ ∀ q ≤ p, ∃ r ≤ q, r ⊩ᶜ φ := by rw [not]; simp [not] + lemma complete {φ : Proposition L} : ℙ⁻ ∀⊩ᶜ φ ↔ 𝐋𝐊¹ ⊢ φ := by constructor · intro h diff --git a/Foundation/FirstOrder/Completeness/CounterModel.lean b/Foundation/FirstOrder/Completeness/CounterModel.lean new file mode 100644 index 000000000..8f12533ed --- /dev/null +++ b/Foundation/FirstOrder/Completeness/CounterModel.lean @@ -0,0 +1,70 @@ +module + +public import Foundation.FirstOrder.Completeness.CanonicalModel +public import Foundation.Vorspiel.Order.Dense +public import Mathlib.Logic.Equiv.List +public import Mathlib.Logic.Encodable.Basic + +@[expose] public section + +namespace LO.FirstOrder.Derivation.Canonical + +open Order + +variable {L : Language} + +local notation "ℙ" => Sequent L +local notation "ℙ⁻" => ConsistentSequent L + +scoped notation "ℍ" => LowerSet ℙ⁻ + +instance [L.Encodable] [L.DecidableEq] : Encodable (Sequent L) := List.encodable + +open Classical in +noncomputable instance [L.Encodable] : Encodable ℙ⁻ := Subtype.encodable + +def value (φ : Proposition L) : ℍ where + carrier := { p | p ⊩ᶜ φ } + lower' _ _ hqp hp := IsWeaklyForced.monotone hqp hp + +notation "‖" φ "‖" => value φ + +lemma provable_iff_dense {φ : Proposition L} : + 𝐋𝐊¹ ⊢ φ ↔ IsDense (‖φ‖ : Set ℙ⁻) := calc + 𝐋𝐊¹ ⊢ φ ↔ ℙ⁻ ∀⊩ᶜ φ := IsWeaklyForced.complete.symm + _ ↔ IsDense (‖φ‖ : Set ℙ⁻) := by + constructor + · intro h p + suffices ∃ q ≤ p, q ⊩ᶜ φ by simpa [value] + refine ⟨p, by simp, h p⟩ + · intro h p + apply IsWeaklyForced.gnericity.mpr + intro q hqp + simpa [value] using h q + +open Classical +def decidablePoints (φ : Proposition L) : DenseSet ℙ⁻ where + set := {p | p ⊩ᶜ φ ∨ p ⊩ᶜ ∼φ} + is_dense := by + intro p + have : p ⊩ᶜ φ ⋎ ∼φ := IsWeaklyForced.complete.mpr Entailment.lem! p + have : ∀ q ≤ p, ∃ r ≤ q, r ⊩ᶜ φ ∨ r ⊩ᶜ ∼φ := by simpa using this + simpa using this p (by rfl) + +variable [L.Encodable] + +theorem genericFilter_exists (p : ℙ⁻) : + ∃ G : PFilter ℙ⁻, G.IsGeneric (Set.range decidablePoints) ∧ p ∈ G := + PFilter.countable_isGeneric (Set.range decidablePoints) (Set.countable_range decidablePoints) p + +noncomputable def genericFilter (p : ℙ⁻) : PFilter ℙ⁻ := Classical.choose (genericFilter_exists p) + +instance genericFilter_isGeneric (p : ℙ⁻) : (genericFilter p).IsGeneric (Set.range decidablePoints) := + Classical.choose_spec (genericFilter_exists p) |>.1 + +@[simp] lemma mem_genericFilter (p : ℙ⁻) : p ∈ genericFilter p := + Classical.choose_spec (genericFilter_exists p) |>.2 + + + +end LO.FirstOrder.Derivation.Canonical diff --git a/Foundation/Vorspiel/Order/Dense.lean b/Foundation/Vorspiel/Order/Dense.lean index 2ae08b808..d4a108586 100644 --- a/Foundation/Vorspiel/Order/Dense.lean +++ b/Foundation/Vorspiel/Order/Dense.lean @@ -99,30 +99,32 @@ def ofDescendingChain (s : ℕ → α) (hs : ∀ i j, i ≤ j → s i ≥ s j) : @[simp] lemma mem_descendingChain_iff (s : ℕ → α) (hs : ∀ i j, i ≤ j → s i ≥ s j) : x ∈ ofDescendingChain s hs ↔ ∃ i, s i ≤ x := by rfl -class Generic (F : PFilter α) (𝓓 : Set (DenseSet α)) where - generic : ∀ d ∈ 𝓓, ∃ a ∈ F, a ∈ d +class IsGeneric (F : PFilter α) (𝓓 : Set (DenseSet α)) where + isGeneric : ∀ d ∈ 𝓓, ∃ a ∈ F, a ∈ d -@[simp] instance Generic.empty (F : PFilter α) : F.Generic ∅ := ⟨by simp⟩ +@[simp] instance IsGeneric.empty (F : PFilter α) : F.IsGeneric ∅ := ⟨by simp⟩ -theorem countable_generic [Inhabited α] (𝓓 : Set (DenseSet α)) (ctb : Set.Countable 𝓓) : - ∃ G, Generic G 𝓓 := by +theorem countable_isGeneric (𝓓 : Set (DenseSet α)) (ctb : Set.Countable 𝓓) (a : α) : + ∃ G : PFilter α, G.IsGeneric 𝓓 ∧ a ∈ G := by by_cases emp : 𝓓.Nonempty - case neg => exact ⟨default, by simp [Set.not_nonempty_iff_eq_empty.mp emp]⟩ + case neg => exact ⟨principal a, by simp [Set.not_nonempty_iff_eq_empty.mp emp]⟩ have : ∃ D : ℕ → 𝓓, Function.Surjective D := ctb.exists_surjective emp rcases this with ⟨D, hD⟩ - let s (n : ℕ) : α := n.rec default fun i ↦ (D i).val.choose + let s (n : ℕ) : α := n.rec a fun i ↦ (D i).val.choose have hs : ∀ i j, i ≤ j → s i ≥ s j := fun i j hij ↦ Nat.monotone_of_succ_monotone (r := fun i j ↦ s i ≥ s j) (fun _ ↦ le_refl _) ⟨fun _ _ _ ↦ ge_trans⟩ (by simp [s]) hij - refine ⟨ofDescendingChain s hs, ⟨?_⟩⟩ - intro d hd - rcases show ∃ i, D i = ⟨d, hd⟩ from hD ⟨d, hd⟩ with ⟨i, hi⟩ - refine ⟨s (i + 1), ?_, ?_⟩ - · simp only [mem_descendingChain_iff] - exact ⟨i + 1, by rfl⟩ - · simp [s, hi] + refine ⟨ofDescendingChain s hs, ⟨?_⟩, ?_⟩ + · intro d hd + rcases show ∃ i, D i = ⟨d, hd⟩ from hD ⟨d, hd⟩ with ⟨i, hi⟩ + refine ⟨s (i + 1), ?_, ?_⟩ + · simp only [mem_descendingChain_iff] + exact ⟨i + 1, by rfl⟩ + · simp [s, hi] + · suffices ∃ i, s i ≤ a by simpa + refine ⟨0, by simp [s]⟩ end Order.PFilter From 4c08da96d9eb3bd8f0a441793cc35768e3f80853 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Wed, 22 Apr 2026 15:41:40 +0900 Subject: [PATCH 41/61] forcing lemma --- .../Completeness/CanonicalModel.lean | 10 +- .../FirstOrder/Completeness/CounterModel.lean | 172 +++++++++++++++--- Foundation/Vorspiel/Order/Dense.lean | 53 +++++- Foundation/Vorspiel/Order/LowerSet.lean | 38 +--- 4 files changed, 203 insertions(+), 70 deletions(-) diff --git a/Foundation/FirstOrder/Completeness/CanonicalModel.lean b/Foundation/FirstOrder/Completeness/CanonicalModel.lean index 0853fe948..72a7615ad 100644 --- a/Foundation/FirstOrder/Completeness/CanonicalModel.lean +++ b/Foundation/FirstOrder/Completeness/CanonicalModel.lean @@ -365,7 +365,13 @@ instance : Preorder ℙ⁻ where le_refl p := by simp le_trans p q r := le_trans -instance : Inhabited ℙ⁻ := ⟨⟨[], by simp⟩⟩ +def nil : ℙ⁻ := ⟨[], by simp⟩ + +instance : OrderTop ℙ⁻ where + top := nil + le_top := by + rintro ⟨Γ, hΓ⟩ + exact ⟨StrongerThan.ofSubset <| List.nil_subset Γ⟩ end ConsistentSequent @@ -472,7 +478,7 @@ lemma dn_neg_iff {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ ∼φ ↔ p ⊩ @[simp] lemma falsum (p : ℙ⁻) : ¬p ⊩ᶜ ⊥ := by simp [iff_isForced] -lemma not {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ ∼φ ↔ ∀ q ≤ p, ¬q ⊩ᶜ φ := by +@[simp] lemma not {φ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ ∼φ ↔ ∀ q ≤ p, ¬q ⊩ᶜ φ := by simp [IsForced.not, dn_neg_iff,]; rfl @[simp] lemma and {φ ψ : Proposition L} {p : ℙ⁻} : p ⊩ᶜ φ ⋏ ψ ↔ p ⊩ᶜ φ ∧ p ⊩ᶜ ψ := by diff --git a/Foundation/FirstOrder/Completeness/CounterModel.lean b/Foundation/FirstOrder/Completeness/CounterModel.lean index 8f12533ed..e5b33c57b 100644 --- a/Foundation/FirstOrder/Completeness/CounterModel.lean +++ b/Foundation/FirstOrder/Completeness/CounterModel.lean @@ -23,25 +23,6 @@ instance [L.Encodable] [L.DecidableEq] : Encodable (Sequent L) := List.encodable open Classical in noncomputable instance [L.Encodable] : Encodable ℙ⁻ := Subtype.encodable -def value (φ : Proposition L) : ℍ where - carrier := { p | p ⊩ᶜ φ } - lower' _ _ hqp hp := IsWeaklyForced.monotone hqp hp - -notation "‖" φ "‖" => value φ - -lemma provable_iff_dense {φ : Proposition L} : - 𝐋𝐊¹ ⊢ φ ↔ IsDense (‖φ‖ : Set ℙ⁻) := calc - 𝐋𝐊¹ ⊢ φ ↔ ℙ⁻ ∀⊩ᶜ φ := IsWeaklyForced.complete.symm - _ ↔ IsDense (‖φ‖ : Set ℙ⁻) := by - constructor - · intro h p - suffices ∃ q ≤ p, q ⊩ᶜ φ by simpa [value] - refine ⟨p, by simp, h p⟩ - · intro h p - apply IsWeaklyForced.gnericity.mpr - intro q hqp - simpa [value] using h q - open Classical def decidablePoints (φ : Proposition L) : DenseSet ℙ⁻ where set := {p | p ⊩ᶜ φ ∨ p ⊩ᶜ ∼φ} @@ -51,20 +32,155 @@ def decidablePoints (φ : Proposition L) : DenseSet ℙ⁻ where have : ∀ q ≤ p, ∃ r ≤ q, r ⊩ᶜ φ ∨ r ⊩ᶜ ∼φ := by simpa using this simpa using this p (by rfl) -variable [L.Encodable] +@[simp] lemma mem_decidablePoints_def (p : ℙ⁻) (φ : Proposition L) : + p ∈ decidablePoints φ ↔ p ⊩ᶜ φ ∨ p ⊩ᶜ ∼φ := by rfl -theorem genericFilter_exists (p : ℙ⁻) : - ∃ G : PFilter ℙ⁻, G.IsGeneric (Set.range decidablePoints) ∧ p ∈ G := - PFilter.countable_isGeneric (Set.range decidablePoints) (Set.countable_range decidablePoints) p +def henkinPoints (φ : Semiproposition L 1) : DenseSet ℙ⁻ where + set := {p | ∀ q ≤ p, q ⊩ᶜ ∃⁰ φ → ∃ t, q ⊩ᶜ φ/[t]} + is_dense := by + intro p + suffices ∃ q ≤ p, ∀ q_1 ≤ q, (∀ q ≤ q_1, ∃ r ≤ q, ∃ t, r ⊩ᶜ φ/[t]) → ∃ t, q_1 ⊩ᶜ φ/[t] by + simpa only [IsWeaklyForced.exs, Set.mem_setOf_eq] + have : p ⊩ᶜ (∃⁰ φ) ⋎ (∀⁰ ∼φ) := IsWeaklyForced.complete.mpr Entailment.lem! p + have : ∀ q ≤ p, ∃ r ≤ q, (∀ q ≤ r, ∃ r ≤ q, ∃ t, r ⊩ᶜ φ/[t]) ∨ + (∀ t, ∀ q ≤ r, ¬q ⊩ᶜ φ/[t]) := by simpa using this + rcases this p (by rfl) with ⟨q, hqp, (h | h)⟩ + · rcases h q (by rfl) with ⟨r, hrq, t, ht⟩ + refine ⟨r, le_trans hrq hqp, fun s hsr _ ↦ ⟨t, IsWeaklyForced.monotone hsr ht⟩⟩ + · refine ⟨q, hqp, ?_⟩ + intro r hrq hA + rcases hA r (by rfl) with ⟨s, hsr, u, hu⟩ + have : ¬s ⊩ᶜ φ/[u] := h u s (le_trans hsr hrq) + contradiction + +@[simp] lemma mem_henkinPoints_def (p : ℙ⁻) (φ : Semiproposition L 1) : + p ∈ henkinPoints φ ↔ ∀ q ≤ p, q ⊩ᶜ ∃⁰ φ → ∃ t, q ⊩ᶜ φ/[t] := by rfl + +abbrev denseSets : Set (DenseSet ℙ⁻) := Set.range decidablePoints ∪ Set.range henkinPoints -noncomputable def genericFilter (p : ℙ⁻) : PFilter ℙ⁻ := Classical.choose (genericFilter_exists p) +variable [L.Encodable] -instance genericFilter_isGeneric (p : ℙ⁻) : (genericFilter p).IsGeneric (Set.range decidablePoints) := - Classical.choose_spec (genericFilter_exists p) |>.1 +theorem exists_genericFilter (p : ℙ⁻) : + ∃ G : PFilter ℙ⁻, G.IsGeneric denseSets ∧ p ∈ G := + PFilter.exists_genericFilter_of_countable denseSets + (Set.countable_union.mpr ⟨Set.countable_range decidablePoints, Set.countable_range henkinPoints⟩) p -@[simp] lemma mem_genericFilter (p : ℙ⁻) : p ∈ genericFilter p := - Classical.choose_spec (genericFilter_exists p) |>.2 +noncomputable def genericFilter (p : ℙ⁻) : PFilter ℙ⁻ := Classical.choose (exists_genericFilter p) +instance genericFilter_isGeneric (p : ℙ⁻) : (genericFilter p).IsGeneric denseSets := + Classical.choose_spec (exists_genericFilter p) |>.1 +@[simp] lemma mem_genericFilter (p : ℙ⁻) : p ∈ genericFilter p := + Classical.choose_spec (exists_genericFilter p) |>.2 + +def GenericForces (p : ℙ⁻) (φ : Proposition L) : Prop := ∃ q ∈ genericFilter p, q ⊩ᶜ φ + +local infix: 60 " ⊫ " => GenericForces + +lemma GenericForces.em (p : ℙ⁻) (φ : Proposition L) : p ⊫ φ ∨ p ⊫ ∼φ := by + have : ∃ q ∈ genericFilter p, q ∈ decidablePoints φ := + (genericFilter_isGeneric p).isGeneric (decidablePoints φ) (by simp) + rcases this with ⟨q, hqG, hq⟩ + have : q ⊩ᶜ φ ∨ q ⊩ᶜ ∼φ := by simpa using hq + rcases this with (em | em) + · left + refine ⟨q, hqG, em⟩ + · right + refine ⟨q, hqG, em⟩ + +@[simp] lemma GenericForces.neg {p : ℙ⁻} {φ : Proposition L} : p ⊫ ∼φ ↔ ¬p ⊫ φ := by + suffices p ⊫ ∼φ → p ⊫ φ → False by + have := GenericForces.em p φ + grind + rintro ⟨q₀, hG₀, h₀⟩ + rintro ⟨q₁, hG₁, h₁⟩ + have : ∃ r ∈ genericFilter p, r ≤ q₀ ∧ r ≤ q₁ := (genericFilter p).directed _ hG₀ _ hG₁ + rcases this with ⟨r, hG, hr₀, hr₁⟩ + have : r ⊩ᶜ φ := h₁.monotone hr₁ + have : ¬r ⊩ᶜ φ := IsWeaklyForced.not.mp h₀ r (by assumption) + contradiction + +@[simp] lemma GenericForces.verum (p : ℙ⁻) : p ⊫ ⊤ := + ⟨p, by simp⟩ + +@[simp] lemma GenericForces.not_falsum (p : ℙ⁻) : ¬p ⊫ ⊥ := by + rintro ⟨q, hq⟩; simp_all + +@[simp] lemma GenericForces.nrel {p : ℙ⁻} : p ⊫ .nrel R v ↔ ¬p ⊫ .rel R v := calc + p ⊫ .nrel R v ↔ p ⊫ ∼(.rel R v) := by simp + _ ↔ ¬p ⊫ .rel R v := by rw [GenericForces.neg] + +lemma GenericForces.henkin {p : ℙ⁻} {φ : Semiproposition L 1} : p ⊫ ∃⁰ φ → ∃ t, p ⊫ φ/[t] := by + have : ∃ q ∈ genericFilter p, ∀ r ≤ q, r ⊩ᶜ ∃⁰ φ → ∃ t, r ⊩ᶜ φ/[t] := + (genericFilter_isGeneric p).isGeneric (henkinPoints φ) (by simp) + rcases this with ⟨q, hqG, H⟩ + rintro ⟨r, hrG, hr⟩ + have : ∃ z ∈ genericFilter p, z ≤ q ∧ z ≤ r := (genericFilter p).directed _ hqG _ hrG + rcases this with ⟨z, hGz, hzq, hzr⟩ + have : ∃ t, z ⊩ᶜ φ/[t] := H z hzq (hr.monotone hzr) + rcases this with ⟨t, hzt⟩ + refine ⟨t, ⟨z, hGz, hzt⟩⟩ + +@[simp] lemma GenericForces.exs {p : ℙ⁻} : p ⊫ ∃⁰ φ ↔ ∃ t, p ⊫ φ/[t] := by + constructor + · exact GenericForces.henkin + · rintro ⟨t, q, hqG, h⟩ + refine ⟨q, hqG, ?_⟩ + suffices ∀ r ≤ q, ∃ s ≤ r, ∃ t, s ⊩ᶜ φ/[t] by simpa + intro r hrq + refine ⟨r, by simp, t, h.monotone hrq⟩ + +@[simp] lemma GenericForces.fal {p : ℙ⁻} : p ⊫ ∀⁰ φ ↔ ∀ t, p ⊫ φ/[t] := calc + p ⊫ ∀⁰ φ ↔ p ⊫ ∼(∃⁰ ∼φ) := by simp + _ ↔ ¬p ⊫ ∃⁰ ∼φ := by rw [GenericForces.neg] + _ ↔ ∀ t, p ⊫ φ/[t] := by simp [GenericForces.exs] + +@[simp] lemma GenericForces.and {p : ℙ⁻} {φ ψ : Proposition L} : p ⊫ φ ⋏ ψ ↔ p ⊫ φ ∧ p ⊫ ψ := by + constructor + · rintro ⟨q, hqG, hq⟩ + have : q ⊩ᶜ φ ∧ q ⊩ᶜ ψ := by simpa using hq + rcases this with ⟨hφ, hψ⟩ + exact ⟨⟨q, hqG, hφ⟩, ⟨q, hqG, hψ⟩⟩ + · rintro ⟨⟨q₁, hG₁, h₁⟩, ⟨q₂, hG₂, h₂⟩⟩ + have : ∃ r ∈ genericFilter p, r ≤ q₁ ∧ r ≤ q₂ := (genericFilter p).directed _ hG₁ _ hG₂ + rcases this with ⟨r, hGr, hr₁, hr₂⟩ + refine ⟨r, hGr, ?_⟩ + have : r ⊩ᶜ φ := h₁.monotone hr₁ + have : r ⊩ᶜ ψ := h₂.monotone hr₂ + simp [*] + +@[simp] lemma GenericForces.or {p : ℙ⁻} {φ ψ : Proposition L} : p ⊫ φ ⋎ ψ ↔ p ⊫ φ ∨ p ⊫ ψ := calc + p ⊫ φ ⋎ ψ ↔ p ⊫ ∼(∼φ ⋏ ∼ψ) := by simp + _ ↔ ¬p ⊫ ∼φ ⋏ ∼ψ := by rw [GenericForces.neg] + _ ↔ p ⊫ φ ∨ p ⊫ ψ := by simp; tauto + +local notation "𝔗" => Term L ℕ + +abbrev termModelOf (p : ℙ⁻) : Structure L 𝔗 where + func _ f v := .func f v + rel _ R v := p ⊫ .rel R v + +@[simp] lemma termModel_func_def (f : L.Func k) (v : Fin k → 𝔗) : + (termModelOf p).func f v = Semiterm.func f v := rfl + +@[simp] lemma termModel_rel_def (R : L.Rel k) (v) : + (termModelOf p).rel R v ↔ p ⊫ .rel R v := by rfl + +@[simp] lemma termModel_val_eq (t : Semiterm L ξ n) (fv : ξ → 𝔗) (bv : Fin n → 𝔗) : + t.val (s := termModelOf p) bv fv = Rew.bind bv fv t := by + induction t <;> simp [*, Function.comp_def] + +lemma forcing_lemma (φ : Semiformula L ξ n) (fv : ξ → 𝔗) (bv : Fin n → 𝔗) : + φ.Eval (s := termModelOf p) bv fv ↔ p ⊫ Rew.bind bv fv ▹ φ := + have e (t : 𝔗) (φ : Semiformula L ξ (n + 1)) : ((Rew.bind bv fv).q ▹ φ)/[t] = Rew.bind (t :> bv) fv ▹ φ := by + unfold Rewriting.subst; rw [←TransitiveRewriting.comp_app] + congr; ext x + · cases x using Fin.cases <;> simp [Rew.comp_app] + · simp [Rew.comp_app] + match φ with + | .rel R v | .nrel R v => by simp [Function.comp_def] + | ⊤ | ⊥ => by simp + | φ ⋏ ψ | φ ⋎ ψ => by simp [forcing_lemma φ, forcing_lemma ψ] + | ∀⁰ φ | ∃⁰ φ => by simp [e, forcing_lemma φ] end LO.FirstOrder.Derivation.Canonical diff --git a/Foundation/Vorspiel/Order/Dense.lean b/Foundation/Vorspiel/Order/Dense.lean index d4a108586..1c6f34311 100644 --- a/Foundation/Vorspiel/Order/Dense.lean +++ b/Foundation/Vorspiel/Order/Dense.lean @@ -56,6 +56,49 @@ namespace Order variable {α : Type*} [Preorder α] +/-! ### Compatibility and incompatibility -/ + +def IsCompatiblePair (a b : α) : Prop := ∃ c, c ≤ a ∧ c ≤ b + +scoped infix:50 " ‖ " => IsCompatiblePair + +@[simp, refl] protected lemma IsCompatiblePair.refl (a : α) : a ‖ a := ⟨a, by simp⟩ + +@[symm] protected lemma IsCompatiblePair.symm_iff {a b : α} : a ‖ b ↔ b ‖ a := by + constructor + · rintro ⟨c, hca, hcb⟩; exact ⟨c, hcb, hca⟩ + · rintro ⟨c, hcb, hca⟩; exact ⟨c, hca, hcb⟩ + +alias ⟨IsCompatiblePair.symm, _⟩ := IsCompatiblePair.symm_iff + +@[grind <-] lemma IsCompatiblePair.of_le {a b : α} (h : a ≤ b) : a ‖ b := ⟨a, by simp [h]⟩ + +def IsIncompatiblePair (a b : α) : Prop := ¬(a ‖ b) + +scoped infix:50 " ⟂ " => IsIncompatiblePair + +lemma isIncompatiblePair_iff {a b : α} : a ⟂ b ↔ ∀ c ≤ a, ¬c ≤ b := by + simp [IsIncompatiblePair, IsCompatiblePair] + +@[simp] lemma IsIncompatiblePair.antirefl (a : α) : ¬(a ⟂ a) := by simp [IsIncompatiblePair] + +lemma IsIncompatiblePair.symm_iff {a b : α} : a ⟂ b ↔ b ⟂ a := by + contrapose; simpa [IsIncompatiblePair] using IsCompatiblePair.symm_iff + +alias ⟨IsIncompatiblePair.symm, _⟩ := IsIncompatiblePair.symm_iff + +lemma IsIncompatiblePair.lower {a a' b b' : α} (h : a ⟂ b) (ha'a : a' ≤ a) (hb'b : b' ≤ b) : a' ⟂ b' := by + rintro ⟨c, hca, hcb⟩ + exact h ⟨c, le_trans hca ha'a, le_trans hcb hb'b⟩ + +@[simp, grind =] lemma not_isCompatiblePair_iff_isIncompatiblePair {a b : α} : ¬(a ‖ b) ↔ a ⟂ b := by + rfl + +@[simp, grind =] lemma not_isIncompatiblePair_iff_isCompatiblePair {a b : α} : ¬(a ⟂ b) ↔ a ‖ b := by + simp [IsIncompatiblePair, IsCompatiblePair] + +/-! ### Density -/ + def IsDense (s : Set α) : Prop := ∀ p, ∃ q ≤ p, q ∈ s def IsDenseBelow (s : Set α) (a : α) : Prop := ∀ p ≤ a, ∃ q ≤ p, q ∈ s @@ -104,10 +147,12 @@ class IsGeneric (F : PFilter α) (𝓓 : Set (DenseSet α)) where @[simp] instance IsGeneric.empty (F : PFilter α) : F.IsGeneric ∅ := ⟨by simp⟩ -theorem countable_isGeneric (𝓓 : Set (DenseSet α)) (ctb : Set.Countable 𝓓) (a : α) : +theorem exists_genericFilter_of_countable + (𝓓 : Set (DenseSet α)) (ctb : Set.Countable 𝓓) (a : α) : ∃ G : PFilter α, G.IsGeneric 𝓓 ∧ a ∈ G := by by_cases emp : 𝓓.Nonempty - case neg => exact ⟨principal a, by simp [Set.not_nonempty_iff_eq_empty.mp emp]⟩ + case neg => + exact ⟨principal a, by simp [Set.not_nonempty_iff_eq_empty.mp emp], by simp⟩ have : ∃ D : ℕ → 𝓓, Function.Surjective D := ctb.exists_surjective emp rcases this with ⟨D, hD⟩ let s (n : ℕ) : α := n.rec a fun i ↦ (D i).val.choose @@ -126,6 +171,6 @@ theorem countable_isGeneric (𝓓 : Set (DenseSet α)) (ctb : Set.Countable 𝓓 · suffices ∃ i, s i ≤ a by simpa refine ⟨0, by simp [s]⟩ -end Order.PFilter +end PFilter -end +end Order diff --git a/Foundation/Vorspiel/Order/LowerSet.lean b/Foundation/Vorspiel/Order/LowerSet.lean index da4aeb623..89ddc8679 100644 --- a/Foundation/Vorspiel/Order/LowerSet.lean +++ b/Foundation/Vorspiel/Order/LowerSet.lean @@ -4,6 +4,7 @@ public import Mathlib.Topology.Order.UpperLowerSetTopology public import Mathlib.Topology.Sets.Opens public import Mathlib.Order.Heyting.Regular public import Foundation.Vorspiel.Order.Regular +public import Foundation.Vorspiel.Order.Dense @[expose] public section @@ -11,42 +12,7 @@ variable {α : Type*} [Preorder α] namespace LowerSet -def IsCompatiblePair (a b : α) : Prop := ∃ c, c ≤ a ∧ c ≤ b - -infix:50 " ‖ " => IsCompatiblePair - -@[simp, refl] protected lemma IsCompatiblePair.refl (a : α) : a ‖ a := ⟨a, by simp⟩ - -@[symm] protected lemma IsCompatiblePair.symm_iff {a b : α} : a ‖ b ↔ b ‖ a := by - constructor - · rintro ⟨c, hca, hcb⟩; exact ⟨c, hcb, hca⟩ - · rintro ⟨c, hcb, hca⟩; exact ⟨c, hca, hcb⟩ - -alias ⟨IsCompatiblePair.symm, _⟩ := IsCompatiblePair.symm_iff - -def IsIncompatiblePair (a b : α) : Prop := ¬(a ‖ b) - -infix:50 " ⟂ " => IsIncompatiblePair - -lemma isIncompatiblePair_iff {a b : α} : a ⟂ b ↔ ∀ c ≤ a, ¬c ≤ b := by - simp [IsIncompatiblePair, IsCompatiblePair] - -@[simp] lemma IsIncompatiblePair.antirefl (a : α) : ¬(a ⟂ a) := by simp [IsIncompatiblePair] - -lemma IsIncompatiblePair.symm_iff {a b : α} : a ⟂ b ↔ b ⟂ a := by - contrapose; simpa [IsIncompatiblePair] using IsCompatiblePair.symm_iff - -alias ⟨IsIncompatiblePair.symm, _⟩ := IsIncompatiblePair.symm_iff - -lemma IsIncompatiblePair.lower {a a' b b' : α} (h : a ⟂ b) (ha'a : a' ≤ a) (hb'b : b' ≤ b) : a' ⟂ b' := by - rintro ⟨c, hca, hcb⟩ - exact h ⟨c, le_trans hca ha'a, le_trans hcb hb'b⟩ - -@[simp, grind =] lemma not_isCompatiblePair_iff_isIncompatiblePair {a b : α} : ¬(a ‖ b) ↔ a ⟂ b := by - rfl - -@[simp, grind =] lemma not_isIncompatiblePair_iff_isCompatiblePair {a b : α} : ¬(a ⟂ b) ↔ a ‖ b := by - simp [IsIncompatiblePair, IsCompatiblePair] +open Order instance : HeytingAlgebra (LowerSet α) := inferInstance From 930e5947c5dddd40f31d7fd97f71e71f00418a3c Mon Sep 17 00:00:00 2001 From: palalansouki Date: Fri, 1 May 2026 01:07:32 +0900 Subject: [PATCH 42/61] Pullback --- Foundation/Logic/Calculus.lean | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Foundation/Logic/Calculus.lean b/Foundation/Logic/Calculus.lean index 43a8ee044..e0dd5d558 100644 --- a/Foundation/Logic/Calculus.lean +++ b/Foundation/Logic/Calculus.lean @@ -119,6 +119,25 @@ instance : Entailment.Cl 𝓔 where end EmptyEntailment +abbrev Pullback (𝔇 : List F → Type*) {G : Type*} [LogicalConnective G] (f : G →ˡᶜ F) : List G → Type _ := fun Γ ↦ 𝔇 (Γ.map f) + +namespace Pullback + +variable {G : Type*} [LogicalConnective G] [DeMorgan G] [NegInvolutive G] {f : G →ˡᶜ F} + +def cast (d : 𝔇 Δ) (h : Δ = Γ.map f := by simp) : Pullback 𝔇 f Γ := by + unfold Pullback + exact h ▸ d + +instance [OneSidedLK 𝔇] : OneSidedLK (Pullback 𝔇 f) where + identity φ := cast <| identity (f φ) + wk {Δ Γ} d h := cast (wk d (List.map_subset f h) : 𝔇 (Γ.map f)) (by simp) + verum := cast verum + and d₁ d₂ := cast <| and d₁ d₂ + or d := cast <| or d + +end Pullback + protected class Entailment (𝔇 : outParam (List F → Type*)) (S : Type*) [Entailment S F] [AdjunctiveSet F S] where equiv {𝓢 : S} {φ} : 𝓢 ⊢! φ ≃ (l : {l : List F // ∀ φ ∈ l, φ ∈ 𝓢}) × 𝔇 (φ :: ∼l) From e77ef259673879f0c9a57071302f58352deed36f Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 7 May 2026 02:14:32 +0900 Subject: [PATCH 43/61] calc --- Foundation/FirstOrder/Basic/Calculus.lean | 209 +++++++----------- .../FirstOrder/Basic/Syntax/Formula.lean | 4 + .../FirstOrder/Basic/Syntax/Schema.lean | 104 --------- .../Completeness/CanonicalModel.lean | 5 + .../FirstOrder/Completeness/CounterModel.lean | 66 ++++-- Foundation/Logic/Calculus.lean | 157 ++++++++++--- Foundation/Logic/Entailment.lean | 6 +- Foundation/Propositional/Tait/Calculus.lean | 2 +- Foundation/Syntax/Predicate/Rew.lean | 8 +- 9 files changed, 277 insertions(+), 284 deletions(-) delete mode 100644 Foundation/FirstOrder/Basic/Syntax/Schema.lean diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index c4f8f62b7..73b80e357 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -3,7 +3,7 @@ module /- public import Foundation.Logic.Calculus -/ public import Foundation.Logic.Calculus public import Foundation.Propositional.Entailment.AxiomEFQ -public import Foundation.FirstOrder.Basic.Syntax.Schema +public import Foundation.FirstOrder.Basic.Syntax.Rew public import Mathlib.Data.List.MinMax /-! # One-sided sequent calculus for first-order classical logic -/ @@ -27,11 +27,22 @@ def newVar (Γ : Sequent L) : ℕ := (Γ.map Semiformula.fvSup).foldr max 0 lemma not_fvar?_newVar {φ : Proposition L} {Γ : Sequent L} (h : φ ∈ Γ) : ¬FVar? φ Γ.newVar := not_fvar?_of_lt_fvSup φ (by simpa [newVar] using List.le_max_of_le (List.mem_map_of_mem h) (by simp)) -@[simp] lemma rew_neg_comm {Γ : Sequent L} (ω : Rew L ℕ 0 ℕ 0) : - (∼Γ).map (ω ▹ ·) = ∼Γ.map (ω ▹ ·) := by simp [List.tilde_def] +@[simp] lemma lcHom_comm {Γ : List (Formula L ξ)} (f : Formula L ξ →ˡᶜ Proposition L) : + (∼Γ).map f = ∼Γ.map f := by simp [List.tilde_def] def IsClosed (Γ : Sequent L) : Prop := ∃ φ ∈ Γ, ∼φ ∈ Γ +def embed (Γ : List (Sentence L)) : Sequent L := List.map Rewriting.emb Γ + +@[simp] lemma embed_nil : embed ([] : List (Sentence L)) = [] := rfl + +@[simp] lemma embed_cons {φ : Sentence L} {Γ : List (Sentence L)} : + embed (φ :: Γ) = (↑φ :: embed Γ) := rfl + +@[simp] lemma embed_shift (Γ : List (Sentence L)) : + (embed Γ)⁺ = embed Γ := by + simp [embed, Rewriting.shifts] + end Sequent /-! ## Derivation for one-sided $\mathbf{LK}$ -/ @@ -164,7 +175,7 @@ protected def shift {Δ : Sequent L} (d : ⊢ᴸᴷ¹ Δ) : ⊢ᴸᴷ¹ Δ⁺ := section Hom -variable {L₁ : Language} {L₂ : Language} {𝔖₁ : Schema L₁} {Δ₁ : Sequent L₁} +variable {L₁ : Language} {L₂ : Language} {Δ₁ : Sequent L₁} lemma shifts_image (Φ : L₁ →ᵥ L₂) {Δ : List (Proposition L₁)} : (Δ.map <| Semiformula.lMap Φ)⁺ = (Δ⁺.map <| Semiformula.lMap Φ) := by @@ -238,172 +249,120 @@ end Derivation /-! ## Classical proof system -/ -inductive Proof.Symbol (L : Language) +inductive LK.Symbol (L : Language) | symbol -notation "𝐋𝐊¹" => Proof.Symbol.symbol +notation "𝐋𝐊¹" => LK.Symbol.symbol -abbrev Proof (φ : Proposition L) := ⊢ᴸᴷ¹ [φ] +notation "𝐋𝐊¹[" L "]" => LK.Symbol.symbol (L := L) -instance : Entailment (Proof.Symbol L) (Proposition L) where - Prf _ := Proof +abbrev LK (φ : Proposition L) := ⊢ᴸᴷ¹ [φ] -namespace Proof +instance : Entailment (LK.Symbol L) (Proposition L) where + Prf _ := LK + +namespace LK lemma def_eq (φ : Proposition L) : (𝐋𝐊¹ ⊢! φ) = (⊢ᴸᴷ¹ [φ]) := rfl -instance : OneSidedLK.EmptyEntailment (Derivation (L := L)) (𝐋𝐊¹ : Proof.Symbol L) where +lemma provable_def (φ : Proposition L) : 𝐋𝐊¹ ⊢ φ ↔ Nonempty (⊢ᴸᴷ¹ [φ]) := by rfl + +lemma unprovable_def (φ : Proposition L) : 𝐋𝐊¹ ⊬ φ ↔ IsEmpty (⊢ᴸᴷ¹ [φ]) := by + unfold Entailment.Unprovable; simp [provable_def] + +instance : OneSidedLK.PrincipalEntailment (Derivation (L := L)) (𝐋𝐊¹ : LK.Symbol L) where equiv := Equiv.refl _ -instance classical : Entailment.Cl (𝐋𝐊¹ : Proof.Symbol L) := inferInstance +instance classical : Entailment.Cl (𝐋𝐊¹ : LK.Symbol L) := inferInstance + +lemma all (φ : Semiproposition L 1) : 𝐋𝐊¹ ⊢ φ.free → 𝐋𝐊¹ ⊢ ∀⁰ φ := fun h ↦ ⟨Derivation.all h.get⟩ -end Proof +lemma allClosure_fixitr {φ : Proposition L} (dp : 𝐋𝐊¹ ⊢ φ) : (m : ℕ) → 𝐋𝐊¹ ⊢ ∀⁰* Rew.fixitr 0 m ▹ φ + | 0 => by simpa + | m + 1 => by + simp only [LawfulSyntacticRewriting.allClosure_fixitr] + apply all; simpa using allClosure_fixitr dp m -structure Schema.Proof (𝔖 : Schema L) (φ : Proposition L) where - axioms : List (Proposition L) - axioms_mem : ∀ ψ ∈ axioms, ψ ∈ 𝔖 - derivation : ⊢ᴸᴷ¹ φ :: ∼axioms +lemma univCl' {φ : Proposition L} (b : 𝐋𝐊¹ ⊢ φ) : 𝐋𝐊¹ ⊢ φ.univCl' := allClosure_fixitr b φ.fvSup -namespace Schema +end LK -instance : Entailment (Schema L) (Proposition L) where - Prf := Schema.Proof +structure Theory.LK (T : Theory L) (σ : Sentence L) where + axioms : List (Sentence L) + axioms_mem : ∀ ψ ∈ axioms, ψ ∈ T + derivation : OneSidedLK.Pullback Derivation Rewriting.emb (σ :: ∼axioms) -variable {𝔖 : Schema L} +namespace Theory -attribute [simp] Proof.axioms_mem +instance : Entailment (Theory L) (Sentence L) where + Prf := Theory.LK -def equiv (𝔖 : Schema L) (φ) : - (𝔖 ⊢! φ) ≃ (Γ : {Γ : Sequent L // ∀ ψ ∈ Γ, ψ ∈ 𝔖}) × ⊢ᴸᴷ¹ φ :: ∼Γ where - toFun b := ⟨⟨b.axioms, b.axioms_mem⟩, b.derivation⟩ - invFun := fun ⟨⟨Γ, hΓ⟩, d⟩ ↦ ⟨Γ, hΓ, d⟩ +variable {T : Theory L} -instance : Entailment.Compact (Schema L) where +attribute [simp] LK.axioms_mem + +instance : Entailment.Compact (Theory L) where core b := {φ | φ ∈ b.axioms} corePrf b := ⟨b.axioms, by simp, b.derivation⟩ core_finite b := by simp [AdjunctiveSet.Finite, AdjunctiveSet.set] core_subset b := by simpa [AdjunctiveSet.subset_iff] using b.axioms_mem -instance : OneSidedLK.Entailment (Derivation (L := L)) (Schema L) where - equiv {𝔖 φ} := equiv 𝔖 φ +instance : OneSidedLK.ContextualEntailment (OneSidedLK.Pullback Derivation Rewriting.emb) (Theory L) where + equiv {T φ} := + { toFun b := ⟨⟨b.axioms, b.axioms_mem⟩, b.derivation⟩ + invFun := fun ⟨⟨Γ, hΓ⟩, d⟩ ↦ ⟨Γ, hΓ, d⟩ } -instance : Entailment.Cl 𝔖 := inferInstance +instance : Entailment.Cl T := OneSidedLK.ContextualEntailment.cl T -lemma weakerThan_of_le {𝔖 𝔘 : Schema L} (h : 𝔖 ≤ 𝔘) : 𝔖 ⪯ 𝔘 := Entailment.Axiomatized.weakerThanOfSubset h +lemma weakerThan_of_le {T U : Theory L} (h : T ⊆ U) : T ⪯ U := Entailment.Axiomatized.weakerThanOfSubset h -instance (𝔖 𝔘 : Schema L) : 𝔖 ⪯ 𝔖 ⊔ 𝔘 := weakerThan_of_le (by simp) +instance (T U : Theory L) : T ⪯ T ∪ U := weakerThan_of_le (by simp) -instance (𝔖 𝔘 : Schema L) : 𝔘 ⪯ 𝔖 ⊔ 𝔘 := weakerThan_of_le (by simp) +instance (T U : Theory L) : U ⪯ T ∪ U := weakerThan_of_le (by simp) lemma provable_iff : - 𝔖 ⊢ φ ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝔖) ∧ Nonempty (⊢ᴸᴷ¹ φ :: ∼Γ) := - OneSidedLK.Entailment.provable_iff + T ⊢ φ ↔ ∃ Γ : List (Sentence L), (∀ ψ ∈ Γ, ψ ∈ T) ∧ Nonempty (⊢ᴸᴷ¹ φ :: ∼Sequent.embed Γ) := by + simpa using OneSidedLK.ContextualEntailment.provable_iff (𝓢 := T) (φ := φ) lemma inconsistent_iff : - Entailment.Inconsistent 𝔖 ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝔖) ∧ Nonempty (⊢ᴸᴷ¹ ∼Γ) := - OneSidedLK.Entailment.inconsistent_iff - -def rewrite [𝔖.IsClosed] (b : 𝔖 ⊢! φ) (f : ℕ → SyntacticTerm L) : - 𝔖 ⊢! Rew.rewrite f ▹ φ where - axioms := b.axioms.map (Rew.rewrite f ▹ ·) - axioms_mem := by - suffices ∀ ψ ∈ b.axioms, Rew.rewrite f ▹ ψ ∈ 𝔖 by simpa - intro ψ hψ - exact Schema.IsClosed.closed (Rew.rewrite f) _ (b.axioms_mem ψ hψ) - derivation := b.derivation.rewrite f |>.cast - -@[simp] lemma empty_provable_iff_eprovable : - (⊥ : Schema L) ⊢ φ ↔ 𝐋𝐊¹ ⊢ φ := - OneSidedLK.Entailment.empty_provable_iff_eprovable 𝐋𝐊¹ + Entailment.Inconsistent T ↔ ∃ Γ : List (Sentence L), (∀ ψ ∈ Γ, ψ ∈ T) ∧ Nonempty (⊢ᴸᴷ¹ ∼Sequent.embed Γ) := by + simpa using OneSidedLK.ContextualEntailment.inconsistent_iff (𝓢 := T) -end Schema +open Entailment Derivation -namespace Derivation +@[simp] lemma empty_provable_iff_eprovable : + (∅ : Theory L) ⊢ φ ↔ 𝐋𝐊¹ ⊢ (φ : Proposition L) := by + simpa using OneSidedLK.ContextualEntailment.empty_provable_iff_eprovable + (S := Theory L) + (𝓟 := pullback 𝐋𝐊¹[L] (Rewriting.emb : Sentence L → Proposition L)) + (φ := φ) -open Entailment - -variable {Γ Δ : Sequent L} - -def eCut (d₁ : ⊢ᴸᴷ¹ φ :: Γ) (d₂ : ⊢ᴸᴷ¹ ψ :: Δ) (e : ∼φ = ψ := by simp) : ⊢ᴸᴷ¹ Γ ++ Δ := cut d₁ (d₂.cast (by simp [e])) - -def disj₂ {Γ Δ : Sequent L} : ⊢ᴸᴷ¹ Γ ++ Δ → ⊢ᴸᴷ¹ ⋁Γ :: Δ := fun d ↦ - match Γ with - | [] => d.weakening - | [φ] => d - | [φ, ψ] => d.or - | φ :: ψ :: χ :: Γ => - let Φ := ⋁(χ :: Γ) - have : ⊢ᴸᴷ¹ (φ ⋎ ψ :: χ :: Γ) ++ Δ := d.or - have d₁ : ⊢ᴸᴷ¹ (φ ⋎ ψ) ⋎ Φ :: Δ := this.disj₂ - have d₂ : ⊢ᴸᴷ¹ [(∼φ ⋏ ∼ψ) ⋏ ∼Φ, φ ⋎ ψ ⋎ Φ] := - have : ⊢ᴸᴷ¹ [φ, ψ ⋎ Φ, (∼φ ⋏ ∼ψ) ⋏ ∼Φ] := - ((eta φ).rotate.tensor (eta ψ).rotate).tensor - (eta Φ).rotate |>.rotate.rotate.or.weakening - this.or.rotate - d₂.eCut d₁ - termination_by _ => Γ.length - -def conj₂ {Γ Δ : Sequent L} (d : (φ : Proposition L) → φ ∈ Γ → ⊢ᴸᴷ¹ φ :: Δ) : ⊢ᴸᴷ¹ ⋀Γ :: Δ := - match Γ with - | [] => verum.weakening - | [φ] => d φ (by simp) - | φ :: ψ :: Γ => - have : ⊢ᴸᴷ¹ ⋀(ψ :: Γ) :: Δ := conj₂ (Γ := ψ :: Γ) (fun χ h ↦ d χ (by simp_all)) - (d φ (by simp)).and this - -def disjClosure : ⊢ᴸᴷ¹ Γ → 𝐋𝐊¹ ⊢! ⋁Γ := fun d ↦ - have : ⊢ᴸᴷ¹ Γ ++ [] := d.cast - this.disj₂ - -def disjClosureInv : 𝐋𝐊¹ ⊢! ⋁Γ → ⊢ᴸᴷ¹ Γ := fun d ↦ - have d₁ : ⊢ᴸᴷ¹ [⋁Γ] := d - have d₂ : ⊢ᴸᴷ¹ ⋀(∼Γ) :: Γ := conj₂ fun φ h ↦ close φ (by simp) (by simp_all) - d₁.eCut d₂ - -lemma nonempty_iff_provable_disj : Nonempty (⊢ᴸᴷ¹ Γ) ↔ 𝐋𝐊¹ ⊢ ⋁Γ := - ⟨by rintro ⟨d⟩; exact ⟨d.disjClosure⟩, by rintro ⟨d⟩; exact ⟨d.disjClosureInv⟩⟩ +lemma iff_context {T : Theory L} : + T ⊢ φ ↔ T *⊢[pullback 𝐋𝐊¹[L] (Rewriting.emb : _ → Proposition L)] φ := + OneSidedLK.ContextualEntailment.iff_context -end Derivation +end Theory -namespace Schema +namespace Theory open Entailment Derivation -lemma iff_context {𝔖 : Schema L} : 𝔖 ⊢ φ ↔ 𝔖 *⊢[𝐋𝐊¹] φ := by - constructor - · rintro ⟨d⟩ - have : 𝐋𝐊¹ ⊢! ⋀d.axioms 🡒 φ := - have : ⊢ᴸᴷ¹ ∼d.axioms ++ [φ] := d.derivation.weakening - this.disj₂.or.cast <| by simp [Semiformula.imp_eq] - refine ⟨⟨d.axioms, by simpa using d.axioms_mem, this⟩⟩ - · rintro ⟨Γ, h, d⟩ - have d : ⊢ᴸᴷ¹ [⋁(∼Γ) ⋎ φ] := d.cast (by simp [Semiformula.imp_eq]) - have : ⊢ᴸᴷ¹ ⋀Γ ⋏ ∼φ :: φ :: ∼Γ := - have : ⊢ᴸᴷ¹ ⋀Γ :: ∼Γ := Derivation.conj₂ fun φ h ↦ close φ (by simp) (by simp [h]) - this.tensor (eta φ).rotate |>.weakening - refine ⟨⟨Γ, h, (d.eCut this).cast⟩⟩ +lemma of_LK_provable {T : Theory L} {φ : Sentence L} : 𝐋𝐊¹ ⊢ (φ : Proposition L) → T ⊢ φ := fun h ↦ + have : pullback 𝐋𝐊¹[L] (Rewriting.emb : Sentence L → Proposition L) ⊢ φ := h + OneSidedLK.ContextualEntailment.of_principal_provable this open Classical in +noncomputable instance : Entailment.Deduction (Theory L) := + OneSidedLK.ContextualEntailment.deduction (pullback 𝐋𝐊¹[L] (Rewriting.emb : Sentence L → Proposition L)) -noncomputable instance : Entailment.Deduction (Schema L) where - ofInsert {φ ψ 𝔖 b} := - have : insert φ ↑𝔖 *⊢[𝐋𝐊¹] ψ := iff_context.mp ⟨b⟩ - have : ↑𝔖 *⊢[𝐋𝐊¹] φ 🡒 ψ := Context.deduct! this - (iff_context.mpr this).get - inv {φ ψ 𝔖 b} := - have : ↑(adjoin φ 𝔖) *⊢[𝐋𝐊¹] ψ := Context.deductInv! (iff_context.mp ⟨b⟩) - (iff_context.mpr this).get - -end Schema +end Theory -/-! - ### Theory --/ +/-! ### Theory -/ -def Schema.theory (𝔖 : Schema L) : Theory L := {σ | 𝔖 ⊢ ↑σ} +def Theory.theory (T : Theory L) : Theory L := {σ | T ⊢ ↑σ} -@[simp] lemma Schema.mem_theory {𝔖 : Schema L} : - σ ∈ 𝔖.theory ↔ 𝔖 ⊢ ↑σ := by simp [Schema.theory] +@[simp] lemma Theory.mem_theory {T : Theory L} : + σ ∈ T.theory ↔ T ⊢ ↑σ := by simp [Theory.theory] end FirstOrder diff --git a/Foundation/FirstOrder/Basic/Syntax/Formula.lean b/Foundation/FirstOrder/Basic/Syntax/Formula.lean index 106ded2d5..086d3dede 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Formula.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Formula.lean @@ -582,6 +582,10 @@ end enumarateFVar end Semiformula +abbrev Theory (L : Language) := Set (Sentence L) + +abbrev ArithmeticTheory := Theory ℒₒᵣ + end LO.FirstOrder end diff --git a/Foundation/FirstOrder/Basic/Syntax/Schema.lean b/Foundation/FirstOrder/Basic/Syntax/Schema.lean deleted file mode 100644 index 45c1a4b46..000000000 --- a/Foundation/FirstOrder/Basic/Syntax/Schema.lean +++ /dev/null @@ -1,104 +0,0 @@ -module - -public import Foundation.FirstOrder.Basic.Syntax.Rew - -@[expose] public section - -/-! -# Schema - -First-order schema `Schema L` is defined as a set of propositions, which may contains free variables. - --/ - -namespace LO.FirstOrder - -abbrev Schema (L : Language) := Set (Proposition L) - -abbrev Theory (L : Language) := Set (Sentence L) - -namespace Schema - -variable {L : Language} - -@[coe] def ofProposition (φ : Proposition L) : Schema L := {φ} - -instance : Coe (Proposition L) (Schema L) := ⟨fun φ ↦ ofProposition φ⟩ - -@[simp] lemma mem_coe (φ ψ : Proposition L) : ψ ∈ (φ : Schema L) ↔ ψ = φ := by rfl - -instance : AdjunctiveSet (Proposition L) (Schema L) where - Subset 𝔖₁ 𝔖₂ := 𝔖₁ ≤ 𝔖₂ - emptyCollection := ⊥ - adjoin φ 𝔖 := φ ⊔ 𝔖 - subset_iff := by simp [Set.subset_def] - not_mem_empty _ := by simp - mem_cons_iff := by simp - -class IsClosed (𝔖 : Schema L) : Prop where - closed : ∀ ω : Rew L ℕ 0 ℕ 0, ∀ φ ∈ 𝔖, ω ▹ φ ∈ 𝔖 - -namespace IsClosed - -instance : IsClosed (⊤ : Schema L) where - closed _ _ _ := by trivial - -instance : IsClosed (⊥ : Schema L) where - closed _ _ := by rintro ⟨⟩ - -instance sup (𝔖₁ 𝔖₂ : Schema L) [IsClosed 𝔖₁] [IsClosed 𝔖₂] : IsClosed (𝔖₁ ∪ 𝔖₂) where - closed ω φ h := by - have : φ ∈ 𝔖₁ ∨ φ ∈ 𝔖₂ := by simpa using h - rcases this with (h |h ) - · left; apply IsClosed.closed ω φ h - · right; apply IsClosed.closed ω φ h - -instance inf (𝔖₁ 𝔖₂ : Schema L) [IsClosed 𝔖₁] [IsClosed 𝔖₂] : IsClosed (𝔖₁ ∩ 𝔖₂) where - closed ω φ h := by - have : φ ∈ 𝔖₁ ∧ φ ∈ 𝔖₂ := by simpa using h - rcases this with ⟨h₁, h₂⟩ - constructor - · apply IsClosed.closed ω φ h₁ - · apply IsClosed.closed ω φ h₂ - -lemma sSup (s : Set (Schema L)) (H : ∀ 𝔖 ∈ s, IsClosed 𝔖) : IsClosed (sSup s) where - closed ω φ h := by - have : ∃ 𝔖 ∈ s, φ ∈ 𝔖 := by simpa using h - rcases this with ⟨𝔖, hs, hφ⟩ - have : IsClosed 𝔖 := H 𝔖 hs - exact ⟨𝔖, hs, IsClosed.closed _ _ hφ⟩ - -instance sentence (σ : Sentence L) : IsClosed (σ : Schema L) where - closed _ φ h := by - have : φ = σ := by simpa using h - rcases this - simp - -end IsClosed - -@[coe] def uniClosure (𝔖 : Schema L) : Theory L := Set.image Semiformula.univCl {φ | φ ∈ 𝔖} - -instance : Coe (Schema L) (Theory L) := ⟨uniClosure⟩ - -variable {𝔖 : Schema L} - -@[simp] lemma mem_uniClosure : - σ ∈ (𝔖 : Theory L) ↔ ∃ φ ∈ 𝔖, Semiformula.univCl φ = σ := by simp [uniClosure] - -@[simp] lemma coe_sup (𝔖₁ 𝔖₂ : Schema L) : ((𝔖₁ ∪ 𝔖₂ : Schema L) : Theory L) = (𝔖₁ : Theory L) ∪ (𝔖₂ : Theory L) := by - ext σ; simp [uniClosure]; grind - -@[simp] lemma coe_sSup (s : Set (Schema L)) : ((sSup s : Schema L) : Theory L) = ⋃ 𝔖 ∈ s, (𝔖 : Theory L) := by - ext σ; simp [uniClosure, sSup]; grind - -@[simp] lemma coe_coe_proposition (φ : Proposition L) : ((φ : Schema L) : Theory L) = {φ.univCl} := by - ext σ; simp [uniClosure] - -@[grind <-] lemma coe_subset_coe_of_le {𝔖₁ 𝔖₂ : Schema L} (h : 𝔖₁ ≤ 𝔖₂) : (𝔖₁ : Theory L) ⊆ (𝔖₂ : Theory L) := - Set.image_mono h - -end Schema - -end LO.FirstOrder - -end diff --git a/Foundation/FirstOrder/Completeness/CanonicalModel.lean b/Foundation/FirstOrder/Completeness/CanonicalModel.lean index 72a7615ad..0b201d889 100644 --- a/Foundation/FirstOrder/Completeness/CanonicalModel.lean +++ b/Foundation/FirstOrder/Completeness/CanonicalModel.lean @@ -373,6 +373,8 @@ instance : OrderTop ℙ⁻ where rintro ⟨Γ, hΓ⟩ exact ⟨StrongerThan.ofSubset <| List.nil_subset Γ⟩ +def ofUnprovable (φ : Proposition L) (h : 𝐋𝐊¹ ⊬ ∼φ) : ℙ⁻ := ⟨[φ], by simpa [LK.unprovable_def] using h⟩ + end ConsistentSequent abbrev IsForced (p : ℙ⁻) (φ : Propositionᵢ L) := Nonempty (Forces p.val φ) @@ -512,6 +514,9 @@ lemma complete {φ : Proposition L} : ℙ⁻ ∀⊩ᶜ φ ↔ 𝐋𝐊¹ ⊢ φ · intro b exact sound_minimal <| Provable.gödel_gentzen b +protected lemma refl (φ : Proposition L) (h : 𝐋𝐊¹ ⊬ ∼φ) : + ConsistentSequent.ofUnprovable φ h ⊩ᶜ φ := ⟨Forces.refl φ⟩ + end IsWeaklyForced end Canonical diff --git a/Foundation/FirstOrder/Completeness/CounterModel.lean b/Foundation/FirstOrder/Completeness/CounterModel.lean index e5b33c57b..83cb80cf6 100644 --- a/Foundation/FirstOrder/Completeness/CounterModel.lean +++ b/Foundation/FirstOrder/Completeness/CounterModel.lean @@ -1,6 +1,7 @@ module public import Foundation.FirstOrder.Completeness.CanonicalModel +public import Foundation.FirstOrder.Ultraproduct public import Foundation.Vorspiel.Order.Dense public import Mathlib.Logic.Equiv.List public import Mathlib.Logic.Encodable.Basic @@ -16,8 +17,6 @@ variable {L : Language} local notation "ℙ" => Sequent L local notation "ℙ⁻" => ConsistentSequent L -scoped notation "ℍ" => LowerSet ℙ⁻ - instance [L.Encodable] [L.DecidableEq] : Encodable (Sequent L) := List.encodable open Classical in @@ -42,8 +41,7 @@ def henkinPoints (φ : Semiproposition L 1) : DenseSet ℙ⁻ where suffices ∃ q ≤ p, ∀ q_1 ≤ q, (∀ q ≤ q_1, ∃ r ≤ q, ∃ t, r ⊩ᶜ φ/[t]) → ∃ t, q_1 ⊩ᶜ φ/[t] by simpa only [IsWeaklyForced.exs, Set.mem_setOf_eq] have : p ⊩ᶜ (∃⁰ φ) ⋎ (∀⁰ ∼φ) := IsWeaklyForced.complete.mpr Entailment.lem! p - have : ∀ q ≤ p, ∃ r ≤ q, (∀ q ≤ r, ∃ r ≤ q, ∃ t, r ⊩ᶜ φ/[t]) ∨ - (∀ t, ∀ q ≤ r, ¬q ⊩ᶜ φ/[t]) := by simpa using this + have : ∀ q ≤ p, ∃ r ≤ q, (∀ q ≤ r, ∃ r ≤ q, ∃ t, r ⊩ᶜ φ/[t]) ∨ (∀ t, ∀ q ≤ r, ¬q ⊩ᶜ φ/[t]) := by simpa using this rcases this p (by rfl) with ⟨q, hqp, (h | h)⟩ · rcases h q (by rfl) with ⟨r, hrq, t, ht⟩ refine ⟨r, le_trans hrq hqp, fun s hsr _ ↦ ⟨t, IsWeaklyForced.monotone hsr ht⟩⟩ @@ -83,10 +81,8 @@ lemma GenericForces.em (p : ℙ⁻) (φ : Proposition L) : p ⊫ φ ∨ p ⊫ rcases this with ⟨q, hqG, hq⟩ have : q ⊩ᶜ φ ∨ q ⊩ᶜ ∼φ := by simpa using hq rcases this with (em | em) - · left - refine ⟨q, hqG, em⟩ - · right - refine ⟨q, hqG, em⟩ + · left; refine ⟨q, hqG, em⟩ + · right; refine ⟨q, hqG, em⟩ @[simp] lemma GenericForces.neg {p : ℙ⁻} {φ : Proposition L} : p ⊫ ∼φ ↔ ¬p ⊫ φ := by suffices p ⊫ ∼φ → p ⊫ φ → False by @@ -94,8 +90,7 @@ lemma GenericForces.em (p : ℙ⁻) (φ : Proposition L) : p ⊫ φ ∨ p ⊫ grind rintro ⟨q₀, hG₀, h₀⟩ rintro ⟨q₁, hG₁, h₁⟩ - have : ∃ r ∈ genericFilter p, r ≤ q₀ ∧ r ≤ q₁ := (genericFilter p).directed _ hG₀ _ hG₁ - rcases this with ⟨r, hG, hr₀, hr₁⟩ + rcases (genericFilter p).directed _ hG₀ _ hG₁ with ⟨r, hG, hr₀, hr₁⟩ have : r ⊩ᶜ φ := h₁.monotone hr₁ have : ¬r ⊩ᶜ φ := IsWeaklyForced.not.mp h₀ r (by assumption) contradiction @@ -115,8 +110,7 @@ lemma GenericForces.henkin {p : ℙ⁻} {φ : Semiproposition L 1} : p ⊫ ∃ (genericFilter_isGeneric p).isGeneric (henkinPoints φ) (by simp) rcases this with ⟨q, hqG, H⟩ rintro ⟨r, hrG, hr⟩ - have : ∃ z ∈ genericFilter p, z ≤ q ∧ z ≤ r := (genericFilter p).directed _ hqG _ hrG - rcases this with ⟨z, hGz, hzq, hzr⟩ + rcases (genericFilter p).directed _ hqG _ hrG with ⟨z, hGz, hzq, hzr⟩ have : ∃ t, z ⊩ᶜ φ/[t] := H z hzq (hr.monotone hzr) rcases this with ⟨t, hzt⟩ refine ⟨t, ⟨z, hGz, hzt⟩⟩ @@ -142,12 +136,11 @@ lemma GenericForces.henkin {p : ℙ⁻} {φ : Semiproposition L 1} : p ⊫ ∃ rcases this with ⟨hφ, hψ⟩ exact ⟨⟨q, hqG, hφ⟩, ⟨q, hqG, hψ⟩⟩ · rintro ⟨⟨q₁, hG₁, h₁⟩, ⟨q₂, hG₂, h₂⟩⟩ - have : ∃ r ∈ genericFilter p, r ≤ q₁ ∧ r ≤ q₂ := (genericFilter p).directed _ hG₁ _ hG₂ - rcases this with ⟨r, hGr, hr₁, hr₂⟩ + rcases (genericFilter p).directed _ hG₁ _ hG₂ with ⟨r, hGr, hr₁, hr₂⟩ refine ⟨r, hGr, ?_⟩ have : r ⊩ᶜ φ := h₁.monotone hr₁ have : r ⊩ᶜ ψ := h₂.monotone hr₂ - simp [*] + simp_all @[simp] lemma GenericForces.or {p : ℙ⁻} {φ ψ : Proposition L} : p ⊫ φ ⋎ ψ ↔ p ⊫ φ ∨ p ⊫ ψ := calc p ⊫ φ ⋎ ψ ↔ p ⊫ ∼(∼φ ⋏ ∼ψ) := by simp @@ -170,7 +163,7 @@ abbrev termModelOf (p : ℙ⁻) : Structure L 𝔗 where t.val (s := termModelOf p) bv fv = Rew.bind bv fv t := by induction t <;> simp [*, Function.comp_def] -lemma forcing_lemma (φ : Semiformula L ξ n) (fv : ξ → 𝔗) (bv : Fin n → 𝔗) : +lemma forcing_lemma (φ : Semiformula L ξ n) {fv : ξ → 𝔗} {bv : Fin n → 𝔗} : φ.Eval (s := termModelOf p) bv fv ↔ p ⊫ Rew.bind bv fv ▹ φ := have e (t : 𝔗) (φ : Semiformula L ξ (n + 1)) : ((Rew.bind bv fv).q ▹ φ)/[t] = Rew.bind (t :> bv) fv ▹ φ := by unfold Rewriting.subst; rw [←TransitiveRewriting.comp_app] @@ -183,4 +176,45 @@ lemma forcing_lemma (φ : Semiformula L ξ n) (fv : ξ → 𝔗) (bv : Fin n → | φ ⋏ ψ | φ ⋎ ψ => by simp [forcing_lemma φ, forcing_lemma ψ] | ∀⁰ φ | ∃⁰ φ => by simp [e, forcing_lemma φ] +lemma refl (φ : Proposition L) (h : 𝐋𝐊¹ ⊬ ∼φ) : + φ.Evalf (s := termModelOf (ConsistentSequent.ofUnprovable φ h)) (&·) := + (forcing_lemma φ).mpr ⟨ConsistentSequent.ofUnprovable φ h, by simp, by simpa using IsWeaklyForced.refl φ h⟩ + +lemma satisfiable_of_irrefutable (σ : Sentence L) (h : Entailment.pullback 𝐋𝐊¹[L] ((↑·) : Sentence L → Proposition L) ⊬ ∼σ) : + Satisfiable {σ} := + ⟨⟨_, inferInstance, termModelOf (ConsistentSequent.ofUnprovable σ (by simpa using h))⟩, by + simpa [models_iff] using refl (↑σ : Proposition L) (by simpa using h)⟩ + +open LO.Entailment + +theorem satisfiable_of_consistent (𝔖 : Schema L) (consistent : Entailment.Consistent 𝔖) : + Satisfiable (↑𝔖 : Theory L) := compact.mpr fun u hu ↦ by { + have : ∃ s : Finset (Proposition L), ↑s ⊆ 𝔖 ∧ s.image Semiformula.univCl = u := + Finset.subset_set_image_iff.mp hu + rcases this with ⟨s, hs𝔖, rfl⟩ + simp + } + + +/--/ +theorem satisfiable_of_consistent (𝔖 : Schema L) (consistent : Entailment.Consistent 𝔖) : + Satisfiable (↑𝔖 : Theory L) := compact.mpr fun u hu ↦ by { + have : ∃ s : Finset (Proposition L), ↑s ⊆ 𝔖 ∧ s.image Semiformula.univCl = u := + Finset.subset_set_image_iff.mp hu + rcases this with ⟨s, hs𝔖, rfl⟩ + let φ := ⋀s.toList + have : 𝔖 ⊢ φ := by + refine Schema.iff_context.mpr <| + Context.provable_iff.mpr + ⟨s.toList, fun ψ hψ ↦ hs𝔖 (by simpa using hψ), FiniteContext.provable_iff.mpr Entailment.C!_id⟩ + have ub : 𝐋𝐊¹ ⊬ ∼φ := fun h ↦ + have : 𝔖 ⊢ ⊥ := neg_mdp (Schema.provable_of_LK h) (by assumption) + consistent_iff_unprovable_bot.mp consistent this + let str : Structure L 𝔗 := termModelOf (ConsistentSequent.ofUnprovable φ ub) + refine ⟨⟨_, inferInstance, str⟩, ?_⟩ + have : ∀ φ : Proposition L, φ ∈ s → φ.Evalf (M := 𝔗) (&·) := by simpa [φ] using Canonical.refl φ ub + simp [models_iff] + + } + end LO.FirstOrder.Derivation.Canonical diff --git a/Foundation/Logic/Calculus.lean b/Foundation/Logic/Calculus.lean index e0dd5d558..55a6addad 100644 --- a/Foundation/Logic/Calculus.lean +++ b/Foundation/Logic/Calculus.lean @@ -35,6 +35,10 @@ variable {F : Type*} [LogicalConnective F] [DeMorgan F] [NegInvolutive F] {𝔇 def cast (b : 𝔇 Γ) (h : Γ = Δ := by simp) : 𝔇 Δ := h ▸ b +def weakening (d : 𝔇 Γ) (h : Γ ⊆ Δ := by simp) : 𝔇 Δ := wk d (by simp [h]) + +def rotate (d : 𝔇 (φ :: Γ)) : 𝔇 (Γ ++ [φ]) := weakening d + def close (φ : F) (hp : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : 𝔇 Γ := wk (identity φ) (by simp_all) def top (h : ⊤ ∈ Γ := by simp) : 𝔇 Γ := wk verum (by simp [h]) @@ -52,23 +56,51 @@ def swap₃ (d : 𝔇 (φ₄ :: φ₁ :: φ₂ :: φ₃ :: Γ)) : 𝔇 (φ₁ :: alias cut := OneSidedLK.Cut.cut +def eCut [Cut 𝔇] (d₁ : 𝔇 (φ :: Γ)) (d₂ : 𝔇 (ψ :: Δ)) (e : ∼φ = ψ := by simp) : 𝔇 (Γ ++ Δ) := cut d₁ (cast d₂ (by simp [e])) + +def disj₂ {Γ Δ : List F} [Cut 𝔇] : 𝔇 (Γ ++ Δ) → 𝔇 (⋁Γ :: Δ) := fun d ↦ + match Γ with + | [] => weakening d + | [φ] => d + | [φ, ψ] => or d + | φ :: ψ :: χ :: Γ => by + let Φ := ⋁(χ :: Γ) + have : 𝔇 ((φ ⋎ ψ :: χ :: Γ) ++ Δ) := or d + have d₁ : 𝔇 ((φ ⋎ ψ) ⋎ Φ :: Δ) := disj₂ this + have d₂ : 𝔇 [(∼φ ⋏ ∼ψ) ⋏ ∼Φ, φ ⋎ ψ ⋎ Φ] := + have : 𝔇 [φ, ψ ⋎ Φ, (∼φ ⋏ ∼ψ) ⋏ ∼Φ] := + weakening <| or <| rotate <| rotate <| + tensor (tensor (rotate (identity (𝔇 := 𝔇) φ)) (rotate (identity ψ))) (rotate (identity Φ)) + rotate <| or <| this + exact eCut d₂ d₁ + termination_by _ => Γ.length + +def conj₂ {Γ Δ : List F} (d : (φ : F) → φ ∈ Γ → 𝔇 (φ :: Δ)) : 𝔇 (⋀Γ :: Δ) := + match Γ with + | [] => weakening verum + | [φ] => d φ (by simp) + | φ :: ψ :: Γ => + have : 𝔇 (⋀(ψ :: Γ) :: Δ) := conj₂ (Γ := ψ :: Γ) (fun χ h ↦ d χ (by simp_all)) + and (d φ (by simp)) this + open Entailment -class EmptyEntailment (𝔇 : outParam (List F → Type*)) {E : Type*} [Entailment E F] (𝓔 : E) where - equiv {φ} : 𝓔 ⊢! φ ≃ 𝔇 [φ] +/-- An entailment relation which is determined solely by derivability. -/ +class PrincipalEntailment (𝔇 : outParam (List F → Type*)) {P : Type*} [Entailment P F] (𝓟 : P) where + equiv {φ} : 𝓟 ⊢! φ ≃ 𝔇 [φ] -namespace EmptyEntailment +namespace PrincipalEntailment -variable {E : Type*} [Entailment E F] (𝓔 : E) [EmptyEntailment 𝔇 𝓔] +variable {P : Type*} [Entailment P F] {𝓟 : P} [PrincipalEntailment 𝔇 𝓟] omit [LogicalConnective F] [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] in lemma provable_iff : - 𝓔 ⊢ φ ↔ Nonempty (𝔇 [φ]) := by - simpa using OneSidedLK.EmptyEntailment.equiv.nonempty_congr + 𝓟 ⊢ φ ↔ Nonempty (𝔇 [φ]) := by + simpa using OneSidedLK.PrincipalEntailment.equiv.nonempty_congr -variable [OneSidedLK.Cut 𝔇] +variable [OneSidedLK.Cut 𝔇] (𝓟) -instance : Entailment.ModusPonens 𝓔 where +instance : Entailment.ModusPonens 𝓟 where mdp {φ ψ} b₁ b₂ := let b₁ := equiv b₁ let b₂ := equiv b₂ @@ -77,47 +109,59 @@ instance : Entailment.ModusPonens 𝓔 where have : 𝔇 [ψ] := wk (cut b₂ this) (by simp) equiv.symm <| cast this -instance : Entailment.Cl 𝓔 where +instance : Entailment.Cl 𝓟 where negEquiv {φ} := Entailment.cast - (show 𝓔 ⊢! (φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ) from + (show 𝓟 ⊢! (φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ) from equiv.symm <| and (or <| swap₁ <| or <| close φ) (or <| and (identity φ) top)) (by simp [Axioms.NegEquiv, DeMorgan.imply, LogicalConnective.iff]) verum := equiv.symm <| verum implyK {φ ψ} := - have : 𝓔 ⊢! ∼φ ⋎ ∼ψ ⋎ φ := equiv.symm <| or <| swap₁ <| or <| close φ + have : 𝓟 ⊢! ∼φ ⋎ ∼ψ ⋎ φ := equiv.symm <| or <| swap₁ <| or <| close φ Entailment.cast this (by simp [DeMorgan.imply]) implyS {φ ψ χ} := - have : 𝓔 ⊢! φ ⋏ ψ ⋏ ∼χ ⋎ φ ⋏ ∼ψ ⋎ ∼φ ⋎ χ := + have : 𝓟 ⊢! φ ⋏ ψ ⋏ ∼χ ⋎ φ ⋏ ∼ψ ⋎ ∼φ ⋎ χ := equiv.symm <| or <| swap₁ <| or <| swap₁ <| or <| swap₃ <| and (close φ) (and (swap₃ <| and (close φ) (close ψ)) (close χ)) Entailment.cast this (by simp [DeMorgan.imply]) and₁ {φ ψ} := - have : 𝓔 ⊢! (∼φ ⋎ ∼ψ) ⋎ φ := equiv.symm <|or <| or <| close φ + have : 𝓟 ⊢! (∼φ ⋎ ∼ψ) ⋎ φ := equiv.symm <|or <| or <| close φ Entailment.cast this (by simp [DeMorgan.imply]) and₂ {φ ψ} := - have : 𝓔 ⊢! (∼φ ⋎ ∼ψ) ⋎ ψ := equiv.symm <| or <| or <| close ψ + have : 𝓟 ⊢! (∼φ ⋎ ∼ψ) ⋎ ψ := equiv.symm <| or <| or <| close ψ Entailment.cast this (by simp [DeMorgan.imply]) and₃ {φ ψ} := - have : 𝓔 ⊢! ∼φ ⋎ ∼ψ ⋎ φ ⋏ ψ := equiv.symm <| or <| swap₁ <| or <| swap₁ <| and (close φ) (close ψ) + have : 𝓟 ⊢! ∼φ ⋎ ∼ψ ⋎ φ ⋏ ψ := equiv.symm <| or <| swap₁ <| or <| swap₁ <| and (close φ) (close ψ) Entailment.cast this (by simp [DeMorgan.imply]) or₁ {φ ψ} := - have : 𝓔 ⊢! ∼φ ⋎ φ ⋎ ψ := equiv.symm <| or <| swap₁ <| or <| close φ + have : 𝓟 ⊢! ∼φ ⋎ φ ⋎ ψ := equiv.symm <| or <| swap₁ <| or <| close φ Entailment.cast this (by simp [DeMorgan.imply]) or₂ {φ ψ} := - have : 𝓔 ⊢! ∼ψ ⋎ φ ⋎ ψ := equiv.symm <| or <| swap₁ <| or <| close ψ + have : 𝓟 ⊢! ∼ψ ⋎ φ ⋎ ψ := equiv.symm <| or <| swap₁ <| or <| close ψ Entailment.cast this (by simp [DeMorgan.imply]) or₃ {φ ψ χ} := - have : 𝓔 ⊢! φ ⋏ ∼χ ⋎ ψ ⋏ ∼ χ ⋎ ∼φ ⋏ ∼ψ ⋎ χ := + have : 𝓟 ⊢! φ ⋏ ∼χ ⋎ ψ ⋏ ∼ χ ⋎ ∼φ ⋏ ∼ψ ⋎ χ := equiv.symm <| or <| swap₁ <| or <| swap₁ <| or <| and (swap₃ <| and (close φ) (close χ)) (swap₂ <| and (close ψ) (close χ)) Entailment.cast this (by simp [DeMorgan.imply]) dne {φ} := - have : 𝓔 ⊢! ∼φ ⋎ φ := equiv.symm <| or <| close φ + have : 𝓟 ⊢! ∼φ ⋎ φ := equiv.symm <| or <| close φ Entailment.cast this (by simp [DeMorgan.imply]) -end EmptyEntailment +variable {𝓟} + +lemma derivable_iff_provable_disj : Nonempty (𝔇 Γ) ↔ 𝓟 ⊢ ⋁Γ := by + constructor + · rintro ⟨d⟩ + have : 𝔇 (Γ ++ []) := cast d + exact provable_iff.mpr ⟨disj₂ this⟩ + · rintro h + have d₁ : 𝔇 [⋁Γ] := (provable_iff.mp h).some + have d₂ : 𝔇 (⋀(∼Γ) :: Γ) := conj₂ fun φ h ↦ close φ (by simp) (by simp_all) + exact ⟨eCut d₁ d₂⟩ + +end PrincipalEntailment abbrev Pullback (𝔇 : List F → Type*) {G : Type*} [LogicalConnective G] (f : G →ˡᶜ F) : List G → Type _ := fun Γ ↦ 𝔇 (Γ.map f) @@ -129,21 +173,40 @@ def cast (d : 𝔇 Δ) (h : Δ = Γ.map f := by simp) : Pullback 𝔇 f Γ := by unfold Pullback exact h ▸ d -instance [OneSidedLK 𝔇] : OneSidedLK (Pullback 𝔇 f) where +def uncast (d : Pullback 𝔇 f Γ) (h : Δ = Γ.map f := by simp) : 𝔇 Δ := h ▸ d + +instance oneSidedLK [OneSidedLK 𝔇] : OneSidedLK (Pullback 𝔇 f) where identity φ := cast <| identity (f φ) wk {Δ Γ} d h := cast (wk d (List.map_subset f h) : 𝔇 (Γ.map f)) (by simp) verum := cast verum and d₁ d₂ := cast <| and d₁ d₂ or d := cast <| or d +instance cut [Cut 𝔇] : Cut (Pullback 𝔇 f) where + cut {φ Γ Δ} bp bn := + have bp : 𝔇 (f φ :: Γ.map f) := uncast bp + have bn : 𝔇 (∼f φ :: Δ.map f) := uncast bn + cast (Cut.cut bp bn) + +instance {P : Type*} [Entailment P F] (𝓟 : P) [PrincipalEntailment 𝔇 𝓟] : + PrincipalEntailment (Pullback 𝔇 f) (Entailment.pullback 𝓟 f) where + equiv {φ} := PrincipalEntailment.equiv (φ := f φ) + +omit [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] [DeMorgan G] [NegInvolutive G] in +@[simp] lemma nonempty_iff {Γ} : Nonempty (Pullback 𝔇 f Γ) ↔ Nonempty (𝔇 (Γ.map f)) := by simp [Pullback] + +omit [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] [DeMorgan G] [NegInvolutive G] in +@[simp] lemma isEmpty_iff {Γ} : IsEmpty (Pullback 𝔇 f Γ) ↔ IsEmpty (𝔇 (Γ.map f)) := by simp [Pullback] + end Pullback -protected class Entailment (𝔇 : outParam (List F → Type*)) (S : Type*) [Entailment S F] [AdjunctiveSet F S] where +/-- An entailment relation which is determined by a context and derivability. -/ +class ContextualEntailment (𝔇 : outParam (List F → Type*)) (S : Type*) [Entailment S F] [AdjunctiveSet F S] where equiv {𝓢 : S} {φ} : 𝓢 ⊢! φ ≃ (l : {l : List F // ∀ φ ∈ l, φ ∈ 𝓢}) × 𝔇 (φ :: ∼l) -namespace Entailment +namespace ContextualEntailment -variable {S : Type*} [Entailment S F] [AdjunctiveSet F S] [OneSidedLK.Entailment 𝔇 S] +variable {S : Type*} [Entailment S F] [AdjunctiveSet F S] [ContextualEntailment 𝔇 S] omit [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] in lemma provable_iff {𝓢 : S} : @@ -209,7 +272,7 @@ lemma inconsistent_iff {𝓢 : S} : · rintro ⟨Γ, hΓ, ⟨d⟩⟩ exact ⟨Γ, hΓ, ⟨wk d (by simp)⟩⟩ -instance (𝓢 : S) : Entailment.Cl 𝓢 where +instance cl (𝓢 : S) : Entailment.Cl 𝓢 where negEquiv {φ} := Entailment.cast (show 𝓢 ⊢! (φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ) from toProof _ <| and (or <| swap₁ <| or <| close φ) (or <| and (identity φ) top)) @@ -249,23 +312,55 @@ instance (𝓢 : S) : Entailment.Cl 𝓢 where have : 𝓢 ⊢! ∼φ ⋎ φ := toProof _ <| or <| close φ Entailment.cast this (by simp [DeMorgan.imply]) -variable {E : Type*} [Entailment E F] +variable {P : Type*} [Entailment P F] omit [DeMorgan F] [OneSidedLK 𝔇] [Cut 𝔇] in -lemma empty_provable_iff_eprovable (𝓔 : E) [EmptyEntailment 𝔇 𝓔] : - (∅ : S) ⊢ φ ↔ 𝓔 ⊢ φ := by +lemma empty_provable_iff_eprovable {𝓟 : P} [PrincipalEntailment 𝔇 𝓟] : + (∅ : S) ⊢ φ ↔ 𝓟 ⊢ φ := by constructor · rintro ⟨d⟩ let ⟨l, d⟩ := equiv d - have : 𝓔 ⊢! φ := EmptyEntailment.equiv.symm <| cast d <| by + have : 𝓟 ⊢! φ := PrincipalEntailment.equiv.symm <| cast d <| by have : ∀ φ, φ ∉ (l : List F) := by simpa using l.prop simp [List.eq_nil_iff_forall_not_mem]; grind exact ⟨this⟩ · rintro ⟨b⟩ - have : 𝔇 [φ] := EmptyEntailment.equiv b + have : 𝔇 [φ] := PrincipalEntailment.equiv b exact ⟨equiv.symm ⟨⟨[], by simp⟩, this⟩⟩ -end Entailment +lemma iff_context {𝓢 : S} {𝓟 : P} [PrincipalEntailment 𝔇 𝓟] : + 𝓢 ⊢ φ ↔ AdjunctiveSet.set 𝓢 *⊢[𝓟] φ := by + constructor + · rintro h + have ⟨Γ, hΓ, ⟨d⟩⟩ := provable_iff.mp h + have : 𝓟 ⊢ ⋀Γ 🡒 φ := by + have : 𝔇 (∼Γ ++ [φ]) := weakening d + have : Nonempty (𝔇 [⋀Γ 🡒 φ]) := by simpa [DeMorgan.imply] using Nonempty.intro (or <| disj₂ this) + exact PrincipalEntailment.provable_iff.mpr this + refine ⟨⟨Γ, by simpa using hΓ, this.some⟩⟩ + · rintro ⟨Γ, h, d⟩ + have : 𝓟 ⊢! ⋀Γ 🡒 φ := d + have d : 𝔇 [⋁(∼Γ) ⋎ φ] := cast (PrincipalEntailment.equiv this) (by simp [DeMorgan.imply]) + have : 𝔇 (⋀Γ ⋏ ∼φ :: φ :: ∼Γ) := + have : 𝔇 (⋀Γ :: ∼Γ) := conj₂ fun φ h ↦ close φ (by simp) (by simp [h]) + weakening <| tensor this (rotate <| identity φ) + have : 𝔇 (φ :: ∼Γ) := eCut d this + refine provable_iff.mpr ⟨Γ, h, ⟨this⟩⟩ + +lemma of_principal_provable {𝓟 : P} [PrincipalEntailment 𝔇 𝓟] {𝓢 : S} : 𝓟 ⊢ φ → 𝓢 ⊢ φ := fun h ↦ + iff_context.mpr (Entailment.Context.of! h) + +open Classical in +noncomputable abbrev deduction (𝓟 : P) [PrincipalEntailment 𝔇 𝓟] : Entailment.Deduction S where + ofInsert {φ ψ 𝓢 b} := + have : AdjunctiveSet.set (Adjoin.adjoin φ 𝓢) *⊢[𝓟] ψ := iff_context.mp ⟨b⟩ + have : AdjunctiveSet.set 𝓢 *⊢[𝓟] φ 🡒 ψ := Context.deduct! <| by simpa using this + (iff_context.mpr this).get + inv {φ ψ 𝓢 b} := + have : AdjunctiveSet.set (Adjoin.adjoin φ 𝓢) *⊢[𝓟] ψ := by simpa using Context.deductInv! (iff_context.mp ⟨b⟩) + (iff_context.mpr this).get + +end ContextualEntailment end OneSidedLK diff --git a/Foundation/Logic/Entailment.lean b/Foundation/Logic/Entailment.lean index 800be72f7..22e8fe906 100644 --- a/Foundation/Logic/Entailment.lean +++ b/Foundation/Logic/Entailment.lean @@ -372,7 +372,7 @@ lemma le_of_subset (h : 𝓢 ⊆ 𝓣) : 𝓢 ⪯ 𝓣 := ⟨by rintro φ ⟨b lemma weakening! (h : 𝓢 ⊆ 𝓣 := by simp) {φ} : 𝓢 ⊢ φ → 𝓣 ⊢ φ := by rintro ⟨b⟩; exact ⟨weakening h b⟩ -def weakerThanOfSubset (h : 𝓢 ⊆ 𝓣) : 𝓢 ⪯ 𝓣 := ⟨fun _ ↦ weakening! h⟩ +abbrev weakerThanOfSubset (h : 𝓢 ⊆ 𝓣) : 𝓢 ⪯ 𝓣 := ⟨fun _ ↦ weakening! h⟩ def toAdjoin {𝓢 : S} : 𝓢 ⊢! ψ → adjoin φ 𝓢 ⊢! ψ := fun b ↦ wk (by simp) b @@ -407,10 +407,10 @@ lemma cut! {𝓢 : S} {𝓣 : T} {φ : F} (H : 𝓢 ⊢* AdjunctiveSet.set 𝓣) end StrongCut -noncomputable def WeakerThan.ofAxm! [AdjunctiveSet F S] [StrongCut S S] {𝓢₁ 𝓢₂ : S} (B : 𝓢₂ ⊢* AdjunctiveSet.set 𝓢₁) : +noncomputable abbrev WeakerThan.ofAxm! [AdjunctiveSet F S] [StrongCut S S] {𝓢₁ 𝓢₂ : S} (B : 𝓢₂ ⊢* AdjunctiveSet.set 𝓢₁) : 𝓢₁ ⪯ 𝓢₂ := ⟨fun _ b ↦ StrongCut.cut! B b⟩ -def WeakerThan.ofSubset [AdjunctiveSet F S] [Axiomatized S] {𝓢 𝓣 : S} (h : 𝓢 ⊆ 𝓣) : 𝓢 ⪯ 𝓣 := ⟨fun _ ↦ wk! h⟩ +abbrev WeakerThan.ofSubset [AdjunctiveSet F S] [Axiomatized S] {𝓢 𝓣 : S} (h : 𝓢 ⊆ 𝓣) : 𝓢 ⪯ 𝓣 := ⟨fun _ ↦ wk! h⟩ /-! ### Compactness -/ diff --git a/Foundation/Propositional/Tait/Calculus.lean b/Foundation/Propositional/Tait/Calculus.lean index 181fe58c3..2657035c9 100644 --- a/Foundation/Propositional/Tait/Calculus.lean +++ b/Foundation/Propositional/Tait/Calculus.lean @@ -84,7 +84,7 @@ namespace Proof lemma def_eq (φ : NNFormula α) : (𝐋𝐊⁰ ⊢! φ) = (⊢ᴸᴷ⁰ [φ]) := rfl -instance : OneSidedLK.EmptyEntailment (Derivation (α := α)) (𝐋𝐊⁰ : Proof.Symbol α) where +instance : OneSidedLK.PrincipalEntailment (Derivation (α := α)) (𝐋𝐊⁰ : Proof.Symbol α) where equiv := Equiv.refl _ instance classical : Entailment.Cl (𝐋𝐊⁰ : Proof.Symbol α) := inferInstance diff --git a/Foundation/Syntax/Predicate/Rew.lean b/Foundation/Syntax/Predicate/Rew.lean index f80a636f9..b2e299c75 100644 --- a/Foundation/Syntax/Predicate/Rew.lean +++ b/Foundation/Syntax/Predicate/Rew.lean @@ -815,11 +815,11 @@ abbrev subst [Rewriting L ξ F ξ F] (φ : F n₁) (w : Fin n₁ → Semiterm L infix:90 " ⇜ " => LO.FirstOrder.Rewriting.subst -abbrev shift [Rewriting L ℕ F ℕ F] (φ : F n) : F n := @Rew.shift L n ▹ φ +abbrev shift [Rewriting L ℕ F ℕ F] : F n →ˡᶜ F n := app Rew.shift -abbrev free [Rewriting L ℕ F ℕ F] (φ : F (n + 1)) : F n := @Rew.free L n ▹ φ +abbrev free [Rewriting L ℕ F ℕ F] : F (n + 1) →ˡᶜ F n := app Rew.free -abbrev fix [Rewriting L ℕ F ℕ F] (φ : F n) : F (n + 1) := @Rew.fix L n ▹ φ +abbrev fix [Rewriting L ℕ F ℕ F] : F n →ˡᶜ F (n + 1) := app Rew.fix def shifts [Rewriting L ℕ F ℕ F] (Γ : List (F n)) : List (F n) := Γ.map Rewriting.shift @@ -832,7 +832,7 @@ scoped[LO.FirstOrder] postfix:max "⁺" => FirstOrder.Rewriting.shifts @[simp] lemma shifts_neg [Rewriting L ℕ F ℕ F] (Γ : List (F n)) : (∼Γ)⁺ = ∼(Γ⁺) := by simp [shifts, List.tilde_def] -@[coe] abbrev emb {ο ξ} [IsEmpty ο] {O F : ℕ → Type*} [LCWQ O] [LCWQ F] [Rewriting L ο O ξ F] (φ : O n) : F n := @Rew.emb L ο _ ξ n ▹ φ +abbrev emb {ο ξ} [IsEmpty ο] {O F : ℕ → Type*} [LCWQ O] [LCWQ F] [Rewriting L ο O ξ F] : O n →ˡᶜ F n := app (Rew.emb (ξ := ξ)) end Rewriting From 0ba23055ef103cab2d5016d2c2aa5f98c3ca6624 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 7 May 2026 05:10:59 +0900 Subject: [PATCH 44/61] soundness --- Foundation/FirstOrder/Basic/Calculus.lean | 38 ++++++----- .../FirstOrder/Basic/Semantics/Semantics.lean | 33 ++++----- Foundation/FirstOrder/Basic/Soundness.lean | 68 +++++++++---------- 3 files changed, 69 insertions(+), 70 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index 73b80e357..2f87d17f0 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -249,19 +249,19 @@ end Derivation /-! ## Classical proof system -/ -inductive LK.Symbol (L : Language) +inductive LK (L : Language) | symbol -notation "𝐋𝐊¹" => LK.Symbol.symbol +notation "𝐋𝐊¹" => LK.symbol -notation "𝐋𝐊¹[" L "]" => LK.Symbol.symbol (L := L) +notation "𝐋𝐊¹[" L "]" => LK.symbol (L := L) -abbrev LK (φ : Proposition L) := ⊢ᴸᴷ¹ [φ] +abbrev LK.Proof (φ : Proposition L) := ⊢ᴸᴷ¹ [φ] -instance : Entailment (LK.Symbol L) (Proposition L) where - Prf _ := LK +instance : Entailment (LK L) (Proposition L) where + Prf _ := LK.Proof -namespace LK +namespace LK.Proof lemma def_eq (φ : Proposition L) : (𝐋𝐊¹ ⊢! φ) = (⊢ᴸᴷ¹ [φ]) := rfl @@ -270,10 +270,10 @@ lemma provable_def (φ : Proposition L) : 𝐋𝐊¹ ⊢ φ ↔ Nonempty (⊢ᴸ lemma unprovable_def (φ : Proposition L) : 𝐋𝐊¹ ⊬ φ ↔ IsEmpty (⊢ᴸᴷ¹ [φ]) := by unfold Entailment.Unprovable; simp [provable_def] -instance : OneSidedLK.PrincipalEntailment (Derivation (L := L)) (𝐋𝐊¹ : LK.Symbol L) where +instance : OneSidedLK.PrincipalEntailment (Derivation (L := L)) (𝐋𝐊¹ : LK L) where equiv := Equiv.refl _ -instance classical : Entailment.Cl (𝐋𝐊¹ : LK.Symbol L) := inferInstance +instance classical : Entailment.Cl (𝐋𝐊¹ : LK L) := inferInstance lemma all (φ : Semiproposition L 1) : 𝐋𝐊¹ ⊢ φ.free → 𝐋𝐊¹ ⊢ ∀⁰ φ := fun h ↦ ⟨Derivation.all h.get⟩ @@ -285,21 +285,21 @@ lemma allClosure_fixitr {φ : Proposition L} (dp : 𝐋𝐊¹ ⊢ φ) : (m : ℕ lemma univCl' {φ : Proposition L} (b : 𝐋𝐊¹ ⊢ φ) : 𝐋𝐊¹ ⊢ φ.univCl' := allClosure_fixitr b φ.fvSup -end LK +end LK.Proof -structure Theory.LK (T : Theory L) (σ : Sentence L) where +structure Theory.Proof (T : Theory L) (σ : Sentence L) where axioms : List (Sentence L) axioms_mem : ∀ ψ ∈ axioms, ψ ∈ T derivation : OneSidedLK.Pullback Derivation Rewriting.emb (σ :: ∼axioms) -namespace Theory +namespace Theory.Proof instance : Entailment (Theory L) (Sentence L) where - Prf := Theory.LK + Prf := Theory.Proof variable {T : Theory L} -attribute [simp] LK.axioms_mem +attribute [simp] Theory.Proof.axioms_mem instance : Entailment.Compact (Theory L) where core b := {φ | φ ∈ b.axioms} @@ -314,6 +314,8 @@ instance : OneSidedLK.ContextualEntailment (OneSidedLK.Pullback Derivation Rewri instance : Entailment.Cl T := OneSidedLK.ContextualEntailment.cl T +instance : Entailment.Axiomatized (Theory L) := inferInstance + lemma weakerThan_of_le {T U : Theory L} (h : T ⊆ U) : T ⪯ U := Entailment.Axiomatized.weakerThanOfSubset h instance (T U : Theory L) : T ⪯ T ∪ U := weakerThan_of_le (by simp) @@ -334,14 +336,14 @@ open Entailment Derivation (∅ : Theory L) ⊢ φ ↔ 𝐋𝐊¹ ⊢ (φ : Proposition L) := by simpa using OneSidedLK.ContextualEntailment.empty_provable_iff_eprovable (S := Theory L) - (𝓟 := pullback 𝐋𝐊¹[L] (Rewriting.emb : Sentence L → Proposition L)) + (𝓟 := pullback (𝐋𝐊¹[L]) (Rewriting.emb : Sentence L → Proposition L)) (φ := φ) lemma iff_context {T : Theory L} : T ⊢ φ ↔ T *⊢[pullback 𝐋𝐊¹[L] (Rewriting.emb : _ → Proposition L)] φ := OneSidedLK.ContextualEntailment.iff_context -end Theory +end Theory.Proof namespace Theory @@ -359,10 +361,10 @@ end Theory /-! ### Theory -/ -def Theory.theory (T : Theory L) : Theory L := {σ | T ⊢ ↑σ} +def Theory.theory (T : Theory L) : Theory L := {σ | T ⊢ σ} @[simp] lemma Theory.mem_theory {T : Theory L} : - σ ∈ T.theory ↔ T ⊢ ↑σ := by simp [Theory.theory] + σ ∈ T.theory ↔ T ⊢ σ := by simp [Theory.theory] end FirstOrder diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index 65f8afc48..849493b10 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -1,6 +1,6 @@ module -public import Foundation.FirstOrder.Basic.Syntax.Schema +public import Foundation.FirstOrder.Basic.Syntax.Rew public import Foundation.Vorspiel.IsEmpty public import Foundation.Vorspiel.Empty @@ -238,7 +238,7 @@ abbrev Evalf [s : Structure L M] (f : ξ → M) : Formula L ξ →ˡᶜ Prop := abbrev Evalb [s : Structure L M] (b : Fin n → M) : Semiformula L Empty n →ˡᶜ Prop := Eval b Empty.elim -abbrev Eval₀ (M : Type*) [s : Structure L M] : +abbrev Realize (M : Type*) [s : Structure L M] : Sentence L →ˡᶜ Prop := Eval (s := s) ![] Empty.elim abbrev Models (s : Structure L M) : Formula L M →ˡᶜ Prop := Eval ![] id @@ -447,7 +447,7 @@ lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeV intro x hx; simp [Rew.fixitr_fvar, lt_fvSup_of_fvar? hx] @[simp] lemma eval_univCl [Nonempty M] (φ : Proposition L) : - Eval₀ M φ.univCl ↔ ∀ f : ℕ → M, Evalf f φ := by + Realize M φ.univCl ↔ ∀ f : ℕ → M, Evalf f φ := by haveI : Inhabited M := Classical.inhabited_of_nonempty inferInstance simp [Semiformula.univCl, ←eval_toEmpty (f := default)] @@ -491,7 +491,7 @@ end end Structure instance : Semantics (Struc L) (Sentence L) where - Models := fun str ↦ Semiformula.Eval₀ str.Dom + Models := fun str ↦ Semiformula.Realize str.Dom instance : Semantics.Tarski (Struc L) where models_verum := by simp [Semantics.Models] @@ -521,15 +521,12 @@ variable {M} lemma struc_models_iff_models {s : Struc L} : s ⊧ σ ↔ s.Dom↓[L] ⊧ σ := by rfl -lemma models_iff : M↓[L] ⊧ σ ↔ σ.Eval₀ M := by rfl +lemma models_iff : M↓[L] ⊧ σ ↔ σ.Realize M := by rfl lemma models_iff_proposition {φ : Proposition L} : M↓[L] ⊧ φ.univCl ↔ ∀ f : ℕ → M, φ.Evalf f := by simp [models_iff] -lemma models_theory_iff : M↓[L] ⊧* T ↔ (∀ {φ}, φ ∈ T → M↓[L] ⊧ φ) := Semantics.modelsSet_iff - -lemma models_schema_iff {𝔖 : Schema L} : M↓[L] ⊧* (𝔖 : Theory L) ↔ (∀ {φ : Proposition L}, φ ∈ 𝔖 → ∀ f : ℕ → M, φ.Evalf f) := by - simp [models_theory_iff, models_iff] +lemma models_theory_iff : M↓[L] ⊧* T ↔ ∀ φ ∈ T, M↓[L] ⊧ φ := Semantics.modelsSet_iff lemma models_of_mem {T : Theory L} [M↓[L] ⊧* T] {φ} (h : φ ∈ T) : M↓[L] ⊧ φ := Semantics.ModelsSet.models _ h @@ -592,7 +589,7 @@ lemma consequence_iff_unsatisfiable {σ : Sentence L} : intro hT; simpa using models_iff.mp (h hT) · intro h; apply consequence_iff.mpr intro M _ s hT - have : σ.Eval₀ M := by + have : σ.Realize M := by have := by simpa only [Semantics.ModelsSet.insert_iff, not_and', models_iff] using unsatisfiable_iff.mp h M inferInstance s simpa using this hT apply models_iff.mpr (by simpa using this) @@ -619,7 +616,7 @@ end lMap end Semiformula -section schema +section theory variable (M) [Nonempty M] [Structure L M] @@ -628,19 +625,19 @@ variable {M} lemma models_of_ss {T U : Theory L} (h : M↓[L] ⊧* U) (ss : T ⊆ U) : M↓[L] ⊧* T := Semantics.ModelsSet.of_subset h ss -lemma models_of_le {𝔖₁ 𝔖₂ : Schema L} (h : M↓[L] ⊧* ↑↑𝔖₂) (le : 𝔖₁ ≤ 𝔖₂) : M↓[L] ⊧* ↑↑𝔖₁ := - Semantics.ModelsSet.of_subset h (Schema.coe_subset_coe_of_le le) +lemma models_of_le {T₁ T₂ : Theory L} (h : M↓[L] ⊧* T₂) (le : T₁ ⊆ T₂) : M↓[L] ⊧* T₁ := + Semantics.ModelsSet.of_subset h le -instance models_schema_sup (𝔖₁ 𝔖₂ : Schema L) [M↓[L] ⊧* ↑↑𝔖₁] [M↓[L] ⊧* ↑↑𝔖₂] : M↓[L] ⊧* ↑↑(𝔖₁ ∪ 𝔖₂) := by - simp only [Schema.coe_sup, Semantics.ModelsSet.union_iff] +instance models_theory_sup (T₁ T₂ : Theory L) [M↓[L] ⊧* T₁] [M↓[L] ⊧* T₂] : M↓[L] ⊧* T₁ ∪ T₂ := by + simp only [Semantics.ModelsSet.union_iff] constructor · infer_instance · infer_instance -lemma modelsUnivCl_of_mem_schema {𝔖 : Schema L} [h : M↓[L] ⊧* ↑↑𝔖] (hf : φ ∈ 𝔖) : M↓[L] ⊧ φ.univCl := - h.models _ <| by simp; grind +lemma models_of_mem_theory {T : Theory L} [h : M↓[L] ⊧* T] (hf : φ ∈ T) : M↓[L] ⊧ φ := + h.models _ hf -end schema +end theory namespace Structure diff --git a/Foundation/FirstOrder/Basic/Soundness.lean b/Foundation/FirstOrder/Basic/Soundness.lean index e34bdbe99..9efdc0941 100644 --- a/Foundation/FirstOrder/Basic/Soundness.lean +++ b/Foundation/FirstOrder/Basic/Soundness.lean @@ -72,53 +72,53 @@ end Derivation theorem Provable.sound {M : Type*} [s : Structure L M] [Nonempty M] {φ : Proposition L} (f : ℕ → M) : 𝐋𝐊¹ ⊢ φ → φ.Evalf f := fun b ↦ by simpa using Derivation.sound f b.get -variable {𝔖 : Schema L} - -theorem Schema.sound_proposition {M : Type*} [s : Structure L M] [Nonempty M] : - 𝔖 ⊢ φ → M↓[L] ⊧* ↑↑𝔖 → ∀ f : ℕ → M, φ.Evalf f := fun b H f ↦ by - rcases Schema.provable_iff.mp b with ⟨Γ, hΓ, ⟨b⟩⟩ - have : φ.Evalf f ∨ ∃ ψ, ∼ψ ∈ Γ ∧ ψ.Evalf f := by simpa using b.sound f +variable {T : Theory L} + +theorem Theory.Proof.sound_proposition {M : Type*} [s : Structure L M] [Nonempty M] : + T ⊢ φ → M↓[L] ⊧* T → φ.Realize M := fun b H ↦ by + rcases Theory.Proof.provable_iff.mp b with ⟨Γ, hΓ, ⟨b⟩⟩ + have : Inhabited M := Classical.inhabited_of_nonempty inferInstance + let f : ℕ → M := fun _ ↦ default + have : φ.Realize M ∨ ∃ ψ, ∼ψ ∈ Sequent.embed Γ ∧ ψ.Evalf f := by simpa using b.sound f rcases this with (h | ⟨ψ, hψ, h⟩) · assumption - · have : ¬ψ.Evalf f := by - have := by simpa [models_iff] using H.models _ (φ := (∼ψ).univCl) (by grind only [Schema.mem_uniClosure]) - exact this f + · have : ∃ χ, ∼χ ∈ Γ ∧ ↑χ = ψ := by + have : ∃ χ ∈ Γ, χ = ∼ψ := by simpa [Sequent.embed] using hψ + rcases this with ⟨χ, hχ, e⟩ + refine ⟨∼χ, by simpa using hχ, by simp [e]⟩ + rcases this with ⟨χ, hχ, rfl⟩ + have : χ.Realize M := by simpa using h + have : ¬χ.Realize M := by + simpa [models_iff] using H.models _ (hΓ _ hχ) contradiction -theorem Schema.sound_proposition' : - 𝔖 ⊢ φ → (𝔖 : Theory L) ⊨[Struc.{v, u} L] φ.univCl := fun b s hS ↦ by +theorem Theory.Proof.sound {φ : Sentence L} : + T ⊢ φ → T ⊨[Struc.{v, u} L] φ := fun b s hS ↦ by simpa [struc_models_iff_models (s := s), models_iff] - using Schema.sound_proposition b hS - -theorem Schema.sound_sentence {σ : Sentence L} : - 𝔖 ⊢ ↑σ → (𝔖 : Theory L) ⊨[Struc.{v, u} L] σ := fun b ↦ by - simpa using Schema.sound_proposition' b + using Theory.Proof.sound_proposition b hS -theorem Schema.smallSound_sentence {σ : Sentence L} : 𝔖 ⊢ ↑σ → (𝔖 : Theory L) ⊨ σ := Schema.sound_sentence +theorem Theory.Proof.sound_small : T ⊢ φ → T ⊨ φ := Theory.Proof.sound -instance sound (𝔖 : Schema L) : - Sound (Entailment.pullback 𝔖 ((↑·) : Sentence L → Proposition L)) (Semantics.models (Struc.{v, u} L) 𝔖) := - ⟨Schema.sound_sentence⟩ +instance sound (T : Theory L) : Sound T (Semantics.models (Struc.{v, u} L) T) := ⟨Theory.Proof.sound⟩ -lemma models_of_subtheory {𝔖 𝔗 : Schema L} [𝔖 ⪯ 𝔗] {M : Type*} [Structure L M] [Nonempty M] : M↓[L] ⊧* ↑↑𝔗 → M↓[L] ⊧* ↑↑𝔖 := - fun hM ↦ ⟨fun {σ} hσ ↦ by - rcases show ∃ φ ∈ 𝔖, univCl φ = σ by simpa using hσ with ⟨φ, hφ, rfl⟩ - have : 𝔖 ⪯ 𝔗 := inferInstance - have : 𝔗 ⊢ φ := this.pbl (Entailment.by_axm hφ) - exact Schema.sound_proposition' this hM⟩ +lemma models_of_subtheory {T U : Theory L} [T ⪯ U] {M : Type*} [Structure L M] [Nonempty M] : M↓[L] ⊧* U → M↓[L] ⊧* T := + fun hM ↦ ⟨fun {φ} hφ ↦ by + have : T ⪯ U := inferInstance + have : U ⊢ φ := this.pbl (Entailment.by_axm hφ) + exact Theory.Proof.sound this hM⟩ -lemma consistent_of_satisfiable (h : Semantics.Satisfiable (Struc.{v, u} L) ↑↑𝔖) : Entailment.Consistent 𝔖 := - Entailment.Pullback.consistent <| Sound.consistent_of_satisfiable (𝓢 := Entailment.pullback 𝔖 ((↑·) : Sentence L → Proposition L)) h +lemma consistent_of_satisfiable (h : Semantics.Satisfiable (Struc.{v, u} L) T) : Entailment.Consistent T := + Sound.consistent_of_satisfiable h -lemma consistent_of_model (𝔖 : Schema L) (M : Type*) [Structure L M] [Nonempty M] [hM : M↓[L] ⊧* ↑↑𝔖] : - Entailment.Consistent 𝔖 := consistent_of_satisfiable ⟨M↓[L], hM⟩ +lemma consistent_of_model (T : Theory L) (M : Type*) [Structure L M] [Nonempty M] [hM : M↓[L] ⊧* T] : + Entailment.Consistent T := consistent_of_satisfiable ⟨M↓[L], hM⟩ -lemma unprovable_of_countermodel {M : Type*} [Structure L M] [Nonempty M] [hM : M↓[L] ⊧* ↑↑𝔖] {σ} : M↓[L] ⊭ σ → 𝔖 ⊬ ↑σ := by +lemma unprovable_of_countermodel {M : Type*} [Structure L M] [Nonempty M] [hM : M↓[L] ⊧* T] {φ} : M↓[L] ⊭ φ → T ⊬ φ := by contrapose!; intro h - exact Schema.sound_sentence h hM + exact Theory.Proof.sound h hM -lemma models_of_provable {M : Type*} [Nonempty M] [Structure L M] (hT : M↓[L] ⊧* ↑↑𝔖) {σ : Sentence L} (h : 𝔖 ⊢ ↑σ) : - M↓[L] ⊧ σ := consequence_iff.mp (Schema.sound_sentence h) M inferInstance +lemma models_of_provable {M : Type*} [Nonempty M] [Structure L M] (hT : M↓[L] ⊧* ↑↑T) {φ : Sentence L} (h : T ⊢ φ) : + M↓[L] ⊧ φ := consequence_iff.mp (Theory.Proof.sound h) M inferInstance end sound From b443d6df62200b467b78aa51bca5a3a2ad4eafaf Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 7 May 2026 05:56:02 +0900 Subject: [PATCH 45/61] eq --- Foundation/FirstOrder/Basic/Eq.lean | 264 ++++++++++++--------- Foundation/FirstOrder/Basic/Soundness.lean | 56 +++-- 2 files changed, 182 insertions(+), 138 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Eq.lean b/Foundation/FirstOrder/Basic/Eq.lean index 97f223238..db9c10550 100644 --- a/Foundation/FirstOrder/Basic/Eq.lean +++ b/Foundation/FirstOrder/Basic/Eq.lean @@ -19,121 +19,144 @@ namespace LO namespace FirstOrder -variable {L : Language} {ξ : Type*} [Semiformula.Operator.Eq L] +variable {L : Language} {ξ : Type*} [Semiformula.Operator.Eq L] -namespace Eq - -protected abbrev refl (t : Term L ℕ) : Proposition L := op(=).operator ![t, t] +namespace Theory -protected abbrev symm (t u : Term L ℕ) : Proposition L := op(=).operator ![t, u] 🡒 op(=).operator ![u, t] +section Eq -protected abbrev trans (t u v : Term L ℕ) : Proposition L := op(=).operator ![t, u] 🡒 op(=).operator ![u, v] 🡒 op(=).operator ![t, v] +variable (L) -def funcExt {k} (f : L.Func k) (v w : Fin k → Term L ℕ) : Proposition L := - (Matrix.conj fun i ↦ op(=).operator ![v i, w i]) 🡒 op(=).operator ![Semiterm.func f v, Semiterm.func f w] +abbrev Eq.refl : Sentence L := “∀ x, x = x” -@[simp] lemma rew_funcExt (ω : Rew L ℕ 0 ℕ 0) {k} (f : L.Func k) (v w : Fin k → Term L ℕ) : - ω ▹ funcExt f v w = funcExt f (ω ∘ v) (ω ∘ w) := by - simp [funcExt, Function.comp_def] +abbrev Eq.symm : Sentence L := “∀ x y, x = y → y = x” -def relExt {k} (r : L.Rel k) (v w : Fin k → Term L ℕ) : Proposition L := - (Matrix.conj fun i ↦ op(=).operator ![v i, w i]) 🡒 Semiformula.rel r v 🡒 Semiformula.rel r w +abbrev Eq.trans : Sentence L := “∀ x y z, x = y → y = z → x = z” -@[simp] lemma rew_relExt (ω : Rew L ℕ 0 ℕ 0) {k} (r : L.Rel k) (v w : Fin k → Term L ℕ) : - ω ▹ relExt r v w = relExt r (ω ∘ v) (ω ∘ w) := by - simp [relExt, Function.comp_def] +variable {L} -inductive EqSchema : Proposition L → Prop - | refl (t : Term L ℕ) : EqSchema (Eq.refl t) - | symm (t u : Term L ℕ) : EqSchema (Eq.symm t u) - | trans (t u v : Term L ℕ) : EqSchema (Eq.trans t u v) - | funcExt {k} (f : L.Func k) (v w : Fin k → Term L ℕ) : EqSchema (funcExt f v w) - | relExt {k} (r : L.Rel k) (v w : Fin k → Term L ℕ) : EqSchema (relExt r v w) +abbrev Eq.funcExt {k} (f : L.Func k) : Sentence L := + let σ : Semisentence L (k + k) := + (Matrix.conj fun i : Fin k ↦ “#(i.addCast k) = #(i.addNat k)”) 🡒 + op(=).operator ![Semiterm.func f (fun i ↦ #(i.addCast k)), Semiterm.func f (fun i ↦ #(i.addNat k))] + ∀⁰* σ -attribute [simp] EqSchema.refl EqSchema.symm EqSchema.trans EqSchema.funcExt EqSchema.relExt +abbrev Eq.relExt {k} (r : L.Rel k) : Sentence L := + let σ : Semisentence L (k + k) := + (Matrix.conj fun i : Fin k ↦ “#(i.addCast k) = #(i.addNat k)”) 🡒 + Semiformula.rel r (fun i ↦ #(i.addCast k)) 🡒 Semiformula.rel r (fun i ↦ #(i.addNat k)) + ∀⁰* σ variable (L) -abbrev eqSchema : Schema L := {φ | EqSchema φ} +inductive eqAxiom : Theory L + | refl : eqAxiom (Eq.refl L) + | symm : eqAxiom (Eq.symm L) + | trans : eqAxiom (Eq.trans L) + | funcExt {k} (f : L.Func k) : eqAxiom (Eq.funcExt f) + | relExt {k} (r : L.Rel k) : eqAxiom (Eq.relExt r) -notation "𝗘𝗤" => eqSchema +notation "𝗘𝗤" => eqAxiom -instance : Schema.IsClosed (𝗘𝗤 L) := ⟨by rintro ω _ (_ | _ | _ | _ | _) <;> simp [eqSchema]⟩ +variable {L} + +lemma Eq.defeq : + 𝗘𝗤 L = {Eq.refl L, Eq.symm L, Eq.trans L} + ∪ Set.range (fun f : (k : ℕ) × L.Func k ↦ Eq.funcExt f.2) + ∪ Set.range (fun f : (k : ℕ) × L.Rel k ↦ Eq.relExt f.2) := by + ext φ; constructor + · rintro ⟨⟩ + case refl => simp + case symm => simp + case trans => simp + case funcExt k f => + left; right; exact ⟨⟨k, f⟩, rfl⟩ + case relExt k r => + right; exact ⟨⟨k, r⟩, rfl⟩ + · rintro (((rfl | rfl | rfl) | ⟨f, rfl⟩) | ⟨r, rfl⟩) + · exact eqAxiom.refl + · exact eqAxiom.symm + · exact eqAxiom.trans + · exact eqAxiom.funcExt _ + · exact eqAxiom.relExt _ + +@[simp] lemma EqAxiom.finite [L.Finite] : Set.Finite (𝗘𝗤 L) := by + haveI : Fintype ((k : ℕ) × L.Func k) := Language.Finite.func + haveI : Fintype ((k : ℕ) × L.Rel k) := Language.Finite.rel + rw [Eq.defeq] + simp [Set.finite_range] end Eq +end Theory + namespace Structure namespace Eq variable (L) (M : Type*) [Nonempty M] [Structure L M] -@[simp] instance models_eqSchema [Structure.Eq L M] : - M↓[L] ⊧* ↑↑(𝗘𝗤 L) := ⟨by - intro σ h - have : ∃ φ, Eq.EqSchema φ ∧ Semiformula.univCl φ = σ := by simpa using h - rcases this with ⟨φ, (_ | _ | _ | _ | _), rfl⟩ <;> simp [models_iff, Eq.funcExt, Eq.relExt] - · grind - · grind +@[simp] instance models_eq [Structure.Eq L M] : + M↓[L] ⊧* 𝗘𝗤 L := ⟨by + intro φ h + rcases h with (_ | _ | _ | _ | _) <;> simp [models_iff, Theory.Eq.funcExt, Theory.Eq.relExt] · simp [Function.comp_def]; grind · simp [Function.comp_def]; grind⟩ +instance models_eqAxiom' [Structure.Eq L M] : M↓[L] ⊧* 𝗘𝗤 L := models_eq _ _ + variable {M} def eqv (a b : M) : Prop := (@Semiformula.Operator.Eq.eq L _).val ![a, b] variable {L} -variable [H : M↓[L] ⊧* ↑↑(𝗘𝗤 L)] +variable [H : M↓[L] ⊧* 𝗘𝗤 L] open Semiterm Theory Semiformula lemma eqv_refl (a : M) : eqv L a a := by - have : ∀ f : ℕ → M, op(=)[L].val ![f 0, f 0] := by - simpa [models_iff] using modelsUnivCl_of_mem_schema (M := M) (𝔖 := 𝗘𝗤 L) (Eq.EqSchema.refl &0) - simpa using this fun _ ↦ a + have : M↓[L] ⊧ “∀ x, x = x” := H.models _ (Theory.eqAxiom.refl (L := L)) + have : ∀ x : M, op(=)[L].val ![x, x] := by simpa [models_iff] using this + simpa using this a lemma eqv_symm {a b : M} : eqv L a b → eqv L b a := by - have : ∀ f : ℕ → M, op(=)[L].val ![f 0, f 1] → op(=)[L].val ![f 1, f 0] := by - simpa [models_iff] using modelsUnivCl_of_mem_schema (M := M) (𝔖 := 𝗘𝗤 L) (Eq.EqSchema.symm &0 &1) - simpa using this (a :>ₙ fun _ ↦ b) + have : M↓[L] ⊧ “∀ x y, x = y → y = x” := H.models _ (Theory.eqAxiom.symm (L := L)) + have : ∀ x y : M, op(=)[L].val ![x, y] → op(=)[L].val ![y, x] := by simpa [models_iff] using this + simpa using this a b lemma eqv_trans {a b c : M} : eqv L a b → eqv L b c → eqv L a c := by - have : ∀ f : ℕ → M, op(=)[L].val ![f 0, f 1] → op(=)[L].val ![f 1, f 2] → op(=)[L].val ![f 0, f 2] := by - simpa [models_iff] using modelsUnivCl_of_mem_schema (M := M) (𝔖 := 𝗘𝗤 L) (Eq.EqSchema.trans &0 &1 &2) - simpa using this (a :>ₙ b :>ₙ fun _ ↦ c) - -lemma eqv_funcExt {k} (F : L.Func k) {v w : Fin k → M} (h : ∀ i, eqv L (v i) (w i)) : - eqv L (func F v) (func F w) := by - have : ∀ f : ℕ → M, - (∀ i : Fin k, op(=)[L].val ![f i, f (k + i)]) → - op(=)[L].val ![func F fun x ↦ f x, func F fun x ↦ f (k + x)] := by - have := by simpa [models_iff, Eq.funcExt,] using - modelsUnivCl_of_mem_schema (M := M) (𝔖 := 𝗘𝗤 L) (Eq.EqSchema.funcExt F (fun i ↦ &i) (fun j ↦ &(k + j))) - simpa [Function.comp_def] using this - have : (∀ i : Fin k, op(=)[L].val ![v i, w i]) → - op(=)[L].val ![func F fun x ↦ v x, func F fun x ↦ w x] := by - simpa using this <| fun x ↦ if h : x < k then v ⟨x, h⟩ else if h : x < k + k then w ⟨x - k, by grind⟩ else Classical.ofNonempty - exact this h + have : M↓[L] ⊧ “∀ x y z, x = y → y = z → x = z” := H.models _ (Theory.eqAxiom.trans (L := L)) + have : ∀ x y z : M, op(=)[L].val ![x, y] → op(=)[L].val ![y, z] → op(=)[L].val ![x, z] := by simpa [models_iff] using this + simpa using this a b c + +lemma eqv_funcExt {k} (f : L.Func k) {v w : Fin k → M} (h : ∀ i, eqv L (v i) (w i)) : + eqv L (func f v) (func f w) := by + have : M↓[L] ⊧ Eq.funcExt f := H.models _ (eqAxiom.funcExt f) + have : + ∀ m : Fin (k + k) → M, + (∀ (i : Fin k), op(=)[L].val ![m (Fin.addCast k i), m (i.addNat k)]) → + op(=)[L].val ![func f fun i ↦ m (Fin.addCast k i), func f fun i ↦ m (i.addNat k)] := by + simpa [models_iff, Semiterm.val_func] using this + have := this (Matrix.vecAppend rfl v w) (fun i ↦ by simpa [Matrix.vecAppend_eq_ite] using h i) + simpa [Semiterm.val_func, Matrix.vecAppend_eq_ite] using this lemma eqv_relExt_aux {k} (r : L.Rel k) {v w : Fin k → M} (h : ∀ i, eqv L (v i) (w i)) : rel r v → rel r w := by - have : ∀ f : ℕ → M, - (∀ i : Fin k, op(=)[L].val ![f i, f (k + i)]) → - (rel r fun x ↦ f x) → rel r fun x ↦ f (k + x) := by - have := by simpa [models_iff, Eq.relExt] using - modelsUnivCl_of_mem_schema (M := M) (𝔖 := 𝗘𝗤 L) (Eq.EqSchema.relExt r (fun i ↦ &i) (fun j ↦ &(k + j))) - simpa [Function.comp_def] using this - have : (∀ i : Fin k, op(=)[L].val ![v i, w i]) → - (rel r fun x ↦ v x) → rel r fun x ↦ w x := by - simpa using this <| fun x ↦ if h : x < k then v ⟨x, h⟩ else if h : x < k + k then w ⟨x - k, by grind⟩ else Classical.ofNonempty - exact this h + have : M↓[L] ⊧ Eq.relExt r := H.models _ (eqAxiom.relExt r) + have : + ∀ m : Fin (k + k) → M, + (∀ (i : Fin k), op(=)[L].val ![m (Fin.addCast k i), m (i.addNat k)]) → + (rel r fun i ↦ m (Fin.addCast k i)) → rel r fun i ↦ m (i.addNat k) := by + simpa [models_iff, Semiterm.val_func] using this + have := this (Matrix.vecAppend rfl v w) (fun i ↦ by simpa [Matrix.vecAppend_eq_ite] using h i) + simpa [Semiterm.val_func, Matrix.vecAppend_eq_ite] using this lemma eqv_relExt {k} (r : L.Rel k) {v w : Fin k → M} (h : ∀ i, eqv L (v i) (w i)) : rel r v ↔ rel r w := by constructor · exact eqv_relExt_aux r h - · exact eqv_relExt_aux r fun i ↦ eqv_symm (h i) + · exact eqv_relExt_aux r (fun i => eqv_symm (h i)) lemma eqv_equivalence : Equivalence (eqv L (M := M)) where refl := eqv_refl @@ -155,39 +178,54 @@ lemma of_eq_of {a b : M} : (⟦a⟧ : QuotEq L M) = ⟦b⟧ ↔ eqv L a b := Quo namespace QuotEq def func ⦃k⦄ (f : L.Func k) (v : Fin k → QuotEq L M) : QuotEq L M := - Quotient.liftVec (s := eqvSetoid L M) (⟦Structure.func f ·⟧) (fun _ _ hvw => of_eq_of.mpr (eqv_funcExt f hvw)) v + Quotient.liftVec (s := eqvSetoid L M) (⟦Structure.func f ·⟧) (fun _ _ hvw ↦ of_eq_of.mpr (eqv_funcExt f hvw)) v def Rel ⦃k⦄ (r : L.Rel k) (v : Fin k → QuotEq L M) : Prop := - Quotient.liftVec (s := eqvSetoid L M) (Structure.rel r) (fun _ _ hvw =>eq_iff_iff.mpr <| eqv_relExt r hvw) v + Quotient.liftVec (s := eqvSetoid L M) (Structure.rel r) (fun _ _ hvw ↦ eq_iff_iff.mpr <| eqv_relExt r hvw) v instance struc : Structure L (QuotEq L M) where func := QuotEq.func rel := QuotEq.Rel -lemma funk_mk {k} (f : L.Func k) (v : Fin k → M) : Structure.func (M := QuotEq L M) f (Quotient.mk _ ∘ v) = ⟦Structure.func f v⟧ := +lemma funk_mk {k} (f : L.Func k) (v : Fin k → M) : Structure.func (M := QuotEq L M) f (⟦v ·⟧) = ⟦Structure.func f v⟧ := Quotient.liftVec_mk (s := eqvSetoid L M) _ _ _ -lemma rel_mk {k} (r : L.Rel k) (v : Fin k → M) : Structure.rel (M := QuotEq L M) r (Quotient.mk _ ∘ v) ↔ Structure.rel r v := +lemma rel_mk {k} (r : L.Rel k) (v : Fin k → M) : Structure.rel (M := QuotEq L M) r (⟦v ·⟧) ↔ Structure.rel r v := of_eq <| Quotient.liftVec_mk (s := eqvSetoid L M) _ _ _ -lemma val_mk (e : Fin n → M) (ε : ξ → M) (t : Semiterm L ξ n) : - t.val (M := QuotEq L M) (Quotient.mk _ ∘ e) (Quotient.mk _ ∘ ε) = ⟦t.val e ε⟧ := by - match t with - | #x | &x => simp - | .func F v => - simp [←funk_mk, Function.comp_def (g := v), fun i ↦ val_mk e ε (v i)]; rfl - -lemma eval_mk {e} {ε} {φ : Semiformula L ξ n} : - φ.Eval (M := QuotEq L M) (Quotient.mk _ ∘ e) (Quotient.mk _ ∘ ε) ↔ φ.Eval e ε := by - match φ with - | .rel R v | .nrel R v => simp [←val_mk, ←rel_mk, Function.comp_def] - | ⊤ | ⊥ => simp - | φ ⋏ ψ | φ ⋎ ψ => simp [←eval_mk (φ := φ), ←eval_mk (φ := ψ)] - | ∀⁰ φ => simpa [←eval_mk (φ := φ), Matrix.comp_vecCons'', ] using Quotient.forall - | ∃⁰ φ => simpa [←eval_mk (φ := φ), Matrix.comp_vecCons'', ] using Quotient.exists +lemma val_mk {bv fv} (t : Semiterm L ξ n) : + t.val (M := QuotEq L M) (⟦bv ·⟧) (⟦fv ·⟧) = ⟦t.val bv fv⟧ := by + induction t <;> simp [*, funk_mk, Function.comp_def] + +lemma eval_mk {bv fv} {φ : Semiformula L ξ n} : + φ.Eval (M := QuotEq L M) (⟦bv ·⟧) (⟦fv ·⟧) ↔ φ.Eval bv fv := by + induction φ using Semiformula.rec' + case hall n φ ih => + constructor + · intro h a; exact (ih (bv := a :> bv)).mp (by simpa [Matrix.comp_vecCons] using h ⟦a⟧) + · intro h a; + induction' a using Quotient.ind with a + simpa [Matrix.comp_vecCons] using ih.mpr (h a) + case hexs n φ ih => + constructor + · intro ⟨a, h⟩ + induction' a using Quotient.ind with a + exact ⟨a, (ih (bv := a :> bv)).mp (by simpa [Matrix.comp_vecCons] using h)⟩ + · intro ⟨a, h⟩; exact ⟨⟦a⟧, by simpa [Matrix.comp_vecCons] using ih.mpr h⟩ + case _ => simp [*] + case _ => simp [*] + case _ => simp [*, val_mk, rel_mk, Function.comp_def] + case _ => simp [*, val_mk, rel_mk, Function.comp_def] + case _ => simp [*] + case _ => simp [*] + +lemma evalf_mk {fv} {φ : Formula L ξ} : + φ.Evalf (M := QuotEq L M) (⟦fv ·⟧) ↔ φ.Evalf fv := by + simpa [Matrix.empty_eq] using eval_mk (bv := ![]) (fv := fv) (φ := φ) lemma models_iff {σ : Sentence L} : (QuotEq L M)↓[L] ⊧ σ ↔ M↓[L] ⊧ σ := by - simpa [Empty.eq_elim] using eval_mk (M := M) (e := ![]) (ε := Empty.elim) (φ := σ) + simpa [Empty.eq_elim, Matrix.empty_eq] using + eval_mk (M := M) (ξ := Empty) (φ := σ) (bv := ![]) (fv := Empty.elim) variable (L M) @@ -196,12 +234,12 @@ lemma elementaryEquiv : QuotEq L M ≡ₑ[L] M := ⟨models_iff⟩ variable {L M} set_option backward.isDefEq.respectTransparency false in -lemma rel_eq (a b : QuotEq L M) : op(=)[L].val ![a, b] ↔ a = b := by +lemma rel_eq (a b : QuotEq L M) : (@Semiformula.Operator.Eq.eq L _).val (M := QuotEq L M) ![a, b] ↔ a = b := by induction' a using Quotient.ind with a induction' b using Quotient.ind with b - rw [of_eq_of] - simpa [eqv, Semiformula.Operator.val, Empty.eq_elim] using - eval_mk (H := H) (e := ![a, b]) (ε := Empty.elim) (φ := Semiformula.Operator.Eq.eq.sentence) + rw [of_eq_of]; simp [eqv, Semiformula.Operator.val]; + simpa [Matrix.fun_eq_vec_two, Empty.eq_elim] using + eval_mk (H := H) (bv := ![a, b]) (fv := Empty.elim) (φ := Semiformula.Operator.Eq.eq.sentence) instance structureEq : Structure.Eq L (QuotEq L M) := ⟨rel_eq⟩ @@ -211,41 +249,41 @@ end Eq end Structure -lemma consequence_iff_eq {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] {σ : Sentence L} : - ↑↑𝔖 ⊨[Struc.{v, u} L] σ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [Structure.Eq L M], M↓[L] ⊧* ↑↑𝔖 → M↓[L] ⊧ σ) := by +lemma consequence_iff_eq {T : Theory L} [𝗘𝗤 L ⪯ T] {σ : Sentence L} : + T ⊨[Struc.{v, u} L] σ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [Structure.Eq L M], M↓[L] ⊧* T → M↓[L] ⊧ σ) := by simp only [consequence_iff, Nonempty.forall] constructor · intro h M x s _ hM; exact h M x hM · intro h M x s hM - have : Nonempty M := ⟨x⟩ - have H : M↓[L] ⊧* ↑↑(𝗘𝗤 L) := models_of_subtheory hM + haveI : Nonempty M := ⟨x⟩ + have H : M↓[L] ⊧* 𝗘𝗤 L := models_of_subtheory hM have e : Structure.Eq.QuotEq L M ≡ₑ[L] M := Structure.Eq.QuotEq.elementaryEquiv L M - exact e.models.mp <| h (Structure.Eq.QuotEq L M) ⟦x⟧ (e.modelsTheory.mpr hM) + exact e.models.mp $ h (Structure.Eq.QuotEq L M) ⟦x⟧ (e.modelsTheory.mpr hM) -lemma consequence_iff_eq' {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] {σ : Sentence L} : - ↑↑𝔖 ⊨[Struc.{v, u} L] σ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [Structure.Eq L M] [M↓[L] ⊧* ↑↑𝔖], M↓[L] ⊧ σ) := by +lemma consequence_iff_eq' {T : Theory L} [𝗘𝗤 L ⪯ T] {σ : Sentence L} : + T ⊨[Struc.{v, u} L] σ ↔ (∀ (M : Type v) [Nonempty M] [Structure L M] [Structure.Eq L M] [M↓[L] ⊧* T], M↓[L] ⊧ σ) := by rw [consequence_iff_eq] -lemma satisfiable_iff_eq {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] : - Semantics.Satisfiable (Struc.{v, u} L) ↑↑𝔖 ↔ (∃ (M : Type v) (_ : Nonempty M) (_ : Structure L M) (_ : Structure.Eq L M), M↓[L] ⊧* ↑↑𝔖) := by +lemma satisfiable_iff_eq {T : Theory L} [𝗘𝗤 L ⪯ T] : + Semantics.Satisfiable (Struc.{v, u} L) T ↔ (∃ (M : Type v) (_ : Nonempty M) (_ : Structure L M) (_ : Structure.Eq L M), M↓[L] ⊧* T) := by simp only [satisfiable_iff, Nonempty.exists, exists_prop] constructor · intro ⟨M, x, s, hM⟩; - have : Nonempty M := ⟨x⟩ - have H : M↓[L] ⊧* ↑↑(𝗘𝗤 L) := models_of_subtheory hM + haveI : Nonempty M := ⟨x⟩ + have H : M↓[L] ⊧* 𝗘𝗤 L := models_of_subtheory hM have e : Structure.Eq.QuotEq L M ≡ₑ[L] M := Structure.Eq.QuotEq.elementaryEquiv L M exact ⟨Structure.Eq.QuotEq L M, ⟦x⟧, inferInstance, inferInstance, e.modelsTheory.mpr hM⟩ · intro ⟨M, i, s, _, hM⟩; exact ⟨M, i, s, hM⟩ -instance {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] (sat : Semantics.Satisfiable (Struc.{v, u} L) ↑↑𝔖) : - (ModelOfSat sat)↓[L] ⊧* ↑↑(𝗘𝗤 L) := models_of_subtheory (ModelOfSat.models sat) +instance {T : Theory L} [𝗘𝗤 L ⪯ T] (sat : Semantics.Satisfiable (Struc.{v, u} L) T) : + (ModelOfSat sat)↓[L] ⊧* 𝗘𝗤 L := models_of_subtheory (ModelOfSat.models sat) -def ModelOfSatEq {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] (sat : Semantics.Satisfiable (Struc.{v, u} L) ↑↑𝔖) : Type _ := +def ModelOfSatEq {T : Theory L} [𝗘𝗤 L ⪯ T] (sat : Semantics.Satisfiable (Struc.{v, u} L) T) : Type _ := Structure.Eq.QuotEq L (ModelOfSat sat) namespace ModelOfSatEq -variable {𝔖 : Schema L} [𝗘𝗤 L ⪯ 𝔖] (sat : Semantics.Satisfiable (Struc.{v, u} L) ↑↑𝔖) +variable {T : Theory L} [𝗘𝗤 L ⪯ T] (sat : Semantics.Satisfiable (Struc.{v, u} L) T) noncomputable instance : Nonempty (ModelOfSatEq sat) := Structure.Eq.QuotEq.inhabited @@ -253,11 +291,11 @@ noncomputable instance struc : Structure L (ModelOfSatEq sat) := Structure.Eq.Qu noncomputable instance : Structure.Eq L (ModelOfSatEq sat) := Structure.Eq.QuotEq.structureEq -lemma models : (ModelOfSatEq sat)↓[L] ⊧* ↑↑𝔖 := +lemma models : (ModelOfSatEq sat)↓[L] ⊧* T := have e : ModelOfSatEq sat ≡ₑ[L] ModelOfSat sat := Structure.Eq.QuotEq.elementaryEquiv L (ModelOfSat sat) e.modelsTheory.mpr (ModelOfSat.models _) -instance mod : (ModelOfSatEq sat)↓[L] ⊧* ↑↑𝔖 := models sat +instance mod : (ModelOfSatEq sat)↓[L] ⊧* T := models sat open Semiterm Semiformula @@ -272,22 +310,22 @@ instance [Operator.One L] : Structure.One L (ModelOfSatEq sat) := ⟨rfl⟩ noncomputable instance [Operator.Add L] : Add (ModelOfSatEq sat) := ⟨fun x y => (@Operator.Add.add L _).val ![x, y]⟩ -instance [Operator.Add L] : Structure.Add L (ModelOfSatEq sat) := ⟨fun _ _ ↦ rfl⟩ +instance [Operator.Add L] : Structure.Add L (ModelOfSatEq sat) := ⟨fun _ _ => rfl⟩ noncomputable instance [Operator.Mul L] : Mul (ModelOfSatEq sat) := ⟨fun x y => (@Operator.Mul.mul L _).val ![x, y]⟩ -instance [Operator.Mul L] : Structure.Mul L (ModelOfSatEq sat) := ⟨fun _ _ ↦ rfl⟩ +instance [Operator.Mul L] : Structure.Mul L (ModelOfSatEq sat) := ⟨fun _ _ => rfl⟩ instance [Operator.LT L] : LT (ModelOfSatEq sat) := ⟨fun x y => (@Operator.LT.lt L _).val ![x, y]⟩ -instance [Operator.LT L] : Structure.LT L (ModelOfSatEq sat) := ⟨fun _ _ ↦ iff_of_eq rfl⟩ +instance [Operator.LT L] : Structure.LT L (ModelOfSatEq sat) := ⟨fun _ _ => iff_of_eq rfl⟩ instance [Operator.Mem L] : Membership (ModelOfSatEq sat) (ModelOfSatEq sat) := ⟨fun x y => (@Operator.Mem.mem L _).val ![y, x]⟩ -instance [Operator.Mem L] : Structure.Mem L (ModelOfSatEq sat) := ⟨fun _ _ ↦ iff_of_eq rfl⟩ +instance [Operator.Mem L] : Structure.Mem L (ModelOfSatEq sat) := ⟨fun _ _ => iff_of_eq rfl⟩ end ModelOfSatEq @@ -301,7 +339,7 @@ prefix:64 "∃⁰! " => existsUnique variable {M : Type*} [s : Structure L M] [Structure.Eq L M] @[simp] lemma eval_existsUnique {e ε} {φ : Semiformula L ξ (n + 1)} : - Eval e ε (∃⁰! φ) ↔ ∃! x : M, Eval (x :> e) ε φ := by + Eval (M := M) e ε (∃⁰! φ) ↔ ∃! x, Eval (M := M) (x :> e) ε φ := by simp [existsUnique, Semiformula.eval_substs, Matrix.comp_vecCons'', ExistsUnique] simp [Function.comp_def] diff --git a/Foundation/FirstOrder/Basic/Soundness.lean b/Foundation/FirstOrder/Basic/Soundness.lean index 9efdc0941..dfc3db1cc 100644 --- a/Foundation/FirstOrder/Basic/Soundness.lean +++ b/Foundation/FirstOrder/Basic/Soundness.lean @@ -5,11 +5,8 @@ public import Foundation.FirstOrder.Basic.Calculus /-! # Soundness theorem for first-order classical logic -/ -namespace LO +namespace LO.FirstOrder -namespace FirstOrder - -section sound open Semiformula variable {L : Language} @@ -69,16 +66,17 @@ lemma sound {M : Type*} [s : Structure L M] [Nonempty M] (f : ℕ → M) {Γ : S end Derivation -theorem Provable.sound {M : Type*} [s : Structure L M] [Nonempty M] {φ : Proposition L} (f : ℕ → M) : +theorem LK.Proof.sound {M : Type*} [s : Structure L M] [Nonempty M] {φ : Proposition L} (f : ℕ → M) : 𝐋𝐊¹ ⊢ φ → φ.Evalf f := fun b ↦ by simpa using Derivation.sound f b.get -variable {T : Theory L} +variable {T U : Theory L} + +namespace Theory.Proof -theorem Theory.Proof.sound_proposition {M : Type*} [s : Structure L M] [Nonempty M] : +theorem sound_proposition {M : Type*} [s : Structure L M] [Nonempty M] : T ⊢ φ → M↓[L] ⊧* T → φ.Realize M := fun b H ↦ by - rcases Theory.Proof.provable_iff.mp b with ⟨Γ, hΓ, ⟨b⟩⟩ - have : Inhabited M := Classical.inhabited_of_nonempty inferInstance - let f : ℕ → M := fun _ ↦ default + rcases provable_iff.mp b with ⟨Γ, hΓ, ⟨b⟩⟩ + let f : ℕ → M := fun _ ↦ Nonempty.some inferInstance have : φ.Realize M ∨ ∃ ψ, ∼ψ ∈ Sequent.embed Γ ∧ ψ.Evalf f := by simpa using b.sound f rcases this with (h | ⟨ψ, hψ, h⟩) · assumption @@ -92,35 +90,43 @@ theorem Theory.Proof.sound_proposition {M : Type*} [s : Structure L M] [Nonempty simpa [models_iff] using H.models _ (hΓ _ hχ) contradiction -theorem Theory.Proof.sound {φ : Sentence L} : +/-- Soundness theorem for first-order logic. -/ +theorem sound {φ : Sentence L} : T ⊢ φ → T ⊨[Struc.{v, u} L] φ := fun b s hS ↦ by simpa [struc_models_iff_models (s := s), models_iff] - using Theory.Proof.sound_proposition b hS - -theorem Theory.Proof.sound_small : T ⊢ φ → T ⊨ φ := Theory.Proof.sound + using sound_proposition b hS -instance sound (T : Theory L) : Sound T (Semantics.models (Struc.{v, u} L) T) := ⟨Theory.Proof.sound⟩ +theorem sound_small : T ⊢ φ → T ⊨ φ := sound -lemma models_of_subtheory {T U : Theory L} [T ⪯ U] {M : Type*} [Structure L M] [Nonempty M] : M↓[L] ⊧* U → M↓[L] ⊧* T := - fun hM ↦ ⟨fun {φ} hφ ↦ by - have : T ⪯ U := inferInstance - have : U ⊢ φ := this.pbl (Entailment.by_axm hφ) - exact Theory.Proof.sound this hM⟩ +instance (T : Theory L) : Sound T (Semantics.models (Struc.{v, u} L) T) := ⟨Theory.Proof.sound⟩ lemma consistent_of_satisfiable (h : Semantics.Satisfiable (Struc.{v, u} L) T) : Entailment.Consistent T := Sound.consistent_of_satisfiable h -lemma consistent_of_model (T : Theory L) (M : Type*) [Structure L M] [Nonempty M] [hM : M↓[L] ⊧* T] : - Entailment.Consistent T := consistent_of_satisfiable ⟨M↓[L], hM⟩ +end Theory.Proof + +section model + +variable (T) (M : Type*) [Nonempty M] [Structure L M] -lemma unprovable_of_countermodel {M : Type*} [Structure L M] [Nonempty M] [hM : M↓[L] ⊧* T] {φ} : M↓[L] ⊭ φ → T ⊬ φ := by +lemma consistent_of_model [hM : M↓[L] ⊧* T] : + Entailment.Consistent T := Theory.Proof.consistent_of_satisfiable ⟨M↓[L], hM⟩ + +variable {M} + +lemma unprovable_of_countermodel [hM : M↓[L] ⊧* T] {φ} : M↓[L] ⊭ φ → T ⊬ φ := by contrapose!; intro h exact Theory.Proof.sound h hM -lemma models_of_provable {M : Type*} [Nonempty M] [Structure L M] (hT : M↓[L] ⊧* ↑↑T) {φ : Sentence L} (h : T ⊢ φ) : +variable {T} + +lemma models_of_provable (hT : M↓[L] ⊧* T) {φ : Sentence L} (h : T ⊢ φ) : M↓[L] ⊧ φ := consequence_iff.mp (Theory.Proof.sound h) M inferInstance -end sound +lemma models_of_subtheory [T ⪯ U] : M↓[L] ⊧* U → M↓[L] ⊧* T := + fun hM ↦ ⟨fun _ hφ ↦ Theory.Proof.sound (Entailment.WeakerThan.pbl (Entailment.by_axm hφ)) hM⟩ + +end model end FirstOrder From 49e6cab9168d6d6d989d981d0f8ba6552b5a1c26 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Thu, 7 May 2026 06:02:03 +0900 Subject: [PATCH 46/61] basic --- Foundation/FirstOrder/Basic.lean | 1 - Foundation/FirstOrder/Basic/Eq.lean | 18 +++++++++--------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/Foundation/FirstOrder/Basic.lean b/Foundation/FirstOrder/Basic.lean index 2b8fb7c17..f3d9b7952 100644 --- a/Foundation/FirstOrder/Basic.lean +++ b/Foundation/FirstOrder/Basic.lean @@ -2,7 +2,6 @@ module public import Foundation.FirstOrder.Basic.Syntax.Formula public import Foundation.FirstOrder.Basic.Syntax.Rew -public import Foundation.FirstOrder.Basic.Syntax.Schema public import Foundation.FirstOrder.Basic.Semantics.Semantics public import Foundation.FirstOrder.Basic.Semantics.Elementary public import Foundation.FirstOrder.Basic.Operator diff --git a/Foundation/FirstOrder/Basic/Eq.lean b/Foundation/FirstOrder/Basic/Eq.lean index db9c10550..cfcd6c90d 100644 --- a/Foundation/FirstOrder/Basic/Eq.lean +++ b/Foundation/FirstOrder/Basic/Eq.lean @@ -234,7 +234,7 @@ lemma elementaryEquiv : QuotEq L M ≡ₑ[L] M := ⟨models_iff⟩ variable {L M} set_option backward.isDefEq.respectTransparency false in -lemma rel_eq (a b : QuotEq L M) : (@Semiformula.Operator.Eq.eq L _).val (M := QuotEq L M) ![a, b] ↔ a = b := by +lemma rel_eq (a b : QuotEq L M) : op(=)[L].val (M := QuotEq L M) ![a, b] ↔ a = b := by induction' a using Quotient.ind with a induction' b using Quotient.ind with b rw [of_eq_of]; simp [eqv, Semiformula.Operator.val]; @@ -308,24 +308,24 @@ noncomputable instance [Operator.One L] : One (ModelOfSatEq sat) := ⟨(@Operato instance [Operator.One L] : Structure.One L (ModelOfSatEq sat) := ⟨rfl⟩ noncomputable instance [Operator.Add L] : Add (ModelOfSatEq sat) := - ⟨fun x y => (@Operator.Add.add L _).val ![x, y]⟩ + ⟨fun x y ↦ (@Operator.Add.add L _).val ![x, y]⟩ -instance [Operator.Add L] : Structure.Add L (ModelOfSatEq sat) := ⟨fun _ _ => rfl⟩ +instance [Operator.Add L] : Structure.Add L (ModelOfSatEq sat) := ⟨fun _ _ ↦ rfl⟩ noncomputable instance [Operator.Mul L] : Mul (ModelOfSatEq sat) := - ⟨fun x y => (@Operator.Mul.mul L _).val ![x, y]⟩ + ⟨fun x y ↦ (@Operator.Mul.mul L _).val ![x, y]⟩ -instance [Operator.Mul L] : Structure.Mul L (ModelOfSatEq sat) := ⟨fun _ _ => rfl⟩ +instance [Operator.Mul L] : Structure.Mul L (ModelOfSatEq sat) := ⟨fun _ _ ↦ rfl⟩ instance [Operator.LT L] : LT (ModelOfSatEq sat) := - ⟨fun x y => (@Operator.LT.lt L _).val ![x, y]⟩ + ⟨fun x y ↦ (@Operator.LT.lt L _).val ![x, y]⟩ -instance [Operator.LT L] : Structure.LT L (ModelOfSatEq sat) := ⟨fun _ _ => iff_of_eq rfl⟩ +instance [Operator.LT L] : Structure.LT L (ModelOfSatEq sat) := ⟨fun _ _ ↦ iff_of_eq rfl⟩ instance [Operator.Mem L] : Membership (ModelOfSatEq sat) (ModelOfSatEq sat) := - ⟨fun x y => (@Operator.Mem.mem L _).val ![y, x]⟩ + ⟨fun x y ↦ (@Operator.Mem.mem L _).val ![y, x]⟩ -instance [Operator.Mem L] : Structure.Mem L (ModelOfSatEq sat) := ⟨fun _ _ => iff_of_eq rfl⟩ +instance [Operator.Mem L] : Structure.Mem L (ModelOfSatEq sat) := ⟨fun _ _ ↦ iff_of_eq rfl⟩ end ModelOfSatEq From 9fcb1efb384364099d8cd014f96968087236462b Mon Sep 17 00:00:00 2001 From: palalansouki Date: Fri, 8 May 2026 23:24:14 +0900 Subject: [PATCH 47/61] sublanguage --- Foundation/FirstOrder/Basic/Calculus.lean | 6 +- .../FirstOrder/Basic/Semantics/Semantics.lean | 8 + .../FirstOrder/Basic/Syntax/Formula.lean | 6 + .../Completeness/BooleanValuedModel.lean | 252 ----------------- .../Completeness/CanonicalModel.lean | 2 +- .../Completeness/CountableSublanguage.lean | 266 ++++++++++++++++++ .../FirstOrder/Completeness/CounterModel.lean | 40 +-- Foundation/Logic/Semantics.lean | 10 +- 8 files changed, 302 insertions(+), 288 deletions(-) delete mode 100644 Foundation/FirstOrder/Completeness/BooleanValuedModel.lean create mode 100644 Foundation/FirstOrder/Completeness/CountableSublanguage.lean diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index 2f87d17f0..57485f8d1 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -343,10 +343,6 @@ lemma iff_context {T : Theory L} : T ⊢ φ ↔ T *⊢[pullback 𝐋𝐊¹[L] (Rewriting.emb : _ → Proposition L)] φ := OneSidedLK.ContextualEntailment.iff_context -end Theory.Proof - -namespace Theory - open Entailment Derivation lemma of_LK_provable {T : Theory L} {φ : Sentence L} : 𝐋𝐊¹ ⊢ (φ : Proposition L) → T ⊢ φ := fun h ↦ @@ -357,7 +353,7 @@ open Classical in noncomputable instance : Entailment.Deduction (Theory L) := OneSidedLK.ContextualEntailment.deduction (pullback 𝐋𝐊¹[L] (Rewriting.emb : Sentence L → Proposition L)) -end Theory +end Theory.Proof /-! ### Theory -/ diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index 849493b10..741b99d0f 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -616,6 +616,14 @@ end lMap end Semiformula +lemma lMap_models_lMap {L₁ L₂ : Language.{u}} {Φ : L₁ →ᵥ L₂} {T : Theory L₁} {σ : Sentence L₁} + (h : T ⊨[Struc.{v, u} L₁] σ) : + T.lMap Φ ⊨[Struc.{v, u} L₂] Semiformula.lMap Φ σ := by + intro s hM + have : (s.struc.lMap Φ).toStruc ⊧ σ := + h ⟨fun _ hq ↦ Semiformula.models_lMap.mp <| hM.models _ (Set.mem_image_of_mem _ hq)⟩ + exact Semiformula.models_lMap.mpr this + section theory variable (M) [Nonempty M] [Structure L M] diff --git a/Foundation/FirstOrder/Basic/Syntax/Formula.lean b/Foundation/FirstOrder/Basic/Syntax/Formula.lean index 086d3dede..fa61b5ed0 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Formula.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Formula.lean @@ -586,6 +586,12 @@ abbrev Theory (L : Language) := Set (Sentence L) abbrev ArithmeticTheory := Theory ℒₒᵣ +namespace Theory + +def lMap (Φ : L₁ →ᵥ L₂) (T : Theory L₁) : Theory L₂ := Semiformula.lMap Φ '' T + +end Theory + end LO.FirstOrder end diff --git a/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean b/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean deleted file mode 100644 index 0c6f2e260..000000000 --- a/Foundation/FirstOrder/Completeness/BooleanValuedModel.lean +++ /dev/null @@ -1,252 +0,0 @@ -module - -public import Foundation.Vorspiel.Order.LowerSet -public import Foundation.Vorspiel.Order.Ideal -public import Foundation.Vorspiel.Order.Heyting -public import Foundation.Vorspiel.Order.Lattice -public import Foundation.FirstOrder.Completeness.CanonicalModel -public import Mathlib.Order.PFilter -public import Mathlib.Order.PrimeSeparator - -@[expose] public section - -/-! -# Heyting and Boolean-valued model associated to the canonical model - -Main reference: Jeremy Avigad, Algebraic proofs of cut elimination [Avi01] - -/ - -namespace LO.FirstOrder.Derivation - -variable {L : Language} - -namespace Canonical - -open Classical - -variable (L) - -def ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴸᴷ¹ ∼Γ)} - -variable {L} - -local notation "ℙ" => Sequent L - -local notation "ℂ" => ConsistentSequent L - -namespace ConsistentSequent - -instance : Preorder ℂ where - le q p := q.val ≤ p.val - le_refl p := by simp - le_trans p q r := le_trans - -instance : Inhabited ℂ := ⟨⟨[], by simp⟩⟩ - -end ConsistentSequent - -/-! ## Heyting-valued model -/ - -namespace HeytingValuedModel - -scoped notation "ℍ" => LowerSet ℂ - -instance : Order.Frame ℍ := inferInstance - -instance : Nontrivial ℍ := ⟨⊥, ⊤, fun e ↦ by simpa using SetLike.ext_iff.mp e default⟩ - -/-- Heyting value of a proposition -/ -def hValue (φ : Propositionᵢ L) : ℍ where - carrier := { p | p.val ⊩ φ } - lower' := fun _ _ hqp hp ↦ IsForced.monotone hqp hp - -scoped prefix:max "♯" => hValue - -protected lemma ext {φ ψ : Propositionᵢ L} : (∀ p : ℂ, p.val ⊩ φ ↔ p.val ⊩ ψ) → ♯φ = ♯ψ := by - intro h; ext p; simp [hValue, h] - -@[simp] lemma mem_hValue {p : ℂ} {φ : Propositionᵢ L} : p ∈ ♯φ ↔ p.val ⊩ φ := by simp [hValue] - -@[simp] lemma falsum : ♯(⊥ : Propositionᵢ L) = ⊥ := by - ext p; simp [hValue, IsForced.falsum, p.prop] - -@[simp] lemma imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ 🡒 ψ) = (♯φ ⇨ ♯ψ) := by - ext p - suffices (∀ q ≤ p.val, q ⊩ φ → q ⊩ ψ) ↔ ∀ q ≤ p, q.val ⊩ φ → q.val ⊩ ψ by - simpa [IsForced.imply, LowerSet.mem_himp_iff] - constructor - · intro h q hqp hqφ - exact h q.val hqp hqφ - · intro h q hqp hqφ - by_cases! hq : IsEmpty (⊢ᴸᴷ¹ ∼q) - · exact h ⟨q, hq⟩ hqp hqφ - · exact IsForced.efq (p := q) (by simp [IsForced.falsum, hq]) ψ - -@[simp] lemma and_eq_inf {φ ψ : Propositionᵢ L} : ♯(φ ⋏ ψ) = (♯φ ⊓ ♯ψ) := by - ext p; simp [hValue] - -@[simp] lemma or_eq_sup {φ ψ : Propositionᵢ L} : ♯(φ ⋎ ψ) = (♯φ ⊔ ♯ψ) := by - ext p; simp [hValue] - -@[simp] lemma fal_eq_Inf {φ : Semipropositionᵢ L 1} : ♯(∀⁰ φ) = ⨅ t, ♯(φ/[t]) := by - ext p; simp [hValue,] - -@[simp] lemma exs_eq_Sup {φ : Semipropositionᵢ L 1} : ♯(∃⁰ φ) = ⨆ t, ♯(φ/[t]) := by - ext p; simp [hValue,] - -@[simp] lemma neg_eq_himp_bot (φ : Propositionᵢ L) : ♯(∼φ) = (♯φ)ᶜ := by - simp [Semiformulaᵢ.neg_def] - -set_option backward.isDefEq.respectTransparency false in -/-- Completeness of the Heyting-valued model `ℍ` -/ -lemma complete {φ : Proposition L} : ♯φᴺ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc - ♯φᴺ = ⊤ ↔ ⊤ ≤ ♯φᴺ := by simp only [top_le_iff] - _ ↔ (∀ p : ℂ, p.val ⊩ φᴺ) := by simp [SetLike.le_def] - _ ↔ ℙ ∀⊩ φᴺ := by - constructor - · intro h p - by_cases! hp : IsEmpty (⊢ᴸᴷ¹ ∼p) - · exact h ⟨p, hp⟩ - · exact IsForced.efq (p := p) (by simp [IsForced.falsum, hp]) φᴺ - · intro h p; exact h p.val - _ ↔ 𝐋𝐊¹ ⊢ φ := IsForced.complete - -lemma cocomplete {φ : Proposition L} : ♯φᴺ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by - simp [Entailment.Unprovable, ←complete, lt_top_iff_ne_top] - -lemma hValue_dn_neg (φ : Proposition L) : ♯(∼φ)ᴺ = (♯φᴺ)ᶜ := calc - ♯(∼φ)ᴺ = ♯(∼φᴺ) := HeytingValuedModel.ext <| by simp [←IsForced.dn_neg_iff] - _ = (♯φᴺ)ᶜ := by simp - -@[simp] lemma dn_isRegular (φ : Proposition L) : Heyting.IsRegular ♯φᴺ := by - have : ♯φᴺ = (♯(∼φ)ᴺ)ᶜ := by simp [←hValue_dn_neg] - simpa [this] using Heyting.isRegular_compl ♯(∼φ)ᴺ - -end HeytingValuedModel - -/-! ## Boolean-valued model -/ - -namespace BooleanValuedModel - -open HeytingValuedModel - -scoped notation "𝔹" => Heyting.Regular ℍ - -instance : CompleteBooleanAlgebra 𝔹 := inferInstance - -instance : Nontrivial 𝔹 := - ⟨⊥, ⊤, fun e ↦ by simpa using Heyting.Regular.coe_inj.mpr e⟩ - -/-- Boolean value of a proposition -/ -def bValue (φ : Proposition L) : 𝔹 := ⟨♯φᴺ, by simp⟩ - -scoped prefix:max "♭" => bValue - -@[simp] lemma coe_bValue (φ : Proposition L) : (♭φ : ℍ) = ♯φᴺ := rfl - -@[simp] lemma falsum : ♭(⊥ : Proposition L) = ⊥ := Heyting.Regular.coe_inj.mp <| by simp - -@[simp] lemma verum : ♭(⊤ : Proposition L) = ⊤ := Heyting.Regular.coe_inj.mp <| by simp - -@[simp] lemma and_eq_inf : ♭(φ ⋏ ψ) = ♭φ ⊓ ♭ψ := Heyting.Regular.coe_inj.mp <| by simp - -@[simp] lemma lConj_eq_inf (Γ : List (Proposition L)) : ♭(⋀Γ) = Γ.toFinset.inf bValue := - match Γ with - | [] => by simp - | [φ] => by simp - | φ :: ψ :: Γ => by - simp [lConj_eq_inf (ψ :: Γ),]; rfl - -@[simp] lemma or_eq_sup : ♭(φ ⋎ ψ) = ♭φ ⊔ ♭ψ := Heyting.Regular.coe_inj.mp <| by simp - -@[simp] lemma fal_eq_Inf : ♭(∀⁰ φ) = ⨅ t, ♭(φ/[t]) := Heyting.Regular.coe_inj.mp <| by - simp [Semiformula.subst_doubleNegation] - -@[simp] lemma exs_eq_Sup : ♭(∃⁰ φ) = ⨆ t, ♭(φ/[t]) := Heyting.Regular.coe_inj.mp <| by - simp [Semiformula.subst_doubleNegation, compl_iSup'] - -@[simp] lemma neg_eq_compl (φ : Proposition L) : ♭(∼φ) = (♭φ)ᶜ := Heyting.Regular.coe_inj.mp <| by - simp [hValue_dn_neg] - -@[simp] lemma imply_eq_himp (φ ψ : Proposition L) : ♭(φ 🡒 ψ) = (♭φ ⇨ ♭ψ) := by - simp [Semiformula.imp_eq, BooleanAlgebra.himp_eq]; grind - -/-- Completeness of the Boolean-valued model `𝔹` -/ -lemma complete : ♭φ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc - ♭φ = ⊤ ↔ ♯φᴺ = ⊤ := by rw [←Heyting.Regular.coe_inj]; simp - _ ↔ 𝐋𝐊¹ ⊢ φ := HeytingValuedModel.complete - -lemma cocomplete : ♭φ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by - simp [Entailment.Unprovable, ←complete, lt_top_iff_ne_top] - -open Order OrderDual - -/-- Filter induced by a schema `𝔖` -/ -def _root_.LO.FirstOrder.Schema.filter (𝔖 : Schema L) : Order.PFilter 𝔹 := - ⟨⨆ φ : 𝔖, Ideal.principal (toDual ♭φ)⟩ - -open Classical - -variable {𝔖 : Schema L} - -lemma mem_filter_iff : - x ∈ 𝔖.filter ↔ ∃ Γ : Finset (Proposition L), ↑Γ ⊆ 𝔖 ∧ Γ.inf bValue ≤ x := calc - x ∈ 𝔖.filter ↔ toDual x ∈ ⨆ φ : 𝔖, Ideal.principal (P := 𝔹ᵒᵈ) (toDual ♭φ) := Order.PFilter.mem_mk _ _ - _ ↔ ∃ Γ : Finset 𝔖, toDual x ∈ Γ.sup (Ideal.principal ∘ toDual ∘ bValue ∘ Subtype.val) := by rw [Ideal.mem_iSup_iff]; rfl - _ ↔ ∃ Γ : Finset 𝔖, toDual x ≤ Γ.sup (toDual ∘ bValue ∘ Subtype.val) := by simp [Ideal.mem_finsup_principal] - _ ↔ ∃ Γ : Finset 𝔖, Γ.inf (bValue ∘ Subtype.val) ≤ x := exists_congr fun Γ ↦ by simp [OrderDual.toDual_le, Function.comp_def] - _ ↔ ∃ Γ : Finset (Proposition L), ↑Γ ⊆ 𝔖 ∧ Γ.inf bValue ≤ x := by - constructor - · rintro ⟨Γ, hΓ⟩ - exact ⟨Γ.map (Function.Embedding.subtype _), fun x ↦ by simp; tauto, by simpa [Function.comp_def]⟩ - · rintro ⟨Γ, hΓ⟩ - refine ⟨Γ.subtype _, ?_⟩ - rw [Finset.subtype_inf_val_of] - · exact hΓ.2 - · intro i hi; exact hΓ.1 hi - -/-- Completeness of a filter induced by a schema `𝔖` -/ -lemma filter_complete : - ♭φ ∈ 𝔖.filter ↔ 𝔖 ⊢ φ := calc - ♭φ ∈ 𝔖.filter ↔ ∃ Γ : Finset (Proposition L), ↑Γ ⊆ 𝔖 ∧ Γ.inf bValue ≤ ♭φ := mem_filter_iff - _ ↔ ∃ Γ : List (Proposition L), ↑Γ.toFinset ⊆ 𝔖 ∧ Γ.toFinset.inf bValue ≤ ♭φ := by - constructor - · rintro ⟨Γ, hΓ⟩ - exact ⟨Γ.toList, by simpa using hΓ⟩ - · rintro ⟨Γ, hΓ⟩ - exact ⟨Γ.toFinset, by simpa using hΓ⟩ - _ ↔ ∃ Γ : List (Proposition L), ↑Γ.toFinset ⊆ 𝔖 ∧ 𝐋𝐊¹ ⊢ ⋀Γ 🡒 φ := by simp [←complete] - _ ↔ 𝔖 *⊢[𝐋𝐊¹] φ := by - constructor - · rintro ⟨Γ, hΓ, ⟨b⟩⟩ - exact ⟨Γ, fun ψ hψ ↦ hΓ (by simpa using hψ), b⟩ - · intro ⟨b⟩ - exact ⟨b.ctx, fun ψ ↦ by simpa using b.subset ψ, ⟨b.prf⟩⟩ - _ ↔ 𝔖 ⊢ φ := Schema.iff_context.symm - -lemma bot_not_mem_iff_consistent : ⊥ ∉ 𝔖.filter ↔ Entailment.Consistent 𝔖 := by - simpa [←Entailment.inconsistent_iff_provable_bot] using Iff.not <| filter_complete (φ := ⊥) (𝔖 := 𝔖) - -lemma primeIdeal_exists (𝔖 : Schema L) (con : Entailment.Consistent 𝔖) : - ∃ J : Order.Ideal 𝔹, J.IsPrime ∧ Disjoint (𝔖.filter : Set 𝔹) J := by - have : Disjoint (𝔖.filter : Set 𝔹) (⊥ : Ideal 𝔹) := Set.disjoint_iff.mpr <| by - intro x - have := bot_not_mem_iff_consistent.mpr con - simp; grind - simpa using DistribLattice.prime_ideal_of_disjoint_filter_ideal this - -noncomputable def primeIdealOf (𝔖 : Schema L) (con : Entailment.Consistent 𝔖) : Ideal 𝔹 := - Classical.choose <| primeIdeal_exists 𝔖 con - -lemma primeIdealOf_isPrime (𝔖 : Schema L) (con : Entailment.Consistent 𝔖) : (primeIdealOf 𝔖 con).IsPrime := - Classical.choose_spec (primeIdeal_exists 𝔖 con) |>.1 - -lemma primeIdealOf_disjoint (𝔖 : Schema L) (con : Entailment.Consistent 𝔖) : - Disjoint (𝔖.filter : Set 𝔹) (primeIdealOf 𝔖 con) := - Classical.choose_spec (primeIdeal_exists 𝔖 con) |>.2 - -end BooleanValuedModel - -end Canonical - -end LO.FirstOrder.Derivation diff --git a/Foundation/FirstOrder/Completeness/CanonicalModel.lean b/Foundation/FirstOrder/Completeness/CanonicalModel.lean index 0b201d889..0ad895bda 100644 --- a/Foundation/FirstOrder/Completeness/CanonicalModel.lean +++ b/Foundation/FirstOrder/Completeness/CanonicalModel.lean @@ -373,7 +373,7 @@ instance : OrderTop ℙ⁻ where rintro ⟨Γ, hΓ⟩ exact ⟨StrongerThan.ofSubset <| List.nil_subset Γ⟩ -def ofUnprovable (φ : Proposition L) (h : 𝐋𝐊¹ ⊬ ∼φ) : ℙ⁻ := ⟨[φ], by simpa [LK.unprovable_def] using h⟩ +def ofUnprovable (φ : Proposition L) (h : 𝐋𝐊¹ ⊬ ∼φ) : ℙ⁻ := ⟨[φ], by simpa [LK.Proof.unprovable_def] using h⟩ end ConsistentSequent diff --git a/Foundation/FirstOrder/Completeness/CountableSublanguage.lean b/Foundation/FirstOrder/Completeness/CountableSublanguage.lean new file mode 100644 index 000000000..23b6ace99 --- /dev/null +++ b/Foundation/FirstOrder/Completeness/CountableSublanguage.lean @@ -0,0 +1,266 @@ +module + +public import Foundation.FirstOrder.Basic + +@[expose] public section +namespace LO + +namespace FirstOrder + +variable {L : Language.{u}} + +/-! ### Finite sublanguage -/ + +namespace Language + +def sublanguage (L : Language) (pFunc : ∀ k, L.Func k → Prop) (pRel : ∀ k, L.Rel k → Prop) : + Language where + Func k := Subtype (pFunc k) + Rel k := Subtype (pRel k) + +section sublanguage + +variable (L) + +variable {pf : (k : ℕ) → L.Func k → Prop} {pr : (k : ℕ) → L.Rel k → Prop} + +def ofSublanguage : sublanguage L pf pr →ᵥ L where + func := Subtype.val + rel := Subtype.val + +@[simp] lemma ofSublanguage_onFunc : + L.ofSublanguage.func φ = φ.val := rfl + +@[simp] lemma ofSublanguage_onRel : + L.ofSublanguage.rel φ = φ.val := rfl + +end sublanguage + +end Language + +namespace Semiterm + +open Language +variable [∀ k, DecidableEq (L.Func k)] + +def symbols : Semiterm L ξ n → Finset (Σ k, L.Func k) + | #_ => ∅ + | &_ => ∅ + | func f v => insert ⟨_, f⟩ (Finset.biUnion Finset.univ (fun i ↦ symbols (v i))) + +@[simp] lemma lang_func {k} (f : L.Func k) (v : Fin k → Semiterm L ξ n) : + ⟨k, f⟩ ∈ (func f v).symbols := by simp [symbols] + +lemma lang_func_ss {k} (f : L.Func k) (v : Fin k → Semiterm L ξ n) (i) : + (v i).symbols ⊆ (func f v).symbols := by + intros x; simp [symbols]; grind + +def toSublanguage' (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) : ∀ t : Semiterm L ξ n, + (∀ k f, ⟨k, f⟩ ∈ t.symbols → pf k f) → Semiterm (sublanguage L pf pr) ξ n + | #x, _ => #x + | &x, _ => &x + | func (arity := k) f v, h => func ⟨f, h k f (by simp)⟩ + (fun i ↦ toSublanguage' pf pr (v i) (fun k' f' h' => h k' f' (lang_func_ss f v i h'))) + +@[simp] lemma lMap_toSubLanguage' (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) + (t : Semiterm L ξ n) (h : ∀ k f, ⟨k, f⟩ ∈ t.symbols → pf k f) : + (t.toSublanguage' pf pr h).lMap L.ofSublanguage = t := by + induction t <;> simp [*, toSublanguage', Function.comp_def] + +end Semiterm + +namespace Semiformula + +variable [L.DecidableEq] + +noncomputable def functionSymbols {n} : Semiformula L ξ n → Finset (Σ k, L.Func k) + | rel _ v => Finset.biUnion Finset.univ fun i ↦ (v i).symbols + | nrel _ v => Finset.biUnion Finset.univ fun i ↦ (v i).symbols + | ⊤ => ∅ + | ⊥ => ∅ + | φ ⋏ ψ => functionSymbols φ ∪ functionSymbols ψ + | φ ⋎ ψ => functionSymbols φ ∪ functionSymbols ψ + | ∀⁰ φ => functionSymbols φ + | ∃⁰ φ => functionSymbols φ + +noncomputable def relationSymbols {n} : Semiformula L ξ n → Finset (Σ k, L.Rel k) + | rel r _ => {⟨_, r⟩} + | nrel r _ => {⟨_, r⟩} + | ⊤ => ∅ + | ⊥ => ∅ + | φ ⋏ ψ => relationSymbols φ ∪ relationSymbols ψ + | φ ⋎ ψ => relationSymbols φ ∪ relationSymbols ψ + | ∀⁰ φ => relationSymbols φ + | ∃⁰ φ => relationSymbols φ + +lemma functionSymbols_rel_ss {k} (r : L.Rel k) (v : Fin k → Semiterm L ξ n) (i) : + (v i).symbols ⊆ (rel r v).functionSymbols := by + intros x + simp only [functionSymbols, Finset.mem_biUnion, Finset.mem_univ, true_and] + intros h; exact ⟨i, h⟩ + +def toSublanguage' (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) {n} : + (φ : Semiformula L ξ n) → + (∀ k f, ⟨k, f⟩ ∈ φ.functionSymbols → pf k f) → + (∀ k r, ⟨k, r⟩ ∈ φ.relationSymbols → pr k r) → + Semiformula (L.sublanguage pf pr) ξ n + | rel r v, hf, hr => + rel ⟨r, hr _ r (by simp [relationSymbols])⟩ + fun i ↦ (v i).toSublanguage' pf pr fun k f h ↦ hf k f (functionSymbols_rel_ss r v i h) + | nrel r v, hf, hr => + nrel ⟨r, hr _ r (by simp [relationSymbols])⟩ + fun i ↦ (v i).toSublanguage' pf pr fun k f h ↦ hf k f (functionSymbols_rel_ss r v i h) + | ⊤, _, _ => ⊤ + | ⊥, _, _ => ⊥ + | φ ⋏ ψ, hf, hr => + toSublanguage' pf pr φ (fun k f h ↦ hf k f (Finset.mem_union_left _ h)) (fun k r h ↦ hr k r (Finset.mem_union_left _ h)) ⋏ + toSublanguage' pf pr ψ (fun k f h ↦ hf k f (Finset.mem_union_right _ h)) (fun k r h ↦ hr k r (Finset.mem_union_right _ h)) + | φ ⋎ ψ, hf, hr => + toSublanguage' pf pr φ (fun k f h ↦ hf k f (Finset.mem_union_left _ h)) (fun k r h ↦ hr k r (Finset.mem_union_left _ h)) ⋎ + toSublanguage' pf pr ψ (fun k f h ↦ hf k f (Finset.mem_union_right _ h)) (fun k r h ↦ hr k r (Finset.mem_union_right _ h)) + | ∀⁰ φ, hf, hr => ∀⁰ toSublanguage' pf pr φ hf hr + | ∃⁰ φ, hf, hr => ∃⁰ toSublanguage' pf pr φ hf hr + +@[simp] lemma lMap_toSubLanguage' + (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) {n} (φ : Semiformula L ξ n) + (hf : ∀ k f, ⟨k, f⟩ ∈ φ.functionSymbols → pf k f) (hr : ∀ k r, ⟨k, r⟩ ∈ φ.relationSymbols → pr k r) : + lMap L.ofSublanguage (φ.toSublanguage' pf pr hf hr) = φ := by + induction φ using rec' <;> simp [*, toSublanguage', lMap_rel, lMap_nrel, Function.comp_def] + +noncomputable def languageFuncIndexed (φ : Semiformula L ξ n) (k) : Finset (L.Func k) := + Finset.preimage (functionSymbols φ) (Sigma.mk k) (Set.injOn_of_injective sigma_mk_injective) + +noncomputable def languageRelIndexed (φ : Semiformula L ξ n) (k) : Finset (L.Rel k) := + Finset.preimage (relationSymbols φ) (Sigma.mk k) (Set.injOn_of_injective sigma_mk_injective) + +/-- A language consists of the function and relation symbols appearing in a given finite set of formulas. -/ +abbrev languageFinset (Γ : Finset (Semiformula L ξ n)) : Language := + Language.sublanguage L (fun k f ↦ ∃ φ ∈ Γ, ⟨k, f⟩ ∈ functionSymbols φ) (fun k r ↦ ∃ φ ∈ Γ, ⟨k, r⟩ ∈ relationSymbols φ) + +noncomputable instance (Γ : Finset (Semiformula L ξ n)) (k) : Fintype ((languageFinset Γ).Func k) := + Fintype.subtype (Γ.biUnion (languageFuncIndexed · k)) (by simp [languageFuncIndexed]) + +noncomputable instance (Γ : Finset (Semiformula L ξ n)) (k) : Fintype ((languageFinset Γ).Rel k) := + Fintype.subtype (Γ.biUnion (languageRelIndexed · k)) (by simp [languageRelIndexed]) + +def toSubLanguageFinsetSelf {Γ : Finset (Semiformula L ξ n)} {φ} (h : φ ∈ Γ) : Semiformula (languageFinset Γ) ξ n := + φ.toSublanguage' _ _ (fun _ _ hf ↦ ⟨φ, h, hf⟩) (fun _ _ hr ↦ ⟨φ, h, hr⟩) + +@[simp] lemma lMap_toSubLanguageFinsetSelf {Γ : Finset (Semiformula L ξ n)} {φ} (h : φ ∈ Γ) : + lMap L.ofSublanguage (toSubLanguageFinsetSelf h) = φ := + lMap_toSubLanguage' _ _ _ _ _ + +end Semiformula + +/-! ### Structure induced by an injective language homomorphism -/ + +namespace Language + +class Hom.Injective (Φ : L₁ →ᵥ L₂) : Prop where + func : ∀ k, Function.Injective (Φ.func : L₁.Func k → L₂.Func k) + rel : ∀ k, Function.Injective (Φ.rel : L₁.Rel k → L₂.Rel k) + +instance ofSublanguage_injective (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) : + (L.ofSublanguage : L.sublanguage pf pr →ᵥ L).Injective := + ⟨fun _ ↦ Subtype.val_injective, fun _ ↦ Subtype.val_injective⟩ + +end Language + +namespace Structure + +/- +instance sublanguageStructure {pf : ∀ k, L.Func k → Prop} {pr : ∀ k, L.Rel k → Prop} + {M : Type w} (s : Structure L M) : Structure (Language.sublanguage L pf pr) M := + s.lMap (Language.ofSublanguage L) +-/ + +noncomputable abbrev extendStructure (Φ : L₁ →ᵥ L₂) {M : Type w} [Nonempty M] (s : Structure L₁ M) : Structure L₂ M where + func {k} f₂ v := Classical.epsilon (∃ f₁ : L₁.Func k, Φ.func f₁ = f₂ ∧ · = s.func f₁ v) + rel {k} r₂ v := ∃ r₁ : L₁.Rel k, Φ.rel r₁ = r₂ ∧ s.rel r₁ v + +namespace extendStructure + +variable {M : Type u} [Nonempty M] (s₁ : Structure L₁ M) + +protected lemma func + (Φ : L₁ →ᵥ L₂) [hΦ : Φ.Injective] + (f₁ : L₁.Func k) (v : Fin k → M) : + (s₁.extendStructure Φ).func (Φ.func f₁) v = s₁.func f₁ v := by + have : ∃ y, ∃ f₁' : L₁.Func k, Φ.func f₁' = Φ.func f₁ ∧ y = s₁.func f₁' v := ⟨s₁.func f₁ v, f₁, rfl, rfl⟩ + rcases Classical.epsilon_spec this with ⟨f', f'eq, h⟩ + rcases hΦ.func k f'eq with rfl; exact h + +protected lemma rel + (Φ : L₁ →ᵥ L₂) [hΦ : Φ.Injective] + (r₁ : L₁.Rel k) (v : Fin k → M) : + (s₁.extendStructure Φ).rel (Φ.rel r₁) v ↔ s₁.rel r₁ v := by + refine ⟨by intros h; rcases h with ⟨r₁', bv, h⟩; rcases hΦ.rel k bv with rfl; exact h, by intros h; refine ⟨r₁, rfl, h⟩⟩ + +lemma val_lMap + (Φ : L₁ →ᵥ L₂) [Φ.Injective] + (bv : Fin n → M) (fv : ξ → M) + (t : Semiterm L₁ ξ n) : + (t.lMap Φ).val (s := s₁.extendStructure Φ) bv fv = t.val (s := s₁) bv fv := by + induction t + case func k f v ih => + simpa [ih, Function.comp_def] using extendStructure.func s₁ Φ f fun i ↦ (v i).val (s := s₁) bv fv + case _ => simp [*] + case _ => simp [*] + +open Semiformula + +lemma eval_lMap (Φ : L₁ →ᵥ L₂) [Φ.Injective] + (bv : Fin n → M) (fv : ξ → M) + {φ : Semiformula L₁ ξ n} : + (lMap Φ φ).Eval (s := s₁.extendStructure Φ) bv fv ↔ φ.Eval (s := s₁) bv fv := by + induction φ using Semiformula.rec' + case hrel k r v => + simp only [Semiformula.lMap_rel, eval_rel, val_lMap s₁ Φ bv fv, Function.comp_def] + exact extendStructure.rel s₁ Φ r (fun i ↦ (v i).val (s := s₁) bv fv) + case hnrel k r v => + simp only [lMap_nrel, eval_nrel, val_lMap s₁ Φ bv fv, Function.comp_def] + simpa [not_iff_not] using + extendStructure.rel s₁ Φ r (fun i ↦ (v i).val (s := s₁) bv fv) + case _ => simp [*] + case _ => simp [*] + case _ => simp [*] + case _ => simp [*] + case _ => simp [*] + case _ => simp [*] + +lemma models_lMap (Φ : L₁ →ᵥ L₂) [Φ.Injective] (φ : Sentence L₁) : + (s₁.extendStructure Φ).toStruc ⊧ φ.lMap Φ ↔ s₁.toStruc ⊧ φ := by + simp [Semantics.Models, eval_lMap s₁ Φ] + +end extendStructure + +end Structure + +section lMap + +variable {L₁ : Language.{u}} {L₂ : Language.{u}} + +lemma lMap_models_lMap_iff (Φ : L₁ →ᵥ L₂) [Φ.Injective] {T : Theory L₁} {φ : Sentence L₁} : + T.lMap Φ ⊨ φ.lMap Φ ↔ T ⊨ φ := by + constructor + · intro h s₁ hs₁ + refine (Structure.extendStructure.models_lMap s₁.struc Φ φ).mp <| h ?_ + suffices ∀ σ ∈ T, (Structure.extendStructure Φ s₁.struc).toStruc ⊧ σ.lMap Φ by + simpa [Semantics.modelsSet_iff, Theory.lMap, Semantics.models] + intro σ hσ + exact (Structure.extendStructure.models_lMap s₁.struc Φ σ).mpr (hs₁.models _ hσ) + · exact lMap_models_lMap + +lemma satisfiable_lMap (Φ : L₁ →ᵥ L₂) [Φ.Injective] {T : Theory L₁} (s : Satisfiable T) : + Satisfiable (T.lMap Φ) := by + rcases s with ⟨⟨M, i, s⟩, hM⟩ + exact ⟨⟨M, i, s.extendStructure Φ⟩, by + have : ∀ φ ∈ T, (Structure.extendStructure Φ s).toStruc ⊧ φ.lMap Φ := + fun φ hφ ↦ (Structure.extendStructure.models_lMap s Φ φ).mpr (hM.models _ hφ) + simpa [Theory.lMap] using this⟩ + +end lMap + +end FirstOrder + +end LO diff --git a/Foundation/FirstOrder/Completeness/CounterModel.lean b/Foundation/FirstOrder/Completeness/CounterModel.lean index 83cb80cf6..7a3c0886b 100644 --- a/Foundation/FirstOrder/Completeness/CounterModel.lean +++ b/Foundation/FirstOrder/Completeness/CounterModel.lean @@ -180,41 +180,23 @@ lemma refl (φ : Proposition L) (h : 𝐋𝐊¹ ⊬ ∼φ) : φ.Evalf (s := termModelOf (ConsistentSequent.ofUnprovable φ h)) (&·) := (forcing_lemma φ).mpr ⟨ConsistentSequent.ofUnprovable φ h, by simp, by simpa using IsWeaklyForced.refl φ h⟩ -lemma satisfiable_of_irrefutable (σ : Sentence L) (h : Entailment.pullback 𝐋𝐊¹[L] ((↑·) : Sentence L → Proposition L) ⊬ ∼σ) : +lemma satisfiable_of_irrefutable_of_countable (σ : Sentence L) (h : 𝐋𝐊¹ ⊬ ∼(σ : Proposition L)) : Satisfiable {σ} := ⟨⟨_, inferInstance, termModelOf (ConsistentSequent.ofUnprovable σ (by simpa using h))⟩, by simpa [models_iff] using refl (↑σ : Proposition L) (by simpa using h)⟩ open LO.Entailment -theorem satisfiable_of_consistent (𝔖 : Schema L) (consistent : Entailment.Consistent 𝔖) : - Satisfiable (↑𝔖 : Theory L) := compact.mpr fun u hu ↦ by { - have : ∃ s : Finset (Proposition L), ↑s ⊆ 𝔖 ∧ s.image Semiformula.univCl = u := - Finset.subset_set_image_iff.mp hu - rcases this with ⟨s, hs𝔖, rfl⟩ - simp - } - - -/--/ -theorem satisfiable_of_consistent (𝔖 : Schema L) (consistent : Entailment.Consistent 𝔖) : - Satisfiable (↑𝔖 : Theory L) := compact.mpr fun u hu ↦ by { - have : ∃ s : Finset (Proposition L), ↑s ⊆ 𝔖 ∧ s.image Semiformula.univCl = u := - Finset.subset_set_image_iff.mp hu - rcases this with ⟨s, hs𝔖, rfl⟩ - let φ := ⋀s.toList - have : 𝔖 ⊢ φ := by - refine Schema.iff_context.mpr <| - Context.provable_iff.mpr - ⟨s.toList, fun ψ hψ ↦ hs𝔖 (by simpa using hψ), FiniteContext.provable_iff.mpr Entailment.C!_id⟩ - have ub : 𝐋𝐊¹ ⊬ ∼φ := fun h ↦ - have : 𝔖 ⊢ ⊥ := neg_mdp (Schema.provable_of_LK h) (by assumption) +/-- The completeness theorem for countable languages. -/ +theorem satisfiable_of_consistent_of_countable (T : Theory L) (consistent : Entailment.Consistent T) : + Satisfiable T := compact.mpr fun u hu ↦ by + let σ := ⋀u.toList + have : T ⊢ σ := Conj₂!_intro fun φ hφ ↦ by_axm <| hu (by simpa using hφ) + have : 𝐋𝐊¹ ⊬ ∼(σ : Proposition L) := fun h ↦ + have : T ⊢ ∼σ := Theory.Proof.of_LK_provable (φ := ∼σ) (by simpa using h) + have : T ⊢ ⊥ := neg_mdp this (by assumption) consistent_iff_unprovable_bot.mp consistent this - let str : Structure L 𝔗 := termModelOf (ConsistentSequent.ofUnprovable φ ub) - refine ⟨⟨_, inferInstance, str⟩, ?_⟩ - have : ∀ φ : Proposition L, φ ∈ s → φ.Evalf (M := 𝔗) (&·) := by simpa [φ] using Canonical.refl φ ub - simp [models_iff] - - } + have : Satisfiable {σ} := satisfiable_of_irrefutable_of_countable σ this + simpa [σ] using this end LO.FirstOrder.Derivation.Canonical diff --git a/Foundation/Logic/Semantics.lean b/Foundation/Logic/Semantics.lean index 44a85305c..4211c6779 100644 --- a/Foundation/Logic/Semantics.lean +++ b/Foundation/Logic/Semantics.lean @@ -162,9 +162,17 @@ lemma modelsSet_iff {𝓜 : M} {T : Set F} : 𝓜 ⊧* T ↔ ∀ ⦃φ⦄, φ @[simp] lemma theory_satisfiable (𝓜 : M) : Satisfiable M (theory 𝓜) := ⟨𝓜, by simp⟩ lemma not_satisfiable_finset [LogicalConnective F] [Tarski M] [DecidableEq F] (t : Finset F) : - ¬Satisfiable M (t : Set F) ↔ Valid M (t.image (∼·)).disj := by + ¬Satisfiable M (t : Set F) ↔ Valid M (t.image (∼·)).disj := by simp [Satisfiable, modelsSet_iff, Valid]; +@[simp] lemma satisfiable_conj₂ [LogicalConnective F] [Tarski M] [DecidableEq F] (l : List F) : + Satisfiable M {⋀l} ↔ Satisfiable M {φ | φ ∈ l} := by + simp [Satisfiable, modelsSet_iff] + +@[simp] lemma satisfiable_fconj [LogicalConnective F] [Tarski M] [DecidableEq F] (s : Finset F) : + Satisfiable M {s.conj} ↔ Satisfiable M {φ | φ ∈ s} := by + simp [Satisfiable, modelsSet_iff] + lemma satisfiableSet_iff_models_nonempty {T : Set F} : Satisfiable M T ↔ (models M T).Nonempty := ⟨by rintro ⟨𝓜, h𝓜⟩; exact ⟨𝓜, h𝓜⟩, by rintro ⟨𝓜, h𝓜⟩; exact ⟨𝓜, h𝓜⟩⟩ From 5dd00730f9cbdcd4198cfdbcf97f2da1c73ad937 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 9 May 2026 00:42:30 +0900 Subject: [PATCH 48/61] completeness --- Foundation/FirstOrder/Basic/Calculus.lean | 6 ++ .../Completeness/CountableSublanguage.lean | 99 ++++++++++--------- .../FirstOrder/Completeness/CounterModel.lean | 82 +++++++++------ 3 files changed, 109 insertions(+), 78 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index 57485f8d1..63e679b20 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -285,6 +285,12 @@ lemma allClosure_fixitr {φ : Proposition L} (dp : 𝐋𝐊¹ ⊢ φ) : (m : ℕ lemma univCl' {φ : Proposition L} (b : 𝐋𝐊¹ ⊢ φ) : 𝐋𝐊¹ ⊢ φ.univCl' := allClosure_fixitr b φ.fvSup +lemma lMap (Φ : L₁ →ᵥ L₂) {φ : Proposition L₁} : 𝐋𝐊¹ ⊢ φ → 𝐋𝐊¹ ⊢ φ.lMap Φ := by + rintro ⟨d⟩ + have : ⊢ᴸᴷ¹ [φ] := d + have : ⊢ᴸᴷ¹ [.lMap Φ φ] := this.lMap Φ + exact ⟨this⟩ + end LK.Proof structure Theory.Proof (T : Theory L) (σ : Sentence L) where diff --git a/Foundation/FirstOrder/Completeness/CountableSublanguage.lean b/Foundation/FirstOrder/Completeness/CountableSublanguage.lean index 23b6ace99..ef0248fdc 100644 --- a/Foundation/FirstOrder/Completeness/CountableSublanguage.lean +++ b/Foundation/FirstOrder/Completeness/CountableSublanguage.lean @@ -1,6 +1,7 @@ module public import Foundation.FirstOrder.Basic +public import Mathlib.Logic.Equiv.List @[expose] public section namespace LO @@ -24,15 +25,15 @@ variable (L) variable {pf : (k : ℕ) → L.Func k → Prop} {pr : (k : ℕ) → L.Rel k → Prop} -def ofSublanguage : sublanguage L pf pr →ᵥ L where +def unsub : sublanguage L pf pr →ᵥ L where func := Subtype.val rel := Subtype.val -@[simp] lemma ofSublanguage_onFunc : - L.ofSublanguage.func φ = φ.val := rfl +@[simp] lemma unsub_onFunc : + L.unsub.func φ = φ.val := rfl -@[simp] lemma ofSublanguage_onRel : - L.ofSublanguage.rel φ = φ.val := rfl +@[simp] lemma unsub_onRel : + L.unsub.rel φ = φ.val := rfl end sublanguage @@ -55,17 +56,17 @@ lemma lang_func_ss {k} (f : L.Func k) (v : Fin k → Semiterm L ξ n) (i) : (v i).symbols ⊆ (func f v).symbols := by intros x; simp [symbols]; grind -def toSublanguage' (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) : ∀ t : Semiterm L ξ n, +def toSublanguage (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) : ∀ t : Semiterm L ξ n, (∀ k f, ⟨k, f⟩ ∈ t.symbols → pf k f) → Semiterm (sublanguage L pf pr) ξ n | #x, _ => #x | &x, _ => &x | func (arity := k) f v, h => func ⟨f, h k f (by simp)⟩ - (fun i ↦ toSublanguage' pf pr (v i) (fun k' f' h' => h k' f' (lang_func_ss f v i h'))) + (fun i ↦ toSublanguage pf pr (v i) (fun k' f' h' => h k' f' (lang_func_ss f v i h'))) -@[simp] lemma lMap_toSubLanguage' (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) +@[simp] lemma lMap_toSublanguage (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) (t : Semiterm L ξ n) (h : ∀ k f, ⟨k, f⟩ ∈ t.symbols → pf k f) : - (t.toSublanguage' pf pr h).lMap L.ofSublanguage = t := by - induction t <;> simp [*, toSublanguage', Function.comp_def] + (t.toSublanguage pf pr h).lMap L.unsub = t := by + induction t <;> simp [*, toSublanguage, Function.comp_def] end Semiterm @@ -99,56 +100,56 @@ lemma functionSymbols_rel_ss {k} (r : L.Rel k) (v : Fin k → Semiterm L ξ n) ( simp only [functionSymbols, Finset.mem_biUnion, Finset.mem_univ, true_and] intros h; exact ⟨i, h⟩ -def toSublanguage' (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) {n} : +def toSublanguage (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) {n} : (φ : Semiformula L ξ n) → (∀ k f, ⟨k, f⟩ ∈ φ.functionSymbols → pf k f) → (∀ k r, ⟨k, r⟩ ∈ φ.relationSymbols → pr k r) → Semiformula (L.sublanguage pf pr) ξ n | rel r v, hf, hr => rel ⟨r, hr _ r (by simp [relationSymbols])⟩ - fun i ↦ (v i).toSublanguage' pf pr fun k f h ↦ hf k f (functionSymbols_rel_ss r v i h) + fun i ↦ (v i).toSublanguage pf pr fun k f h ↦ hf k f (functionSymbols_rel_ss r v i h) | nrel r v, hf, hr => nrel ⟨r, hr _ r (by simp [relationSymbols])⟩ - fun i ↦ (v i).toSublanguage' pf pr fun k f h ↦ hf k f (functionSymbols_rel_ss r v i h) + fun i ↦ (v i).toSublanguage pf pr fun k f h ↦ hf k f (functionSymbols_rel_ss r v i h) | ⊤, _, _ => ⊤ | ⊥, _, _ => ⊥ | φ ⋏ ψ, hf, hr => - toSublanguage' pf pr φ (fun k f h ↦ hf k f (Finset.mem_union_left _ h)) (fun k r h ↦ hr k r (Finset.mem_union_left _ h)) ⋏ - toSublanguage' pf pr ψ (fun k f h ↦ hf k f (Finset.mem_union_right _ h)) (fun k r h ↦ hr k r (Finset.mem_union_right _ h)) + toSublanguage pf pr φ (fun k f h ↦ hf k f (Finset.mem_union_left _ h)) (fun k r h ↦ hr k r (Finset.mem_union_left _ h)) ⋏ + toSublanguage pf pr ψ (fun k f h ↦ hf k f (Finset.mem_union_right _ h)) (fun k r h ↦ hr k r (Finset.mem_union_right _ h)) | φ ⋎ ψ, hf, hr => - toSublanguage' pf pr φ (fun k f h ↦ hf k f (Finset.mem_union_left _ h)) (fun k r h ↦ hr k r (Finset.mem_union_left _ h)) ⋎ - toSublanguage' pf pr ψ (fun k f h ↦ hf k f (Finset.mem_union_right _ h)) (fun k r h ↦ hr k r (Finset.mem_union_right _ h)) - | ∀⁰ φ, hf, hr => ∀⁰ toSublanguage' pf pr φ hf hr - | ∃⁰ φ, hf, hr => ∃⁰ toSublanguage' pf pr φ hf hr + toSublanguage pf pr φ (fun k f h ↦ hf k f (Finset.mem_union_left _ h)) (fun k r h ↦ hr k r (Finset.mem_union_left _ h)) ⋎ + toSublanguage pf pr ψ (fun k f h ↦ hf k f (Finset.mem_union_right _ h)) (fun k r h ↦ hr k r (Finset.mem_union_right _ h)) + | ∀⁰ φ, hf, hr => ∀⁰ toSublanguage pf pr φ hf hr + | ∃⁰ φ, hf, hr => ∃⁰ toSublanguage pf pr φ hf hr -@[simp] lemma lMap_toSubLanguage' +@[simp] lemma lMap_toSublanguage (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) {n} (φ : Semiformula L ξ n) (hf : ∀ k f, ⟨k, f⟩ ∈ φ.functionSymbols → pf k f) (hr : ∀ k r, ⟨k, r⟩ ∈ φ.relationSymbols → pr k r) : - lMap L.ofSublanguage (φ.toSublanguage' pf pr hf hr) = φ := by - induction φ using rec' <;> simp [*, toSublanguage', lMap_rel, lMap_nrel, Function.comp_def] + lMap L.unsub (φ.toSublanguage pf pr hf hr) = φ := by + induction φ using rec' <;> simp [*, toSublanguage, lMap_rel, lMap_nrel, Function.comp_def] -noncomputable def languageFuncIndexed (φ : Semiformula L ξ n) (k) : Finset (L.Func k) := - Finset.preimage (functionSymbols φ) (Sigma.mk k) (Set.injOn_of_injective sigma_mk_injective) - -noncomputable def languageRelIndexed (φ : Semiformula L ξ n) (k) : Finset (L.Rel k) := - Finset.preimage (relationSymbols φ) (Sigma.mk k) (Set.injOn_of_injective sigma_mk_injective) +variable (φ : Semiformula L ξ n) /-- A language consists of the function and relation symbols appearing in a given finite set of formulas. -/ -abbrev languageFinset (Γ : Finset (Semiformula L ξ n)) : Language := - Language.sublanguage L (fun k f ↦ ∃ φ ∈ Γ, ⟨k, f⟩ ∈ functionSymbols φ) (fun k r ↦ ∃ φ ∈ Γ, ⟨k, r⟩ ∈ relationSymbols φ) +abbrev sublanguage : Language := + Language.sublanguage L (fun k f ↦ ⟨k, f⟩ ∈ φ.functionSymbols) (fun k r ↦ ⟨k, r⟩ ∈ φ.relationSymbols) + +noncomputable instance (k) : Fintype (φ.sublanguage.Func k) := + Fintype.subtype (φ.functionSymbols.preimage (⟨k, ·⟩) (Set.injOn_of_injective sigma_mk_injective)) (by simp) -noncomputable instance (Γ : Finset (Semiformula L ξ n)) (k) : Fintype ((languageFinset Γ).Func k) := - Fintype.subtype (Γ.biUnion (languageFuncIndexed · k)) (by simp [languageFuncIndexed]) +noncomputable instance (k) : Fintype (φ.sublanguage.Rel k) := + Fintype.subtype (φ.relationSymbols.preimage (⟨k, ·⟩) (Set.injOn_of_injective sigma_mk_injective)) (by simp) -noncomputable instance (Γ : Finset (Semiformula L ξ n)) (k) : Fintype ((languageFinset Γ).Rel k) := - Fintype.subtype (Γ.biUnion (languageRelIndexed · k)) (by simp [languageRelIndexed]) +noncomputable instance : φ.sublanguage.Encodable where + func _ := Fintype.toEncodable _ + rel _ := Fintype.toEncodable _ -def toSubLanguageFinsetSelf {Γ : Finset (Semiformula L ξ n)} {φ} (h : φ ∈ Γ) : Semiformula (languageFinset Γ) ξ n := - φ.toSublanguage' _ _ (fun _ _ hf ↦ ⟨φ, h, hf⟩) (fun _ _ hr ↦ ⟨φ, h, hr⟩) +def toSubLanguageSelf (φ : Semiformula L ξ n) : Semiformula φ.sublanguage ξ n := + φ.toSublanguage _ _ (fun _ _ ↦ id) (fun _ _ ↦ id) -@[simp] lemma lMap_toSubLanguageFinsetSelf {Γ : Finset (Semiformula L ξ n)} {φ} (h : φ ∈ Γ) : - lMap L.ofSublanguage (toSubLanguageFinsetSelf h) = φ := - lMap_toSubLanguage' _ _ _ _ _ +@[simp] lemma lMap_toSubLanguage {φ : Semiformula L ξ n} : + φ.toSubLanguageSelf.lMap L.unsub = φ := + lMap_toSublanguage _ _ _ _ _ end Semiformula @@ -160,8 +161,8 @@ class Hom.Injective (Φ : L₁ →ᵥ L₂) : Prop where func : ∀ k, Function.Injective (Φ.func : L₁.Func k → L₂.Func k) rel : ∀ k, Function.Injective (Φ.rel : L₁.Rel k → L₂.Rel k) -instance ofSublanguage_injective (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) : - (L.ofSublanguage : L.sublanguage pf pr →ᵥ L).Injective := +instance unsub_injective (pf : ∀ k, L.Func k → Prop) (pr : ∀ k, L.Rel k → Prop) : + (L.unsub : L.sublanguage pf pr →ᵥ L).Injective := ⟨fun _ ↦ Subtype.val_injective, fun _ ↦ Subtype.val_injective⟩ end Language @@ -170,17 +171,17 @@ namespace Structure /- instance sublanguageStructure {pf : ∀ k, L.Func k → Prop} {pr : ∀ k, L.Rel k → Prop} - {M : Type w} (s : Structure L M) : Structure (Language.sublanguage L pf pr) M := - s.lMap (Language.ofSublanguage L) + {M : Type*} (s : Structure L M) : Structure (Language.sublanguage L pf pr) M := + s.lMap (Language.unsub L) -/ -noncomputable abbrev extendStructure (Φ : L₁ →ᵥ L₂) {M : Type w} [Nonempty M] (s : Structure L₁ M) : Structure L₂ M where +noncomputable abbrev extendStructure (Φ : L₁ →ᵥ L₂) {M : Type*} [Nonempty M] (s : Structure L₁ M) : Structure L₂ M where func {k} f₂ v := Classical.epsilon (∃ f₁ : L₁.Func k, Φ.func f₁ = f₂ ∧ · = s.func f₁ v) rel {k} r₂ v := ∃ r₁ : L₁.Rel k, Φ.rel r₁ = r₂ ∧ s.rel r₁ v namespace extendStructure -variable {M : Type u} [Nonempty M] (s₁ : Structure L₁ M) +variable {M : Type*} [Nonempty M] (s₁ : Structure L₁ M) protected lemma func (Φ : L₁ →ᵥ L₂) [hΦ : Φ.Injective] @@ -200,10 +201,10 @@ lemma val_lMap (Φ : L₁ →ᵥ L₂) [Φ.Injective] (bv : Fin n → M) (fv : ξ → M) (t : Semiterm L₁ ξ n) : - (t.lMap Φ).val (s := s₁.extendStructure Φ) bv fv = t.val (s := s₁) bv fv := by + (t.lMap Φ).val (s := s₁.extendStructure Φ) bv fv = t.val bv fv := by induction t case func k f v ih => - simpa [ih, Function.comp_def] using extendStructure.func s₁ Φ f fun i ↦ (v i).val (s := s₁) bv fv + simpa [ih, Function.comp_def] using extendStructure.func s₁ Φ f fun i ↦ (v i).val bv fv case _ => simp [*] case _ => simp [*] @@ -212,15 +213,15 @@ open Semiformula lemma eval_lMap (Φ : L₁ →ᵥ L₂) [Φ.Injective] (bv : Fin n → M) (fv : ξ → M) {φ : Semiformula L₁ ξ n} : - (lMap Φ φ).Eval (s := s₁.extendStructure Φ) bv fv ↔ φ.Eval (s := s₁) bv fv := by + (lMap Φ φ).Eval (s := s₁.extendStructure Φ) bv fv ↔ φ.Eval bv fv := by induction φ using Semiformula.rec' case hrel k r v => simp only [Semiformula.lMap_rel, eval_rel, val_lMap s₁ Φ bv fv, Function.comp_def] - exact extendStructure.rel s₁ Φ r (fun i ↦ (v i).val (s := s₁) bv fv) + exact extendStructure.rel s₁ Φ r (fun i ↦ (v i).val bv fv) case hnrel k r v => simp only [lMap_nrel, eval_nrel, val_lMap s₁ Φ bv fv, Function.comp_def] simpa [not_iff_not] using - extendStructure.rel s₁ Φ r (fun i ↦ (v i).val (s := s₁) bv fv) + extendStructure.rel s₁ Φ r (fun i ↦ (v i).val bv fv) case _ => simp [*] case _ => simp [*] case _ => simp [*] diff --git a/Foundation/FirstOrder/Completeness/CounterModel.lean b/Foundation/FirstOrder/Completeness/CounterModel.lean index 7a3c0886b..6eca2a255 100644 --- a/Foundation/FirstOrder/Completeness/CounterModel.lean +++ b/Foundation/FirstOrder/Completeness/CounterModel.lean @@ -1,6 +1,7 @@ module public import Foundation.FirstOrder.Completeness.CanonicalModel +public import Foundation.FirstOrder.Completeness.CountableSublanguage public import Foundation.FirstOrder.Ultraproduct public import Foundation.Vorspiel.Order.Dense public import Mathlib.Logic.Equiv.List @@ -12,18 +13,18 @@ namespace LO.FirstOrder.Derivation.Canonical open Order -variable {L : Language} +variable {K : Language} -local notation "ℙ" => Sequent L -local notation "ℙ⁻" => ConsistentSequent L +local notation "ℙ" => Sequent K +local notation "ℙ⁻" => ConsistentSequent K -instance [L.Encodable] [L.DecidableEq] : Encodable (Sequent L) := List.encodable +instance [K.Encodable] [K.DecidableEq] : Encodable (Sequent K) := List.encodable open Classical in -noncomputable instance [L.Encodable] : Encodable ℙ⁻ := Subtype.encodable +noncomputable instance [K.Encodable] : Encodable ℙ⁻ := Subtype.encodable open Classical -def decidablePoints (φ : Proposition L) : DenseSet ℙ⁻ where +def decidablePoints (φ : Proposition K) : DenseSet ℙ⁻ where set := {p | p ⊩ᶜ φ ∨ p ⊩ᶜ ∼φ} is_dense := by intro p @@ -31,10 +32,10 @@ def decidablePoints (φ : Proposition L) : DenseSet ℙ⁻ where have : ∀ q ≤ p, ∃ r ≤ q, r ⊩ᶜ φ ∨ r ⊩ᶜ ∼φ := by simpa using this simpa using this p (by rfl) -@[simp] lemma mem_decidablePoints_def (p : ℙ⁻) (φ : Proposition L) : +@[simp] lemma mem_decidablePoints_def (p : ℙ⁻) (φ : Proposition K) : p ∈ decidablePoints φ ↔ p ⊩ᶜ φ ∨ p ⊩ᶜ ∼φ := by rfl -def henkinPoints (φ : Semiproposition L 1) : DenseSet ℙ⁻ where +def henkinPoints (φ : Semiproposition K 1) : DenseSet ℙ⁻ where set := {p | ∀ q ≤ p, q ⊩ᶜ ∃⁰ φ → ∃ t, q ⊩ᶜ φ/[t]} is_dense := by intro p @@ -51,12 +52,12 @@ def henkinPoints (φ : Semiproposition L 1) : DenseSet ℙ⁻ where have : ¬s ⊩ᶜ φ/[u] := h u s (le_trans hsr hrq) contradiction -@[simp] lemma mem_henkinPoints_def (p : ℙ⁻) (φ : Semiproposition L 1) : +@[simp] lemma mem_henkinPoints_def (p : ℙ⁻) (φ : Semiproposition K 1) : p ∈ henkinPoints φ ↔ ∀ q ≤ p, q ⊩ᶜ ∃⁰ φ → ∃ t, q ⊩ᶜ φ/[t] := by rfl abbrev denseSets : Set (DenseSet ℙ⁻) := Set.range decidablePoints ∪ Set.range henkinPoints -variable [L.Encodable] +variable [K.Encodable] theorem exists_genericFilter (p : ℙ⁻) : ∃ G : PFilter ℙ⁻, G.IsGeneric denseSets ∧ p ∈ G := @@ -71,11 +72,11 @@ instance genericFilter_isGeneric (p : ℙ⁻) : (genericFilter p).IsGeneric dens @[simp] lemma mem_genericFilter (p : ℙ⁻) : p ∈ genericFilter p := Classical.choose_spec (exists_genericFilter p) |>.2 -def GenericForces (p : ℙ⁻) (φ : Proposition L) : Prop := ∃ q ∈ genericFilter p, q ⊩ᶜ φ +def GenericForces (p : ℙ⁻) (φ : Proposition K) : Prop := ∃ q ∈ genericFilter p, q ⊩ᶜ φ local infix: 60 " ⊫ " => GenericForces -lemma GenericForces.em (p : ℙ⁻) (φ : Proposition L) : p ⊫ φ ∨ p ⊫ ∼φ := by +lemma GenericForces.em (p : ℙ⁻) (φ : Proposition K) : p ⊫ φ ∨ p ⊫ ∼φ := by have : ∃ q ∈ genericFilter p, q ∈ decidablePoints φ := (genericFilter_isGeneric p).isGeneric (decidablePoints φ) (by simp) rcases this with ⟨q, hqG, hq⟩ @@ -84,7 +85,7 @@ lemma GenericForces.em (p : ℙ⁻) (φ : Proposition L) : p ⊫ φ ∨ p ⊫ · left; refine ⟨q, hqG, em⟩ · right; refine ⟨q, hqG, em⟩ -@[simp] lemma GenericForces.neg {p : ℙ⁻} {φ : Proposition L} : p ⊫ ∼φ ↔ ¬p ⊫ φ := by +@[simp] lemma GenericForces.neg {p : ℙ⁻} {φ : Proposition K} : p ⊫ ∼φ ↔ ¬p ⊫ φ := by suffices p ⊫ ∼φ → p ⊫ φ → False by have := GenericForces.em p φ grind @@ -105,7 +106,7 @@ lemma GenericForces.em (p : ℙ⁻) (φ : Proposition L) : p ⊫ φ ∨ p ⊫ p ⊫ .nrel R v ↔ p ⊫ ∼(.rel R v) := by simp _ ↔ ¬p ⊫ .rel R v := by rw [GenericForces.neg] -lemma GenericForces.henkin {p : ℙ⁻} {φ : Semiproposition L 1} : p ⊫ ∃⁰ φ → ∃ t, p ⊫ φ/[t] := by +lemma GenericForces.henkin {p : ℙ⁻} {φ : Semiproposition K 1} : p ⊫ ∃⁰ φ → ∃ t, p ⊫ φ/[t] := by have : ∃ q ∈ genericFilter p, ∀ r ≤ q, r ⊩ᶜ ∃⁰ φ → ∃ t, r ⊩ᶜ φ/[t] := (genericFilter_isGeneric p).isGeneric (henkinPoints φ) (by simp) rcases this with ⟨q, hqG, H⟩ @@ -129,7 +130,7 @@ lemma GenericForces.henkin {p : ℙ⁻} {φ : Semiproposition L 1} : p ⊫ ∃ _ ↔ ¬p ⊫ ∃⁰ ∼φ := by rw [GenericForces.neg] _ ↔ ∀ t, p ⊫ φ/[t] := by simp [GenericForces.exs] -@[simp] lemma GenericForces.and {p : ℙ⁻} {φ ψ : Proposition L} : p ⊫ φ ⋏ ψ ↔ p ⊫ φ ∧ p ⊫ ψ := by +@[simp] lemma GenericForces.and {p : ℙ⁻} {φ ψ : Proposition K} : p ⊫ φ ⋏ ψ ↔ p ⊫ φ ∧ p ⊫ ψ := by constructor · rintro ⟨q, hqG, hq⟩ have : q ⊩ᶜ φ ∧ q ⊩ᶜ ψ := by simpa using hq @@ -142,30 +143,30 @@ lemma GenericForces.henkin {p : ℙ⁻} {φ : Semiproposition L 1} : p ⊫ ∃ have : r ⊩ᶜ ψ := h₂.monotone hr₂ simp_all -@[simp] lemma GenericForces.or {p : ℙ⁻} {φ ψ : Proposition L} : p ⊫ φ ⋎ ψ ↔ p ⊫ φ ∨ p ⊫ ψ := calc +@[simp] lemma GenericForces.or {p : ℙ⁻} {φ ψ : Proposition K} : p ⊫ φ ⋎ ψ ↔ p ⊫ φ ∨ p ⊫ ψ := calc p ⊫ φ ⋎ ψ ↔ p ⊫ ∼(∼φ ⋏ ∼ψ) := by simp _ ↔ ¬p ⊫ ∼φ ⋏ ∼ψ := by rw [GenericForces.neg] _ ↔ p ⊫ φ ∨ p ⊫ ψ := by simp; tauto -local notation "𝔗" => Term L ℕ +local notation "𝔗" => Term K ℕ -abbrev termModelOf (p : ℙ⁻) : Structure L 𝔗 where +abbrev termModelOf (p : ℙ⁻) : Structure K 𝔗 where func _ f v := .func f v rel _ R v := p ⊫ .rel R v -@[simp] lemma termModel_func_def (f : L.Func k) (v : Fin k → 𝔗) : +@[simp] lemma termModel_func_def (f : K.Func k) (v : Fin k → 𝔗) : (termModelOf p).func f v = Semiterm.func f v := rfl -@[simp] lemma termModel_rel_def (R : L.Rel k) (v) : +@[simp] lemma termModel_rel_def (R : K.Rel k) (v) : (termModelOf p).rel R v ↔ p ⊫ .rel R v := by rfl -@[simp] lemma termModel_val_eq (t : Semiterm L ξ n) (fv : ξ → 𝔗) (bv : Fin n → 𝔗) : +@[simp] lemma termModel_val_eq (t : Semiterm K ξ n) (fv : ξ → 𝔗) (bv : Fin n → 𝔗) : t.val (s := termModelOf p) bv fv = Rew.bind bv fv t := by induction t <;> simp [*, Function.comp_def] -lemma forcing_lemma (φ : Semiformula L ξ n) {fv : ξ → 𝔗} {bv : Fin n → 𝔗} : +lemma forcing_lemma (φ : Semiformula K ξ n) {fv : ξ → 𝔗} {bv : Fin n → 𝔗} : φ.Eval (s := termModelOf p) bv fv ↔ p ⊫ Rew.bind bv fv ▹ φ := - have e (t : 𝔗) (φ : Semiformula L ξ (n + 1)) : ((Rew.bind bv fv).q ▹ φ)/[t] = Rew.bind (t :> bv) fv ▹ φ := by + have e (t : 𝔗) (φ : Semiformula K ξ (n + 1)) : ((Rew.bind bv fv).q ▹ φ)/[t] = Rew.bind (t :> bv) fv ▹ φ := by unfold Rewriting.subst; rw [←TransitiveRewriting.comp_app] congr; ext x · cases x using Fin.cases <;> simp [Rew.comp_app] @@ -176,19 +177,32 @@ lemma forcing_lemma (φ : Semiformula L ξ n) {fv : ξ → 𝔗} {bv : Fin n → | φ ⋏ ψ | φ ⋎ ψ => by simp [forcing_lemma φ, forcing_lemma ψ] | ∀⁰ φ | ∃⁰ φ => by simp [e, forcing_lemma φ] -lemma refl (φ : Proposition L) (h : 𝐋𝐊¹ ⊬ ∼φ) : +lemma refl (φ : Proposition K) (h : 𝐋𝐊¹ ⊬ ∼φ) : φ.Evalf (s := termModelOf (ConsistentSequent.ofUnprovable φ h)) (&·) := (forcing_lemma φ).mpr ⟨ConsistentSequent.ofUnprovable φ h, by simp, by simpa using IsWeaklyForced.refl φ h⟩ -lemma satisfiable_of_irrefutable_of_countable (σ : Sentence L) (h : 𝐋𝐊¹ ⊬ ∼(σ : Proposition L)) : +lemma satisfiable_of_irrefutable_of_countable (σ : Sentence K) (h : 𝐋𝐊¹ ⊬ ∼(σ : Proposition K)) : Satisfiable {σ} := ⟨⟨_, inferInstance, termModelOf (ConsistentSequent.ofUnprovable σ (by simpa using h))⟩, by - simpa [models_iff] using refl (↑σ : Proposition L) (by simpa using h)⟩ + simpa [models_iff] using refl (↑σ : Proposition K) (by simpa using h)⟩ open LO.Entailment -/-- The completeness theorem for countable languages. -/ -theorem satisfiable_of_consistent_of_countable (T : Theory L) (consistent : Entailment.Consistent T) : +variable {L : Language} + +lemma satisfiable_of_irrefutable (σ : Sentence L) (h : 𝐋𝐊¹ ⊬ ∼(σ : Proposition L)) : + Satisfiable {σ} := by + let K := σ.sublanguage + let π : Sentence K := σ.toSubLanguageSelf + have : 𝐋𝐊¹ ⊬ ∼(π : Proposition K) := fun h ↦ by + have : 𝐋𝐊¹ ⊢ ∼(σ : Proposition L) := by + simpa [Semiformula.lMap_emb, π] using LK.Proof.lMap L.unsub h + contradiction + have : Satisfiable {π} := satisfiable_of_irrefutable_of_countable π this + simpa [Theory.lMap, π] using satisfiable_lMap L.unsub this + +/-- Completeness theorem (I) -/ +theorem satisfiable_of_consistent {T : Theory L} (consistent : Entailment.Consistent T) : Satisfiable T := compact.mpr fun u hu ↦ by let σ := ⋀u.toList have : T ⊢ σ := Conj₂!_intro fun φ hφ ↦ by_axm <| hu (by simpa using hφ) @@ -196,7 +210,17 @@ theorem satisfiable_of_consistent_of_countable (T : Theory L) (consistent : Enta have : T ⊢ ∼σ := Theory.Proof.of_LK_provable (φ := ∼σ) (by simpa using h) have : T ⊢ ⊥ := neg_mdp this (by assumption) consistent_iff_unprovable_bot.mp consistent this - have : Satisfiable {σ} := satisfiable_of_irrefutable_of_countable σ this + have : Satisfiable {σ} := satisfiable_of_irrefutable σ this simpa [σ] using this +theorem completeness (T : Theory L) : T ⊨ φ → T ⊢ φ := by + contrapose! + intro h + have : Consistent (insert (∼φ) T) := by sorry + have : Satisfiable (insert (∼φ) T) := satisfiable_of_consistent this + rcases this with ⟨⟨M, i, s⟩, hM⟩ + simp [consequence_iff] + simp at hM + refine ⟨M, i.some, s, hM.2, hM.1⟩ + end LO.FirstOrder.Derivation.Canonical From c6807ce873f9540ba1378d0c94d4da61a9843a42 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 9 May 2026 23:31:05 +0900 Subject: [PATCH 49/61] completeness (II) --- Foundation/FirstOrder/Basic/Soundness.lean | 16 ++--- .../FirstOrder/Completeness/CounterModel.lean | 67 +++++++++++++++---- .../Propositional/Entailment/Cl/Basic.lean | 7 +- 3 files changed, 68 insertions(+), 22 deletions(-) diff --git a/Foundation/FirstOrder/Basic/Soundness.lean b/Foundation/FirstOrder/Basic/Soundness.lean index dfc3db1cc..ee8d80f1f 100644 --- a/Foundation/FirstOrder/Basic/Soundness.lean +++ b/Foundation/FirstOrder/Basic/Soundness.lean @@ -71,11 +71,11 @@ theorem LK.Proof.sound {M : Type*} [s : Structure L M] [Nonempty M] {φ : Propos variable {T U : Theory L} -namespace Theory.Proof +namespace Theory -theorem sound_proposition {M : Type*} [s : Structure L M] [Nonempty M] : +theorem Proof.sound_proposition {M : Type*} [s : Structure L M] [Nonempty M] : T ⊢ φ → M↓[L] ⊧* T → φ.Realize M := fun b H ↦ by - rcases provable_iff.mp b with ⟨Γ, hΓ, ⟨b⟩⟩ + rcases Proof.provable_iff.mp b with ⟨Γ, hΓ, ⟨b⟩⟩ let f : ℕ → M := fun _ ↦ Nonempty.some inferInstance have : φ.Realize M ∨ ∃ ψ, ∼ψ ∈ Sequent.embed Γ ∧ ψ.Evalf f := by simpa using b.sound f rcases this with (h | ⟨ψ, hψ, h⟩) @@ -91,26 +91,26 @@ theorem sound_proposition {M : Type*} [s : Structure L M] [Nonempty M] : contradiction /-- Soundness theorem for first-order logic. -/ -theorem sound {φ : Sentence L} : +theorem Proof.sound {φ : Sentence L} : T ⊢ φ → T ⊨[Struc.{v, u} L] φ := fun b s hS ↦ by simpa [struc_models_iff_models (s := s), models_iff] - using sound_proposition b hS + using Proof.sound_proposition b hS -theorem sound_small : T ⊢ φ → T ⊨ φ := sound +theorem Proof.sound_small : T ⊢ φ → T ⊨ φ := Proof.sound instance (T : Theory L) : Sound T (Semantics.models (Struc.{v, u} L) T) := ⟨Theory.Proof.sound⟩ lemma consistent_of_satisfiable (h : Semantics.Satisfiable (Struc.{v, u} L) T) : Entailment.Consistent T := Sound.consistent_of_satisfiable h -end Theory.Proof +end Theory section model variable (T) (M : Type*) [Nonempty M] [Structure L M] lemma consistent_of_model [hM : M↓[L] ⊧* T] : - Entailment.Consistent T := Theory.Proof.consistent_of_satisfiable ⟨M↓[L], hM⟩ + Entailment.Consistent T := Theory.consistent_of_satisfiable ⟨M↓[L], hM⟩ variable {M} diff --git a/Foundation/FirstOrder/Completeness/CounterModel.lean b/Foundation/FirstOrder/Completeness/CounterModel.lean index 6eca2a255..177760cf5 100644 --- a/Foundation/FirstOrder/Completeness/CounterModel.lean +++ b/Foundation/FirstOrder/Completeness/CounterModel.lean @@ -7,6 +7,8 @@ public import Foundation.Vorspiel.Order.Dense public import Mathlib.Logic.Equiv.List public import Mathlib.Logic.Encodable.Basic +/-! # Completeness theorem -/ + @[expose] public section namespace LO.FirstOrder.Derivation.Canonical @@ -181,13 +183,20 @@ lemma refl (φ : Proposition K) (h : 𝐋𝐊¹ ⊬ ∼φ) : φ.Evalf (s := termModelOf (ConsistentSequent.ofUnprovable φ h)) (&·) := (forcing_lemma φ).mpr ⟨ConsistentSequent.ofUnprovable φ h, by simp, by simpa using IsWeaklyForced.refl φ h⟩ -lemma satisfiable_of_irrefutable_of_countable (σ : Sentence K) (h : 𝐋𝐊¹ ⊬ ∼(σ : Proposition K)) : +end Derivation.Canonical + +namespace LK + +open Classical Derivation.Canonical + +open LO.Entailment + +lemma satisfiable_of_irrefutable_of_countable {K : Language} [K.Encodable] + (σ : Sentence K) (h : 𝐋𝐊¹ ⊬ ∼(σ : Proposition K)) : Satisfiable {σ} := ⟨⟨_, inferInstance, termModelOf (ConsistentSequent.ofUnprovable σ (by simpa using h))⟩, by simpa [models_iff] using refl (↑σ : Proposition K) (by simpa using h)⟩ -open LO.Entailment - variable {L : Language} lemma satisfiable_of_irrefutable (σ : Sentence L) (h : 𝐋𝐊¹ ⊬ ∼(σ : Proposition L)) : @@ -201,26 +210,58 @@ lemma satisfiable_of_irrefutable (σ : Sentence L) (h : 𝐋𝐊¹ ⊬ ∼(σ : have : Satisfiable {π} := satisfiable_of_irrefutable_of_countable π this simpa [Theory.lMap, π] using satisfiable_lMap L.unsub this +end LK + +namespace Theory + +open Classical LO.Entailment + +variable {L : Language.{u}} {T : Theory L} + /-- Completeness theorem (I) -/ -theorem satisfiable_of_consistent {T : Theory L} (consistent : Entailment.Consistent T) : - Satisfiable T := compact.mpr fun u hu ↦ by +theorem small_satisfiable_of_consistent : + Consistent T → Satisfiable T := fun consistent ↦ compact.mpr fun u hu ↦ by let σ := ⋀u.toList have : T ⊢ σ := Conj₂!_intro fun φ hφ ↦ by_axm <| hu (by simpa using hφ) have : 𝐋𝐊¹ ⊬ ∼(σ : Proposition L) := fun h ↦ have : T ⊢ ∼σ := Theory.Proof.of_LK_provable (φ := ∼σ) (by simpa using h) have : T ⊢ ⊥ := neg_mdp this (by assumption) consistent_iff_unprovable_bot.mp consistent this - have : Satisfiable {σ} := satisfiable_of_irrefutable σ this + have : Satisfiable {σ} := LK.satisfiable_of_irrefutable σ this simpa [σ] using this -theorem completeness (T : Theory L) : T ⊨ φ → T ⊢ φ := by +lemma satisfiable_iff_consistent : + Semantics.Satisfiable (Struc.{max u w} L) T ↔ Consistent T := by + constructor + · exact consistent_of_satisfiable + · intro h + let ⟨M, _, _, h⟩ := satisfiable_iff.mp (small_satisfiable_of_consistent h) + exact satisfiable_iff.mpr + ⟨ULift.{w} M, inferInstance, inferInstance, ((uLift_elementaryEquiv L M).modelsTheory).mpr h⟩ + +theorem Proof.complete : + T ⊨[Struc.{max u w} L] φ → T ⊢ φ := by contrapose! intro h - have : Consistent (insert (∼φ) T) := by sorry - have : Satisfiable (insert (∼φ) T) := satisfiable_of_consistent this + have : Consistent (insert (∼φ) T) := unprovable_iff_consistent_adjoin.mp h + have : Semantics.Satisfiable (Struc.{max u w} L) (insert (∼φ) T) := satisfiable_iff_consistent.mpr this rcases this with ⟨⟨M, i, s⟩, hM⟩ - simp [consequence_iff] - simp at hM - refine ⟨M, i.some, s, hM.2, hM.1⟩ + have : ¬M↓[L] ⊧ φ ∧ M↓[L] ⊧* T := by simpa using hM + simpa [consequence_iff] using ⟨M, i.some, s, this.2, this.1⟩ + +/-- Completeness theorem (II) -/ +theorem Proof.small_complete : T ⊨ φ → T ⊢ φ := Proof.complete + +theorem Proof.complete_iff : T ⊨ φ ↔ T ⊢ φ := ⟨fun h ↦ Proof.complete h, Proof.sound⟩ + +instance Proof.isComplete (T : Theory L) : Complete T (Semantics.models (SmallStruc L) T) := ⟨Proof.complete⟩ + +lemma satisfiable_iff_satisfiable : Semantics.Satisfiable (Struc.{max u w} L) T ↔ Satisfiable T := by + simp [satisfiable_iff_consistent.{u, w}, satisfiable_iff_consistent.{u, u}] + +lemma consequence_iff_consequence : T ⊨[Struc.{max u w} L] φ ↔ T ⊨ φ := by + simp [consequence_iff_unsatisfiable, satisfiable_iff_satisfiable.{u, w}] + +end Theory -end LO.FirstOrder.Derivation.Canonical +end LO.FirstOrder diff --git a/Foundation/Propositional/Entailment/Cl/Basic.lean b/Foundation/Propositional/Entailment/Cl/Basic.lean index bfe2c1d5f..2a3a9c08f 100644 --- a/Foundation/Propositional/Entailment/Cl/Basic.lean +++ b/Foundation/Propositional/Entailment/Cl/Basic.lean @@ -153,9 +153,10 @@ end section consistency +omit [Entailment.Cl 𝓢] + variable [AdjunctiveSet F S] [Axiomatized S] [Deduction S] [∀ 𝓢 : S, Entailment.Cl 𝓢] -omit [Entailment.Cl 𝓢] in lemma provable_iff_inconsistent_adjoin {φ : F} : 𝓢 ⊢ φ ↔ Inconsistent (adjoin (∼φ) 𝓢) := by constructor @@ -167,6 +168,10 @@ lemma provable_iff_inconsistent_adjoin {φ : F} : have : 𝓢 ⊢ ∼φ 🡒 ⊥ := Deduction.of_insert! (h _) refine of_NN! <| N!_iff_CO!.mpr this +lemma unprovable_iff_consistent_adjoin {φ : F} : + 𝓢 ⊬ φ ↔ Consistent (adjoin (∼φ) 𝓢) := by + simpa using provable_iff_inconsistent_adjoin.not + instance deductiveExplosion : Entailment.DeductiveExplosion S := inferInstance end consistency From 3dcb481c2df57223af6433f1817eafc6ed08c0a9 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Sat, 9 May 2026 23:54:00 +0900 Subject: [PATCH 50/61] Corollaries --- .../FirstOrder/Completeness/Corollaries.lean | 41 ---------------- .../Completeness/CountableSublanguage.lean | 6 --- .../FirstOrder/Completeness/CounterModel.lean | 49 +++++++++++++++---- 3 files changed, 39 insertions(+), 57 deletions(-) delete mode 100644 Foundation/FirstOrder/Completeness/Corollaries.lean diff --git a/Foundation/FirstOrder/Completeness/Corollaries.lean b/Foundation/FirstOrder/Completeness/Corollaries.lean deleted file mode 100644 index 12e771a8c..000000000 --- a/Foundation/FirstOrder/Completeness/Corollaries.lean +++ /dev/null @@ -1,41 +0,0 @@ -module - -public import Foundation.FirstOrder.Completeness.Completeness - -@[expose] public section -namespace LO.FirstOrder - -namespace ModelsTheory - -variable {L : Language.{u}} (M : Type w) [Nonempty M] [Structure L M] (T U V : Theory L) - -lemma of_provably_subtheory [le : T ⪯ U] (h : M ⊧ₘ* U) : M ⊧ₘ* T := ⟨by - intro φ hp - have : U ⊢ φ := le.pbl (Entailment.by_axm _ hp) - exact consequence_iff'.{u, w}.mp (sound! this) M⟩ - -lemma of_provably_subtheory' [T ⪯ U] [M ⊧ₘ* U] : M ⊧ₘ* T := of_provably_subtheory M T U inferInstance - -lemma of_add_left [M ⊧ₘ* T + U] : M ⊧ₘ* T := of_ss inferInstance (show T ⊆ T + U from by simp [Theory.add_def]) - -lemma of_add_right [M ⊧ₘ* T + U] : M ⊧ₘ* U := of_ss inferInstance (show U ⊆ T + U from by simp [Theory.add_def]) - -lemma of_add_left_left [M ⊧ₘ* T + U + V] : M ⊧ₘ* T := @of_add_left _ M _ _ T U (of_add_left M (T + U) V) - -lemma of_add_left_right [M ⊧ₘ* T + U + V] : M ⊧ₘ* U := @of_add_right _ M _ _ T U (of_add_left M (T + U) V) - -end ModelsTheory - -variable {L : Language.{u}} [L.Eq] {T : Theory L} [𝗘𝗤 ⪯ T] - -lemma EQ.provOf (φ : Sentence L) - (H : ∀ (M : Type (max u w)) - [Nonempty M] - [Structure L M] [Structure.Eq L M] - [M ⊧ₘ* T], - M ⊧ₘ φ) : - T ⊨ φ := consequence_iff_consequence.{u, w}.mp <| consequence_iff_eq.mpr fun M _ _ _ hT => - letI : Structure.Model L M ⊧ₘ* T := Structure.ElementaryEquiv.modelsTheory.mp hT - Structure.ElementaryEquiv.models.mpr (H (Structure.Model L M)) - -end LO.FirstOrder diff --git a/Foundation/FirstOrder/Completeness/CountableSublanguage.lean b/Foundation/FirstOrder/Completeness/CountableSublanguage.lean index ef0248fdc..2345c8641 100644 --- a/Foundation/FirstOrder/Completeness/CountableSublanguage.lean +++ b/Foundation/FirstOrder/Completeness/CountableSublanguage.lean @@ -169,12 +169,6 @@ end Language namespace Structure -/- -instance sublanguageStructure {pf : ∀ k, L.Func k → Prop} {pr : ∀ k, L.Rel k → Prop} - {M : Type*} (s : Structure L M) : Structure (Language.sublanguage L pf pr) M := - s.lMap (Language.unsub L) --/ - noncomputable abbrev extendStructure (Φ : L₁ →ᵥ L₂) {M : Type*} [Nonempty M] (s : Structure L₁ M) : Structure L₂ M where func {k} f₂ v := Classical.epsilon (∃ f₁ : L₁.Func k, Φ.func f₁ = f₂ ∧ · = s.func f₁ v) rel {k} r₂ v := ∃ r₁ : L₁.Rel k, Φ.rel r₁ = r₂ ∧ s.rel r₁ v diff --git a/Foundation/FirstOrder/Completeness/CounterModel.lean b/Foundation/FirstOrder/Completeness/CounterModel.lean index 177760cf5..897fe7a5e 100644 --- a/Foundation/FirstOrder/Completeness/CounterModel.lean +++ b/Foundation/FirstOrder/Completeness/CounterModel.lean @@ -11,6 +11,8 @@ public import Mathlib.Logic.Encodable.Basic @[expose] public section +/-! ### Generic filters -/ + namespace LO.FirstOrder.Derivation.Canonical open Order @@ -185,18 +187,12 @@ lemma refl (φ : Proposition K) (h : 𝐋𝐊¹ ⊬ ∼φ) : end Derivation.Canonical +/-! ### Completeness theorem -/ + namespace LK open Classical Derivation.Canonical -open LO.Entailment - -lemma satisfiable_of_irrefutable_of_countable {K : Language} [K.Encodable] - (σ : Sentence K) (h : 𝐋𝐊¹ ⊬ ∼(σ : Proposition K)) : - Satisfiable {σ} := - ⟨⟨_, inferInstance, termModelOf (ConsistentSequent.ofUnprovable σ (by simpa using h))⟩, by - simpa [models_iff] using refl (↑σ : Proposition K) (by simpa using h)⟩ - variable {L : Language} lemma satisfiable_of_irrefutable (σ : Sentence L) (h : 𝐋𝐊¹ ⊬ ∼(σ : Proposition L)) : @@ -207,7 +203,9 @@ lemma satisfiable_of_irrefutable (σ : Sentence L) (h : 𝐋𝐊¹ ⊬ ∼(σ : have : 𝐋𝐊¹ ⊢ ∼(σ : Proposition L) := by simpa [Semiformula.lMap_emb, π] using LK.Proof.lMap L.unsub h contradiction - have : Satisfiable {π} := satisfiable_of_irrefutable_of_countable π this + have : Satisfiable {π} := + ⟨⟨_, inferInstance, termModelOf (ConsistentSequent.ofUnprovable π (by simpa using this))⟩, by + simpa [models_iff] using refl (π : Proposition K) (by simpa using this)⟩ simpa [Theory.lMap, π] using satisfiable_lMap L.unsub this end LK @@ -254,7 +252,7 @@ theorem Proof.small_complete : T ⊨ φ → T ⊢ φ := Proof.complete theorem Proof.complete_iff : T ⊨ φ ↔ T ⊢ φ := ⟨fun h ↦ Proof.complete h, Proof.sound⟩ -instance Proof.isComplete (T : Theory L) : Complete T (Semantics.models (SmallStruc L) T) := ⟨Proof.complete⟩ +instance Proof.isComplete (T : Theory L) : Complete T (Semantics.models (Struc.{max u w} L) T) := ⟨Proof.complete⟩ lemma satisfiable_iff_satisfiable : Semantics.Satisfiable (Struc.{max u w} L) T ↔ Satisfiable T := by simp [satisfiable_iff_consistent.{u, w}, satisfiable_iff_consistent.{u, u}] @@ -264,4 +262,35 @@ lemma consequence_iff_consequence : T ⊨[Struc.{max u w} L] φ ↔ T ⊨ φ := end Theory +/-! ### Corollaries -/ + +namespace ModelsTheory + +variable {L : Language.{u}} (M : Type w) [Nonempty M] [Structure L M] (T U V : Theory L) + +lemma of_provably_subtheory [le : T ⪯ U] (h : M↓[L] ⊧* U) : M↓[L] ⊧* T := ⟨fun φ hφ ↦ + have : U ⊢ φ := le.pbl (Entailment.by_axm hφ) + consequence_iff'.{u, w}.mp (Theory.Proof.sound this) M⟩ + +lemma of_add_left [M↓[L] ⊧* T ∪ U] : M↓[L] ⊧* T := models_of_ss inferInstance (show T ⊆ T ∪ U from by simp) + +lemma of_add_right [M↓[L] ⊧* T ∪ U] : M↓[L] ⊧* U := models_of_ss inferInstance (show U ⊆ T ∪ U from by simp) + +end ModelsTheory + +variable {L : Language.{u}} [L.Eq] {T : Theory L} [𝗘𝗤 L ⪯ T] + +lemma Theory.Proof.complete_on_eq_models + (φ : Sentence L) + (H : ∀ (M : Type u) + [Nonempty M] + [Structure L M] [Structure.Eq L M] + [M↓[L] ⊧* T], + M↓[L] ⊧ φ) : + T ⊢ φ := + have : T ⊨ φ := Theory.consequence_iff_consequence.mp <| consequence_iff_eq.mpr fun M _ _ _ hT ↦ + letI : (Structure.Model L M)↓[L] ⊧* T := Structure.ElementaryEquiv.modelsTheory.mp hT + Structure.ElementaryEquiv.models.mpr (H (Structure.Model L M)) + Theory.Proof.complete this + end LO.FirstOrder From 8bc1aa7f19b45971d201d132181f366f1825fdb3 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Fri, 15 May 2026 22:21:51 +0900 Subject: [PATCH 51/61] refactor --- Foundation/FirstOrder/Completeness.lean | 5 + .../Completeness/CanonicalModel.lean | 331 +----------------- .../FirstOrder/Completeness/CounterModel.lean | 4 +- Foundation/FirstOrder/Hauptsatz.lean | 283 +-------------- 4 files changed, 28 insertions(+), 595 deletions(-) create mode 100644 Foundation/FirstOrder/Completeness.lean diff --git a/Foundation/FirstOrder/Completeness.lean b/Foundation/FirstOrder/Completeness.lean new file mode 100644 index 000000000..77aa99aa0 --- /dev/null +++ b/Foundation/FirstOrder/Completeness.lean @@ -0,0 +1,5 @@ +module + +public import Foundation.FirstOrder.Completeness.CanonicalModel +public import Foundation.FirstOrder.Completeness.CountableSublanguage +public import Foundation.FirstOrder.Completeness.CounterModel diff --git a/Foundation/FirstOrder/Completeness/CanonicalModel.lean b/Foundation/FirstOrder/Completeness/CanonicalModel.lean index 0ad895bda..43d16c4aa 100644 --- a/Foundation/FirstOrder/Completeness/CanonicalModel.lean +++ b/Foundation/FirstOrder/Completeness/CanonicalModel.lean @@ -1,347 +1,22 @@ module -public import Foundation.FirstOrder.NegationTranslation.GoedelGentzen +public import Foundation.FirstOrder.Hauptsatz public import Foundation.Logic.ForcingRelation @[expose] public section /-! -# Canonical model of classical first-order logic +# Canonical model for classical first-order logic Main reference: Jeremy Avigad, Algebraic proofs of cut elimination [Avi01] -/ -namespace LO.FirstOrder.Derivation +namespace LO.FirstOrder.Derivation.Canonical variable {L : Language} -inductive Positive (Ξ : Sequent L) : Sequent L → Type _ -| or : Positive Ξ (φ :: ψ :: Γ) → Positive Ξ (φ ⋎ ψ :: Γ) -| exs : Positive Ξ (φ/[t] :: Γ) → Positive Ξ ((∃⁰ φ) :: Γ) -| wk : Positive Ξ Δ → Δ ⊆ Γ → Positive Ξ Γ -| protected id : Positive Ξ Ξ - -infix:45 " ⟶⁺ " => Positive - -namespace Positive - -variable {Ξ Γ Δ : Sequent L} - -def ofSubset (ss : Ξ ⊆ Γ) : Ξ ⟶⁺ Γ := wk .id ss - -def trans {Ξ Γ Δ : Sequent L} : Ξ ⟶⁺ Γ → Γ ⟶⁺ Δ → Ξ ⟶⁺ Δ - | b, or d => or (b.trans d) - | b, exs d => exs (b.trans d) - | b, wk d h => wk (b.trans d) h - | b, .id => b - -def cons {Ξ Γ : Sequent L} (φ) : Ξ ⟶⁺ Γ → φ :: Ξ ⟶⁺ φ :: Γ - | or (Γ := Γ) (φ := ψ) (ψ := χ) d => - have : φ :: Ξ ⟶⁺ ψ :: χ :: φ :: Γ := wk (cons φ d) (by simp; tauto) - wk (or this) (by simp) - | exs (Ξ := Ξ) (Γ := Γ) (φ := ψ) (t := t) d => - have : φ :: Ξ ⟶⁺ ψ/[t] :: φ :: Γ := wk (cons φ d) (by simp) - wk this.exs (by simp) - | wk d h => wk (d.cons φ) (by simp [h]) - | .id => .id - -def append {Ξ Γ : Sequent L} : (Δ : Sequent L) → Ξ ⟶⁺ Γ → Δ ++ Ξ ⟶⁺ Δ ++ Γ - | [], d => d - | φ :: Δ, d => (d.append Δ).cons φ - -def add {Γ Δ Ξ Θ : Sequent L} : Γ ⟶⁺ Δ → Ξ ⟶⁺ Θ → Γ ++ Ξ ⟶⁺ Δ ++ Θ - | or d, b => or (d.add b) - | exs d, b => exs (d.add b) - | wk d h, b => wk (d.add b) (by simp [h]) - | .id, b => b.append Γ - -def graft {Ξ Γ : Sequent L} (b : ⊢ᴸᴷ¹ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴸᴷ¹ Γ - | or d => .or (d.graft b) - | exs d => .exs (d.graft b) - | wk d h => .wk (d.graft b) h - | .id => b - -lemma graft_isCutFree_of_isCutFree {b : ⊢ᴸᴷ¹ Ξ} {d : Ξ ⟶⁺ Γ} (hb : Derivation.IsCutFree b) : Derivation.IsCutFree (d.graft b) := by - induction d <;> simp [graft, *] - -end Positive - -namespace Canonical - -open Semiformulaᵢ - local notation "ℙ" => Sequent L -structure StrongerThan (q p : ℙ) where - val : ∼p ⟶⁺ ∼q - -scoped infix:60 " ≼ " => StrongerThan - -scoped instance : Min ℙ := ⟨fun p q ↦ p ++ q⟩ - -lemma inf_def (p q : ℙ) : p ⊓ q = p ++ q := rfl - -@[simp] lemma neg_inf_p_eq (p q : ℙ) : ∼(p ⊓ q) = ∼p ⊓ ∼q := List.map_append - -namespace StrongerThan - -protected def refl (p : ℙ) : p ≼ p := ⟨.id⟩ - -def trans {r q p : ℙ} (srq : r ≼ q) (sqp : q ≼ p) : r ≼ p := ⟨sqp.val.trans srq.val⟩ - -def ofSubset {q p : ℙ} (h : q ⊇ p) : q ≼ p := ⟨.ofSubset <| List.map_subset _ h⟩ - -def and {p : ℙ} (φ ψ : Proposition L) : φ ⋏ ψ :: p ≼ φ :: ψ :: p := ⟨.or .id⟩ - -def K_left {p : ℙ} (φ ψ : Proposition L) : φ ⋏ ψ :: p ≼ φ :: p := trans (and φ ψ) (ofSubset <| by simp) - -def K_right {p : ℙ} (φ ψ : Proposition L) : φ ⋏ ψ :: p ≼ ψ :: p := trans (and φ ψ) (ofSubset <| by simp) - -def all {p : ℙ} (φ : Semiproposition L 1) (t) : (∀⁰ φ) :: p ≼ φ/[t] :: p := ⟨.exs (t := t) (by simpa [← Semiformula.neg_eq] using .id)⟩ - -def minLeLeft (p q : ℙ) : p ⊓ q ≼ p := ofSubset (by simp [inf_def]) - -def minLeRight (p q : ℙ) : p ⊓ q ≼ q := ofSubset (by simp [inf_def]) - -def leMinOfle (srp : r ≼ p) (srq : r ≼ q) : r ≼ p ⊓ q := ⟨ - let d : ∼p ++ ∼q ⟶⁺ ∼r := .wk (srp.val.add srq.val) (by simp) - neg_inf_p_eq _ _ ▸ d⟩ - -def leMinRightOfLe (s : q ≼ p) : q ≼ p ⊓ q := leMinOfle s (.refl q) - -end StrongerThan - -def Forces (p : ℙ) : Propositionᵢ L → Type u - | ⊥ => { b : ⊢ᴸᴷ¹ ∼p // Derivation.IsCutFree b } - | .rel R v => { b : ⊢ᴸᴷ¹ .rel R v :: ∼p // Derivation.IsCutFree b } - | φ ⋏ ψ => Forces p φ × Forces p ψ - | φ ⋎ ψ => Forces p φ ⊕ Forces p ψ - | φ 🡒 ψ => (q : ℙ) → q ≼ p → Forces q φ → Forces q ψ - | ∀⁰ φ => (t : SyntacticTerm L) → Forces p (φ/[t]) - | ∃⁰ φ => (t : SyntacticTerm L) × Forces p (φ/[t]) - termination_by φ => φ.complexity - - -abbrev allForces (φ : Propositionᵢ L) := (p : ℙ) → Forces p φ - -namespace Forces - -scoped infix:45 " ⊩ " => Forces - -scoped prefix:45 "⊩ " => allForces - - -def falsumEquiv : p ⊩ ⊥ ≃ { b : ⊢ᴸᴷ¹ ∼p // Derivation.IsCutFree b} := by unfold Forces; exact .refl _ - -def relEquiv {k} {R : L.Rel k} {v} : p ⊩ .rel R v ≃ { b : ⊢ᴸᴷ¹ .rel R v :: ∼p // Derivation.IsCutFree b } := by - unfold Forces; exact .refl _ - -def andEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ ⋏ ψ ≃ (p ⊩ φ) × (p ⊩ ψ) := by - conv => - lhs - unfold Forces - exact .refl _ - -def orEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ ⋎ ψ ≃ (p ⊩ φ) ⊕ (p ⊩ ψ) := by - conv => - lhs - unfold Forces - exact .refl _ - -def implyEquiv {φ ψ : Propositionᵢ L} : p ⊩ φ 🡒 ψ ≃ ((q : ℙ) → q ≼ p → q ⊩ φ → q ⊩ ψ) := by - conv => - lhs - unfold Forces - exact .refl _ - -def allEquiv {φ} : p ⊩ ∀⁰ φ ≃ ((t : SyntacticTerm L) → Forces p (φ/[t])) := by - conv => - lhs - unfold Forces - exact .refl _ - -def exsEquiv {φ} : p ⊩ ∃⁰ φ ≃ ((t : SyntacticTerm L) × Forces p (φ/[t])) := by - conv => - lhs - unfold Forces - exact .refl _ - -def cast {p : ℙ} (f : p ⊩ φ) (s : φ = ψ) : p ⊩ ψ := s ▸ f - -def monotone {q p : ℙ} (s : q ≼ p) : {φ : Propositionᵢ L} → p ⊩ φ → q ⊩ φ - | ⊥, b => - let ⟨d, hd⟩ := b.falsumEquiv - falsumEquiv.symm ⟨s.val.graft d, Positive.graft_isCutFree_of_isCutFree hd⟩ - | .rel R v, b => - let ⟨d, hd⟩ := b.relEquiv - relEquiv.symm ⟨s.val.cons (.rel R v) |>.graft d, Positive.graft_isCutFree_of_isCutFree hd⟩ - | φ ⋏ ψ, b => andEquiv.symm ⟨monotone s b.andEquiv.1, monotone s b.andEquiv.2⟩ - | φ ⋎ ψ, b => orEquiv.symm <| b.orEquiv.rec (fun b ↦ .inl <| b.monotone s) (fun b ↦ .inr <| b.monotone s) - | φ 🡒 ψ, b => implyEquiv.symm fun r srq bφ ↦ b.implyEquiv r (srq.trans s) bφ - | ∀⁰ φ, b => allEquiv.symm fun t ↦ (b.allEquiv t).monotone s - | ∃⁰ φ, b => - let ⟨t, d⟩ : (t : SyntacticTerm L) × p ⊩ φ/[t] := b.exsEquiv - exsEquiv.symm ⟨t, d.monotone s⟩ - termination_by φ => φ.complexity - -def explosion {p : ℙ} (b : p ⊩ ⊥) : (φ : Propositionᵢ L) → p ⊩ φ - | ⊥ => b - | .rel R v => - let ⟨d, hd⟩ := b.falsumEquiv - relEquiv.symm ⟨.wk d (by simp), by simp [hd]⟩ - | φ ⋏ ψ => andEquiv.symm ⟨b.explosion φ, b.explosion ψ⟩ - | φ ⋎ ψ => orEquiv.symm <| .inl <| b.explosion φ - | φ 🡒 ψ => implyEquiv.symm fun q sqp dφ ↦ (b.monotone sqp).explosion ψ - | ∀⁰ φ => allEquiv.symm fun t ↦ b.explosion (φ/[t]) - | ∃⁰ φ => exsEquiv.symm ⟨default, b.explosion (φ/[default])⟩ - termination_by φ => φ.complexity - -def efq (φ : Propositionᵢ L) : ⊩ ⊥ 🡒 φ := fun _ ↦ implyEquiv.symm fun _ _ d ↦ d.explosion φ - -def implyOf {φ ψ : Propositionᵢ L} (b : (q : ℙ) → q ⊩ φ → p ⊓ q ⊩ ψ) : - p ⊩ φ 🡒 ψ := implyEquiv.symm fun q sqp fφ ↦ - let fψ : p ⊓ q ⊩ ψ := b q fφ - fψ.monotone (StrongerThan.leMinRightOfLe sqp) - -open LawfulSyntacticRewriting - -def modusPonens {φ ψ : Propositionᵢ L} (f : p ⊩ φ 🡒 ψ) (g : p ⊩ φ) : p ⊩ ψ := - f.implyEquiv p (StrongerThan.refl p) g - -def sound {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢! φ → ⊩ φ - | .mdp (φ := ψ) b d => fun p ↦ - let b : p ⊩ ψ 🡒 φ := sound b p - let d : p ⊩ ψ := sound d p - b.implyEquiv p (StrongerThan.refl p) d - | .gen (φ := φ) b => fun p ↦ allEquiv.symm fun t ↦ - let d : 𝗠𝗶𝗻¹ ⊢! φ/[t] := - HilbertProofᵢ.cast (HilbertProofᵢ.rewrite (t :>ₙ fun x ↦ &x) b) (by simp [rewrite_free_eq_subst]) - sound d p - | .verum => fun p ↦ implyEquiv.symm fun q sqp bφ ↦ bφ - | .implyK φ ψ => fun p ↦ implyEquiv.symm fun q sqp bφ ↦ implyEquiv.symm fun r srq bψ ↦ bφ.monotone srq - | .implyS φ ψ χ => fun p ↦ - implyEquiv.symm fun q sqp b₁ ↦ - implyEquiv.symm fun r srq b₂ ↦ - implyEquiv.symm fun s ssr b₃ ↦ - let d₁ : s ⊩ ψ 🡒 χ := b₁.implyEquiv s (ssr.trans srq) b₃ - let d₂ : s ⊩ ψ := b₂.implyEquiv s ssr b₃ - d₁.implyEquiv s (StrongerThan.refl s) d₂ - | .and₁ φ ψ => fun p ↦ - implyEquiv.symm fun q sqp b ↦ - let ⟨dφ, dψ⟩ : q ⊩ φ × q ⊩ ψ := b.andEquiv - dφ - | .and₂ φ ψ => fun p ↦ - implyEquiv.symm fun q sqp b ↦ - let ⟨dφ, dψ⟩ : q ⊩ φ × q ⊩ ψ := b.andEquiv - dψ - | .and₃ φ ψ => fun p ↦ - implyEquiv.symm fun q sqp bφ ↦ - implyEquiv.symm fun r srq bψ ↦ - andEquiv.symm ⟨bφ.monotone srq, bψ⟩ - | .or₁ φ ψ => fun p ↦ - implyEquiv.symm fun q sqp bφ ↦ orEquiv.symm <| .inl bφ - | .or₂ φ ψ => fun p ↦ - implyEquiv.symm fun q sqp bψ ↦ orEquiv.symm <| .inr bψ - | .or₃ φ ψ χ => fun p ↦ - implyEquiv.symm fun q sqp bφχ ↦ - implyEquiv.symm fun r srq bψχ ↦ - implyEquiv.symm fun s ssr b ↦ - let d : s ⊩ φ ⊕ s ⊩ ψ := b.orEquiv - d.rec - (fun dφ ↦ bφχ.implyEquiv s (ssr.trans srq) dφ) - (fun dψ ↦ bψχ.implyEquiv s ssr dψ) - | .all₁ φ t => fun p ↦ implyEquiv.symm fun q sqp b ↦ b.allEquiv t - | .all₂ φ ψ => fun p ↦ - implyEquiv.symm fun q sqp b ↦ - implyEquiv.symm fun r srq bφ ↦ - allEquiv.symm fun t ↦ - let d : q ⊩ φ 🡒 ψ/[t] := by simpa using (b.allEquiv t) - d.implyEquiv r srq bφ - | .ex₁ t φ => fun p ↦ - implyEquiv.symm fun q sqp bφ ↦ exsEquiv.symm ⟨t, bφ⟩ - | .ex₂ φ ψ => fun p ↦ - implyEquiv.symm fun q sqp b ↦ - implyEquiv.symm fun r srq bφ ↦ - let ⟨t, dt⟩ : (t : SyntacticTerm L) × r ⊩ φ/[t] := bφ.exsEquiv - let d : q ⊩ φ/[t] 🡒 ψ := by simpa using b.allEquiv t - d.implyEquiv r srq dt - termination_by b => HilbertProofᵢ.depth b - -def relRefl {k} (R : L.Rel k) (v : Fin k → SyntacticTerm L) : [.rel R v] ⊩ rel R v := - relEquiv.symm ⟨Derivation.identity _ _, by simp⟩ - -protected def refl.or (ihφ : [φ] ⊩ φᴺ) (ihψ : [ψ] ⊩ ψᴺ) : [φ ⋎ ψ] ⊩ (φ ⋎ ψ)ᴺ := - implyOf fun q dq ↦ - let ⟨dφ, dψ⟩ : q ⊩ ∼φᴺ × q ⊩ ∼ψᴺ := dq.andEquiv - let ihφ : [φ] ⊩ φᴺ := ihφ - let ihψ : [ψ] ⊩ ψᴺ := ihψ - let bφ : [φ] ⊓ q ⊩ ⊥ := dφ.implyEquiv ([φ] ⊓ q) (.minLeRight _ _) (ihφ.monotone (.minLeLeft _ _)) - let bψ : [ψ] ⊓ q ⊩ ⊥ := dψ.implyEquiv ([ψ] ⊓ q) (.minLeRight _ _) (ihψ.monotone (.minLeLeft _ _)) - let ⟨bbφ, hbbφ⟩ := bφ.falsumEquiv - let ⟨bbψ, hbbψ⟩ := bψ.falsumEquiv - let band : ⊢ᴸᴷ¹ ∼φ ⋏ ∼ψ :: ∼q := Derivation.and - (Derivation.cast bbφ (by simp [inf_def])) (Derivation.cast bbψ (by simp [inf_def])) - falsumEquiv.symm ⟨Derivation.cast band (by simp [inf_def]), by simp [band, hbbφ, hbbψ]⟩ - -set_option backward.isDefEq.respectTransparency false in -protected def refl.exs (d : ∀ x, [φ/[&x]] ⊩ (φ/[&x])ᴺ) : [∃⁰ φ] ⊩ (∃⁰ φ)ᴺ := - implyOf fun q f ↦ - let x := Sequent.newVar ((∀⁰ ∼φ) :: ∼q) - let ih : [φ/[&x]] ⊩ φᴺ/[&x] := cast (d x) (by simp [Semiformula.subst_doubleNegation]) - let b : [φ/[&x]] ⊓ q ⊩ ⊥ := - (f.allEquiv &x).implyEquiv ([φ/[&x]] ⊓ q) (StrongerThan.minLeRight _ _) (ih.monotone (StrongerThan.minLeLeft _ _)) - let ⟨b, hb⟩ := b.falsumEquiv - let ba : ⊢ᴸᴷ¹ (∀⁰ ∼φ) :: ∼q := - Derivation.genelalizeByNewver (m := x) - (by have : ¬Semiformula.FVar? (∀⁰ ∼φ) x := Sequent.not_fvar?_newVar (by simp) - simpa using this) - (fun ψ hψ ↦ Sequent.not_fvar?_newVar (List.mem_cons_of_mem (∀⁰ ∼φ) hψ)) - (Derivation.cast b (by simp [inf_def])) - falsumEquiv.symm ⟨ba, by simp [ba, hb]⟩ - -set_option backward.isDefEq.respectTransparency false in -protected def refl : (φ : Proposition L) → [φ] ⊩ φᴺ - | ⊤ => implyEquiv.symm fun q sqp dφ ↦ dφ - | ⊥ => falsumEquiv.symm ⟨Derivation.verum, by simp⟩ - | .rel R v => implyOf fun q dq ↦ - let b : [.rel R v] ⊓ q ⊩ rel R v := (relRefl R v).monotone (StrongerThan.minLeLeft _ _) - dq.implyEquiv ([.rel R v] ⊓ q) (StrongerThan.minLeRight _ _) b - | .nrel R v => implyOf fun q dq ↦ - let ⟨d, hd⟩ := dq.relEquiv - falsumEquiv.symm ⟨Derivation.cast d (by simp [inf_def]), by simp [hd]⟩ - | φ ⋏ ψ => - let ihφ : [φ] ⊩ φᴺ := Forces.refl φ - let ihψ : [ψ] ⊩ ψᴺ := Forces.refl ψ - andEquiv.symm ⟨ihφ.monotone (.K_left φ ψ), ihψ.monotone (.K_right φ ψ)⟩ - | φ ⋎ ψ => refl.or (Forces.refl φ) (Forces.refl ψ) - | ∀⁰ φ => allEquiv.symm fun t ↦ - let b : [φ/[t]] ⊩ φᴺ/[t] := by simpa [Semiformula.rew_doubleNegation] using Forces.refl (φ/[t]) - b.monotone (StrongerThan.all φ t) - | ∃⁰ φ => refl.exs fun x ↦ Forces.refl (φ/[&x]) - termination_by φ => φ.complexity - -def conj : {Γ : Sequentᵢ L} → (b : (φ : Propositionᵢ L) → φ ∈ Γ → p ⊩ φ) → p ⊩ ⋀Γ - | [], _ => implyEquiv.symm fun q sqp bφ ↦ bφ - | [φ], b => b φ (by simp) - | φ :: ψ :: Γ, b => andEquiv.symm ⟨b φ (by simp), conj (fun χ hχ ↦ b χ (List.mem_cons_of_mem φ hχ))⟩ - -def conj' : {Γ : Sequent L} → (b : (φ : Proposition L) → φ ∈ Γ → p ⊩ φᴺ) → p ⊩ ⋀Γᴺ - | [], _ => implyEquiv.symm fun q sqp bφ ↦ bφ - | [φ], b => b φ (by simp) - | φ :: ψ :: Γ, b => andEquiv.symm ⟨b φ (by simp), conj' (fun χ hχ ↦ b χ (List.mem_cons_of_mem φ hχ))⟩ - -end Forces - -/-- Cut elimination theorem of $\mathbf{LK}$. -/ -def hauptsatz [L.DecidableEq] {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → {d : ⊢ᴸᴷ¹ Γ // Derivation.IsCutFree d} := fun d ↦ - let d : 𝗠𝗶𝗻¹ ⊢! ⋀(∼Γ)ᴺ 🡒 ⊥ := Entailment.FiniteContext.toDef (Derivation.gödelGentzen d) - let ff : Forces (∼Γ) (⋀(∼Γ)ᴺ 🡒 ⊥) := Forces.sound d (∼Γ) - let fc : Forces (∼Γ) (⋀(∼Γ)ᴺ) := Forces.conj' fun φ hφ ↦ - (Forces.refl φ).monotone (StrongerThan.ofSubset <| List.cons_subset.mpr ⟨hφ, by simp⟩) - let b : Forces (∼Γ) ⊥ := ff.modusPonens fc - let ⟨b, hb⟩ := b.falsumEquiv - ⟨Derivation.cast b (by simp), by simp [hb]⟩ - instance : LE ℙ := ⟨fun q p ↦ Nonempty (q ≼ p)⟩ instance : Preorder ℙ where diff --git a/Foundation/FirstOrder/Completeness/CounterModel.lean b/Foundation/FirstOrder/Completeness/CounterModel.lean index 897fe7a5e..83ef52698 100644 --- a/Foundation/FirstOrder/Completeness/CounterModel.lean +++ b/Foundation/FirstOrder/Completeness/CounterModel.lean @@ -237,6 +237,7 @@ lemma satisfiable_iff_consistent : exact satisfiable_iff.mpr ⟨ULift.{w} M, inferInstance, inferInstance, ((uLift_elementaryEquiv L M).modelsTheory).mpr h⟩ +/-- Completeness theorem (II) -/ theorem Proof.complete : T ⊨[Struc.{max u w} L] φ → T ⊢ φ := by contrapose! @@ -247,7 +248,6 @@ theorem Proof.complete : have : ¬M↓[L] ⊧ φ ∧ M↓[L] ⊧* T := by simpa using hM simpa [consequence_iff] using ⟨M, i.some, s, this.2, this.1⟩ -/-- Completeness theorem (II) -/ theorem Proof.small_complete : T ⊨ φ → T ⊢ φ := Proof.complete theorem Proof.complete_iff : T ⊨ φ ↔ T ⊢ φ := ⟨fun h ↦ Proof.complete h, Proof.sound⟩ @@ -282,7 +282,7 @@ variable {L : Language.{u}} [L.Eq] {T : Theory L} [𝗘𝗤 L ⪯ T] lemma Theory.Proof.complete_on_eq_models (φ : Sentence L) - (H : ∀ (M : Type u) + (H : ∀ (M : Type (max u v)) [Nonempty M] [Structure L M] [Structure.Eq L M] [M↓[L] ⊧* T], diff --git a/Foundation/FirstOrder/Hauptsatz.lean b/Foundation/FirstOrder/Hauptsatz.lean index 70b8c3d6c..7f3c48edc 100644 --- a/Foundation/FirstOrder/Hauptsatz.lean +++ b/Foundation/FirstOrder/Hauptsatz.lean @@ -1,87 +1,28 @@ module public import Foundation.FirstOrder.NegationTranslation.GoedelGentzen -public import Foundation.Logic.ForcingRelation -public import Foundation.Vorspiel.Order.Preorder @[expose] public section + /-! -# Algebraic proofs of cut elimination +# Hauptsatz of classical first-order logic Main reference: Jeremy Avigad, Algebraic proofs of cut elimination [Avi01] -/ -namespace LO.FirstOrder - -variable {L : Language.{u}} - -namespace Derivation - -inductive IsCutFree : {Γ : Sequent L} → ⊢ᴸᴷ¹ Γ → Prop -| axL (r : L.Rel k) (v) : IsCutFree (identity r v) -| verum : IsCutFree verum -| or {d : ⊢ᴸᴷ¹ φ :: ψ :: Γ} : IsCutFree d → IsCutFree d.or -| and {dφ : ⊢ᴸᴷ¹ φ :: Γ} {dψ : ⊢ᴸᴷ¹ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) -| all {d : ⊢ᴸᴷ¹ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all -| exs (t) {d : ⊢ᴸᴷ¹ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs -| wk {d : ⊢ᴸᴷ¹ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) - -attribute [simp] IsCutFree.axL IsCutFree.verum +namespace LO.FirstOrder.Derivation -variable {Γ Δ : Sequent L} +variable {L : Language} -@[simp] lemma isCutFree_or_iff {d : ⊢ᴸᴷ¹ φ :: ψ :: Γ} : - IsCutFree d.or ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .or⟩ +inductive Positive (Ξ : Sequent L) : Sequent L → Type _ +| or : Positive Ξ (φ :: ψ :: Γ) → Positive Ξ (φ ⋎ ψ :: Γ) +| exs : Positive Ξ (φ/[t] :: Γ) → Positive Ξ ((∃⁰ φ) :: Γ) +| wk : Positive Ξ Δ → Δ ⊆ Γ → Positive Ξ Γ +| protected id : Positive Ξ Ξ -@[simp] lemma isCutFree_and_iff {dφ : ⊢ᴸᴷ¹ φ :: Γ} {dψ : ⊢ᴸᴷ¹ ψ :: Γ} : - IsCutFree (dφ.and dψ) ↔ IsCutFree dφ ∧ IsCutFree dψ := - ⟨by rintro ⟨⟩; constructor <;> assumption, by intro ⟨hφ, hψ⟩; exact hφ.and hψ⟩ +infix:45 " ⟶⁺ " => Positive -@[simp] lemma isCutFree_all_iff {d : ⊢ᴸᴷ¹ Rewriting.free φ :: Γ⁺} : - IsCutFree d.all ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .all⟩ - -@[simp] lemma isCutFree_exs_iff {d : ⊢ᴸᴷ¹ φ/[t] :: Γ} : - IsCutFree d.exs ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .exs t⟩ - -@[simp] lemma isCutFree_wk_iff {d : ⊢ᴸᴷ¹ Δ} {ss : Δ ⊆ Γ} : - IsCutFree (d.wk ss) ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .wk _⟩ - -@[simp] lemma IsCutFree.cast {d : ⊢ᴸᴷ¹ Γ} {e : Γ = Δ} : - IsCutFree (.cast d e) ↔ IsCutFree d := by rcases e; rfl - -@[simp] lemma IsCutFree.not_cut (dp : ⊢ᴸᴷ¹ φ :: Γ) (dn : ⊢ᴸᴷ¹ ∼φ :: Δ) : ¬IsCutFree (dp.cut dn) := by - intro h - refine h.rec - (motive := fun {_} d _ => - match d with - | .cut _ _ => False - | _ => True) - ?_ ?_ ?_ ?_ ?_ ?_ ?_ - all_goals simp - -set_option backward.isDefEq.respectTransparency false in -@[simp] lemma isCutFree_rewrite_iff_isCutFree {f : ℕ → SyntacticTerm L} {d : ⊢ᴸᴷ¹ Γ} : - IsCutFree (rewrite f d) ↔ IsCutFree d := by - induction d generalizing f <;> simp [rewrite, *] - -@[simp] lemma isCutFree_map_iff_isCutFree {f : ℕ → ℕ} {d : ⊢ᴸᴷ¹ Γ} : - IsCutFree (Derivation.map d f) ↔ IsCutFree d := isCutFree_rewrite_iff_isCutFree - -set_option backward.isDefEq.respectTransparency false in -@[simp] lemma IsCutFree.genelalizeByNewver_isCutFree {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ ψ ∈ Δ, ¬ψ.FVar? m) - (d : ⊢ᴸᴷ¹ φ/[&m] :: Δ) : IsCutFree (genelalizeByNewver hp hΔ d) ↔ IsCutFree d := by simp [genelalizeByNewver] - -end Derivation - -inductive PositiveDerivationFrom (Ξ : Sequent L) : Sequent L → Type _ -| or : PositiveDerivationFrom Ξ (φ :: ψ :: Γ) → PositiveDerivationFrom Ξ (φ ⋎ ψ :: Γ) -| exs : PositiveDerivationFrom Ξ (φ/[t] :: Γ) → PositiveDerivationFrom Ξ ((∃⁰ φ) :: Γ) -| wk : PositiveDerivationFrom Ξ Δ → Δ ⊆ Γ → PositiveDerivationFrom Ξ Γ -| protected id : PositiveDerivationFrom Ξ Ξ - -infix:45 " ⟶⁺ " => PositiveDerivationFrom - -namespace PositiveDerivationFrom +namespace Positive variable {Ξ Γ Δ : Sequent L} @@ -122,9 +63,9 @@ def graft {Ξ Γ : Sequent L} (b : ⊢ᴸᴷ¹ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴸᴷ lemma graft_isCutFree_of_isCutFree {b : ⊢ᴸᴷ¹ Ξ} {d : Ξ ⟶⁺ Γ} (hb : Derivation.IsCutFree b) : Derivation.IsCutFree (d.graft b) := by induction d <;> simp [graft, *] -end PositiveDerivationFrom +end Positive -namespace Hauptsatz +namespace Canonical open Semiformulaᵢ @@ -229,10 +170,10 @@ def cast {p : ℙ} (f : p ⊩ φ) (s : φ = ψ) : p ⊩ ψ := s ▸ f def monotone {q p : ℙ} (s : q ≼ p) : {φ : Propositionᵢ L} → p ⊩ φ → q ⊩ φ | ⊥, b => let ⟨d, hd⟩ := b.falsumEquiv - falsumEquiv.symm ⟨s.val.graft d, PositiveDerivationFrom.graft_isCutFree_of_isCutFree hd⟩ + falsumEquiv.symm ⟨s.val.graft d, Positive.graft_isCutFree_of_isCutFree hd⟩ | .rel R v, b => let ⟨d, hd⟩ := b.relEquiv - relEquiv.symm ⟨s.val.cons (.rel R v) |>.graft d, PositiveDerivationFrom.graft_isCutFree_of_isCutFree hd⟩ + relEquiv.symm ⟨s.val.cons (.rel R v) |>.graft d, Positive.graft_isCutFree_of_isCutFree hd⟩ | φ ⋏ ψ, b => andEquiv.symm ⟨monotone s b.andEquiv.1, monotone s b.andEquiv.2⟩ | φ ⋎ ψ, b => orEquiv.symm <| b.orEquiv.rec (fun b ↦ .inl <| b.monotone s) (fun b ↦ .inr <| b.monotone s) | φ 🡒 ψ, b => implyEquiv.symm fun r srq bφ ↦ b.implyEquiv r (srq.trans s) bφ @@ -390,7 +331,8 @@ def conj' : {Γ : Sequent L} → (b : (φ : Proposition L) → φ ∈ Γ → p end Forces -def main [L.DecidableEq] {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → {d : ⊢ᴸᴷ¹ Γ // Derivation.IsCutFree d} := fun d ↦ +/-- Cut elimination theorem of $\mathbf{LK}$. -/ +def hauptsatz [L.DecidableEq] {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → {d : ⊢ᴸᴷ¹ Γ // Derivation.IsCutFree d} := fun d ↦ let d : 𝗠𝗶𝗻¹ ⊢! ⋀(∼Γ)ᴺ 🡒 ⊥ := Entailment.FiniteContext.toDef (Derivation.gödelGentzen d) let ff : Forces (∼Γ) (⋀(∼Γ)ᴺ 🡒 ⊥) := Forces.sound d (∼Γ) let fc : Forces (∼Γ) (⋀(∼Γ)ᴺ) := Forces.conj' fun φ hφ ↦ @@ -399,193 +341,4 @@ def main [L.DecidableEq] {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → {d : ⊢ᴸᴷ¹ let ⟨b, hb⟩ := b.falsumEquiv ⟨Derivation.cast b (by simp), by simp [hb]⟩ - - -instance : LE ℙ := ⟨fun q p ↦ Nonempty (q ≼ p)⟩ - -instance : Preorder ℙ where - le_refl p := ⟨StrongerThan.refl p⟩ - le_trans p q r := by - rintro ⟨hqp⟩ ⟨hrq⟩ - exact ⟨StrongerThan.trans hqp hrq⟩ - -abbrev IsForced (p : ℙ) (φ : Propositionᵢ L) := Nonempty (Forces p φ) - -instance : ForcingRelation ℙ (Propositionᵢ L) where - Forces := IsForced - -namespace IsForced - -open Classical - -@[simp] lemma rel {p : ℙ} {k} {R : L.Rel k} {v} : p ⊩ .rel R v ↔ Nonempty (⊢ᴸᴷ¹ .rel R v :: ∼p) := by - constructor - · rintro ⟨b⟩ - have ⟨d, hd⟩ := b.relEquiv - exact ⟨d⟩ - · rintro ⟨d⟩ - let ⟨b, hb⟩ := main d - exact ⟨Forces.relEquiv.symm ⟨b, hb⟩⟩ - -@[simp] lemma fal {p : ℙ} : p ⊩ ∀⁰ φ ↔ ∀ t, p ⊩ φ/[t] := by - constructor - · rintro ⟨b⟩ t - exact ⟨b.allEquiv t⟩ - · rintro h - exact ⟨Forces.allEquiv.symm fun t ↦ (h t).some⟩ - -@[simp] lemma and {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ ⋏ ψ ↔ p ⊩ φ ∧ p ⊩ ψ := by - constructor - · rintro ⟨b⟩ - have ⟨bφ, bψ⟩ := b.andEquiv - exact ⟨⟨bφ⟩, ⟨bψ⟩⟩ - · rintro ⟨⟨bφ⟩, ⟨bψ⟩⟩ - exact ⟨Forces.andEquiv.symm ⟨bφ, bψ⟩⟩ - -@[simp] lemma or {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ ⋎ ψ ↔ p ⊩ φ ∨ p ⊩ ψ := by - constructor - · rintro ⟨b⟩ - have b' := b.orEquiv - exact b'.rec (fun bφ ↦ .inl ⟨bφ⟩) (fun bψ ↦ .inr ⟨bψ⟩) - · rintro (⟨⟨hφ⟩⟩ | ⟨⟨hψ⟩⟩) - · exact ⟨Forces.orEquiv.symm <| .inl hφ⟩ - · exact ⟨Forces.orEquiv.symm <| .inr hψ⟩ - -lemma imply {p : ℙ} {φ ψ : Propositionᵢ L} : p ⊩ φ 🡒 ψ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ψ) := by - constructor - · rintro ⟨b⟩ q ⟨sqp⟩ ⟨bφ⟩ - exact ⟨b.implyEquiv _ sqp bφ⟩ - · rintro h - refine ⟨Forces.implyEquiv.symm fun q sqp hφ ↦ (h q ⟨sqp⟩ ⟨hφ⟩).some⟩ - -@[simp] lemma exs {p : ℙ} : p ⊩ ∃⁰ φ ↔ ∃ t, p ⊩ φ/[t] := by - constructor - · rintro ⟨b⟩ - have ⟨t, f⟩ := b.exsEquiv - exact ⟨t, ⟨f⟩⟩ - · rintro ⟨t, h⟩ - exact ⟨Forces.exsEquiv.symm ⟨t, h.some⟩⟩ - -lemma falsum {p : ℙ} : p ⊩ ⊥ ↔ Nonempty (⊢ᴸᴷ¹ ∼p) := by - constructor - · rintro ⟨b⟩ - have ⟨d, hd⟩ := b.falsumEquiv - exact ⟨d⟩ - · rintro ⟨d⟩ - let ⟨b, hb⟩ := main d - exact ⟨Forces.falsumEquiv.symm ⟨b, hb⟩⟩ - -lemma neg {p : ℙ} {φ : Propositionᵢ L} : p ⊩ ∼φ ↔ (∀ q ≤ p, q ⊩ φ → q ⊩ ⊥) := by - simp [Semiformulaᵢ.neg_def, imply] - -lemma monotone {p q : ℙ} (hqp : q ≤ p) {φ : Propositionᵢ L} (hφ : p ⊩ φ) : q ⊩ φ := - ⟨Forces.monotone hqp.some hφ.some⟩ - -instance : ForcingRelation.PreIntKripke ℙ (· ≥ ·) where - verum _ := ⟨Forces.implyEquiv.symm fun _ _ d ↦ d⟩ - and _ := and - or _ := or - imply _ := imply - monotone hφ _ hpq := hφ.monotone hpq - -lemma efq {p : ℙ} (h : p ⊩ ⊥) (φ : Propositionᵢ L) : p ⊩ φ := by - have : p ⊩ ⊥ 🡒 φ := ⟨Forces.efq φ p⟩ - exact imply.mp this p (by simp) h - -lemma sound_minimal {φ : Propositionᵢ L} : 𝗠𝗶𝗻¹ ⊢ φ → ℙ ∀⊩ φ := by - rintro ⟨d⟩ p; exact ⟨Forces.sound d p⟩ - -lemma dn_neg_iff {φ : Proposition L} {p : ℙ} : p ⊩ (∼φ)ᴺ ↔ p ⊩ ∼(φᴺ) := by - have := by simpa using (sound_minimal (Derivation.neg_doubleNegation φ) p) - exact (this p (by simp)).symm - -protected lemma refl (φ : Proposition L) : [φ] ⊩ φᴺ := ⟨Forces.refl φ⟩ - -lemma complete {φ : Proposition L} : ℙ ∀⊩ φᴺ ↔ 𝐋𝐊¹ ⊢ φ := by - constructor - · intro h - have hn : [∼φ] ⊩ ∼(φᴺ) := by simpa [dn_neg_iff] using (IsForced.refl (∼φ)) - have hp : [∼φ] ⊩ φᴺ := h [∼φ] - have : 𝐋𝐊¹ ⊢ φ := by simpa using falsum.mp <| neg.mp hn [∼φ] (by simp) hp - exact this - · intro b - exact sound_minimal <| Provable.gödel_gentzen b - -end IsForced - -variable (L) - -def ConsistentSequent := {Γ : Sequent L // IsEmpty (⊢ᴸᴷ¹ ∼Γ)} - -local notation "ℂ" => ConsistentSequent L - -variable {L} - -namespace ConsistentSequent - -instance : Preorder ℂ where - le q p := q.val ≤ p.val - le_refl p := by simp - le_trans p q r := le_trans - -end ConsistentSequent - -def hValue (φ : Propositionᵢ L) : LowerSet ℂ where - carrier := { p | p.val ⊩ φ } - lower' := fun _ _ hqp hp ↦ IsForced.monotone hqp hp - -scoped prefix:max "♯" => hValue - -@[simp] lemma mem_hValue {p : ℂ} {φ : Propositionᵢ L} : p ∈ ♯φ ↔ p.val ⊩ φ := by simp [hValue] - -@[simp] lemma hValue_and_eq_inf {φ ψ : Propositionᵢ L} : ♯(φ ⋏ ψ) = (♯φ ⊓ ♯ψ) := by - ext p; simp [hValue] - -@[simp] lemma hValue_or_eq_sup {φ ψ : Propositionᵢ L} : ♯(φ ⋎ ψ) = (♯φ ⊔ ♯ψ) := by - ext p; simp [hValue] - -@[simp] lemma hValue_fal_eq_Inf {φ : Semipropositionᵢ L 1} : ♯(∀⁰ φ) = ⨅ t, ♯(φ/[t]) := by - ext p; simp [hValue,] - -@[simp] lemma hValue_exs_eq_Sup {φ : Semipropositionᵢ L 1} : ♯(∃⁰ φ) = ⨆ t, ♯(φ/[t]) := by - ext p; simp [hValue,] - -@[simp] lemma hValue_falsum : ♯(⊥ : Propositionᵢ L) = ⊥ := by - ext p; simp [hValue, IsForced.falsum, p.prop] - -@[simp] lemma hValue_imply_eq_himp {φ ψ : Propositionᵢ L} : ♯(φ 🡒 ψ) = (♯φ ⇨ ♯ψ) := by - ext p - suffices (∀ q ≤ p.val, q ⊩ φ → q ⊩ ψ) ↔ ∀ q ≤ p, q.val ⊩ φ → q.val ⊩ ψ by - simpa [IsForced.imply, LowerSet.mem_himp_iff] - constructor - · intro h q hqp hqφ - exact h q.val hqp hqφ - · intro h q hqp hqφ - by_cases! hq : IsEmpty (⊢ᴸᴷ¹ ∼q) - · exact h ⟨q, hq⟩ hqp hqφ - · exact IsForced.efq (p := q) (by simp [IsForced.falsum, hq]) ψ - -@[simp] lemma hValue_neg_eq_himp_bot (φ : Propositionᵢ L) : ♯(∼φ) = (♯φ)ᶜ := by - simp [Semiformulaᵢ.neg_def] - -lemma eq_top_iff_provable {φ : Proposition L} : ♯φᴺ = ⊤ ↔ 𝐋𝐊¹ ⊢ φ := calc - ♯φᴺ = ⊤ ↔ ⊤ ≤ ♯φᴺ := by simp only [top_le_iff] - _ ↔ (∀ p : ℂ, p.val ⊩ φᴺ) := by simp [SetLike.le_def] - _ ↔ ℙ ∀⊩ φᴺ := by - constructor - · intro h p - by_cases! hp : IsEmpty (⊢ᴸᴷ¹ ∼p) - · exact h ⟨p, hp⟩ - · exact IsForced.efq (p := p) (by simp [IsForced.falsum, hp]) φᴺ - · intro h p; exact h p.val - _ ↔ 𝐋𝐊¹ ⊢ φ := IsForced.complete - -lemma lt_top_iff_provable {φ : Proposition L} : ♯φᴺ < ⊤ ↔ 𝐋𝐊¹ ⊬ φ := by - simp [Entailment.Unprovable, ←eq_top_iff_provable, lt_top_iff_ne_top] - - -end Hauptsatz - -alias hauptsatz := Hauptsatz.main - -end LO.FirstOrder +end Canonical From 6632f0a99deab1557968f5bfe12bc6fbc9eaa42a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Palalansouk=C3=AE?= Date: Thu, 25 Jun 2026 04:04:01 +0900 Subject: [PATCH 52/61] Change bootstrapping 2 (#825) --- Foundation.lean | 10 +- .../Arithmetic/Basic/Hierarchy.lean | 4 +- .../FirstOrder/Arithmetic/Basic/Misc.lean | 12 +- .../FirstOrder/Arithmetic/Basic/Model.lean | 62 ++--- .../FirstOrder/Arithmetic/Basic/Monotone.lean | 6 +- .../Arithmetic/Definability/Absoluteness.lean | 64 ++--- .../Definability/BoundedDefinable.lean | 54 ++-- .../Arithmetic/Definability/Definable.lean | 90 +++++-- .../Arithmetic/Definability/Hierarchy.lean | 32 +-- .../Arithmetic/Exponential/Bit.lean | 34 +-- .../Arithmetic/Exponential/Exp.lean | 8 +- .../Arithmetic/Exponential/Log.lean | 8 +- .../Arithmetic/Exponential/PPow2.lean | 6 +- .../Arithmetic/Exponential/Pow2.lean | 9 +- .../FirstOrder/Arithmetic/HFS/Basic.lean | 61 ++++- .../FirstOrder/Arithmetic/HFS/Coding.lean | 2 +- .../FirstOrder/Arithmetic/HFS/Fixpoint.lean | 20 +- Foundation/FirstOrder/Arithmetic/HFS/PRF.lean | 12 +- Foundation/FirstOrder/Arithmetic/HFS/Seq.lean | 2 +- Foundation/FirstOrder/Arithmetic/HFS/Vec.lean | 6 +- .../FirstOrder/Arithmetic/IOpen/Basic.lean | 42 +-- .../FirstOrder/Arithmetic/Induction.lean | 8 +- .../FirstOrder/Arithmetic/Omega1/Basic.lean | 22 +- .../FirstOrder/Arithmetic/Omega1/Nuon.lean | 12 +- .../Arithmetic/PeanoMinus/Basic.lean | 77 +++--- .../Arithmetic/PeanoMinus/Functions.lean | 6 +- .../FirstOrder/Arithmetic/PeanoMinus/Q.lean | 17 +- Foundation/FirstOrder/Arithmetic/Q/Basic.lean | 38 +-- .../FirstOrder/Arithmetic/R0/Basic.lean | 105 ++++---- .../Arithmetic/R0/Representation.lean | 39 ++- .../FirstOrder/Arithmetic/Schemata.lean | 158 ++++++------ .../FirstOrder/Arithmetic/TA/Basic.lean | 12 +- .../FirstOrder/Arithmetic/TA/Nonstandard.lean | 30 +-- Foundation/FirstOrder/Basic/Calculus.lean | 62 +++-- Foundation/FirstOrder/Basic/Calculus2.lean | 208 ++++++++++----- Foundation/FirstOrder/Basic/CutFree.lean | 6 +- Foundation/FirstOrder/Basic/Definability.lean | 13 + Foundation/FirstOrder/Basic/Operator.lean | 47 ++-- .../FirstOrder/Basic/Semantics/Semantics.lean | 6 +- Foundation/FirstOrder/Basic/Soundness.lean | 2 +- .../FirstOrder/Basic/Syntax/Formula.lean | 2 +- .../DerivabilityCondition/D1.lean | 12 +- .../DerivabilityCondition/D2.lean | 10 +- .../DerivabilityCondition/D3.lean | 60 ++--- .../EquationalTheory.lean | 31 +-- .../DerivabilityCondition/PeanoMinus.lean | 62 ++--- .../FirstOrder/Bootstrapping/FixedPoint.lean | 38 +-- .../Bootstrapping/Syntax/Formula/Basic.lean | 6 +- .../Bootstrapping/Syntax/Formula/Coding.lean | 14 +- .../Syntax/Formula/Functions.lean | 2 +- .../Syntax/Formula/Iteration.lean | 2 +- .../Bootstrapping/Syntax/Formula/Typed.lean | 4 +- .../Bootstrapping/Syntax/Language.lean | 12 +- .../Bootstrapping/Syntax/Proof/Basic.lean | 242 +++++++++--------- .../Bootstrapping/Syntax/Proof/Coding.lean | 75 +++--- .../Bootstrapping/Syntax/Proof/Typed.lean | 78 +++--- .../Bootstrapping/Syntax/Term/Basic.lean | 13 +- .../Bootstrapping/Syntax/Term/Coding.lean | 2 +- .../Bootstrapping/Syntax/Term/Functions.lean | 2 +- .../Bootstrapping/Syntax/Term/Typed.lean | 2 +- .../Bootstrapping/Syntax/Theory.lean | 33 +-- Foundation/FirstOrder/Hauptsatz.lean | 24 +- .../Incompleteness/Consistency.lean | 16 +- .../FirstOrder/Incompleteness/First.lean | 12 +- .../FirstOrder/Incompleteness/Halting.lean | 4 +- .../FirstOrder/Incompleteness/Jeroslow.lean | 14 +- .../Incompleteness/L\303\266b.lean" | 6 +- .../ProvabilityAbstraction/Basic.lean | 9 +- .../ProvabilityAbstraction/Refutability.lean | 2 +- .../Incompleteness/RestrictedProvability.lean | 16 +- .../Incompleteness/RosserProvability.lean | 28 +- .../FirstOrder/Incompleteness/Second.lean | 4 +- .../Incompleteness/StandardProvability.lean | 20 +- .../FirstOrder/Incompleteness/Tarski.lean | 2 +- .../Incompleteness/WitnessComparison.lean | 26 +- .../FirstOrder/Incompleteness/Yablo.lean | 67 ++--- Foundation/FirstOrder/Interpretation.lean | 6 +- .../NegationTranslation/GoedelGentzen.lean | 2 +- Foundation/FirstOrder/Order/Le.lean | 22 +- Foundation/FirstOrder/SetTheory/Universe.lean | 4 +- Foundation/FirstOrder/SetTheory/Z.lean | 16 +- .../LinearLogic/FirstOrder/Formula.lean | 2 +- Foundation/LinearLogic/MLL.lean | 2 +- Foundation/Logic/Calculus.lean | 58 ++--- Foundation/Logic/LogicSymbol.lean | 55 +++- Foundation/Modal/Entailment/Basic.lean | 2 +- Foundation/Modal/Formula/NNFormula.lean | 2 +- .../Propositional/Boolean/NNFormula.lean | 2 +- .../Propositional/Formula/NNFormula.lean | 2 +- .../ProvabilityLogic/SolovaySentences.lean | 4 +- Foundation/SecondOrder/Syntax/Formula.lean | 2 +- 91 files changed, 1390 insertions(+), 1155 deletions(-) diff --git a/Foundation.lean b/Foundation.lean index 88e505493..66d0922e2 100644 --- a/Foundation.lean +++ b/Foundation.lean @@ -53,7 +53,6 @@ public import Foundation.FirstOrder.Basic.Semantics.Semantics public import Foundation.FirstOrder.Basic.Soundness public import Foundation.FirstOrder.Basic.Syntax.Formula public import Foundation.FirstOrder.Basic.Syntax.Rew -public import Foundation.FirstOrder.Basic.Syntax.Schema -- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D1 -- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D2 -- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D3 @@ -75,8 +74,9 @@ public import Foundation.FirstOrder.Basic.Syntax.Schema -- public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Functions -- public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Typed -- public import Foundation.FirstOrder.Bootstrapping.Syntax.Theory -public import Foundation.FirstOrder.Completeness.BooleanValuedModel public import Foundation.FirstOrder.Completeness.CanonicalModel +public import Foundation.FirstOrder.Completeness.CountableSublanguage +public import Foundation.FirstOrder.Completeness.CounterModel -- public import Foundation.FirstOrder.Hauptsatz -- public import Foundation.FirstOrder.Incompleteness.Consistency -- public import Foundation.FirstOrder.Incompleteness.Dense @@ -116,7 +116,7 @@ public import Foundation.FirstOrder.Polarity -- public import Foundation.FirstOrder.SetTheory.TransitiveModel -- public import Foundation.FirstOrder.SetTheory.Universe -- public import Foundation.FirstOrder.SetTheory.Z -public import Foundation.FirstOrder.Skolemization.Hull +-- public import Foundation.FirstOrder.Skolemization.Hull public import Foundation.FirstOrder.Ultraproduct public import Foundation.Init public import Foundation.InterpretabilityLogic.Axioms @@ -375,7 +375,7 @@ public import Foundation.Modal.VanBentham.StandardTranslation public import Foundation.Propositional.Boolean.Basic public import Foundation.Propositional.Boolean.Hilbert public import Foundation.Propositional.Boolean.NNFormula -public import Foundation.Propositional.Boolean.Tait +-- public import Foundation.Propositional.Boolean.Tait public import Foundation.Propositional.Boolean.ZeroSubst public import Foundation.Propositional.ConsistentTableau public import Foundation.Propositional.Dialectica.Basic @@ -458,7 +458,7 @@ public import Foundation.Propositional.Neighborhood.NB.Basic public import Foundation.Propositional.Neighborhood.NB.Hilbert.Basic public import Foundation.Propositional.Neighborhood.NB.Hilbert.WF public import Foundation.Propositional.Slash -public import Foundation.Propositional.Tait.Calculus +-- public import Foundation.Propositional.Tait.Calculus public import Foundation.Propositional.Translation -- public import Foundation.ProvabilityLogic.Arithmetic -- public import Foundation.ProvabilityLogic.Classification.LetterlessTrace diff --git a/Foundation/FirstOrder/Arithmetic/Basic/Hierarchy.lean b/Foundation/FirstOrder/Arithmetic/Basic/Hierarchy.lean index 98f3d5dad..176d0e1da 100644 --- a/Foundation/FirstOrder/Arithmetic/Basic/Hierarchy.lean +++ b/Foundation/FirstOrder/Arithmetic/Basic/Hierarchy.lean @@ -256,7 +256,7 @@ lemma sigma_of_sigma_ex {φ : Semiformula L ξ (n + 1)} : Hierarchy 𝚺 s (∃ set_option linter.flexible false in lemma rew (ω : Rew L ξ₁ n₁ ξ₂ n₂) {φ : Semiformula L ξ₁ n₁} : Hierarchy Γ s φ → Hierarchy Γ s (ω ▹ φ) := by - intro h; induction h generalizing n₂ <;> try simp [*, Semiformula.rew_rel, Semiformula.rew_nrel] + intro h; induction h generalizing n₂ <;> try simp [*] case sigma ih => exact (ih _).accum _ case pi ih => exact (ih _).accum _ case dummy_pi ih => exact (ih _).dummy_pi @@ -476,7 +476,7 @@ end Arithmetic abbrev ArithmeticTheory.SoundOnHierarchy (T : ArithmeticTheory) (Γ : Polarity) (k : ℕ) := T.SoundOn (Arithmetic.Hierarchy Γ k) lemma ArithmeticTheory.soundOnHierarchy (T : ArithmeticTheory) (Γ : Polarity) (k : ℕ) [T.SoundOnHierarchy Γ k] : - T ⊢ σ → Arithmetic.Hierarchy Γ k σ → ℕ ⊧ₘ σ := SoundOn.sound + T ⊢ σ → Arithmetic.Hierarchy Γ k σ → ℕ↓[ℒₒᵣ] ⊧ σ := SoundOn.sound instance (T : ArithmeticTheory) [T.SoundOnHierarchy 𝚺 1] : Entailment.Consistent T := T.consistent_of_sound (Arithmetic.Hierarchy 𝚺 1) (by simp) diff --git a/Foundation/FirstOrder/Arithmetic/Basic/Misc.lean b/Foundation/FirstOrder/Arithmetic/Basic/Misc.lean index c2399c981..6f6af070c 100644 --- a/Foundation/FirstOrder/Arithmetic/Basic/Misc.lean +++ b/Foundation/FirstOrder/Arithmetic/Basic/Misc.lean @@ -135,14 +135,12 @@ def bexsLTSucc (t : Semiterm L ξ n) (φ : Semiformula L ξ (n + 1)) : Semiformu variable {M : Type*} {s : Structure L M} [LT M] [One M] [Add M] [Structure.LT L M] [Structure.One L M] [Structure.Add L M] -variable {t : Semiterm L ξ n} {φ : Semiformula L ξ (n + 1)} - -lemma eval_ballLTSucc {e ε} : - Eval s e ε (φ.ballLTSucc t) ↔ ∀ x < t.val s e ε + 1, Eval s (x :> e) ε φ := by +lemma eval_ballLTSucc {φ : Semiformula L ξ (n + 1)} {t : Semiterm L ξ n} {fv bv} : + (φ.ballLTSucc t).Eval (M := M) fv bv ↔ ∀ x < t.val (M := M) fv bv + 1, φ.Eval (M := M) (x :> fv) bv := by simp [ballLTSucc, Semiterm.Operator.numeral] -lemma eval_bexsLTSucc {e ε} : - Eval s e ε (φ.bexsLTSucc t) ↔ ∃ x < t.val s e ε + 1, Eval s (x :> e) ε φ := by +lemma eval_bexsLTSucc {φ : Semiformula L ξ (n + 1)} {t : Semiterm L ξ n} {fv bv} : + (φ.bexsLTSucc t).Eval (M := M) fv bv ↔ ∃ x < t.val (M := M) fv bv + 1, φ.Eval (M := M) (x :> fv) bv := by simp [bexsLTSucc, Semiterm.Operator.numeral] end Semiformula @@ -167,8 +165,6 @@ macro_rules end BinderNotation -abbrev ArithmeticTheory := Theory ℒₒᵣ - end FirstOrder end LO diff --git a/Foundation/FirstOrder/Arithmetic/Basic/Model.lean b/Foundation/FirstOrder/Arithmetic/Basic/Model.lean index ec33dc820..73f32608e 100644 --- a/Foundation/FirstOrder/Arithmetic/Basic/Model.lean +++ b/Foundation/FirstOrder/Arithmetic/Basic/Model.lean @@ -5,15 +5,15 @@ public import Foundation.FirstOrder.Arithmetic.Basic.Misc @[expose] public section namespace LO.FirstOrder.Arithmetic -private lemma consequence_of_aux (T : ArithmeticTheory) [𝗘𝗤 ⪯ T] (φ : Sentence ℒₒᵣ) +private lemma complete_aux (T : ArithmeticTheory) [𝗘𝗤 ℒₒᵣ ⪯ T] (φ : Sentence ℒₒᵣ) (H : ∀ (M : Type w) [ORingStructure M] [Structure ℒₒᵣ M] [Structure.ORing ℒₒᵣ M] - [M ⊧ₘ* T], - M ⊧ₘ φ) : - T ⊨ φ := consequence_iff_consequence.{_, w}.mp <| consequence_iff_eq.mpr fun M _ _ _ hT => - letI : Structure.Model ℒₒᵣ M ⊧ₘ* T := Structure.ElementaryEquiv.modelsTheory.mp hT + [M↓[ℒₒᵣ] ⊧* T], + M↓[ℒₒᵣ] ⊧ φ) : + T ⊢ φ := Theory.Proof.complete <| consequence_iff_eq.mpr fun M _ _ _ hT ↦ + letI : (Structure.Model ℒₒᵣ M)↓[ℒₒᵣ] ⊧* T := Structure.ElementaryEquiv.modelsTheory.mp hT Structure.ElementaryEquiv.models.mpr (H (Structure.Model ℒₒᵣ M)) open Language @@ -23,38 +23,40 @@ section semantics variable (M : Type*) [ORingStructure M] instance standardModel : Structure ℒₒᵣ M where - func := fun _ f => + func := fun _ f ↦ match f with - | ORing.Func.zero => fun _ => 0 - | ORing.Func.one => fun _ => 1 - | ORing.Func.add => fun v => v 0 + v 1 - | ORing.Func.mul => fun v => v 0 * v 1 - rel := fun _ r => + | ORing.Func.zero => fun _ ↦ 0 + | ORing.Func.one => fun _ ↦ 1 + | ORing.Func.add => fun v ↦ v 0 + v 1 + | ORing.Func.mul => fun v ↦ v 0 * v 1 + rel := fun _ r ↦ match r with - | ORing.Rel.eq => fun v => v 0 = v 1 - | ORing.Rel.lt => fun v => v 0 < v 1 + | ORing.Rel.eq => fun v ↦ v 0 = v 1 + | ORing.Rel.lt => fun v ↦ v 0 < v 1 -instance : Structure.Eq ℒₒᵣ M := - ⟨by intro a b; simp [standardModel, Semiformula.Operator.val, Semiformula.Operator.Eq.sentence_eq, Semiformula.eval_rel]⟩ +instance : Structure.Eq ℒₒᵣ M where + eq a b := by + unfold standardModel + simp [Semiformula.Operator.val, Semiformula.Operator.Eq.sentence_eq] instance : Structure.Zero ℒₒᵣ M := ⟨rfl⟩ instance : Structure.One ℒₒᵣ M := ⟨rfl⟩ -instance : Structure.Add ℒₒᵣ M := ⟨fun _ _ => rfl⟩ +instance : Structure.Add ℒₒᵣ M := ⟨fun _ _ ↦ rfl⟩ -instance : Structure.Mul ℒₒᵣ M := ⟨fun _ _ => rfl⟩ +instance : Structure.Mul ℒₒᵣ M := ⟨fun _ _ ↦ rfl⟩ -instance : Structure.Eq ℒₒᵣ M := ⟨fun _ _ => iff_of_eq rfl⟩ +instance : Structure.Eq ℒₒᵣ M := ⟨fun _ _ ↦ iff_of_eq rfl⟩ -instance : Structure.LT ℒₒᵣ M := ⟨fun _ _ => iff_of_eq rfl⟩ +instance : Structure.LT ℒₒᵣ M := ⟨fun _ _ ↦ iff_of_eq rfl⟩ instance : ORing ℒₒᵣ := ORing.mk lemma standardModel_unique' (s : Structure ℒₒᵣ M) (hZero : Structure.Zero ℒₒᵣ M) (hOne : Structure.One ℒₒᵣ M) (hAdd : Structure.Add ℒₒᵣ M) (hMul : Structure.Mul ℒₒᵣ M) (hEq : Structure.Eq ℒₒᵣ M) (hLT : Structure.LT ℒₒᵣ M) : s = standardModel M := Structure.ext - (funext₃ fun k f _ => + (funext₃ fun k f _ ↦ match k, f with | _, Language.Zero.zero => by simp [Matrix.empty_eq] | _, Language.One.one => by simp [Matrix.empty_eq] @@ -72,31 +74,29 @@ lemma standardModel_unique (s : Structure ℒₒᵣ M) end semantics -lemma consequence_of_models (T : ArithmeticTheory) [𝗘𝗤 ⪯ T] (φ : Sentence ℒₒᵣ) (H : ∀ (M : Type*) [ORingStructure M] [M ⊧ₘ* T], M ⊧ₘ φ) : - T ⊨ φ := consequence_of_aux T φ fun M _ s _ _ ↦ by +/-- provable_of_models -/ +lemma complete (T : ArithmeticTheory) [𝗘𝗤 ℒₒᵣ ⪯ T] (φ : Sentence ℒₒᵣ) (H : ∀ (M : Type*) [ORingStructure M] [M↓[ℒₒᵣ] ⊧* T], M↓[ℒₒᵣ] ⊧ φ) : + T ⊢ φ := complete_aux T φ fun M _ s _ _ ↦ by rcases standardModel_unique M s exact H M -lemma provable_of_models (T : ArithmeticTheory) [𝗘𝗤 ⪯ T] (φ : Sentence ℒₒᵣ) (H : ∀ (M : Type*) [ORingStructure M] [M ⊧ₘ* T], M ⊧ₘ φ) : - T ⊢ φ := complete <| consequence_of_models _ _ H - -lemma weakerThan_of_models (T S : ArithmeticTheory) [𝗘𝗤 ⪯ S] +lemma weakerThan_of_models (T S : ArithmeticTheory) [𝗘𝗤 ℒₒᵣ ⪯ S] (H : ∀ (M : Type*) [ORingStructure M] - [M ⊧ₘ* S], - M ⊧ₘ* T) : T ⪯ S := - Entailment.weakerThan_iff.mpr fun h ↦ complete <| consequence_of_models _ _ fun M _ _ ↦ sound! h (H M) + [M↓[ℒₒᵣ] ⊧* S], + M↓[ℒₒᵣ] ⊧* T) : T ⪯ S := + Entailment.weakerThan_iff.mpr fun h ↦ complete _ _ fun M _ _ ↦ Theory.Proof.sound h (H M) end Arithmetic class ArithmeticTheory.SoundOn (T : ArithmeticTheory) (F : Sentence ℒₒᵣ → Prop) where - sound : ∀ {σ}, T ⊢ σ → F σ → ℕ ⊧ₘ σ + sound : ∀ {σ}, T ⊢ σ → F σ → ℕ↓[ℒₒᵣ] ⊧ σ namespace ArithmeticTheory variable (T : ArithmeticTheory) (F : Sentence ℒₒᵣ → Prop) -instance [ℕ ⊧ₘ* T] : T.SoundOn F := ⟨fun b _ ↦ consequence_iff.mp (sound! b) ℕ inferInstance⟩ +instance [ℕ↓[ℒₒᵣ] ⊧* T] : T.SoundOn F := ⟨fun b _ ↦ consequence_iff.mp (Theory.Proof.sound b) ℕ inferInstance⟩ lemma consistent_of_sound [SoundOn T F] (hF : F ⊥) : Entailment.Consistent T := Entailment.consistent_iff_unprovable_bot.mpr fun b ↦ SoundOn.sound b hF diff --git a/Foundation/FirstOrder/Arithmetic/Basic/Monotone.lean b/Foundation/FirstOrder/Arithmetic/Basic/Monotone.lean index f56a3f1b8..a08711f10 100644 --- a/Foundation/FirstOrder/Arithmetic/Basic/Monotone.lean +++ b/Foundation/FirstOrder/Arithmetic/Basic/Monotone.lean @@ -14,9 +14,9 @@ namespace Monotone variable {L : Language} {M : Type*} [LE M] [Structure L M] [Monotone L M] -lemma term_monotone (t : Semiterm L ξ n) {e₁ e₂ : Fin n → M} {ε₁ ε₂ : ξ → M} - (he : ∀ i, e₁ i ≤ e₂ i) (hε : ∀ i, ε₁ i ≤ ε₂ i) : - t.valm M e₁ ε₁ ≤ t.valm M e₂ ε₂ := by +lemma term_monotone (t : Semiterm L ξ n) {fv₁ fv₂ : Fin n → M} {bv₁ bv₂ : ξ → M} + (he : ∀ i, fv₁ i ≤ fv₂ i) (hε : ∀ i, bv₁ i ≤ bv₂ i) : + t.val fv₁ bv₁ ≤ t.val fv₂ bv₂ := by induction t <;> simp [*, Semiterm.val_func, Monotone.monotone] end Monotone diff --git a/Foundation/FirstOrder/Arithmetic/Definability/Absoluteness.lean b/Foundation/FirstOrder/Arithmetic/Definability/Absoluteness.lean index af10365e6..96b1bf4b3 100644 --- a/Foundation/FirstOrder/Arithmetic/Definability/Absoluteness.lean +++ b/Foundation/FirstOrder/Arithmetic/Definability/Absoluteness.lean @@ -8,76 +8,78 @@ namespace LO.FirstOrder.Arithmetic open PeanoMinus R0 lemma nat_modelsWithParam_iff_models_substs {v : Fin k → ℕ} {φ : Semisentence ℒₒᵣ k} : - ℕ ⊧/v φ ↔ ℕ ⊧ₘ (φ ⇜ (fun i ↦ Semiterm.Operator.numeral ℒₒᵣ (v i))) := by - simp [models_iff] + φ.Evalb v ↔ ℕ↓[ℒₒᵣ] ⊧ (φ ⇜ (fun i ↦ Semiterm.Operator.numeral ℒₒᵣ (v i))) := by + simp [models_iff, Function.comp_def, Matrix.empty_eq] -variable (V : Type*) [ORingStructure V] [V ⊧ₘ* 𝗣𝗔⁻] +variable (V : Type*) [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] lemma modelsWithParam_iff_models_substs {v : Fin k → ℕ} {φ : Semisentence ℒₒᵣ k} : - V ⊧/(v ·) φ ↔ V ⊧ₘ (φ ⇜ (fun i ↦ Semiterm.Operator.numeral ℒₒᵣ (v i))) := by - simp [models_iff, numeral_eq_natCast] + φ.Evalb (M := V) (Nat.cast ∘ v) ↔ V↓[ℒₒᵣ] ⊧ (φ ⇜ (fun i ↦ Semiterm.Operator.numeral ℒₒᵣ (v i))) := by + simp [models_iff, Function.comp_def, Matrix.empty_eq, numeral_eq_natCast] lemma shigmaZero_absolute {k} (φ : 𝚺₀.Semisentence k) (v : Fin k → ℕ) : - ℕ ⊧/v φ.val ↔ V ⊧/(v ·) φ.val := + φ.val.Evalb v ↔ φ.val.Evalb (M := V) (Nat.cast ∘ v) := ⟨by simpa [nat_modelsWithParam_iff_models_substs, modelsWithParam_iff_models_substs] using nat_extention_sigmaOne V (by simp), by simpa [nat_modelsWithParam_iff_models_substs, modelsWithParam_iff_models_substs] using nat_extention_piOne V (by simp)⟩ lemma Defined.shigmaZero_absolute {k} {R : (Fin k → ℕ) → Prop} {R' : (Fin k → V) → Prop} {φ : 𝚺₀.Semisentence k} (hR : 𝚺₀.Defined R φ) (hR' : 𝚺₀.Defined R' φ) (v : Fin k → ℕ) : - R v ↔ R' (fun i ↦ (v i : V)) := by + R v ↔ R' (Nat.cast ∘ v) := by simpa [hR.iff, hR'.iff] using Arithmetic.shigmaZero_absolute V φ v lemma DefinedFunction.shigmaZero_absolute_func {k} {f : (Fin k → ℕ) → ℕ} {f' : (Fin k → V) → V} {φ : 𝚺₀.Semisentence (k + 1)} (hf : 𝚺₀.DefinedFunction f φ) (hf' : 𝚺₀.DefinedFunction f' φ) (v : Fin k → ℕ) : - (f v : V) = f' (fun i ↦ (v i)) := by + (f v : V) = f' (Nat.cast ∘ v) := by simpa using Defined.shigmaZero_absolute V hf hf' (f v :> v) lemma sigmaOne_upward_absolute {k} (φ : 𝚺₁.Semisentence k) (v : Fin k → ℕ) : - ℕ ⊧/v φ.val → V ⊧/(v ·) φ.val := by + φ.val.Evalb v → φ.val.Evalb (M := V) (Nat.cast ∘ v) := by simpa [nat_modelsWithParam_iff_models_substs, modelsWithParam_iff_models_substs] using nat_extention_sigmaOne V (by simp) lemma piOne_downward_absolute {k} (φ : 𝚷₁.Semisentence k) (v : Fin k → ℕ) : - V ⊧/(v ·) φ.val → ℕ ⊧/v φ.val := by + φ.val.Evalb (M := V) (Nat.cast ∘ v) → φ.val.Evalb v := by simpa [nat_modelsWithParam_iff_models_substs, modelsWithParam_iff_models_substs] using nat_extention_piOne V (by simp) lemma deltaOne_absolute {k} (φ : 𝚫₁.Semisentence k) (properNat : φ.ProperOn ℕ) (proper : φ.ProperOn V) (v : Fin k → ℕ) : - ℕ ⊧/v φ.val ↔ V ⊧/(v ·) φ.val := + φ.val.Evalb v ↔ φ.val.Evalb (M := V) (Nat.cast ∘ v) := ⟨by simpa [HierarchySymbol.Semiformula.val_sigma] using sigmaOne_upward_absolute V φ.sigma v, by simpa [proper.iff', properNat.iff'] using piOne_downward_absolute V φ.pi v⟩ lemma Defined.shigmaOne_absolute {k} {R : (Fin k → ℕ) → Prop} {R' : (Fin k → V) → Prop} {φ : 𝚫₁.Semisentence k} (hR : 𝚫₁.Defined R φ) (hR' : 𝚫₁.Defined R' φ) (v : Fin k → ℕ) : - R v ↔ R' (fun i ↦ (v i : V)) := by + R v ↔ R' (Nat.cast ∘ v) := by simpa using deltaOne_absolute V φ hR.proper hR'.proper v lemma DefinedFunction.shigmaOne_absolute_func {k} {f : (Fin k → ℕ) → ℕ} {f' : (Fin k → V) → V} {φ : 𝚺₁.Semisentence (k + 1)} (hf : 𝚺₁.DefinedFunction f φ) (hf' : 𝚺₁.DefinedFunction f' φ) (v : Fin k → ℕ) : - (f v : V) = f' (fun i ↦ (v i)) := by + (f v : V) = f' (Nat.cast ∘ v) := by simpa using Defined.shigmaOne_absolute V hf.graph_delta hf'.graph_delta (f v :> v) variable {V} lemma models_iff_of_Sigma0 {σ : Semisentence ℒₒᵣ n} (hσ : Hierarchy 𝚺 0 σ) {e : Fin n → ℕ} : - V ⊧/(e ·) σ ↔ ℕ ⊧/e σ := by - by_cases h : ℕ ⊧/e σ <;> simp [h] - · have : V ⊧/(e ·) σ := by + σ.Evalb (M := V) (Nat.cast ∘ e) ↔ σ.Evalb e := by + by_cases h : σ.Evalb e <;> simp [h] + · have : σ.Evalb (M := V) (Nat.cast ∘ e) := by simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp [Hierarchy.of_zero hσ]) h simpa [HierarchySymbol.Semiformula.val_sigma] using this - · have : ℕ ⊧/e (∼σ) := by simpa using h - have : V ⊧/(e ·) (∼σ) := by simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp [Hierarchy.of_zero hσ]) this + · have : (∼σ).Evalb (M := ℕ) e := by simpa using h + have : (∼σ).Evalb (M := V) (Nat.cast ∘ e) := by + simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp [Hierarchy.of_zero hσ]) this simpa using this lemma models_iff_of_Delta1 {σ : 𝚫₁.Semisentence n} (hσ : σ.ProperOn ℕ) (hσV : σ.ProperOn V) {e : Fin n → ℕ} : - V ⊧/(e ·) σ.val ↔ ℕ ⊧/e σ.val := by - by_cases h : ℕ ⊧/e σ.val <;> simp [h] - · have : ℕ ⊧/e σ.sigma.val := by simpa [HierarchySymbol.Semiformula.val_sigma] using h - have : V ⊧/(e ·) σ.sigma.val := by simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp) this + σ.val.Evalb (M := V) (Nat.cast ∘ e) ↔ σ.val.Evalb e := by + by_cases h : σ.val.Evalb e <;> simp [h] + · have : σ.sigma.val.Evalb e := by simpa [HierarchySymbol.Semiformula.val_sigma] using h + have : σ.sigma.val.Evalb (M := V) (Nat.cast ∘ e) := by simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp) this simpa [HierarchySymbol.Semiformula.val_sigma] using this - · have : ℕ ⊧/e (∼σ.pi.val) := by simpa [hσ.iff'] using h - have : V ⊧/(e ·) (∼σ.pi.val) := by simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp) this + · have : (∼σ.pi.val).Evalb (M := ℕ) e := by simpa [hσ.iff'] using h + have : (∼σ.pi.val).Evalb (M := V) (Nat.cast ∘ e) := by + simpa [numeral_eq_natCast] using bold_sigma_one_completeness' (M := V) (by simp) this simpa [hσV.iff'] using this variable {T : ArithmeticTheory} [𝗣𝗔⁻ ⪯ T] [T.SoundOnHierarchy 𝚺 1] @@ -86,21 +88,21 @@ noncomputable instance : 𝗥₀ ⪯ T := Entailment.WeakerThan.trans (𝓣 := theorem sigma_one_completeness_iff_param {σ : Semisentence ℒₒᵣ n} (hσ : Hierarchy 𝚺 1 σ) {e : Fin n → ℕ} : ℕ ⊧/e σ ↔ T ⊢ (σ ⇜ fun x ↦ Semiterm.Operator.numeral ℒₒᵣ (e x)) := Iff.trans - (by simp [models_iff, Semiformula.eval_substs]) + (by simp [models_iff, Semiformula.eval_substs, Function.comp_def, Matrix.empty_eq]) (sigma_one_completeness_iff (T := T) (by simp [hσ])) -lemma models_iff_provable_of_Sigma0_param [V ⊧ₘ* T] {σ : Semisentence ℒₒᵣ n} (hσ : Hierarchy 𝚺 0 σ) {e : Fin n → ℕ} : - V ⊧/(e ·) σ ↔ T ⊢ (σ ⇜ fun x ↦ Semiterm.Operator.numeral ℒₒᵣ (e x)) := by +lemma models_iff_provable_of_Sigma0_param [V↓[ℒₒᵣ] ⊧* T] {σ : Semisentence ℒₒᵣ n} (hσ : Hierarchy 𝚺 0 σ) {e : Fin n → ℕ} : + V ⊧/(Nat.cast ∘ e) σ ↔ T ⊢ (σ ⇜ fun x ↦ Semiterm.Operator.numeral ℒₒᵣ (e x)) := by calc - V ⊧/(e ·) σ ↔ ℕ ⊧/e σ := by + V ⊧/(Nat.cast ∘ e) σ ↔ ℕ ⊧/e σ := by simp [models_iff_of_Sigma0 hσ] _ ↔ T ⊢ (σ ⇜ fun x ↦ Semiterm.Operator.numeral ℒₒᵣ (e x)) := by apply sigma_one_completeness_iff_param (by simp [Hierarchy.of_zero hσ]) -lemma models_iff_provable_of_Delta1_param [V ⊧ₘ* T] {σ : 𝚫₁.Semisentence n} (hσ : σ.ProperOn ℕ) (hσV : σ.ProperOn V) {e : Fin n → ℕ} : - V ⊧/(e ·) σ.val ↔ T ⊢ (σ.val ⇜ fun x ↦ Semiterm.Operator.numeral ℒₒᵣ (e x)) := by +lemma models_iff_provable_of_Delta1_param [V↓[ℒₒᵣ] ⊧* T] {σ : 𝚫₁.Semisentence n} (hσ : σ.ProperOn ℕ) (hσV : σ.ProperOn V) {e : Fin n → ℕ} : + V ⊧/(Nat.cast ∘ e) σ.val ↔ T ⊢ (σ.val ⇜ fun x ↦ Semiterm.Operator.numeral ℒₒᵣ (e x)) := by calc - V ⊧/(e ·) σ.val ↔ ℕ ⊧/e σ.val := by + V ⊧/(Nat.cast ∘ e) σ.val ↔ ℕ ⊧/e σ.val := by simp [models_iff_of_Delta1 hσ hσV] _ ↔ ℕ ⊧/e σ.sigma.val := by simp [HierarchySymbol.Semiformula.val_sigma] diff --git a/Foundation/FirstOrder/Arithmetic/Definability/BoundedDefinable.lean b/Foundation/FirstOrder/Arithmetic/Definability/BoundedDefinable.lean index 4b9502407..6d3124deb 100644 --- a/Foundation/FirstOrder/Arithmetic/Definability/BoundedDefinable.lean +++ b/Foundation/FirstOrder/Arithmetic/Definability/BoundedDefinable.lean @@ -16,7 +16,7 @@ variable {ℌ : HierarchySymbol} {Γ Γ' : SigmaPiDelta} variable (ℌ) class Bounded (f : (Fin k → V) → V) : Prop where - bounded : ∃ t : Semiterm ℒₒᵣ V k, ∀ v : Fin k → V, f v ≤ t.valm V v id + bounded : ∃ t : Semiterm ℒₒᵣ V k, ∀ v : Fin k → V, f v ≤ t.val v id abbrev Bounded₁ (f : V → V) : Prop := Bounded (k := 1) (fun v ↦ f (v 0)) @@ -32,23 +32,23 @@ variable {ℌ} namespace Bounded -@[simp] lemma var [V ⊧ₘ* 𝗣𝗔⁻] {k} (i : Fin k) : Bounded fun v : Fin k → V ↦ v i := ⟨#i, by intro _; simp⟩ +@[simp] lemma var [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {k} (i : Fin k) : Bounded fun v : Fin k → V ↦ v i := ⟨#i, by intro _; simp⟩ -@[simp] lemma const [V ⊧ₘ* 𝗣𝗔⁻] {k} (c : V) : Bounded (fun _ : Fin k → V ↦ c) := ⟨&c, by intro _; simp⟩ +@[simp] lemma const [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {k} (c : V) : Bounded (fun _ : Fin k → V ↦ c) := ⟨&c, by intro _; simp⟩ -@[simp] lemma term_retraction [V ⊧ₘ* 𝗣𝗔⁻] (t : Semiterm ℒₒᵣ V n) (e : Fin n → Fin k) : - Bounded fun v : Fin k → V ↦ Semiterm.valm V (fun x ↦ v (e x)) id t := - ⟨Rew.subst (fun x ↦ #(e x)) t, by intro _; simp [Semiterm.val_substs]⟩ +@[simp] lemma term_retraction [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] (t : Semiterm ℒₒᵣ V n) (e : Fin n → Fin k) : + Bounded fun v : Fin k → V ↦ t.val (fun x ↦ v (e x)) id := + ⟨Rew.subst (fun x ↦ #(e x)) t, by intro _; simp [Semiterm.val_substs, Function.comp_def]⟩ -@[simp] lemma term [V ⊧ₘ* 𝗣𝗔⁻] (t : Semiterm ℒₒᵣ V k) : Bounded fun v : Fin k → V => Semiterm.valm V v id t := +@[simp] lemma term [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] (t : Semiterm ℒₒᵣ V k) : Bounded fun v : Fin k → V => t.val v id := ⟨t, by intro _; simp⟩ lemma retraction {f : (Fin k → V) → V} (hf : Bounded f) (e : Fin k → Fin n) : Bounded fun v ↦ f (fun i ↦ v (e i)) := by rcases hf with ⟨t, ht⟩ - exact ⟨Rew.subst (fun x ↦ #(e x)) t, by intro; simp [Semiterm.val_substs, ht]⟩ + exact ⟨Rew.subst (fun x ↦ #(e x)) t, by intro _; simp [Semiterm.val_substs, Function.comp_def, ht]⟩ -lemma comp [V ⊧ₘ* 𝗣𝗔⁻] {k} {f : (Fin l → V) → V} {g : Fin l → (Fin k → V) → V} (hf : Bounded f) (hg : ∀ i, Bounded (g i)) : +lemma comp [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {k} {f : (Fin l → V) → V} {g : Fin l → (Fin k → V) → V} (hf : Bounded f) (hg : ∀ i, Bounded (g i)) : Bounded (fun v ↦ f (g · v)) where bounded := by rcases hf.bounded with ⟨tf, htf⟩ @@ -60,14 +60,14 @@ lemma comp [V ⊧ₘ* 𝗣𝗔⁻] {k} {f : (Fin l → V) → V} {g : Fin l → end Bounded -lemma Bounded₁.comp [V ⊧ₘ* 𝗣𝗔⁻] {f : V → V} {k} {g : (Fin k → V) → V} (hf : Bounded₁ f) (hg : Bounded g) : +lemma Bounded₁.comp [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {f : V → V} {k} {g : (Fin k → V) → V} (hf : Bounded₁ f) (hg : Bounded g) : Bounded (fun v ↦ f (g v)) := Bounded.comp hf (l := 1) (fun _ ↦ hg) -lemma Bounded₂.comp [V ⊧ₘ* 𝗣𝗔⁻] {f : V → V → V} {k} {g₁ g₂ : (Fin k → V) → V} +lemma Bounded₂.comp [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {f : V → V → V} {k} {g₁ g₂ : (Fin k → V) → V} (hf : Bounded₂ f) (hg₁ : Bounded g₁) (hg₂ : Bounded g₂) : Bounded (fun v ↦ f (g₁ v) (g₂ v)) := Bounded.comp hf (g := ![g₁, g₂]) (fun i ↦ by cases i using Fin.cases <;> simp [*]) -lemma Bounded₃.comp [V ⊧ₘ* 𝗣𝗔⁻] {f : V → V → V → V} {k} {g₁ g₂ g₃ : (Fin k → V) → V} +lemma Bounded₃.comp [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {f : V → V → V → V} {k} {g₁ g₂ g₃ : (Fin k → V) → V} (hf : Bounded₃ f) (hg₁ : Bounded g₁) (hg₂ : Bounded g₂) (hg₃ : Bounded g₃) : Bounded (fun v ↦ f (g₁ v) (g₂ v) (g₃ v)) := Bounded.comp hf (g := ![g₁, g₂, g₃]) (fun i ↦ by @@ -76,7 +76,7 @@ lemma Bounded₃.comp [V ⊧ₘ* 𝗣𝗔⁻] {f : V → V → V → V} {k} {g namespace Bounded₂ -variable [V ⊧ₘ* 𝗣𝗔⁻] +variable [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] instance add : Bounded₂ ((· + ·) : V → V → V) where bounded := ⟨‘x y. x + y’, by intro _; simp⟩ @@ -137,7 +137,7 @@ end DefinableBoundedFunction namespace HierarchySymbol.Definable -variable [V ⊧ₘ* 𝗣𝗔⁻] +variable [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] variable {P Q : (Fin k → V) → Prop} @@ -145,10 +145,10 @@ lemma ball_blt {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : DefinableBoundedFunction f) (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) : ℌ.Definable fun v ↦ ∀ x < f v, P v x := by rcases hf.bounded with ⟨bf, hbf⟩ - have : ℌ.Definable fun v ↦ ∃ x ≤ Semiterm.valm V v id bf, x = f v ∧ ∀ y < x, P v y := by + have : ℌ.Definable fun v ↦ ∃ x ≤ bf.val v id, x = f v ∧ ∀ y < x, P v y := by apply bexs'; apply and · exact hf.definable - · suffices ℌ.Definable fun x ↦ ∀ y < Semiterm.valm (L := ℒₒᵣ) V x id (#0), P (fun x_1 ↦ x x_1.succ) y by simpa + · suffices ℌ.Definable fun x ↦ ∀ y < (#0).val (L := ℒₒᵣ) x id, P (fun x_1 ↦ x x_1.succ) y by simpa apply ball ?_ #0 simpa using h.retraction (0 :> (·.succ.succ)) exact this.of_iff <| fun v ↦ ⟨fun h ↦ ⟨f v, hbf v, rfl, h⟩, by rintro ⟨y, hy, rfl, h⟩; exact h⟩ @@ -157,10 +157,10 @@ lemma bexs_blt {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : DefinableBoundedFunction f) (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) : ℌ.Definable fun v ↦ ∃ x < f v, P v x := by rcases hf.bounded with ⟨bf, hbf⟩ - have : ℌ.Definable fun v ↦ ∃ x ≤ Semiterm.valm V v id bf, x = f v ∧ ∃ y < x, P v y := by + have : ℌ.Definable fun v ↦ ∃ x ≤ bf.val v id, x = f v ∧ ∃ y < x, P v y := by apply bexs'; apply and · exact hf.definable - · suffices ℌ.Definable fun x ↦ ∃ y < Semiterm.valm (L := ℒₒᵣ) V x id (#0), P (fun x_1 ↦ x x_1.succ) y by simpa + · suffices ℌ.Definable fun x ↦ ∃ y < (#0).val (L := ℒₒᵣ) x id, P (fun x_1 ↦ x x_1.succ) y by simpa apply bexs ?_ #0 simpa using h.retraction (0 :> (·.succ.succ)) exact this.of_iff <| fun v ↦ ⟨fun h ↦ ⟨f v, hbf v, rfl, h⟩, by rintro ⟨y, hy, rfl, h⟩; exact h⟩ @@ -169,10 +169,10 @@ lemma ball_ble {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : DefinableBoundedFunction f) (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) : ℌ.Definable fun v ↦ ∀ x ≤ f v, P v x := by rcases hf.bounded with ⟨bf, hbf⟩ - have : ℌ.Definable fun v ↦ ∃ x ≤ Semiterm.valm V v id bf, x = f v ∧ ∀ y ≤ x, P v y := by + have : ℌ.Definable fun v ↦ ∃ x ≤ bf.val v id, x = f v ∧ ∀ y ≤ x, P v y := by apply bexs'; apply and · exact hf.definable - · suffices ℌ.Definable fun x ↦ ∀ y ≤ Semiterm.valm (L := ℒₒᵣ) V x id (#0), P (fun x_1 ↦ x x_1.succ) y by simpa + · suffices ℌ.Definable fun x ↦ ∀ y ≤ (#0).val (L := ℒₒᵣ) x id, P (fun x_1 ↦ x x_1.succ) y by simpa apply ball' ?_ #0 simpa using h.retraction (0 :> (·.succ.succ)) exact this.of_iff <| fun v ↦ ⟨fun h ↦ ⟨f v, hbf v, rfl, h⟩, by rintro ⟨y, hy, rfl, h⟩; exact h⟩ @@ -181,10 +181,10 @@ lemma bexs_ble {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : DefinableBoundedFunction f) (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) : ℌ.Definable fun v ↦ ∃ x ≤ f v, P v x := by rcases hf.bounded with ⟨bf, hbf⟩ - have : ℌ.Definable fun v ↦ ∃ x ≤ Semiterm.valm V v id bf, x = f v ∧ ∃ y ≤ x, P v y := by + have : ℌ.Definable fun v ↦ ∃ x ≤ bf.val v id, x = f v ∧ ∃ y ≤ x, P v y := by apply bexs'; apply and · exact hf.definable - · suffices ℌ.Definable fun x ↦ ∃ y ≤ Semiterm.valm (L := ℒₒᵣ) V x id (#0), P (fun x_1 ↦ x x_1.succ) y by simpa + · suffices ℌ.Definable fun x ↦ ∃ y ≤ (#0).val (L := ℒₒᵣ) x id, P (fun x_1 ↦ x x_1.succ) y by simpa apply bexs' ?_ #0 simpa using h.retraction (0 :> (·.succ.succ)) exact this.of_iff <| fun v ↦ ⟨fun h ↦ ⟨f v, hbf v, rfl, h⟩, by rintro ⟨y, hy, rfl, h⟩; exact h⟩ @@ -249,17 +249,17 @@ lemma of_iff {f g : (Fin k → V) → V} (H : DefinableBoundedFunction f) (h : have : f = g := by funext v; simp [h] rcases this; exact H -variable [V ⊧ₘ* 𝗣𝗔⁻] +variable [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] @[simp] lemma var {k} (i : Fin k) : DefinableBoundedFunction (fun v : Fin k → V ↦ v i) := ⟨by simp, by simp⟩ @[simp] lemma const {k} (c : V) : DefinableBoundedFunction (fun _ : Fin k → V ↦ c) := ⟨by simp, by simp⟩ @[simp] lemma term_retraction (t : Semiterm ℒₒᵣ V n) (e : Fin n → Fin k) : - DefinableBoundedFunction fun v : Fin k → V ↦ Semiterm.valm V (fun x ↦ v (e x)) id t := ⟨by simp, by simp⟩ + DefinableBoundedFunction fun v : Fin k → V ↦ t.val (fun x ↦ v (e x)) id := ⟨by simp, by simp⟩ @[simp] lemma term (t : Semiterm ℒₒᵣ V k) : - DefinableBoundedFunction fun v : Fin k → V ↦ Semiterm.valm V v id t := ⟨by simp, by simp⟩ + DefinableBoundedFunction fun v : Fin k → V ↦ t.val v id := ⟨by simp, by simp⟩ end DefinableBoundedFunction @@ -267,7 +267,7 @@ namespace HierarchySymbol.Definable open DefinableBoundedFunction -variable [V ⊧ₘ* 𝗣𝗔⁻] +variable [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] lemma bcomp₁ {k} {P : V → Prop} {f : (Fin k → V) → V} [hP : ℌ.DefinablePred P] (hf : DefinableBoundedFunction f) : ℌ.Definable fun v ↦ P (f v) := @@ -313,7 +313,7 @@ lemma bcomp₄_zero {k} {R : V → V → V → V → Prop} {f₁ f₂ f₃ f₄ end HierarchySymbol.Definable -variable [V ⊧ₘ* 𝗣𝗔⁻] +variable [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] lemma HierarchySymbol.DefinableFunction.bcomp {k} {F : (Fin l → V) → V} {f : Fin l → (Fin k → V) → V} (hF : ℌ.DefinableFunction F) (hf : ∀ i, DefinableBoundedFunction (f i)) : diff --git a/Foundation/FirstOrder/Arithmetic/Definability/Definable.lean b/Foundation/FirstOrder/Arithmetic/Definability/Definable.lean index 00b3fc939..e8a2edab0 100644 --- a/Foundation/FirstOrder/Arithmetic/Definability/Definable.lean +++ b/Foundation/FirstOrder/Arithmetic/Definability/Definable.lean @@ -186,13 +186,14 @@ lemma df {R : (Fin k → V) → Prop} {φ : ℌ.Semisentence k} (h : Defined R @[simp] lemma proper {R : (Fin k → V) → Prop} {m} {φ : 𝚫-[m].Semisentence k} [h : Defined R φ] : φ.ProperOn V := h.defined.1 @[simp] lemma iff {R : (Fin k → V) → Prop} {φ : ℌ.Semisentence k} [h : Defined R φ] : - Semiformula.Evalbm V v φ.val ↔ R v := h.df _ + φ.val.Evalb v ↔ R v := h.df _ @[simp] lemma iff_delta_pi {R : (Fin k → V) → Prop} {φ : (𝚫-[m]).Semisentence k} [h : Defined R φ] : - Semiformula.Evalbm V v φ.pi.val ↔ R v := by simp [h.proper.iff'] + φ.pi.val.Evalb v ↔ R v := by + simp [h.proper.iff'] @[simp] lemma iff_delta_sigma {R : (Fin k → V) → Prop} {φ : (𝚫-[m]).Semisentence k} [h : Defined R φ] : - Semiformula.Evalbm V v φ.sigma.val ↔ R v := by simp [h.proper.iff] + φ.sigma.val.Evalb v ↔ R v := by simp [h.proper.iff] lemma of_zero {R : (Fin k → V) → Prop} {φ : 𝚺₀.Semisentence k} (h : Defined R φ) : Defined R (φ.ofZero ℌ) := Defined.mk <| match ℌ with @@ -244,7 +245,7 @@ lemma df {R : (Fin k → V) → Prop} {φ : ℌ.Semiformula V k} (h : IsDefinedB | 𝚫-[_] => h.2 lemma iff {R : (Fin k → V) → Prop} {φ : ℌ.Semiformula V k} (h : IsDefinedByWithParam R φ) {v} : - Semiformula.Evalm V v id φ.val ↔ R v := h.df _ + φ.val.Eval v id ↔ R v := h.df _ lemma proper {R : (Fin k → V) → Prop} {m} {φ : 𝚫-[m].Semiformula V k} (h : IsDefinedByWithParam R φ) : φ.ProperWithParamOn V := h.1 @@ -258,7 +259,7 @@ namespace DefinableRel @[simp] instance lt : ℌ.DefinableRel (LT.lt : V → V → Prop) := Defined.to_definable₀ (φ := .mkSigma “#0 < #1”) ⟨by intro _; simp⟩ -@[simp] instance le [V ⊧ₘ* 𝗣𝗔⁻] : ℌ.DefinableRel (LE.le : V → V → Prop) := +@[simp] instance le [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] : ℌ.DefinableRel (LE.le : V → V → Prop) := Defined.to_definable₀ (φ := .mkSigma “#0 ≤ #1”) ⟨by intro _; simp⟩ end DefinableRel @@ -277,13 +278,13 @@ namespace DefinableFunction₂ @[simp] instance hMul : ℌ.DefinableFunction₂ (HMul.hMul : V → V → V) := Defined.to_definable₀ (φ := .mkSigma “#0 = #1 * #2”) ⟨by intro _; simp⟩ -@[simp] protected instance sq [V ⊧ₘ* 𝗣𝗔⁻] : ℌ.DefinableFunction₁ fun x : V ↦ x^2 := +@[simp] protected instance sq [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] : ℌ.DefinableFunction₁ fun x : V ↦ x^2 := Defined.to_definable₀ (φ := .mkSigma “#0 = #1 * #1”) ⟨by intro _; simp [sq]⟩ -@[simp] instance pow3 [V ⊧ₘ* 𝗣𝗔⁻] : ℌ.DefinableFunction₁ fun x : V ↦ x^3 := +@[simp] instance pow3 [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] : ℌ.DefinableFunction₁ fun x : V ↦ x^3 := Defined.to_definable₀ (φ := .mkSigma “#0 = #1 * #1 * #1”) ⟨by intro _; simp [Arithmetic.pow_three]⟩ -@[simp] instance pow4 [V ⊧ₘ* 𝗣𝗔⁻] : ℌ.DefinableFunction₁ fun x : V ↦ x^4 := +@[simp] instance pow4 [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] : ℌ.DefinableFunction₁ fun x : V ↦ x^4 := Defined.to_definable₀ (φ := .mkSigma “#0 = #1 * #1 * #1 * #1”) ⟨by intro _; simp [pow_four]⟩ end DefinableFunction₂ @@ -293,7 +294,7 @@ namespace Definable lemma mk' {ℌ : HierarchySymbol} (φ : ℌ.Semiformula V k) (H : IsDefinedByWithParam P φ) : ℌ.Definable P := ⟨φ, H⟩ lemma mkPolarity {Γ : Polarity} - (φ : Semiformula ℒₒᵣ V k) (hp : Hierarchy Γ m φ) (hP : ∀ v, P v ↔ Semiformula.Evalm V v id φ) : Γ-[m].Definable P := + (φ : Semiformula ℒₒᵣ V k) (hp : Hierarchy Γ m φ) (hP : ∀ v, P v ↔ φ.Eval v id) : Γ-[m].Definable P := match Γ with | 𝚺 => ⟨.mkSigma φ hp, by intro v; simp [hP]⟩ | 𝚷 => ⟨.mkPi φ hp, by intro v; simp [hP]⟩ @@ -344,16 +345,16 @@ lemma retraction (h : ℌ.Definable P) (f : Fin k → Fin l) : rcases h with ⟨φ, h⟩ apply Definable.mk' (φ.rew <| Rew.subst fun x ↦ #(f x)) match ℌ with - | 𝚺-[_] | 𝚷-[_] => intro; simp [h.iff] - | 𝚫-[_] => exact ⟨h.proper.rew _, by intro; simp [h.iff]⟩ + | 𝚺-[_] | 𝚷-[_] => intro; simp [h.iff, Function.comp_def] + | 𝚫-[_] => exact ⟨h.proper.rew _, by intro; simp [h.iff, Function.comp_def]⟩ lemma retractiont (h : ℌ.Definable P) (f : Fin k → Semiterm ℒₒᵣ V n) : - ℌ.Definable fun v ↦ P (fun i ↦ Semiterm.valm V v id (f i)) := by + ℌ.Definable fun v ↦ P (fun i ↦ (f i).val v id) := by rcases h with ⟨φ, h⟩ exact ⟨φ.rew (Rew.subst f), match ℌ with - | 𝚺-[_] | 𝚷-[_] => by intro; simp [h.df.iff] - | 𝚫-[_] => ⟨h.proper.rew _, by intro; simp [h.df.iff]⟩⟩ + | 𝚺-[_] | 𝚷-[_] => by intro; simp [h.df.iff, Function.comp_def] + | 𝚫-[_] => ⟨h.proper.rew _, by intro; simp [h.df.iff, Function.comp_def]⟩⟩ @[simp] instance const {P : Prop} : ℌ.Definable (fun _ : Fin k → V ↦ P) := by by_cases hP : P @@ -420,7 +421,7 @@ lemma biconditional (h₁ : 𝚫-[m].Definable P) (h₂ : 𝚫-[m].Definable Q) .of_delta <| ((h₁.impDelta h₂).and (h₂.impDelta h₁)).of_iff <| by intro v; simp [iff_iff_implies_and_implies] lemma ball {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) (t : Semiterm ℒₒᵣ V k) : - ℌ.Definable fun v ↦ ∀ x < t.valm V v id, P v x := by + ℌ.Definable fun v ↦ ∀ x < t.val v id, P v x := by rcases h with ⟨φ, h⟩ match ℌ with | 𝚺-[m] => exact ⟨HierarchySymbol.Semiformula.ball t φ, by intro v; simp [h.iff]⟩ @@ -428,20 +429,20 @@ lemma ball {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w | 𝚫-[m] => exact ⟨HierarchySymbol.Semiformula.ball t φ, ⟨h.proper.ball, by intro v; simp [h.iff]⟩⟩ lemma bexs {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) (t : Semiterm ℒₒᵣ V k) : - ℌ.Definable fun v ↦ ∃ x < t.valm V v id, P v x := by + ℌ.Definable fun v ↦ ∃ x < t.val v id, P v x := by rcases h with ⟨φ, h⟩ match ℌ with | 𝚺-[m] => exact ⟨HierarchySymbol.Semiformula.bexs t φ, by intro v; simp [h.iff]⟩ | 𝚷-[m] => exact ⟨HierarchySymbol.Semiformula.bexs t φ, by intro v; simp [h.iff]⟩ | 𝚫-[m] => exact ⟨HierarchySymbol.Semiformula.bexs t φ, ⟨h.proper.bexs, by intro v; simp [h.iff]⟩⟩ -lemma ball' [V ⊧ₘ* 𝗣𝗔⁻] {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) (t : Semiterm ℒₒᵣ V k) : - ℌ.Definable fun v ↦ ∀ x ≤ t.valm V v id, P v x := by +lemma ball' [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) (t : Semiterm ℒₒᵣ V k) : + ℌ.Definable fun v ↦ ∀ x ≤ t.val v id, P v x := by apply (ball h ‘!!t + 1’).of_iff intro v; simp [lt_succ_iff_le] -lemma bexs' [V ⊧ₘ* 𝗣𝗔⁻] {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) (t : Semiterm ℒₒᵣ V k) : - ℌ.Definable fun v ↦ ∃ x ≤ t.valm V v id, P v x := by +lemma bexs' [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {P : (Fin k → V) → V → Prop} (h : ℌ.Definable fun w ↦ P (w ·.succ) (w 0)) (t : Semiterm ℒₒᵣ V k) : + ℌ.Definable fun v ↦ ∃ x ≤ t.val v id, P v x := by apply (bexs h ‘!!t + 1’).of_iff intro v; simp [lt_succ_iff_le] @@ -705,13 +706,14 @@ lemma of_sigmaOne .of_zero (Γ' := 𝚺) ⟨.mkSigma “x. #0 = &c”, by intro v; simp⟩ @[simp] lemma term_retraction (t : Semiterm ℒₒᵣ V n) (e : Fin n → Fin k) : - ℌ.DefinableFunction fun v : Fin k → V ↦ Semiterm.valm V (fun x ↦ v (e x)) id t := + ℌ.DefinableFunction fun v : Fin k → V ↦ t.val (fun x ↦ v (e x)) id := .of_zero (Γ' := 𝚺) - ⟨.mkSigma “x. x = !!(Rew.subst (fun x ↦ #(e x).succ) t)”, by intro v; simp [Semiterm.val_substs]⟩ + ⟨.mkSigma “x. x = !!(Rew.subst (fun x ↦ #(e x).succ) t)”, fun v ↦ by + simp [Semiterm.val_substs, Function.comp_def]⟩ @[simp] lemma term (t : Semiterm ℒₒᵣ V k) : - ℌ.DefinableFunction fun v : Fin k → V ↦ Semiterm.valm V v id t := - .of_zero (Γ' := 𝚺) ⟨.mkSigma “x. x = !!(Rew.bShift t)”, by intro v; simp [Semiterm.val_bShift']⟩ + ℌ.DefinableFunction fun v : Fin k → V ↦ t.val v id := + .of_zero (Γ' := 𝚺) ⟨.mkSigma “x. x = !!(Rew.bShift t)”, fun v ↦ by simp [Semiterm.val_bShift']⟩ lemma of_eq (g) (h : ∀ v, f v = g v) (H : ℌ.DefinableFunction f) : ℌ.DefinableFunction g := by rwa [show g = f from by funext v; simp [h]] @@ -723,7 +725,7 @@ lemma retraction {n} (hf : ℌ.DefinableFunction f) (e : Fin k → Fin n) : this.of_iff (by intro x; simp) lemma retractiont {n} (hf : ℌ.DefinableFunction f) (t : Fin k → Semiterm ℒₒᵣ V n) : - ℌ.DefinableFunction fun v ↦ f (fun i ↦ Semiterm.valm V v id (t i)) := + ℌ.DefinableFunction fun v ↦ f (fun i ↦ (t i).val v id) := have := Definable.retractiont (n := n + 1) hf (#0 :> fun i ↦ Rew.bShift (t i)) this.of_iff (by intro x; simp [Semiterm.val_bShift']) @@ -818,13 +820,13 @@ lemma bexs_lt {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} ⟨ .mkPi (∀⁰ (bf.val 🡒 (∃⁰[“#0 < #1”] φ.pi.val ⇜ (#0 :> (#·.succ.succ))))) (by simp), by intro v; simp [hbf.df.iff, hp.df.iff, hp.proper.iff'] ⟩ -lemma ball_le [V ⊧ₘ* 𝗣𝗔⁻] {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} +lemma ball_le [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : 𝚺-[m + 1].DefinableFunction f) (h : Γ-[m + 1].Definable (fun w ↦ P (w ·.succ) (w 0))) : Γ-[m + 1].Definable (fun v ↦ ∀ x ≤ f v, P v x) := by have : Γ-[m + 1].Definable (fun v ↦ ∀ x < f v + 1, P v x) := ball_lt (DefinableFunction₂.comp hf (by simp)) h exact this.of_iff <| by intro v; simp [lt_succ_iff_le] -lemma bexs_le [V ⊧ₘ* 𝗣𝗔⁻] {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} +lemma bexs_le [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : 𝚺-[m + 1].DefinableFunction f) (h : Γ-[m + 1].Definable (fun w ↦ P (w ·.succ) (w 0))) : Γ-[m + 1].Definable (fun v ↦ ∃ x ≤ f v, P v x) := by have : Γ-[m + 1].Definable (fun v ↦ ∃ x < f v + 1, P v x) := bexs_lt (DefinableFunction₂.comp hf (by simp)) h @@ -834,7 +836,7 @@ lemma ball_lt' {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : 𝚺-[m + 1].DefinableFunction f) (h : Γ-[m + 1].Definable (fun w ↦ P (w ·.succ) (w 0))) : Γ-[m + 1].Definable (fun v ↦ ∀ {x}, x < f v → P v x) := ball_lt hf h -lemma ball_le' [V ⊧ₘ* 𝗣𝗔⁻] {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} +lemma ball_le' [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] {Γ} {P : (Fin k → V) → V → Prop} {f : (Fin k → V) → V} (hf : 𝚺-[m + 1].DefinableFunction f) (h : Γ-[m + 1].Definable (fun w ↦ P (w ·.succ) (w 0))) : Γ-[m + 1].Definable (fun v ↦ ∀ {x}, x ≤ f v → P v x) := ball_le hf h @@ -872,4 +874,36 @@ attribute [aesop 11 (rule_sets := [Definability]) safe] Definable.all Definable.exs +/-! ### Auxiliary lemmata for aesop -/ + +section + +variable (P : (Fin k → V) → Prop) (f : (Fin k → V) → V) + +instance [𝚺₁.Definable P] : 𝚺-[0+1].Definable P := inferInstance + +instance [𝚷₁.Definable P] : 𝚷-[0+1].Definable P := inferInstance + +instance [𝚫₁.Definable P] : 𝚫-[0+1].Definable P := inferInstance + +instance [𝚺₁.DefinableFunction f] : 𝚺-[0+1].DefinableFunction f := inferInstance + +instance [𝚷₁.DefinableFunction f] : 𝚷-[0+1].DefinableFunction f := inferInstance + +instance [𝚫₁.DefinableFunction f] : 𝚫-[0+1].DefinableFunction f := inferInstance + +instance [𝚺-[2].Definable P] : 𝚺-[0+1+1].Definable P := inferInstance + +instance [𝚷-[2].Definable P] : 𝚷-[0+1+1].Definable P := inferInstance + +instance [𝚫-[2].Definable P] : 𝚫-[0+1+1].Definable P := inferInstance + +instance [𝚺-[2].DefinableFunction f] : 𝚺-[0+1+1].DefinableFunction f := inferInstance + +instance [𝚷-[2].DefinableFunction f] : 𝚷-[0+1+1].DefinableFunction f := inferInstance + +instance [𝚫-[2].DefinableFunction f] : 𝚫-[0+1+1].DefinableFunction f := inferInstance + +end + end LO.FirstOrder.Arithmetic.HierarchySymbol diff --git a/Foundation/FirstOrder/Arithmetic/Definability/Hierarchy.lean b/Foundation/FirstOrder/Arithmetic/Definability/Hierarchy.lean index b06ee6243..fa974206d 100644 --- a/Foundation/FirstOrder/Arithmetic/Definability/Hierarchy.lean +++ b/Foundation/FirstOrder/Arithmetic/Definability/Hierarchy.lean @@ -130,10 +130,10 @@ variable {M : Type*} [ORingStructure M] variable (M) def ProperOn (φ : 𝚫-[m].Semisentence n) : Prop := - ∀ (e : Fin n → M), Semiformula.Evalbm M e φ.sigma.val ↔ Semiformula.Evalbm M e φ.pi.val + ∀ (e : Fin n → M), φ.sigma.val.Evalb e ↔ φ.pi.val.Evalb e def ProperWithParamOn (φ : 𝚫-[m].Semiformula M n) : Prop := - ∀ (e : Fin n → M), Semiformula.Evalm M e id φ.sigma.val ↔ Semiformula.Evalm M e id φ.pi.val + ∀ (e : Fin n → M), φ.sigma.val.Eval e id ↔ φ.pi.val.Eval e id def ProvablyProperOn (φ : 𝚫-[m].Semisentence n) (T : Theory ℒₒᵣ) : Prop := T ⊢ ∀⁰* “!φ.sigma.val ⋯ ↔ !φ.pi.val ⋯” @@ -142,19 +142,19 @@ variable {M} lemma ProperOn.iff {φ : 𝚫-[m].Semisentence n} (h : φ.ProperOn M) (e : Fin n → M) : - Semiformula.Evalbm M e φ.sigma.val ↔ Semiformula.Evalbm M e φ.pi.val := h e + φ.sigma.val.Evalb e ↔ φ.pi.val.Evalb e := h e lemma ProperWithParamOn.iff {φ : 𝚫-[m].Semiformula M n} (h : φ.ProperWithParamOn M) (e : Fin n → M) : - Semiformula.Evalm M e id φ.sigma.val ↔ Semiformula.Evalm (L := ℒₒᵣ) M e id φ.pi.val := h e + φ.sigma.val.Eval e id ↔ φ.pi.val.Eval e id := h e lemma ProperOn.iff' {φ : 𝚫-[m].Semisentence n} (h : φ.ProperOn M) (e : Fin n → M) : - Semiformula.Evalbm M e φ.pi.val ↔ Semiformula.Evalbm M e φ.val := by simp [←h.iff, val_sigma] + φ.pi.val.Evalb e ↔ φ.val.Evalb e := by simp [←h.iff, val_sigma] lemma ProperWithParamOn.iff' {φ : 𝚫-[m].Semiformula M n} (h : φ.ProperWithParamOn M) (e : Fin n → M) : - Semiformula.Evalm M e id φ.pi.val ↔ Semiformula.Evalm (L := ℒₒᵣ) M e id φ.val := by simp [←h.iff, val_sigma] + φ.pi.val.Eval e id ↔ φ.val.Eval e id := by simp [←h.iff, val_sigma] inductive ProvablyProperOn' (T : Theory ℒₒᵣ) : {Γ : HierarchySymbol} → {n : ℕ} → (φ : Γ.Semisentence n) → Prop | sigma (φ : 𝚺-[m].Semisentence n) : φ.ProvablyProperOn' T @@ -165,9 +165,9 @@ section ProvablyProperOn variable (T : Theory ℒₒᵣ) -lemma ProvablyProperOn.ofProperOn [𝗘𝗤 ⪯ T] {φ : 𝚫-[m].Semisentence n} - (h : ∀ (M : Type w) [ORingStructure M] [M ⊧ₘ* T], φ.ProperOn M) : φ.ProvablyProperOn T := by - apply FirstOrder.Arithmetic.provable_of_models.{w} T _ ?_ +lemma ProvablyProperOn.ofProperOn [𝗘𝗤 ℒₒᵣ ⪯ T] {φ : 𝚫-[m].Semisentence n} + (h : ∀ (M : Type w) [ORingStructure M] [M↓[ℒₒᵣ] ⊧* T], φ.ProperOn M) : φ.ProvablyProperOn T := by + apply FirstOrder.Arithmetic.complete.{w} T _ ?_ intro M _ _ simpa [models_iff] using (h M).iff @@ -175,9 +175,9 @@ variable {T} lemma ProvablyProperOn.properOn {φ : 𝚫-[m].Semisentence n} (h : φ.ProvablyProperOn T) - (M : Type w) [ORingStructure M] [M ⊧ₘ* T] : φ.ProperOn M := by + (M : Type w) [ORingStructure M] [M↓[ℒₒᵣ] ⊧* T] : φ.ProperOn M := by intro v - have := by simpa [models_iff] using consequence_iff.mp (sound! h) M inferInstance + have := by simpa [models_iff] using consequence_iff.mp (Theory.Proof.sound h) M inferInstance exact this v end ProvablyProperOn @@ -357,8 +357,8 @@ lemma ProperOn.or {φ ψ : 𝚫-[m].Semisentence k} (hp : φ.ProperOn M) (hq : lemma ProperOn.neg {φ : 𝚫-[m].Semisentence k} (hp : φ.ProperOn M) : (∼φ).ProperOn M := by intro e; simp [hp.iff] -lemma ProperOn.eval_neg {φ : 𝚫-[m].Semisentence k} (hp : φ.ProperOn M) (e) : - Semiformula.Evalbm M e (∼φ).val ↔ ¬Semiformula.Evalbm M e φ.val := by +lemma ProperOn.eval_neg {φ : 𝚫-[m].Semisentence k} (hp : φ.ProperOn M) (e : Fin k → M) : + (∼φ).val.Evalb e ↔ ¬φ.val.Evalb e := by simp [←val_sigma, hp.iff] lemma ProperOn.ball {t} {φ : 𝚫-[m + 1].Semisentence (k + 1)} (hp : φ.ProperOn M) : (ball t φ).ProperOn M := by @@ -382,8 +382,8 @@ lemma ProperWithParamOn.or {φ ψ : 𝚫-[m].Semiformula M k} lemma ProperWithParamOn.neg {φ : 𝚫-[m].Semiformula M k} (hp : φ.ProperWithParamOn M) : (∼φ).ProperWithParamOn M := by intro e; simp [hp.iff] -lemma ProperWithParamOn.eval_neg {φ : 𝚫-[m].Semiformula M k} (hp : φ.ProperWithParamOn M) (e) : - Semiformula.Evalm M e id (∼φ).val ↔ ¬Semiformula.Evalm M e id φ.val := by +lemma ProperWithParamOn.eval_neg {φ : 𝚫-[m].Semiformula M k} (hp : φ.ProperWithParamOn M) (e : Fin k → M) : + (∼φ).val.Eval e id ↔ ¬φ.val.Eval e id := by simp [←val_sigma, hp.iff] lemma ProperWithParamOn.ball {t} {φ : 𝚫-[m].Semiformula M (k + 1)} @@ -396,7 +396,7 @@ lemma ProperWithParamOn.bexs {t} {φ : 𝚫-[m].Semiformula M (k + 1)} def graphDelta (φ : 𝚺-[m].Semiformula ξ (k + 1)) : 𝚫-[m].Semiformula ξ (k + 1) := match m with - | 0 => φ.ofZero _ + | 0 => φ.ofZero _ | m + 1 => mkDelta φ (mkPi “x. ∀ y, !φ.val y ⋯ → y = x”) @[simp] lemma graphDelta_val (φ : 𝚺-[m].Semiformula ξ (k + 1)) : φ.graphDelta.val = φ.val := by cases m <;> simp [graphDelta] diff --git a/Foundation/FirstOrder/Arithmetic/Exponential/Bit.lean b/Foundation/FirstOrder/Arithmetic/Exponential/Bit.lean index 2e73bb79b..65737a098 100644 --- a/Foundation/FirstOrder/Arithmetic/Exponential/Bit.lean +++ b/Foundation/FirstOrder/Arithmetic/Exponential/Bit.lean @@ -14,7 +14,7 @@ variable {V : Type*} [ORingStructure V] section -variable [V ⊧ₘ* 𝗜𝚺₁] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] section model @@ -149,20 +149,20 @@ section model scoped instance : Structure.Mem ℒₒᵣ V := ⟨by intro a b; simp [Semiformula.Operator.val, operator_mem_def]⟩ -@[simp] lemma eval_ballIn {t : Semiterm ℒₒᵣ ξ n} {p : Semiformula ℒₒᵣ ξ (n + 1)} {e ε} : - Semiformula.Evalm V e ε (ballIn t p) ↔ ∀ x ∈ t.valm V e ε, Semiformula.Evalm V (x :> e) ε p := by +@[simp] lemma eval_ballIn {t : Semiterm ℒₒᵣ ξ n} {φ : Semiformula ℒₒᵣ ξ (n + 1)} {bv : Fin n → V} {fv : ξ → V} : + (ballIn t φ).Eval (M := V) bv fv ↔ ∀ x ∈ t.val bv fv, φ.Eval (x :> bv) fv := by suffices - (∀ x < t.valm V e ε, x ∈ t.valm V e ε → Semiformula.Evalm V (x :> e) ε p) ↔ - ∀ x ∈ t.valm V e ε, Semiformula.Evalm V (x :> e) ε p by simpa [ballIn] + (∀ x < t.val bv fv, x ∈ t.val bv fv → φ.Eval (x :> bv) fv) ↔ + ∀ x ∈ t.val bv fv, φ.Eval (x :> bv) fv by simpa [ballIn] constructor · intro h x hx; exact h x (lt_of_mem hx) hx · intro h x _ hx; exact h x hx -@[simp] lemma eval_bexsIn {t : Semiterm ℒₒᵣ ξ n} {p : Semiformula ℒₒᵣ ξ (n + 1)} {e ε} : - Semiformula.Evalm V e ε (bexsIn t p) ↔ ∃ x ∈ t.valm V e ε, Semiformula.Evalm V (x :> e) ε p := by +@[simp] lemma eval_bexsIn {t : Semiterm ℒₒᵣ ξ n} {φ : Semiformula ℒₒᵣ ξ (n + 1)} {bv : Fin n → V} {fv : ξ → V} : + (bexsIn t φ).Eval (M := V) bv fv ↔ ∃ x ∈ t.val bv fv, φ.Eval (x :> bv) fv := by suffices - (∃ x < t.valm V e ε, x ∈ t.valm V e ε ∧ Semiformula.Evalm V (x :> e) ε p) ↔ - ∃ x ∈ t.valm V e ε, Semiformula.Evalm V (x :> e) ε p by simpa [bexsIn] + (∃ x < t.val bv fv, x ∈ t.val bv fv ∧ φ.Eval (x :> bv) fv) ↔ + ∃ x ∈ t.val bv fv, φ.Eval (x :> bv) fv by simpa [bexsIn] constructor · rintro ⟨x, _, hx, h⟩; exact ⟨x, hx, h⟩ · rintro ⟨x, hx, h⟩; exact ⟨x, lt_of_mem hx, hx, h⟩ @@ -195,7 +195,7 @@ section empty scoped instance : EmptyCollection V := ⟨0⟩ -omit [V ⊧ₘ* 𝗜𝚺₁] in +omit [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] in lemma emptyset_def : (∅ : V) = 0 := rfl @[simp] lemma not_mem_empty (i : V) : i ∉ (∅ : V) := by simp [emptyset_def, mem_iff_bit, Bit] @@ -489,12 +489,12 @@ end section -variable {m : ℕ} [Fact (1 ≤ m)] [V ⊧ₘ* 𝗜𝗡𝗗 𝚺 m] +variable {m : ℕ} [Fact (1 ≤ m)] [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚺 m] lemma finset_comprehension_aux (Γ : Polarity) {P : V → Prop} (hP : Γ-[m]-Predicate P) (a : V) : - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) ∃ s < Exp.exp a, ∀ i < a, i ∈ s ↔ P i := by - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) have : ∃ s < Exp.exp a, ∀ i < a, P i → i ∈ s := ⟨under a, pred_lt_self_of_pos (by simp), fun i hi _ ↦ by simpa [mem_under_iff] using hi⟩ rcases this with ⟨s, hsn, hs⟩ @@ -521,7 +521,7 @@ lemma finset_comprehension_aux (Γ : Polarity) {P : V → Prop} (hP : Γ-[m]-Pre exact ⟨t, lt_of_le_of_lt t_le_s hsn, fun i hi ↦ ⟨this i hi, ht i hi⟩⟩ theorem finset_comprehension {Γ} {P : V → Prop} (hP : Γ-[m]-Predicate P) (a : V) : - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) ∃ s < Exp.exp a, ∀ i < a, i ∈ s ↔ P i := match Γ with | 𝚺 => finset_comprehension_aux 𝚺 hP a @@ -529,9 +529,9 @@ theorem finset_comprehension {Γ} {P : V → Prop} (hP : Γ-[m]-Predicate P) (a | 𝚫 => finset_comprehension_aux 𝚺 hP.of_delta a theorem finset_comprehension_exists_unique {P : V → Prop} (hP : Γ-[m]-Predicate P) (a : V) : - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) ∃! s, s < Exp.exp a ∧ ∀ i < a, i ∈ s ↔ P i := by - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) rcases finset_comprehension hP a with ⟨s, hs, Hs⟩ exact ExistsUnique.intro s ⟨hs, Hs⟩ (by intro t ⟨ht, Ht⟩ @@ -550,7 +550,7 @@ end section -variable [V ⊧ₘ* 𝗜𝚺₁] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] instance : Fact (1 ≤ 1) := ⟨by rfl⟩ diff --git a/Foundation/FirstOrder/Arithmetic/Exponential/Exp.lean b/Foundation/FirstOrder/Arithmetic/Exponential/Exp.lean index 34bc51407..4fc81064c 100644 --- a/Foundation/FirstOrder/Arithmetic/Exponential/Exp.lean +++ b/Foundation/FirstOrder/Arithmetic/Exponential/Exp.lean @@ -19,7 +19,7 @@ variable {V : Type*} [ORingStructure V] section ISigma0 -variable [V ⊧ₘ* 𝗜𝚺₀] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] noncomputable def ext (u z : V) : V := z / u % u @@ -91,7 +91,7 @@ def Exponential.Seqₛ.def : 𝚺₀.Semisentence 3 := .mkSigma (∃ ext_u_Y <⁺ Y, !extDef ext_u_Y u Y ∧ !extDef (2 * ext_u_Y²) u² Y) ) ” instance Exponential.Seqₛ.defined : 𝚺₀-Relation₃[V] Exponential.Seqₛ via Exponential.Seqₛ.def := .mk fun v ↦ by - simp [Exponential.Seqₛ.iff, Exponential.Seqₛ.def, sq, numeral_eq_natCast] + simp [Exponential.Seqₛ.iff, Exponential.Seqₛ.def, sq] lemma Exponential.graph_iff (x y : V) : Exponential x y ↔ @@ -115,7 +115,7 @@ def _root_.LO.FirstOrder.Arithmetic.exponentialDef : 𝚺₀.Semisentence 2 := . /-- The graph of the exponential function can be defined by the $\Delta_0$-formula. -/ instance Exponential.defined : 𝚺₀-Relation[V] Exponential via exponentialDef := .mk fun v ↦ by - simp [Exponential.graph_iff, exponentialDef, pow_four, sq, numeral_eq_natCast] + simp [Exponential.graph_iff, exponentialDef, pow_four, sq] /-- The graph of the exponential function can be defined by the $\Delta_0$-formula. -/ instance exponential_definable : 𝚺₀-Relation (Exponential : V → V → Prop) := Exponential.defined.to_definable @@ -712,7 +712,7 @@ end ISigma0 section ISigma1 -variable [V ⊧ₘ* 𝗜𝚺₁] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] namespace Exponential diff --git a/Foundation/FirstOrder/Arithmetic/Exponential/Log.lean b/Foundation/FirstOrder/Arithmetic/Exponential/Log.lean index a15f2c27c..e68557e25 100644 --- a/Foundation/FirstOrder/Arithmetic/Exponential/Log.lean +++ b/Foundation/FirstOrder/Arithmetic/Exponential/Log.lean @@ -13,7 +13,7 @@ variable {V : Type*} [ORingStructure V] section ISigma0 -variable [V ⊧ₘ* 𝗜𝚺₀] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] lemma log_exists_unique_pos {y : V} (hy : 0 < y) : ∃! x, x < y ∧ ∃ y' ≤ y, Exponential x y' ∧ y < 2 * y' := by have : ∃ x < y, ∃ y' ≤ y, Exponential x y' ∧ y < 2 * y' := by @@ -71,7 +71,7 @@ lemma log_graph {x y : V} : x = log y ↔ (y = 0 → x = 0) ∧ (0 < y → x < y def _root_.LO.FirstOrder.Arithmetic.logDef : 𝚺₀.Semisentence 2 := .mkSigma “x y. (y = 0 → x = 0) ∧ (0 < y → x < y ∧ ∃ y' <⁺ y, !exponentialDef x y' ∧ y < 2 * y')” -instance log_defined : 𝚺₀-Function₁[V] log via logDef := .mk fun v ↦ by simp [logDef, log_graph, numeral_eq_natCast] +instance log_defined : 𝚺₀-Function₁[V] log via logDef := .mk fun v ↦ by simp [logDef, log_graph] instance log_definable : 𝚺₀-Function₁ (log : V → V) := log_defined.to_definable @@ -406,7 +406,7 @@ lemma fbit_eq_zero_of_le {a i : V} (hi : ‖a‖ ≤ i) : fbit a i = 0 := by sim def _root_.LO.FirstOrder.Arithmetic.fbitDef : 𝚺₀.Semisentence 3 := .mkSigma “b a i. ∃ x <⁺ a, !bexpDef x a i ∧ ∃ y <⁺ a, !divDef y a x ∧ !remDef b y 2” -instance fbit_defined : 𝚺₀-Function₂[V] fbit via fbitDef := .mk fun v ↦ by simp [fbitDef, fbit, numeral_eq_natCast] +instance fbit_defined : 𝚺₀-Function₂[V] fbit via fbitDef := .mk fun v ↦ by simp [fbitDef, fbit] instance fbit_definable : 𝚺₀-Function₂[V] fbit := fbit_defined.to_definable @@ -432,7 +432,7 @@ end ISigma0 section ISigma1 -variable [V ⊧ₘ* 𝗜𝚺₁] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] @[simp] lemma log_exponential (a : V) : log (Exp.exp a) = a := (exponential_exp a).log_eq_of_exp diff --git a/Foundation/FirstOrder/Arithmetic/Exponential/PPow2.lean b/Foundation/FirstOrder/Arithmetic/Exponential/PPow2.lean index c10afb446..df702ae05 100644 --- a/Foundation/FirstOrder/Arithmetic/Exponential/PPow2.lean +++ b/Foundation/FirstOrder/Arithmetic/Exponential/PPow2.lean @@ -11,7 +11,7 @@ $\mathrm{PPow2}(n)$ is a property that holds iff $n = 2^{2^i}$ for some $i$. namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₀] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] def SPPow2 (m : V) : Prop := ¬LenBit 1 m ∧ LenBit 2 m ∧ ∀ i ≤ m, Pow2 i → 2 < i → (LenBit i m ↔ (√i)^2 = i ∧ LenBit (√i) m) @@ -22,7 +22,7 @@ def _root_.LO.FirstOrder.Arithmetic.sppow2Def : 𝚺₀.Semisentence 1 := ” instance sppow2_defined : 𝚺₀-Predicate[V] SPPow2 via sppow2Def := .mk fun v ↦ by - simp [SPPow2, sppow2Def, sq, numeral_eq_natCast] + simp [SPPow2, sppow2Def, sq] def PPow2 (i : V) : Prop := Pow2 i ∧ ∃ m < 2 * i, SPPow2 m ∧ LenBit i m @@ -30,7 +30,7 @@ def _root_.LO.FirstOrder.Arithmetic.ppow2Def : 𝚺₀.Semisentence 1 := .mkSigma “i. !pow2Def i ∧ ∃ m < 2 * i, !sppow2Def m ∧ !lenbitDef i m” instance ppow2_defined : 𝚺₀-Predicate (PPow2 : V → Prop) via ppow2Def := .mk fun v ↦ by - simp [PPow2, ppow2Def, numeral_eq_natCast] + simp [PPow2, ppow2Def] instance ppow2_definable : 𝚺₀-Predicate (PPow2 : V → Prop) := ppow2_defined.to_definable diff --git a/Foundation/FirstOrder/Arithmetic/Exponential/Pow2.lean b/Foundation/FirstOrder/Arithmetic/Exponential/Pow2.lean index 80f5bff5e..d3f482de1 100644 --- a/Foundation/FirstOrder/Arithmetic/Exponential/Pow2.lean +++ b/Foundation/FirstOrder/Arithmetic/Exponential/Pow2.lean @@ -15,7 +15,7 @@ variable {V : Type*} [ORingStructure V] section IOpen -variable [V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻] def Pow2 (a : V) : Prop := 0 < a ∧ ∀ r ≤ a, 1 < r → r ∣ a → 2 ∣ r @@ -23,8 +23,7 @@ def _root_.LO.FirstOrder.Arithmetic.pow2Def : 𝚺₀.Semisentence 1 := .mkSigma “a. 0 < a ∧ ∀ r <⁺ a, 1 < r → r ∣ a → 2 ∣ r” instance pow2_defined : 𝚺₀-Predicate (Pow2 : V → Prop) via pow2Def := .mk fun v ↦ by - simp [Semiformula.eval_substs, Matrix.comp_vecCons', Matrix.constant_eq_singleton, - Pow2, pow2Def, le_iff_lt_succ, numeral_eq_natCast] + simp [Semiformula.eval_substs, Pow2, pow2Def, le_iff_lt_succ] instance pow2_definable : 𝚺₀-Predicate (Pow2 : V → Prop) := pow2_defined.to_definable @@ -116,7 +115,7 @@ def _root_.LO.FirstOrder.Arithmetic.lenbitDef : 𝚺₀.Semisentence 2 := .mkSigma “i a. ∃ z <⁺ a, !divDef.val z a i ∧ ¬2 ∣ z” instance lenbit_defined : 𝚺₀-Relation (LenBit : V → V → Prop) via lenbitDef := .mk fun v ↦ by - simp [lenbitDef, LenBit, numeral_eq_natCast] + simp [lenbitDef, LenBit] instance lenbit_definable : 𝚺₀-Relation (LenBit : V → V → Prop) := lenbit_defined.to_definable @@ -194,7 +193,7 @@ end IOpen section ISigma0 -variable [V ⊧ₘ* 𝗜𝚺₀] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] namespace Pow2 diff --git a/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean b/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean index 17340f50d..a3a88aed9 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/Basic.lean @@ -11,7 +11,7 @@ public import Foundation.FirstOrder.Arithmetic.Exponential namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] @[simp] lemma susbset_insert (x a : V) : a ⊆ insert x a := by intro z hz; simp [hz] @@ -579,6 +579,65 @@ theorem sigma₁_replacement₂ {f : V → V → V} (hf : 𝚺₁-Function₂ f) · rintro ⟨x₁, h₁, x₂, h₂, rfl⟩; exact ⟨⟪x₁, x₂⟫, by simp [h₁, h₂]⟩)).mp (sigma₁_replacement this (s₁ ×ʰᶠ s₂)) +/-! ### Image of HFS -/ + +noncomputable def hfsImage (f : V → V) [𝚺₁-Function₁ f] (s : V) : V := Classical.choose! (sigma₁_replacement (f := f) inferInstance s) + + +variable {L} + +section hfsImage + +variable {f : V → V} [𝚺₁-Function₁ f] + +lemma mem_hfsImage_iff {s y : V} : y ∈ hfsImage f s ↔ ∃ x ∈ s, y = f x := + Classical.choose!_spec (sigma₁_replacement (f := f) inferInstance s) y + +lemma app_mem_hfsImage {p s : V} (h : p ∈ s) : f p ∈ hfsImage f s := + mem_hfsImage_iff.mpr ⟨p, h, rfl⟩ + +lemma hfsImage_subset_of_subset {s t : V} (h : s ⊆ t) : hfsImage f s ⊆ hfsImage f t := by + intro y hy + rcases mem_hfsImage_iff.mp hy with ⟨x, hx, rfl⟩ + exact app_mem_hfsImage (h hx) + +@[simp] lemma mem_hfsImage_union {s t : V} : hfsImage f (s ∪ t) = hfsImage f s ∪ hfsImage f t := mem_ext <| by + simp only [mem_hfsImage_iff, mem_cup_iff]; grind + +@[simp] lemma mem_hfsImage_insert {x s : V} : hfsImage f (insert x s) = insert (f x) (hfsImage f s) := mem_ext <| by + simp [mem_hfsImage_iff] + +@[simp] lemma hfsImage_empty : hfsImage f (∅ : V) = ∅ := mem_ext <| by simp [mem_hfsImage_iff] + +section + +private lemma hfsImage_graph (t s : V) : + t = hfsImage f s ↔ (∀ y ∈ t, ∃ x ∈ s, y = f x) ∧ (∀ x ∈ s, f x ∈ t) := by + constructor + · rintro rfl + constructor + · intro y hy; exact mem_hfsImage_iff.mp hy + · intro x hx; exact mem_hfsImage_iff.mpr ⟨x, hx, rfl⟩ + · rintro ⟨h₁, h₂⟩ + apply mem_ext; intro y; constructor + · intro hy; exact mem_hfsImage_iff.mpr (h₁ y hy) + · intro hy + rcases mem_hfsImage_iff.mp hy with ⟨x, hx, rfl⟩ + exact h₂ x hx + +noncomputable def hfsImage.graph (δ : 𝚺₁.Semisentence 2) : 𝚺₁.Semisentence 2 := .mkSigma + “t s. (∀ y ∈' t, ∃ x ∈' s, !δ y x) ∧ (∀ x ∈' s, ∃ y, !δ y x ∧ y ∈ t)” + +abbrev hfsImage.defined (f : V → V) [𝚺₁-Function₁ f] (δ : 𝚺₁.Semisentence 2) [𝚺₁-Function₁ f via δ] : + 𝚺₁-Function₁[V] (hfsImage f) via (hfsImage.graph δ) := .mk fun v ↦ by simp [hfsImage.graph, hfsImage_graph] + +abbrev hfsImage.definable (f : V → V) [𝚺₁-Function₁ f] (δ : 𝚺₁.Semisentence 2) [𝚺₁-Function₁ f via δ] : + 𝚺₁-Function₁[V] hfsImage f := (hfsImage.defined f δ).to_definable + +end + +end hfsImage + section fstIdx noncomputable def fstIdx (p : V) : V := π₁ (p - 1) diff --git a/Foundation/FirstOrder/Arithmetic/HFS/Coding.lean b/Foundation/FirstOrder/Arithmetic/HFS/Coding.lean index d1459dce6..17e2d7281 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/Coding.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/Coding.lean @@ -5,7 +5,7 @@ public import Foundation.FirstOrder.Arithmetic.HFS.Vec @[expose] public section namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] noncomputable def finsetArithmetizeAux : List V → V | [] => ∅ diff --git a/Foundation/FirstOrder/Arithmetic/HFS/Fixpoint.lean b/Foundation/FirstOrder/Arithmetic/HFS/Fixpoint.lean index 2dd02d56b..9aea931e8 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/Fixpoint.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/Fixpoint.lean @@ -11,7 +11,7 @@ public import Foundation.FirstOrder.Arithmetic.HFS.PRF namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] namespace Fixpoint @@ -65,7 +65,7 @@ namespace Construction variable {k : ℕ} {φ : Blueprint k} (c : Construction V φ) (v : Fin k → V) lemma eval_formula (v : Fin k.succ.succ → V) : - Semiformula.Evalbm V v φ.core.val ↔ c.Φ (v ·.succ.succ) {x | x ∈ v 1} (v 0) := c.defined.iff + φ.core.val.Evalb v ↔ c.Φ (v ·.succ.succ) {x | x ∈ v 1} (v 0) := c.defined.iff lemma succ_existsUnique (s ih : V) : ∃! u : V, ∀ x, (x ∈ u ↔ x ≤ s ∧ c.Φ v {z | z ∈ ih} x) := by @@ -98,8 +98,8 @@ lemma succ_defined : 𝚺₁.DefinedFunction (fun v : Fin (k + 2) → V ↦ c.su c.defined.proper.iff', -and_imp, BinderNotation.finSuccItr] grind -lemma eval_succDef (v) : - Semiformula.Evalbm V v φ.succDef.val ↔ v 0 = c.succ (v ·.succ.succ.succ) (v 2) (v 1) := c.succ_defined.iff +lemma eval_succDef (v : Fin (k + 3) → V) : + φ.succDef.val.Evalb v ↔ v 0 = c.succ (v ·.succ.succ.succ) (v 2) (v 1) := c.succ_defined.iff noncomputable def prConstruction : PR.Construction V φ.prBlueprint where zero := fun _ ↦ ∅ @@ -120,8 +120,8 @@ lemma limSeq_succ (s : V) : c.limSeq v (s + 1) = c.succ v s (c.limSeq v s) := by lemma termSet_defined : 𝚺₁.DefinedFunction (fun v ↦ c.limSeq (v ·.succ) (v 0)) φ.limSeqDef := .mk fun v ↦ by simp [c.prConstruction.result_defined_iff, Blueprint.limSeqDef]; rfl -@[simp] lemma eval_limSeqDef (v) : - Semiformula.Evalbm V v φ.limSeqDef.val ↔ v 0 = c.limSeq (v ·.succ.succ) (v 1) := c.termSet_defined.iff +@[simp] lemma eval_limSeqDef (v : Fin (k + 2) → V) : + φ.limSeqDef.val.Evalb v ↔ v 0 = c.limSeq (v ·.succ.succ) (v 1) := c.termSet_defined.iff instance limSeq_definable : 𝚺₁.DefinableFunction (fun v ↦ c.limSeq (v ·.succ) (v 0)) := c.termSet_defined.to_definable @@ -234,15 +234,15 @@ section lemma fixpoint_defined : 𝚺₁.Defined (fun v ↦ c.Fixpoint (v ·.succ) (v 0)) φ.fixpointDef := .mk fun v ↦ by simp [Blueprint.fixpointDef, c.eval_limSeqDef]; rfl -@[simp] lemma eval_fixpointDef (v) : - Semiformula.Evalbm V v φ.fixpointDef.val ↔ c.Fixpoint (v ·.succ) (v 0) := c.fixpoint_defined.iff +@[simp] lemma eval_fixpointDef (v : Fin (k + 1) → V) : + φ.fixpointDef.val.Evalb v ↔ c.Fixpoint (v ·.succ) (v 0) := c.fixpoint_defined.iff lemma fixpoint_definedΔ₁ [c.StrongFinite] : 𝚫₁.Defined (fun v ↦ c.Fixpoint (v ·.succ) (v 0)) φ.fixpointDefΔ₁ := ⟨by intro v; simp [Blueprint.fixpointDefΔ₁, c.eval_limSeqDef], by intro v; simp [Blueprint.fixpointDefΔ₁, c.eval_limSeqDef, fixpoint_iff]⟩ -@[simp] lemma eval_fixpointDefΔ₁ [c.StrongFinite] (v) : - Semiformula.Evalbm V v φ.fixpointDefΔ₁.val ↔ c.Fixpoint (v ·.succ) (v 0) := c.fixpoint_definedΔ₁.iff +@[simp] lemma eval_fixpointDefΔ₁ [c.StrongFinite] (v : Fin (k + 1) → V) : + φ.fixpointDefΔ₁.val.Evalb v ↔ c.Fixpoint (v ·.succ) (v 0) := c.fixpoint_definedΔ₁.iff end diff --git a/Foundation/FirstOrder/Arithmetic/HFS/PRF.lean b/Foundation/FirstOrder/Arithmetic/HFS/PRF.lean index 14591d500..32048abe5 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/PRF.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/PRF.lean @@ -11,7 +11,7 @@ public import Foundation.FirstOrder.Arithmetic.HFS.Seq namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] namespace PR @@ -68,8 +68,8 @@ private lemma cseq_iff (s : V) : c.CSeq v s ↔ lemma cseq_defined : 𝚺₁.Defined (fun v ↦ c.CSeq (v ·.succ) (v 0) : (Fin (k + 1) → V) → Prop) p.cseqDef := .mk fun v ↦ by simp [Blueprint.cseqDef, cseq_iff, c.zero_defined.iff, c.succ_defined.iff] -@[simp] lemma cseq_defined_iff (v) : - Semiformula.Evalbm V v p.cseqDef.val ↔ c.CSeq (v ·.succ) (v 0) := c.cseq_defined.iff +@[simp] lemma cseq_defined_iff (v : Fin (k + 1) → V) : + p.cseqDef.val.Evalb v ↔ c.CSeq (v ·.succ) (v 0) := c.cseq_defined.iff variable {c v} @@ -140,7 +140,7 @@ lemma CSeq.exists (l : V) : ∃ s, c.CSeq v s ∧ l + 1 = lh s := by · apply HierarchySymbol.Definable.exs apply HierarchySymbol.Definable.and · exact ⟨p.cseqDef.rew (Rew.embSubsts <| #0 :> fun i ↦ &(v i)), by - intro w; simpa [Matrix.comp_vecCons'] using c.cseq_defined_iff (w 0 :> v)⟩ + intro w; simpa [Matrix.comp_vecCons''] using c.cseq_defined_iff (w 0 :> v)⟩ · definability case zero => exact ⟨!⟦c.zero v⟧, CSeq.initial, by simp⟩ @@ -194,8 +194,8 @@ lemma result_defined : 𝚺₁.DefinedFunction (fun v ↦ c.result (v ·.succ) ( lemma result_defined_delta : 𝚫₁.DefinedFunction (fun v ↦ c.result (v ·.succ) (v 0) : (Fin (k + 1) → V) → V) p.resultDeltaDef := c.result_defined.graph_delta -@[simp] lemma result_defined_iff (v) : - Semiformula.Evalbm V v p.resultDef.val ↔ v 0 = c.result (v ·.succ.succ) (v 1) := c.result_defined.iff +@[simp] lemma result_defined_iff (v : Fin (k + 2) → V) : + p.resultDef.val.Evalb v ↔ v 0 = c.result (v ·.succ.succ) (v 1) := c.result_defined.iff instance result_definable : 𝚺₁.DefinableFunction (fun v ↦ c.result (v ·.succ) (v 0) : (Fin (k + 1) → V) → V) := c.result_defined.to_definable diff --git a/Foundation/FirstOrder/Arithmetic/HFS/Seq.lean b/Foundation/FirstOrder/Arithmetic/HFS/Seq.lean index ffcfacb98..0ebb19a6c 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/Seq.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/Seq.lean @@ -11,7 +11,7 @@ public import Foundation.FirstOrder.Arithmetic.HFS.Basic namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] def Seq (s : V) : Prop := IsMapping s ∧ ∃ l, domain s = under l diff --git a/Foundation/FirstOrder/Arithmetic/HFS/Vec.lean b/Foundation/FirstOrder/Arithmetic/HFS/Vec.lean index 906b53958..b70f6fdf9 100644 --- a/Foundation/FirstOrder/Arithmetic/HFS/Vec.lean +++ b/Foundation/FirstOrder/Arithmetic/HFS/Vec.lean @@ -11,7 +11,7 @@ public import Foundation.FirstOrder.Arithmetic.HFS.Fixpoint namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] section adjoin @@ -501,8 +501,8 @@ lemma result_defined : 𝚺₁.DefinedFunction (fun v ↦ c.result (v ·.succ) ( · intro h; symm; simpa using c.result_eq_of_graph _ h · intro h; rw [h]; exact c.result_graph _ _ -@[simp] lemma eval_resultDef (v) : - Semiformula.Evalbm V v β.resultDef.val ↔ v 0 = c.result (v ·.succ.succ) (v 1) := c.result_defined.iff +@[simp] lemma eval_resultDef (v : Fin (arity + 2) → V) : + β.resultDef.val.Evalb v ↔ v 0 = c.result (v ·.succ.succ) (v 1) := c.result_defined.iff instance result_definable : 𝚺₁.DefinableFunction (fun v ↦ c.result (v ·.succ) (v 0)) := c.result_defined.to_definable diff --git a/Foundation/FirstOrder/Arithmetic/IOpen/Basic.lean b/Foundation/FirstOrder/Arithmetic/IOpen/Basic.lean index 5bd497cf5..fe38dfe74 100644 --- a/Foundation/FirstOrder/Arithmetic/IOpen/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/IOpen/Basic.lean @@ -14,33 +14,33 @@ variable {V : Type*} [ORingStructure V] section IOpen -variable [V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻] -instance : V ⊧ₘ* 𝗣𝗔⁻ := - have : V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻 := inferInstance +instance : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻 := inferInstance models_of_subtheory this -instance : V ⊧ₘ* InductionScheme ℒₒᵣ Semiformula.Open := - have : V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻 := inferInstance +instance : V↓[ℒₒᵣ] ⊧* InductionScheme ℒₒᵣ Semiformula.Open := + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻 := inferInstance models_of_subtheory this @[elab_as_elim] lemma succ_induction {P : V → Prop} - (hP : ∃ p : Semiformula ℒₒᵣ V 1, p.Open ∧ ∀ x, P x ↔ Semiformula.Evalm V ![x] id p) + (hP : ∃ φ : Semiformula ℒₒᵣ V 1, φ.Open ∧ ∀ x, P x ↔ φ.Eval ![x] id) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := InductionScheme.succ_induction (C := Semiformula.Open) (by - rcases hP with ⟨p, hp, hhp⟩ + rcases hP with ⟨φ, hp, hhp⟩ haveI : Inhabited V := Classical.inhabited_of_nonempty' - refine ⟨p.enumarateFVar, Rew.rewriteMap p.idxOfFVar ▹ p, by simp [hp], ?_⟩ + refine ⟨φ.enumarateFVar, Rew.rewriteMap φ.idxOfFVar ▹ φ, by simp [hp], ?_⟩ intro x simp only [hhp, Nat.succ_eq_add_one, Nat.reduceAdd, Semiformula.eval_rewriteMap] - exact Semiformula.eval_iff_of_funEqOn p (by + exact Semiformula.eval_iff_of_funEqOn φ (by intro z hz simp [Semiformula.enumarateFVar_idxOfFVar (Semiformula.mem_fvarList_iff_fvar?.mpr hz)])) zero succ lemma least_number {P : V → Prop} - (hP : ∃ p : Semiformula ℒₒᵣ V 1, p.Open ∧ ∀ x, P x ↔ Semiformula.Evalm V ![x] id p) + (hP : ∃ φ : Semiformula ℒₒᵣ V 1, φ.Open ∧ ∀ x, P x ↔ φ.Eval ![x] id) (zero : P 0) {a} (counterex : ¬P a) : ∃ x, P x ∧ ¬P (x + 1) := by by_contra A have : ∀ x, P x := by @@ -551,7 +551,7 @@ prefix: 80 "π₁" => pi₁ prefix: 80 "π₂" => pi₂ -@[simp] lemma pair_unpair (a : V) : ⟪π₁ a, π₂ a⟫ = a := by +@[simp, grind =] lemma pair_unpair (a : V) : ⟪π₁ a, π₂ a⟫ = a := by simp only [pi₁, unpair, pi₂] split_ifs with h · simp [pair, h] @@ -563,7 +563,7 @@ prefix: 80 "π₂" => pi₂ _ = √a * √a + (a - √a * √a) := by simp [add_tsub_self_of_le this] _ = a := add_tsub_self_of_le (by simp) -@[simp] lemma unpair_pair (a b : V) : unpair ⟪a, b⟫ = (a, b) := by +@[simp, grind =] lemma unpair_pair (a b : V) : unpair ⟪a, b⟫ = (a, b) := by simp only [pair]; split_ifs with h · have : √(b * b + a) = b := sqrt_eq_of_le_of_le (by simp) (by simpa using le_trans (le_of_lt h) (by simp)) simp [unpair, this, show ¬b ≤ a from by simpa using h] @@ -571,9 +571,9 @@ prefix: 80 "π₂" => pi₂ sqrt_eq_of_le_of_le (by simp) (by simp [two_mul, show b ≤ a from by simpa using h]) simp [unpair, this, add_assoc] -@[simp] lemma pi₁_pair (a b : V) : π₁ ⟪a, b⟫ = a := by simp [pi₁] +@[simp, grind =] lemma pi₁_pair (a b : V) : π₁ ⟪a, b⟫ = a := by simp [pi₁] -@[simp] lemma pi₂_pair (a b : V) : π₂ ⟪a, b⟫ = b := by simp [pi₂] +@[simp, grind =] lemma pi₂_pair (a b : V) : π₂ ⟪a, b⟫ = b := by simp [pi₂] noncomputable def pairEquiv : V × V ≃ V := ⟨Function.uncurry pair, unpair, fun ⟨a, b⟩ => unpair_pair a b, pair_unpair⟩ @@ -670,7 +670,7 @@ lemma pair_lt_pair {a₁ a₂ b₁ b₂ : V} (ha : a₁ < a₂) (hb : b₁ < b · simp [←add_assoc, add_right_comm _ a]; simp [add_right_comm _ (b * b)] · simp [←add_assoc, add_right_comm _ b]; simp [add_right_comm _ a]; simp [add_assoc] -@[simp] lemma pair_ext_iff {a₁ a₂ b₁ b₂ : V} : ⟪a₁, b₁⟫ = ⟪a₂, b₂⟫ ↔ a₁ = a₂ ∧ b₁ = b₂ := +@[simp, grind =>] lemma pair_ext_iff {a₁ a₂ b₁ b₂ : V} : ⟪a₁, b₁⟫ = ⟪a₂, b₂⟫ ↔ a₁ = a₂ ∧ b₁ = b₂ := ⟨fun e ↦ ⟨by simpa using congr_arg (π₁ ·) e, by simpa using congr_arg (π₂ ·) e⟩, by rintro ⟨rfl, rfl⟩; simp⟩ section @@ -769,11 +769,11 @@ end IOpen /-! ### Polynomial induction -/ @[elab_as_elim] -lemma polynomial_induction [V ⊧ₘ* 𝗣𝗔⁻] (Γ m) [V ⊧ₘ* 𝗜𝗡𝗗 Γ m] +lemma polynomial_induction [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] (Γ m) [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m] {P : V → Prop} (hP : Γ-[m]-Predicate P) (zero : P 0) (even : ∀ x > 0, P x → P (2 * x)) (odd : ∀ x, P x → P (2 * x + 1)) : ∀ x, P x := by - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance - have : V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻 := models_of_subtheory this + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻 := models_of_subtheory this intro x; induction x using InductionOnHierarchy.order_induction · exact Γ · exact m @@ -787,15 +787,15 @@ lemma polynomial_induction [V ⊧ₘ* 𝗣𝗔⁻] (Γ m) [V ⊧ₘ* 𝗜𝗡 · simpa [←hx] using even (x / 2) (by by_contra A; simp at A; simp [show x = 0 from by simpa [A] using hx] at pos) (IH (x / 2) this) · simpa [←hx] using odd (x / 2) (IH (x / 2) this) -@[elab_as_elim] lemma sigma0_polynomial_induction [V ⊧ₘ* 𝗜𝚺₀] {P : V → Prop} (hP : 𝚺₀-Predicate P) +@[elab_as_elim] lemma sigma0_polynomial_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] {P : V → Prop} (hP : 𝚺₀-Predicate P) (zero : P 0) (even : ∀ x > 0, P x → P (2 * x)) (odd : ∀ x, P x → P (2 * x + 1)) : ∀ x, P x := polynomial_induction 𝚺 0 (P := P) hP zero even odd -@[elab_as_elim] lemma sigma1_polynomial_induction [V ⊧ₘ* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚺₁-Predicate P) +@[elab_as_elim] lemma sigma1_polynomial_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚺₁-Predicate P) (zero : P 0) (even : ∀ x > 0, P x → P (2 * x)) (odd : ∀ x, P x → P (2 * x + 1)) : ∀ x, P x := polynomial_induction 𝚺 1 (P := P) hP zero even odd -@[elab_as_elim] lemma pi1_polynomial_induction [V ⊧ₘ* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚷₁-Predicate P) +@[elab_as_elim] lemma pi1_polynomial_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚷₁-Predicate P) (zero : P 0) (even : ∀ x > 0, P x → P (2 * x)) (odd : ∀ x, P x → P (2 * x + 1)) : ∀ x, P x := polynomial_induction 𝚷 1 (P := P) hP zero even odd diff --git a/Foundation/FirstOrder/Arithmetic/Induction.lean b/Foundation/FirstOrder/Arithmetic/Induction.lean index 4321a9057..0d32de6fb 100644 --- a/Foundation/FirstOrder/Arithmetic/Induction.lean +++ b/Foundation/FirstOrder/Arithmetic/Induction.lean @@ -13,7 +13,7 @@ variable {V : Type*} [ORingStructure V] section ISigma1 -variable [V ⊧ₘ* 𝗜𝚺₁] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] @[elab_as_elim] lemma sigma1_pos_succ_induction {P : V → Prop} (hP : 𝚺₁-Predicate P) @@ -202,11 +202,11 @@ end ISigma1 section Induction -variable (m : ℕ) [Fact (1 ≤ m)] [V ⊧ₘ* 𝗜𝗡𝗗𝚺 m] +variable (m : ℕ) [Fact (1 ≤ m)] [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗𝚺 m] lemma sigma_or_pi_succ_induction {P Q : V → Prop} (hP : 𝚺-[m]-Predicate P) (hQ : 𝚷-[m]-Predicate Q) (zero : P 0 ∨ Q 0) (succ : ∀ x, P x ∨ Q x → P (x + 1) ∨ Q (x + 1)) : ∀ x, P x ∨ Q x := by - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) intro a have : ∃ p < Exp.exp (a + 1), ∀ x ≤ a, x ∈ p ↔ P x := by simpa [lt_succ_iff_le] using finset_comprehension hP (a + 1) @@ -229,7 +229,7 @@ lemma sigma_or_pi_succ_induction {P Q : V → Prop} (hP : 𝚺-[m]-Predicate P) lemma sigma_or_pi_order_induction {P Q : V → Prop} (hP : 𝚺-[m]-Predicate P) (hQ : 𝚷-[m]-Predicate Q) (ind : ∀ x, (∀ y < x, P y ∨ Q y) → P x ∨ Q x) : ∀ x, P x ∨ Q x := by - haveI : V ⊧ₘ* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := mod_ISigma_of_le (show 1 ≤ m from Fact.out) intro a have : ∃ p < Exp.exp (a + 1), ∀ x ≤ a, x ∈ p ↔ P x := by simpa [lt_succ_iff_le] using finset_comprehension hP (a + 1) diff --git a/Foundation/FirstOrder/Arithmetic/Omega1/Basic.lean b/Foundation/FirstOrder/Arithmetic/Omega1/Basic.lean index bdfdcfbea..3ca043870 100644 --- a/Foundation/FirstOrder/Arithmetic/Omega1/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/Omega1/Basic.lean @@ -25,23 +25,23 @@ noncomputable section variable {V : Type*} [ORingStructure V] -lemma models_Omega1_iff [V ⊧ₘ* 𝗜𝚺₀] : V ⊧ₘ Omega1.omega1 ↔ ∀ x : V, ∃ y, Exponential (‖x‖^2) y := by +lemma models_Omega1_iff [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] : V↓[ℒₒᵣ] ⊧ Omega1.omega1 ↔ ∀ x : V, ∃ y, Exponential (‖x‖^2) y := by simp [models_iff, Omega1.omega1, sq] -lemma omega1_of_ISigma1 [V ⊧ₘ* 𝗜𝚺₁] : V ⊧ₘ Omega1.omega1 := models_Omega1_iff.mpr (fun x ↦ Exponential.range_exists (‖x‖^2)) +lemma omega1_of_ISigma1 [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] : V↓[ℒₒᵣ] ⊧ Omega1.omega1 := models_Omega1_iff.mpr (fun x ↦ Exponential.range_exists (‖x‖^2)) -instance [V ⊧ₘ* 𝗜𝚺₁] : V ⊧ₘ* 𝗜𝚺₀ + 𝝮₁ := - ModelsTheory.add_iff.mpr +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ ∪ 𝝮₁ := + Semantics.ModelsSet.union_iff.mpr ⟨inferInstance, ⟨by intro _; simp only [Theory.OmegaOne.mem_iff]; rintro rfl; exact omega1_of_ISigma1⟩⟩ -variable [V ⊧ₘ* 𝗜𝚺₀ + 𝝮₁] +variable [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ ∪ 𝝮₁] -instance : V ⊧ₘ* 𝗜𝚺₀ := ModelsTheory.of_add_left V 𝗜𝚺₀ 𝝮₁ +instance : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ := ModelsTheory.of_add_left V 𝗜𝚺₀ 𝝮₁ -instance : V ⊧ₘ* 𝝮₁ := ModelsTheory.of_add_right V 𝗜𝚺₀ 𝝮₁ +instance : V↓[ℒₒᵣ] ⊧* 𝝮₁ := ModelsTheory.of_add_right V 𝗜𝚺₀ 𝝮₁ lemma exists_exponential_sq_length (x : V) : ∃ y, Exponential (‖x‖^2) y := - models_Omega1_iff.mp (ModelsTheory.models V Omega1.omega) x + models_Omega1_iff.mp (Theory.models _ _ Omega1.omega) x lemma exists_unique_exponential_sq_length (x : V) : ∃! y, Exponential (‖x‖^2) y := by rcases exists_exponential_sq_length x with ⟨y, h⟩ @@ -127,10 +127,10 @@ lemma smash_two_mul_le_sq_smash (a b : V) : a ⨳ (2 * b) ≤ (a ⨳ b) ^ 2 := b end -instance : 𝗜𝚺₀ ⪯ 𝗜𝚺₀ + 𝝮₁ := inferInstance +instance : 𝗜𝚺₀ ⪯ 𝗜𝚺₀ ∪ 𝝮₁ := inferInstance -instance : 𝗜𝚺₀ + 𝝮₁ ⪯ 𝗜𝚺₁ := weakerThan_of_models.{0} _ _ fun _ _ _ ↦ inferInstance +instance : 𝗜𝚺₀ ∪ 𝝮₁ ⪯ 𝗜𝚺₁ := weakerThan_of_models.{0} _ _ fun _ _ _ ↦ inferInstance -instance : ℕ ⊧ₘ* 𝗜𝚺₀ + 𝝮₁ := inferInstance +instance : ℕ↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ ∪ 𝝮₁ := inferInstance end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Arithmetic/Omega1/Nuon.lean b/Foundation/FirstOrder/Arithmetic/Omega1/Nuon.lean index e5c58df81..6dc920798 100644 --- a/Foundation/FirstOrder/Arithmetic/Omega1/Nuon.lean +++ b/Foundation/FirstOrder/Arithmetic/Omega1/Nuon.lean @@ -5,7 +5,7 @@ public import Foundation.FirstOrder.Arithmetic.Omega1.Basic @[expose] public section namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₀ + 𝝮₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ ∪ 𝝮₁] namespace Nuon @@ -73,7 +73,7 @@ def extDef : 𝚺₀.Semisentence 4 := .mkSigma @[simp] lemma cons_app_nine {n : ℕ} (a : α) (s : Fin n.succ.succ.succ.succ.succ.succ.succ.succ.succ → α) : (a :> s) 9 = s 8 := rfl -instance ext_defined : 𝚺₀-Function₃ (ext : V → V → V → V) via extDef := .mk fun v ↦ by simp [extDef, ext_graph, numeral_eq_natCast] +instance ext_defined : 𝚺₀-Function₃ (ext : V → V → V → V) via extDef := .mk fun v ↦ by simp [extDef, ext_graph] instance ext_Definable : 𝚺₀-Function₃ (ext : V → V → V → V) := ext_defined.to_definable @@ -491,7 +491,7 @@ def isSegmentDef : 𝚺₀.Semisentence 5 := .mkSigma set_option linter.flexible false in instance isSegmentDef_defined : 𝚺₀.Defined (V := V) (λ v ↦ IsSegment (v 0) (v 1) (v 2) (v 3) (v 4)) isSegmentDef := .mk fun v ↦ by - simp [IsSegment, isSegmentDef, numeral_eq_natCast] + simp [IsSegment, isSegmentDef] apply forall₂_congr; intro x _ constructor · rintro ⟨_, h⟩; exact h.symm @@ -511,12 +511,12 @@ def isSeriesDef : 𝚺₀.Semisentence 6 := .mkSigma ∃ y <⁺ T, !extDef y L T (l + 1) ∧ !segmentDef U L A (lI * l) lI x y” -omit [V ⊧ₘ* 𝗜𝚺₀ + 𝝮₁] in +omit [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ ∪ 𝝮₁] in lemma bexs_eq_le_iff {p : V → Prop} {b : V} : (∃ a ≤ z, a = b ∧ p a) ↔ (b ≤ z ∧ p b) := ⟨by rintro ⟨a, hp, rfl, hr⟩; exact ⟨hp, hr⟩, by rintro ⟨hp, hr⟩; exact ⟨b, hp, rfl, hr⟩⟩ -omit [V ⊧ₘ* 𝗜𝚺₀ + 𝝮₁] in +omit [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ ∪ 𝝮₁] in lemma bexs_eq_lt_iff {p : V → Prop} {b : V} : (∃ a < z, a = b ∧ p a) ↔ (b < z ∧ p b) := ⟨by rintro ⟨a, hp, rfl, hr⟩; exact ⟨hp, hr⟩, by rintro ⟨hp, hr⟩; exact ⟨b, hp, rfl, hr⟩⟩ @@ -556,7 +556,7 @@ def nuonAuxDef : 𝚺₀.Semisentence 3 := .mkSigma !seriesSegmentDef ((2 * A + 1) ^' 128) g (lg ²) A k n” instance nuonAux_defined : 𝚺₀-Relation₃ (NuonAux : V → V → V → Prop) via nuonAuxDef := .mk fun v ↦ by - simp [NuonAux, polyU, polyI, polyL, nuonAuxDef, numeral_eq_natCast] + simp [NuonAux, polyU, polyI, polyL, nuonAuxDef] instance nuonAux_definable : 𝚺₀-Relation₃ (NuonAux : V → V → V → Prop) := nuonAux_defined.to_definable diff --git a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Basic.lean b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Basic.lean index fc1e7283d..ad37f8183 100644 --- a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Basic.lean @@ -33,7 +33,7 @@ abbrev ltTri : Sentence ℒₒᵣ := “∀ x y, x < y ∨ x = y ∨ x > end PeanoMinus.Axiom inductive PeanoMinus : ArithmeticTheory - | equal : ∀ φ ∈ 𝗘𝗤, PeanoMinus φ + | equal : ∀ φ ∈ 𝗘𝗤 ℒₒᵣ, PeanoMinus φ | addZero : PeanoMinus PeanoMinus.Axiom.addZero | addAssoc : PeanoMinus PeanoMinus.Axiom.addAssoc | addComm : PeanoMinus PeanoMinus.Axiom.addComm @@ -60,7 +60,7 @@ open FirstOrder Arithmetic Language @[simp] lemma finite : Set.Finite 𝗣𝗔⁻ := by have : 𝗣𝗔⁻ = - 𝗘𝗤 ∪ + 𝗘𝗤 ℒₒᵣ ∪ { Axiom.addZero, Axiom.addAssoc, Axiom.addComm, @@ -137,7 +137,7 @@ open FirstOrder Arithmetic Language apply Set.finite_singleton set_option linter.flexible false in -@[simp] instance : ℕ ⊧ₘ* 𝗣𝗔⁻ := ⟨by +@[simp] instance : ℕ↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := ⟨by intro σ h rcases h <;> simp [models_iff] case addAssoc => intros; exact add_assoc _ _ _ @@ -151,10 +151,10 @@ set_option linter.flexible false in case ltTrans => intro a b c; exact Nat.lt_trans case ltTri => intros; exact Nat.lt_trichotomy _ _ case equal h => - have : ℕ ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h⟩ + have : ℕ↓[ℒₒᵣ] ⊧* (𝗘𝗤 ℒₒᵣ : ArithmeticTheory) := inferInstance + exact models_theory_iff.mp this _ h⟩ -instance : 𝗘𝗤 ⪯ 𝗣𝗔⁻ := Entailment.WeakerThan.ofSubset <| fun φ hp ↦ PeanoMinus.equal φ hp +instance : 𝗘𝗤 ℒₒᵣ ⪯ 𝗣𝗔⁻ := Entailment.WeakerThan.ofSubset fun φ hp ↦ PeanoMinus.equal φ hp end PeanoMinus @@ -164,58 +164,58 @@ scoped instance : LE M := ⟨fun x y => x = y ∨ x < y⟩ lemma le_def {x y : M} : x ≤ y ↔ x = y ∨ x < y := iff_of_eq rfl -variable [M ⊧ₘ* 𝗣𝗔⁻] +variable [M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] protected lemma add_zero' : ∀ x : M, x + 0 = x := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.addZero + simpa [models_iff] using Theory.models M _ PeanoMinus.addZero protected lemma add_assoc : ∀ x y z : M, (x + y) + z = x + (y + z) := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.addAssoc + simpa [models_iff] using Theory.models M _ PeanoMinus.addAssoc protected lemma add_comm : ∀ x y : M, x + y = y + x := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.addComm + simpa [models_iff] using Theory.models M _ PeanoMinus.addComm lemma add_eq_of_lt : ∀ x y : M, x < y → ∃ z, x + z = y := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.addEqOfLt + simpa [models_iff] using Theory.models M _ PeanoMinus.addEqOfLt @[simp] protected lemma zero_le : ∀ x : M, 0 ≤ x := by - simpa [models_iff, Structure.le_iff_of_eq_of_lt] using ModelsTheory.models M PeanoMinus.zeroLe + simpa [models_iff, Structure.le_iff_of_eq_of_lt] using Theory.models M _ PeanoMinus.zeroLe lemma zero_lt_one : (0 : M) < 1 := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.zeroLtOne + simpa [models_iff] using Theory.models M _ PeanoMinus.zeroLtOne lemma one_le_of_zero_lt : ∀ x : M, 0 < x → 1 ≤ x := by - simpa [models_iff, Structure.le_iff_of_eq_of_lt] using ModelsTheory.models M PeanoMinus.oneLeOfZeroLt + simpa [models_iff, Structure.le_iff_of_eq_of_lt] using Theory.models M _ PeanoMinus.oneLeOfZeroLt lemma add_lt_add : ∀ x y z : M, x < y → x + z < y + z := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.addLtAdd + simpa [models_iff] using Theory.models M _ PeanoMinus.addLtAdd protected lemma mul_zero' : ∀ x : M, x * 0 = 0 := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.mulZero + simpa [models_iff] using Theory.models M _ PeanoMinus.mulZero protected lemma mul_one : ∀ x : M, x * 1 = x := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.mulOne + simpa [models_iff] using Theory.models M _ PeanoMinus.mulOne protected lemma mul_assoc : ∀ x y z : M, (x * y) * z = x * (y * z) := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.mulAssoc + simpa [models_iff] using Theory.models M _ PeanoMinus.mulAssoc protected lemma mul_comm : ∀ x y : M, x * y = y * x := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.mulComm + simpa [models_iff] using Theory.models M _ PeanoMinus.mulComm lemma mul_lt_mul : ∀ x y z : M, x < y → 0 < z → x * z < y * z := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.mulLtMul + simpa [models_iff] using Theory.models M _ PeanoMinus.mulLtMul lemma mul_add_distr : ∀ x y z : M, x * (y + z) = x * y + x * z := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.distr + simpa [models_iff] using Theory.models M _ PeanoMinus.distr lemma lt_irrefl : ∀ x : M, ¬x < x := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.ltIrrefl + simpa [models_iff] using Theory.models M _ PeanoMinus.ltIrrefl protected lemma lt_trans : ∀ x y z : M, x < y → y < z → x < z := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.ltTrans + simpa [models_iff] using Theory.models M _ PeanoMinus.ltTrans lemma lt_tri : ∀ x y : M, x < y ∨ x = y ∨ y < x := by - simpa [models_iff] using ModelsTheory.models M PeanoMinus.ltTri + simpa [models_iff] using Theory.models M _ PeanoMinus.ltTri scoped instance : AddCommMonoid M where add_assoc := Arithmetic.add_assoc @@ -293,10 +293,12 @@ scoped instance : CanonicallyOrderedAdd M where scoped instance : IsOrderedAddMonoid M where add_le_add_left _ _ h z := (add_le_add_iff_right z).mpr h -lemma numeral_eq_natCast : (n : ℕ) → (ORingStructure.numeral n : M) = n +lemma numeral_eq_natCast_app : (n : ℕ) → (ORingStructure.numeral n : M) = n | 0 => rfl | 1 => by simp - | n + 2 => by simp [ORingStructure.numeral, numeral_eq_natCast (n + 1), add_assoc, one_add_one_eq_two] + | n + 2 => by simp [ORingStructure.numeral, numeral_eq_natCast_app (n + 1), add_assoc, one_add_one_eq_two] + +lemma numeral_eq_natCast : (ORingStructure.numeral : ℕ → M) = Nat.cast := by ext x; exact numeral_eq_natCast_app x lemma not_neg (x : M) : ¬x < 0 := by simp @@ -324,12 +326,12 @@ lemma eq_nat_of_le_nat {n : ℕ} {x : M} : x ≤ n → ∃ m : ℕ, x = m := fun have : x < ↑(n + 1) := by simpa [←le_iff_lt_succ] using h exact eq_nat_of_lt_nat this -instance models_R0_of_models_PeanoMinus : M ⊧ₘ* 𝗥₀ := modelsTheory_iff.mpr <| by +instance models_R0_of_models_PeanoMinus : M↓[ℒₒᵣ] ⊧* 𝗥₀ := models_theory_iff.mpr <| by intro φ h rcases h case equal h => - have : M ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h + have : M↓[ℒₒᵣ] ⊧* 𝗘𝗤 ℒₒᵣ := inferInstance + exact models_theory_iff.mp this _ h case Ω₁ n m => simp [models_iff, numeral_eq_natCast] case Ω₂ n m => @@ -345,12 +347,12 @@ instance models_R0_of_models_PeanoMinus : M ⊧ₘ* 𝗥₀ := modelsTheory_iff. instance : 𝗥₀ ⪯ 𝗣𝗔⁻ := weakerThan_of_models.{0} _ _ fun _ _ _ ↦ inferInstance -instance models_RobinsonQ_of_models_PeanoMinus : M ⊧ₘ* 𝗤 := modelsTheory_iff.mpr <| by +instance models_RobinsonQ_of_models_PeanoMinus : M↓[ℒₒᵣ] ⊧* 𝗤 := models_theory_iff.mpr <| by intro φ h rcases h case equal h => - have : M ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h + have : M↓[ℒₒᵣ] ⊧* 𝗘𝗤 ℒₒᵣ := inferInstance + exact models_theory_iff.mp this _ h case addSucc h => suffices ∀ a b : M, a + (b + 1) = a + b + 1 by simpa [models_iff]; simp [add_assoc] @@ -538,8 +540,7 @@ open FirstOrder FirstOrder.Semiterm simp [Operator.npow_zero, Operator.val_comp, Matrix.empty_eq] case succ k IH => simp [Operator.npow_succ, Operator.val_comp] - simp [Matrix.fun_eq_vec_two, pow_succ] - simp [IH] + simp [pow_succ, IH] instance : Structure.Monotone ℒₒᵣ M := ⟨ fun {k} f v₁ v₂ h ↦ @@ -568,11 +569,11 @@ lemma eq_fin_of_lt_nat {n : ℕ} {x : M} (hx : x < (n : M)) : ∃ i : Fin n, x = exact ⟨⟨x, by simpa using hx⟩, by simp⟩ @[simp] lemma eval_ballLTSucc' {t : Semiterm ℒₒᵣ ξ n} {φ : Semiformula ℒₒᵣ ξ (n + 1)} : - Semiformula.Evalm M e ε (φ.ballLTSucc t) ↔ ∀ x ≤ Semiterm.valm M e ε t, Semiformula.Evalm M (x :> e) ε φ := by + (φ.ballLTSucc t).Eval e ε ↔ ∀ x ≤ t.val (M := M) e ε, φ.Eval (x :> e) ε := by simp [Semiformula.eval_ballLTSucc, lt_succ_iff_le] @[simp] lemma eval_bexsLTSucc' {t : Semiterm ℒₒᵣ ξ n} {φ : Semiformula ℒₒᵣ ξ (n + 1)} : - Semiformula.Evalm M e ε (φ.bexsLTSucc t) ↔ ∃ x ≤ Semiterm.valm M e ε t, Semiformula.Evalm M (x :> e) ε φ := by + (φ.bexsLTSucc t).Eval e ε ↔ ∃ x ≤ t.val (M := M) e ε, φ.Eval (x :> e) ε := by simp [Semiformula.eval_bexsLTSucc, lt_succ_iff_le] variable (M) @@ -590,8 +591,8 @@ variable {T : ArithmeticTheory} [𝗣𝗔⁻ ⪯ T] instance : 𝗥₀ ⪱ 𝗣𝗔⁻ := Entailment.StrictlyWeakerThan.of_unprovable_provable - R0.unprovable_addZero (Entailment.by_axm _ PeanoMinus.addZero) + R0.unprovable_addZero (Entailment.by_axm PeanoMinus.addZero) -instance (M : Type*) [ORingStructure M] [M ⊧ₘ* 𝗣𝗔⁻] : M ⊧ₘ* 𝗥₀ := models_of_subtheory (T := 𝗣𝗔⁻) inferInstance +instance (M : Type*) [ORingStructure M] [M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] : M↓[ℒₒᵣ] ⊧* 𝗥₀ := models_of_subtheory (U := 𝗣𝗔⁻) inferInstance end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Functions.lean b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Functions.lean index 1b08bece9..d475724b9 100644 --- a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Functions.lean +++ b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Functions.lean @@ -14,7 +14,7 @@ This file provides functions and relations defined in $\mathsf{PA^-} namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗣𝗔⁻] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] variable {a b c : V} @@ -230,8 +230,8 @@ def IsPrime (a : V) : Prop := 1 < a ∧ ∀ b ≤ a, b ∣ a → b = 1 ∨ b = a def _root_.LO.FirstOrder.Arithmetic.isPrime : 𝚺₀.Semisentence 1 := .mkSigma “x. 1 < x ∧ ∀ y <⁺ x, !dvd.val y x → y = 1 ∨ y = x” -instance isPrime_defined : 𝚺₀-Predicate (λ a : V ↦ IsPrime a) via isPrime := .mk fun v ↦ by - simp [Semiformula.eval_substs, Matrix.comp_vecCons', Matrix.constant_eq_singleton, IsPrime, isPrime] +instance isPrime_defined : 𝚺₀-Predicate (fun a : V ↦ IsPrime a) via isPrime := .mk fun v ↦ by + simp [Semiformula.eval_substs, IsPrime, isPrime] end Prime diff --git a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Q.lean b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Q.lean index 5092521da..a9348f170 100644 --- a/Foundation/FirstOrder/Arithmetic/PeanoMinus/Q.lean +++ b/Foundation/FirstOrder/Arithmetic/PeanoMinus/Q.lean @@ -137,12 +137,12 @@ lemma exists_add_one_eq_self : ∃ x : OmegaAddOne, x + 1 = x := end OmegaAddOne set_option linter.flexible false in -instance : OmegaAddOne ⊧ₘ* 𝗤 := ⟨by +instance : OmegaAddOne↓[ℒₒᵣ] ⊧* 𝗤 := ⟨by intro σ h; rcases h; case equal h => - have : OmegaAddOne ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h + have : OmegaAddOne↓[ℒₒᵣ] ⊧* 𝗘𝗤 ℒₒᵣ := inferInstance + exact models_theory_iff.mp this _ h case succInj => suffices ∀ a b : OmegaAddOne, a + 1 = b + 1 → a = b by simpa [models_iff]; intro _; apply OmegaAddOne.succ_inj; @@ -152,12 +152,11 @@ instance : OmegaAddOne ⊧ₘ* 𝗤 := ⟨by end Countermodel lemma RobinsonQ.unprovable_neSucc : 𝗤 ⊬ “∀ x, x + 1 ≠ x” := - unprovable_of_countermodel (M := Countermodel.OmegaAddOne) <| by - simpa [models_iff] using Countermodel.OmegaAddOne.exists_add_one_eq_self + unprovable_of_countermodel (M := Countermodel.OmegaAddOne) 𝗤 <| by + simpa [notModels_iff] using Countermodel.OmegaAddOne.exists_add_one_eq_self -instance : 𝗤 ⪱ 𝗣𝗔⁻ := Entailment.StrictlyWeakerThan.of_unprovable_provable RobinsonQ.unprovable_neSucc $ by - apply provable_of_models.{0}; - intro _ _ _; - simp [models_iff]; +instance : 𝗤 ⪱ 𝗣𝗔⁻ := + Entailment.StrictlyWeakerThan.of_unprovable_provable RobinsonQ.unprovable_neSucc + <| complete.{0} _ _ fun _ _ _ ↦ by simp [models_iff] end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Arithmetic/Q/Basic.lean b/Foundation/FirstOrder/Arithmetic/Q/Basic.lean index ae76cef2e..1af2c1fd7 100644 --- a/Foundation/FirstOrder/Arithmetic/Q/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/Q/Basic.lean @@ -13,7 +13,7 @@ noncomputable section namespace LO.FirstOrder.Arithmetic inductive RobinsonQ : ArithmeticTheory - | equal : ∀ φ ∈ 𝗘𝗤, RobinsonQ φ + | equal : ∀ φ ∈ 𝗘𝗤 ℒₒᵣ, RobinsonQ φ | succNeZero : RobinsonQ “∀ a, a + 1 ≠ 0” | succInj : RobinsonQ “∀ a b, a + 1 = b + 1 → a = b” | zeroOrSucc : RobinsonQ “∀ a, a = 0 ∨ ∃ b, a = b + 1” @@ -29,7 +29,7 @@ namespace RobinsonQ open ORingStructure -@[simp] instance : ℕ ⊧ₘ* 𝗤 := ⟨by +@[simp] instance : ℕ↓[ℒₒᵣ] ⊧* 𝗤 := ⟨by intro σ h cases h case ltDef => @@ -46,41 +46,41 @@ open ORingStructure simp [models_iff] omega; case equal h => - suffices ℕ ⊧/![] σ by simpa [models_iff] - have : ℕ ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h + suffices σ.Evalb ![] by simpa [models_iff] + have : ℕ↓[ℒₒᵣ] ⊧* (𝗘𝗤 ℒₒᵣ : ArithmeticTheory) := inferInstance + exact models_theory_iff.mp this _ h repeat case _ => simp [models_iff, add_assoc, mul_add]⟩ -instance : 𝗘𝗤 ⪯ 𝗤 := Entailment.WeakerThan.ofSubset <| fun φ hp ↦ equal φ hp +instance : 𝗘𝗤 ℒₒᵣ ⪯ 𝗤 := Entailment.WeakerThan.ofSubset <| fun φ hp ↦ equal φ hp end RobinsonQ -variable {M : Type*} [ORingStructure M] [M ⊧ₘ* 𝗤] +variable {M : Type*} [ORingStructure M] [M↓[ℒₒᵣ] ⊧* 𝗤] @[simp] protected lemma succ_ne_zero : ∀ a : M, a + 1 ≠ 0 := by - simpa [models_iff] using ModelsTheory.models M RobinsonQ.succNeZero + simpa [models_iff] using Theory.models M _ RobinsonQ.succNeZero lemma succ_inj {a b : M} : a + 1 = b + 1 → a = b := by - have := by simpa [models_iff] using ModelsTheory.models M RobinsonQ.succInj + have := by simpa [models_iff] using Theory.models M _ RobinsonQ.succInj exact this a b @[simp] protected lemma add_zero {a : M} : a + 0 = a := by - have := by simpa [models_iff] using ModelsTheory.models M RobinsonQ.addZero + have := by simpa [models_iff] using Theory.models M _ RobinsonQ.addZero exact this a protected lemma add_succ (a b : M) : a + (b + 1) = a + b + 1 := by - have := by simpa [models_iff] using ModelsTheory.models M RobinsonQ.addSucc + have := by simpa [models_iff] using Theory.models M _ RobinsonQ.addSucc exact this a b @[simp] protected lemma mul_zero (a : M) : a * 0 = 0 := by - have := by simpa [models_iff] using ModelsTheory.models M RobinsonQ.mulZero + have := by simpa [models_iff] using Theory.models M _ RobinsonQ.mulZero exact this a protected lemma mul_succ : ∀ a b : M, a * (b + 1) = a * b + a := by - simpa [models_iff] using ModelsTheory.models M RobinsonQ.mulSucc + simpa [models_iff] using Theory.models M _ RobinsonQ.mulSucc lemma zero_or_succ (a : M) : a = 0 ∨ ∃ b : M, a = b + 1 := by - have := by simpa [models_iff] using ModelsTheory.models M RobinsonQ.zeroOrSucc + have := by simpa [models_iff] using Theory.models M _ RobinsonQ.zeroOrSucc exact this a lemma exists_succ_of_ne_zero {a : M} (ha : a ≠ 0) : ∃ b : M, a = b + 1 := by @@ -92,7 +92,7 @@ lemma exists_succ_of_ne_zero' {a : M} (ha : a ≠ 0) : ∃ b : M, b + 1 = a := b use b; protected lemma lt_def {a b : M} : a < b ↔ ∃ c : M, a + (c + 1) = b := by - have := by simpa [models_iff] using ModelsTheory.models M RobinsonQ.ltDef + have := by simpa [models_iff] using Theory.models M _ RobinsonQ.ltDef exact this a b @[simp] @@ -303,12 +303,12 @@ lemma iff_lt_numeral_exists_numeral {n : ℕ} {x : M} : x < numeral n ↔ ∃ m namespace R0 -instance : M ⊧ₘ* 𝗥₀ := modelsTheory_iff.mpr <| by +instance : M↓[ℒₒᵣ] ⊧* 𝗥₀ := models_theory_iff.mpr <| by intro φ h rcases h case equal h => - have : M ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h + have : M↓[ℒₒᵣ] ⊧* (𝗘𝗤 ℒₒᵣ : ArithmeticTheory) := inferInstance + exact models_theory_iff.mp this _ h case Ω₁ n m => simp [models_iff, numeral_add] case Ω₂ n m => simp [models_iff, numeral_mul] case Ω₃ n m h => simp [models_iff, numeral_ne_of_ne h]; @@ -322,6 +322,6 @@ instance : 𝗥₀ ⪯ 𝗤 := weakerThan_of_models.{0} _ _ fun _ _ _ ↦ inferI instance : 𝗥₀ ⪱ 𝗤 := Entailment.StrictlyWeakerThan.of_unprovable_provable - R0.unprovable_addZero (Entailment.by_axm _ RobinsonQ.addZero) + R0.unprovable_addZero (Entailment.by_axm RobinsonQ.addZero) end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Arithmetic/R0/Basic.lean b/Foundation/FirstOrder/Arithmetic/R0/Basic.lean index 19d801976..fabcb3453 100644 --- a/Foundation/FirstOrder/Arithmetic/R0/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/R0/Basic.lean @@ -13,7 +13,7 @@ noncomputable section namespace LO.FirstOrder.Arithmetic inductive R0 : ArithmeticTheory - | equal : ∀ φ ∈ 𝗘𝗤, R0 φ + | equal : ∀ φ ∈ 𝗘𝗤 ℒₒᵣ, R0 φ | Ω₁ (n m : ℕ) : R0 “↑n + ↑m = ↑(n + m)” | Ω₂ (n m : ℕ) : R0 “↑n * ↑m = ↑(n * m)” | Ω₃ (n m : ℕ) : n ≠ m → R0 “↑n ≠ ↑m” @@ -23,14 +23,14 @@ notation "𝗥₀" => R0 namespace R0 -instance : 𝗘𝗤 ⪯ 𝗥₀ := Entailment.WeakerThan.ofSubset <| fun φ hp ↦ R0.equal φ hp +instance : 𝗘𝗤 ℒₒᵣ ⪯ 𝗥₀ := Entailment.WeakerThan.ofSubset <| fun φ hp ↦ R0.equal φ hp -instance : ℕ ⊧ₘ* 𝗥₀ := ⟨by +instance : ℕ↓[ℒₒᵣ] ⊧* 𝗥₀ := ⟨by intro σ h rcases h <;> try { simp [models_iff]; done } case equal h => - have : ℕ ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - simpa [models_iff] using modelsTheory_iff.mp this h + have : ℕ↓[ℒₒᵣ] ⊧* (𝗘𝗤 ℒₒᵣ : ArithmeticTheory) := inferInstance + simpa [models_iff] using models_theory_iff.mp this _ h case Ω₃ h => simpa [models_iff, ←le_iff_eq_or_lt] using h⟩ @@ -38,21 +38,21 @@ end R0 section model -variable {M : Type*} [ORingStructure M] [M ⊧ₘ* 𝗥₀] +variable {M : Type*} [ORingStructure M] [M↓[ℒₒᵣ] ⊧* 𝗥₀] open Language ORingStructure lemma numeral_add_numeral (n m : ℕ) : (numeral n : M) + numeral m = numeral (n + m) := by - simpa [models_iff] using ModelsTheory.models M (R0.Ω₁ n m) + simpa [models_iff] using Theory.models M _ (R0.Ω₁ n m) lemma numeral_mul_numeral (n m : ℕ) : (numeral n : M) * numeral m = numeral (n * m) := by - simpa [models_iff] using ModelsTheory.models M (R0.Ω₂ n m) + simpa [models_iff] using Theory.models M _ (R0.Ω₂ n m) lemma numeral_ne_numeral_of_ne {n m : ℕ} (h : n ≠ m) : (numeral n : M) ≠ numeral m := by - simpa [models_iff] using ModelsTheory.models M (R0.Ω₃ n m h) + simpa [models_iff] using Theory.models M _ (R0.Ω₃ n m h) lemma lt_numeral_iff {x : M} {n : ℕ} : x < numeral n ↔ ∃ i : Fin n, x = numeral i := by - have := by simpa [models_iff] using ModelsTheory.models M (R0.Ω₄ n) + have := by simpa [models_iff] using Theory.models M _ (R0.Ω₄ n) constructor · intro hx rcases (this x).mp hx with ⟨i, hi, rfl⟩ @@ -73,18 +73,19 @@ lemma lt_numeral_iff {x : M} {n : ℕ} : x < numeral n ↔ ∃ i : Fin n, x = nu open Hierarchy -lemma val_numeral {n} : ∀ (t : Semiterm ℒₒᵣ ξ n), - ∀ v f, Semiterm.valm M (fun x ↦ numeral (v x)) (fun x ↦ numeral (f x)) t = numeral (Semiterm.valm ℕ v f t) - | #_, _, _ => by simp - | &x, _, _ => by simp - | Semiterm.func Language.Zero.zero _, e, f => by simp - | Semiterm.func Language.One.one _, e, f => by simp - | Semiterm.func Language.Add.add v, e, f => by simp [Semiterm.val_func, val_numeral (v 0), val_numeral (v 1), numeral_add_numeral] - | Semiterm.func Language.Mul.mul v, e, f => by simp [Semiterm.val_func, val_numeral (v 0), val_numeral (v 1), numeral_mul_numeral] - -lemma bold_sigma_one_completeness {n} {φ : Semiformula ℒₒᵣ ξ n} (hp : Hierarchy 𝚺 1 φ) {e f} : - Semiformula.Evalm ℕ e f φ → Semiformula.Evalm M (fun x ↦ numeral (e x)) (fun x ↦ numeral (f x)) φ := by - revert e +lemma val_numeral {n ξ} (bv : Fin n → ℕ) (fv : ξ → ℕ) (t : Semiterm ℒₒᵣ ξ n) : + t.val (M := M) (numeral ∘ bv) (numeral ∘ fv) = numeral (t.val bv fv) := + match t with + | #_ => by simp + | &_ => by simp + | .func Language.Zero.zero _ => by simp [Matrix.empty_eq] + | .func Language.One.one _ => by simp [Matrix.empty_eq] + | .func Language.Add.add v => by simp [Semiterm.val_func, val_numeral _ _ (v 0), val_numeral _ _ (v 1), numeral_add_numeral] + | .func Language.Mul.mul v => by simp [Semiterm.val_func, val_numeral _ _ (v 0), val_numeral _ _ (v 1), numeral_mul_numeral] + +lemma bold_sigma_one_completeness {n} {φ : Semiformula ℒₒᵣ ξ n} (hp : Hierarchy 𝚺 1 φ) {bv : Fin n → ℕ} {fv : ξ → ℕ} : + φ.Eval bv fv → φ.Eval (M := M) (numeral ∘ bv) (numeral ∘ fv) := by + revert bv apply sigma₁_induction' hp case hVerum => simp case hFalsum => simp @@ -92,51 +93,47 @@ lemma bold_sigma_one_completeness {n} {φ : Semiformula ℒₒᵣ ξ n} (hp : Hi case hNEQ => intro n t₁ t₂ e; simp [val_numeral] case hLT => intro n t₁ t₂ e; simp [val_numeral] case hNLT => intro n t₁ t₂ e; simp [val_numeral] - case hAnd => - simp only [LogicalConnective.HomClass.map_and, LogicalConnective.Prop.and_eq, and_imp] - intro n φ ψ _ _ ihp ihq e hp hq - exact ⟨ihp hp, ihq hq⟩ - case hOr => - simp only [LogicalConnective.HomClass.map_or, LogicalConnective.Prop.or_eq] - rintro n φ ψ _ _ ihp ihq e (hp | hq) - · left; exact ihp hp - · right; exact ihq hq + case hAnd => simp; grind + case hOr => simp; grind case hBall => - simp only [Semiformula.eval_ball, Nat.succ_eq_add_one, Semiformula.eval_operator_two, - Semiterm.val_bvar, Matrix.cons_val_zero, Semiterm.val_bShift, Structure.LT.lt, val_numeral] - intro n t φ _ ihp e hp x hx + intro n t φ _ ihp bv + suffices + (∀ x < t.val bv fv, (φ.Eval (x :> bv) fv)) → + ∀ x < numeral (t.val bv fv), (φ.Eval (x :> numeral ∘ bv) (numeral ∘ fv)) by + simpa [val_numeral] + intro hp x hx rcases lt_numeral_iff.mp hx with ⟨x, rfl⟩ - simpa [Matrix.comp_vecCons'] using ihp (hp x (by simp)) + simpa [Matrix.comp_vecCons''] using ihp (hp x (by simp)) case hExs => simp only [Semiformula.eval_ex, Nat.succ_eq_add_one, forall_exists_index] intro n φ _ ihp e x hp - exact ⟨numeral x, by simpa [Matrix.comp_vecCons'] using ihp hp⟩ + exact ⟨numeral x, by simpa [Matrix.comp_vecCons''] using ihp hp⟩ lemma R0.model_complete {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : - ℕ ⊧ₘ σ → M ⊧ₘ σ := by - suffices Semiformula.Evalbm ℕ ![] σ → Semiformula.Evalbm M ![] σ by simpa [models_iff] + ℕ↓[ℒₒᵣ] ⊧ σ → M↓[ℒₒᵣ] ⊧ σ := by + suffices σ.Evalb (M := ℕ) ![] → σ.Evalb (M := M) ![] by simpa [models_iff] intro h simpa [Matrix.empty_eq, Empty.eq_elim] using bold_sigma_one_completeness hσ h variable (M) lemma nat_extention_sigmaOne {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : - ℕ ⊧ₘ σ → M ⊧ₘ σ := fun h ↦ by + ℕ↓[ℒₒᵣ] ⊧ σ → M↓[ℒₒᵣ] ⊧ σ := fun h ↦ by simpa [Matrix.empty_eq] using R0.model_complete (M := M) hσ h lemma nat_extention_piOne {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚷 1 σ) : - M ⊧ₘ σ → ℕ ⊧ₘ σ := by + M↓[ℒₒᵣ] ⊧ σ → ℕ↓[ℒₒᵣ] ⊧ σ := by contrapose simpa using nat_extention_sigmaOne M (σ := ∼σ) (by simpa using hσ) variable {M} -lemma bold_sigma_one_completeness' {n} {σ : Semisentence ℒₒᵣ n} (hσ : Hierarchy 𝚺 1 σ) {e} : - Semiformula.Evalbm ℕ e σ → Semiformula.Evalbm M (fun x ↦ numeral (e x)) σ := fun h ↦ by - simpa [Empty.eq_elim] using bold_sigma_one_completeness (M := M) (φ := σ) hσ (f := Empty.elim) (e := e) h +lemma bold_sigma_one_completeness' {n} {σ : Semisentence ℒₒᵣ n} (hσ : Hierarchy 𝚺 1 σ) {bv} : + σ.Evalb (M := ℕ) bv → σ.Evalb (M := M) (numeral ∘ bv) := fun h ↦ by + simpa [Empty.eq_elim] using bold_sigma_one_completeness (M := M) (φ := σ) hσ (fv := Empty.elim) (bv := bv) h instance consistent : Entailment.Consistent 𝗥₀ := - let : ℕ ⊧ₘ* 𝗥₀ := inferInstance + let : ℕ↓[ℒₒᵣ] ⊧* 𝗥₀ := inferInstance Sound.consistent_of_satisfiable ⟨_, this⟩ end model @@ -144,15 +141,15 @@ end model variable {T : ArithmeticTheory} [𝗥₀ ⪯ T] theorem sigma_one_completeness {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : - ℕ ⊧ₘ σ → T ⊢ σ := fun H => - haveI : 𝗘𝗤 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗥₀) inferInstance inferInstance - provable_of_models.{0} _ _ <| fun M _ _ ↦ by - haveI : M ⊧ₘ* 𝗥₀ := ModelsTheory.of_provably_subtheory M 𝗥₀ T inferInstance + ℕ↓[ℒₒᵣ] ⊧ σ → T ⊢ σ := fun H => + haveI : 𝗘𝗤 _ ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗥₀) inferInstance inferInstance + complete.{0} _ _ <| fun M _ _ ↦ by + haveI : M↓[ℒₒᵣ] ⊧* 𝗥₀ := ModelsTheory.of_provably_subtheory M 𝗥₀ T inferInstance exact R0.model_complete hσ H open Classical in theorem sigma_one_completeness_iff [T.SoundOnHierarchy 𝚺 1] {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : - ℕ ⊧ₘ σ ↔ T ⊢ σ := + ℕ↓[ℒₒᵣ] ⊧ σ ↔ T ⊢ σ := haveI : 𝗥₀ ⪯ T := Entailment.WeakerThan.trans (𝓣 := T) inferInstance inferInstance ⟨fun h ↦ sigma_one_completeness hσ h, fun h ↦ T.soundOnHierarchy 𝚺 1 h (by simp [hσ])⟩ @@ -226,12 +223,12 @@ def cases' {P : OmegaAddOne → Sort*} | .none => top set_option linter.flexible false in -instance : OmegaAddOne ⊧ₘ* 𝗥₀ := ⟨by +instance : OmegaAddOne↓[ℒₒᵣ] ⊧* 𝗥₀ := ⟨by intro σ h rcases h <;> simp [models_iff] case equal h => - have : OmegaAddOne ⊧ₘ* (𝗘𝗤 : ArithmeticTheory) := inferInstance - exact modelsTheory_iff.mp this h + have : OmegaAddOne↓[ℒₒᵣ] ⊧* (𝗘𝗤 _ : ArithmeticTheory) := inferInstance + exact models_theory_iff.mp this _ h case Ω₃ h => exact h case Ω₄ n => intro x @@ -242,8 +239,8 @@ end OmegaAddOne end Countermodel lemma unprovable_addZero : 𝗥₀ ⊬ “∀ x, x + 0 = x” := - unprovable_of_countermodel (M := Countermodel.OmegaAddOne) <| by - simpa [models_iff] using Countermodel.OmegaAddOne.exists_add_zero_ne_self + unprovable_of_countermodel _ (M := Countermodel.OmegaAddOne) <| by + simpa [notModels_iff] using Countermodel.OmegaAddOne.exists_add_zero_ne_self end R0 diff --git a/Foundation/FirstOrder/Arithmetic/R0/Representation.lean b/Foundation/FirstOrder/Arithmetic/R0/Representation.lean index 3d047aaf3..c2a8e46cd 100644 --- a/Foundation/FirstOrder/Arithmetic/R0/Representation.lean +++ b/Foundation/FirstOrder/Arithmetic/R0/Representation.lean @@ -13,7 +13,7 @@ open Mathlib Encodable Semiterm.Operator.GödelNumber section -lemma term_primrec {k f} : (t : Semiterm ℒₒᵣ ξ k) → Primrec (fun v : List.Vector ℕ k ↦ t.valm ℕ v.get f) +lemma term_primrec {k f} : (t : Semiterm ℒₒᵣ ξ k) → Primrec (fun v : List.Vector ℕ k ↦ t.val v.get f) | #x => by simpa using Primrec.vector_get.comp .id (.const _) | &x => by simpa using Primrec.const _ | .func Language.Zero.zero _ => by simpa using Primrec.const 0 @@ -24,32 +24,32 @@ lemma term_primrec {k f} : (t : Semiterm ℒₒᵣ ξ k) → Primrec (fun v : Li simpa [Semiterm.val_func] using Primrec.nat_mul.comp (term_primrec (v 0)) (term_primrec (v 1)) lemma sigma1_re (ε : ξ → ℕ) {k} {φ : Semiformula ℒₒᵣ ξ k} (hp : Hierarchy 𝚺 1 φ) : - REPred fun v : List.Vector ℕ k ↦ Semiformula.Evalm ℕ v.get ε φ := by + REPred fun v : List.Vector ℕ k ↦ φ.Eval v.get ε := by apply sigma₁_induction' hp case hVerum => simp; case hFalsum => simp case hEQ => intro n t₁ t₂ refine ComputablePred.to_re <| ComputablePred.computable_iff.mpr - <| ⟨fun v : List.Vector ℕ n ↦ decide (t₁.valm ℕ v.get ε = t₂.valm ℕ v.get ε), ?_, ?_⟩ + <| ⟨fun v : List.Vector ℕ n ↦ decide (t₁.val v.get ε = t₂.val v.get ε), ?_, ?_⟩ · apply Primrec.to_comp (Primrec.eq.comp (term_primrec t₁) (term_primrec t₂)).decide · simp case hNEQ => intro n t₁ t₂ refine ComputablePred.to_re <| ComputablePred.computable_iff.mpr - <| ⟨fun v : List.Vector ℕ n ↦ !decide (t₁.valm ℕ v.get ε = t₂.valm ℕ v.get ε), ?_, ?_⟩ + <| ⟨fun v : List.Vector ℕ n ↦ !decide (t₁.val v.get ε = t₂.val v.get ε), ?_, ?_⟩ · apply Primrec.to_comp <| Primrec.not.comp (Primrec.eq.comp (term_primrec t₁) (term_primrec t₂)).decide · simp case hLT => intro n t₁ t₂ refine ComputablePred.to_re <| ComputablePred.computable_iff.mpr - <| ⟨fun v : List.Vector ℕ n ↦ decide (t₁.valm ℕ v.get ε < t₂.valm ℕ v.get ε), ?_, ?_⟩ + <| ⟨fun v : List.Vector ℕ n ↦ decide (t₁.val v.get ε < t₂.val v.get ε), ?_, ?_⟩ · apply Primrec.to_comp (Primrec.nat_lt.comp (term_primrec t₁) (term_primrec t₂)).decide · simp case hNLT => intro n t₁ t₂ refine ComputablePred.to_re <| ComputablePred.computable_iff.mpr - <| ⟨fun v : List.Vector ℕ n ↦ !decide (t₁.valm ℕ v.get ε < t₂.valm ℕ v.get ε), ?_, ?_⟩ + <| ⟨fun v : List.Vector ℕ n ↦ !decide (t₁.val v.get ε < t₂.val v.get ε), ?_, ?_⟩ · apply Primrec.to_comp <| Primrec.not.comp (Primrec.nat_lt.comp (term_primrec t₁) (term_primrec t₂)).decide · simp case hAnd => @@ -62,20 +62,20 @@ lemma sigma1_re (ε : ξ → ℕ) {k} {φ : Semiformula ℒₒᵣ ξ k} (hp : Hi intro n t φ _ ih rcases REPred.iff'.mp ih with ⟨f, hf, H⟩ let g : List.Vector ℕ n →. Unit := fun v ↦ - Nat.rec (.some ()) (fun x ih ↦ ih.bind fun _ ↦ f (x ::ᵥ v)) (t.valm ℕ v.get ε) + Nat.rec (.some ()) (fun x ih ↦ ih.bind fun _ ↦ f (x ::ᵥ v)) (t.val v.get ε) have : Partrec g := Partrec.nat_rec (term_primrec t).to_comp (Computable.const ()) (Partrec.to₂ <| hf.comp (Primrec.to_comp <| Primrec.vector_cons.comp (Primrec.fst.comp .snd) .fst)) refine REPred.iff.mpr ⟨_, this, ?_⟩ funext v - suffices ∀ k : ℕ, (∀ x < k, Semiformula.Evalm ℕ (x :> v.get) ε φ) ↔ + suffices ∀ k : ℕ, (∀ x < k, φ.Eval (x :> v.get) ε) ↔ Part.Dom (Nat.rec (.some ()) (fun x ih ↦ ih.bind fun _ ↦ f (x ::ᵥ v)) k) by simpa [g] using this _ intro k; induction k case zero => simp case succ k ih => suffices - (∀ x < k + 1, (Semiformula.Evalm ℕ (x :> v.get) ε) φ) - ↔ (∀ x < k, (Semiformula.Evalm ℕ (x :> v.get) ε) φ) ∧ (f (k ::ᵥ v)).Dom by simpa [←ih] + (∀ x < k + 1, φ.Eval (x :> v.get) ε) + ↔ (∀ x < k, φ.Eval (x :> v.get) ε) ∧ (f (k ::ᵥ v)).Dom by simpa [←ih] constructor · intro h exact ⟨fun x hx ↦ h x (lt_trans hx (by simp)), @@ -87,7 +87,7 @@ lemma sigma1_re (ε : ξ → ℕ) {k} {φ : Semiformula ℒₒᵣ ξ k} (hp : Hi case hExs => intro n φ _ ih rcases REPred.iff'.mp ih with ⟨f, _, _⟩ - have : REPred fun vx : List.Vector ℕ n × ℕ ↦ Semiformula.Evalm ℕ (vx.2 :> vx.1.get) ε φ := by + have : REPred fun vx : List.Vector ℕ n × ℕ ↦ φ.Eval (vx.2 :> vx.1.get) ε := by simpa [List.Vector.cons_get] using ih.comp (Primrec.to_comp <| Primrec.vector_cons.comp .snd .fst) simpa using this.projection @@ -180,7 +180,7 @@ private lemma codeAux_sigma_one {k} (c : Nat.ArithPart₁.Code k) : Hierarchy @[simp] lemma natCast_nat' (n : ℕ) : Nat.cast n = n := by rfl private lemma models_codeAux {c : Code k} {f : List.Vector ℕ k →. ℕ} (hc : c.eval f) (y : ℕ) (v : Fin k → ℕ) : - Semiformula.Evalfm ℕ (y :> v) (codeAux c) ↔ f (List.Vector.ofFn v) = Part.some y := by + (codeAux c).Evalf (y :> v) ↔ f (List.Vector.ofFn v) = Part.some y := by induction hc generalizing y case zero => have : (0 : Part ℕ) = Part.some 0 := rfl @@ -198,8 +198,7 @@ private lemma models_codeAux {c : Code k} {f : List.Vector ℕ k →. ℕ} (hc : case proj => simp [codeAux, eq_comm] case comp m n c d f g _ _ ihf ihg => suffices - (∃ e' : Fin n → ℕ, (Semiformula.Evalfm ℕ (y :> e')) (codeAux c) ∧ - ∀ i, (Semiformula.Evalfm ℕ (e' i :> v)) (codeAux (d i))) + (∃ e' : Fin n → ℕ, (codeAux c).Evalf (y :> e') ∧ ∀ i, (codeAux (d i)).Evalf (e' i :> v)) ↔ (List.Vector.mOfFn (g · (List.Vector.ofFn v))).bind f = Part.some y by simp [codeAux] simpa [Semiformula.eval_rew, Function.comp_def, Matrix.empty_eq, Matrix.comp_vecCons'] @@ -226,16 +225,16 @@ private lemma models_codeAux {c : Code k} {f : List.Vector ℕ k →. ℕ} (hc : · intro h; simpa [pos_iff_ne_zero] using Nat.mem_rfind.mp (Part.eq_some_iff.mp h) lemma models_code {c : Code k} {f : List.Vector ℕ k →. ℕ} (hc : c.eval f) (y : ℕ) (v : Fin k → ℕ) : - Semiformula.Evalbm ℕ (y :> v) (code c) ↔ y ∈ f (List.Vector.ofFn v) := by + (code c).Evalb (y :> v) ↔ y ∈ f (List.Vector.ofFn v) := by simpa [code, models_iff, Semiformula.eval_rew, Matrix.empty_eq, Function.comp_def, Matrix.comp_vecCons', ←Part.eq_some_iff] using models_codeAux hc y v noncomputable def codeOfPartrec' {k} (f : List.Vector ℕ k →. ℕ) : Semisentence ℒₒᵣ (k + 1) := - code <| Classical.epsilon fun c ↦ ∀ y v, Semiformula.Evalbm ℕ (y :> v) (code c) ↔ y ∈ f (List.Vector.ofFn v) + code <| Classical.epsilon fun c ↦ ∀ y v, (code c).Evalb (y :> v) ↔ y ∈ f (List.Vector.ofFn v) lemma codeOfPartrec'_spec {k} {f : List.Vector ℕ k →. ℕ} (hf : Nat.Partrec' f) {y : ℕ} {v : Fin k → ℕ} : - ℕ ⊧/(y :> v) (codeOfPartrec' f) ↔ y ∈ f (List.Vector.ofFn v) := by - have : ∃ c, ∀ y v, Semiformula.Evalbm ℕ (y :> v) (code c) ↔ y ∈ f (List.Vector.ofFn v) := by + (codeOfPartrec' f).Evalb (y :> v) ↔ y ∈ f (List.Vector.ofFn v) := by + have : ∃ c, ∀ y v, (code c).Evalb (y :> v) ↔ y ∈ f (List.Vector.ofFn v) := by rcases Nat.ArithPart₁.exists_code (of_partrec hf) with ⟨c, hc⟩ exact ⟨c, models_code hc⟩ exact Classical.epsilon_spec this y v @@ -247,9 +246,9 @@ noncomputable def codeOfREPred (A : ℕ → Prop) : Semisentence ℒₒᵣ 1 := (codeOfPartrec' (fun v ↦ (f (v.get 0)).map fun _ ↦ 0))/[‘0’, #0] lemma codeOfREPred_spec {A : ℕ → Prop} (hp : REPred A) {x : ℕ} : - ℕ ⊧/![x] (codeOfREPred A) ↔ A x := by + (codeOfREPred A).Evalb (![x]) ↔ A x := by let f : ℕ →. Unit := fun a ↦ Part.assert (A a) fun _ ↦ Part.some () - suffices ℕ ⊧/![x] ((codeOfPartrec' fun v ↦ Part.map (fun _ ↦ 0) (f (v.get 0)))/[‘0’, #0]) ↔ A x from this + suffices (codeOfPartrec' fun v ↦ Part.map (fun _ ↦ 0) (f (v.get 0)))/[‘0’, #0].Evalb (![x]) ↔ A x from this have : Partrec fun v : List.Vector ℕ 1 ↦ (f (v.get 0)).map fun _ ↦ 0 := by refine Partrec.map (Partrec.comp hp (Primrec.to_comp <| Primrec.vector_get.comp .id (.const 0))) (Computable.const 0).to₂ simpa [Semiformula.eval_substs, Matrix.comp_vecCons', Matrix.constant_eq_singleton] diff --git a/Foundation/FirstOrder/Arithmetic/Schemata.lean b/Foundation/FirstOrder/Arithmetic/Schemata.lean index 6eb7e087d..2de4c916e 100644 --- a/Foundation/FirstOrder/Arithmetic/Schemata.lean +++ b/Foundation/FirstOrder/Arithmetic/Schemata.lean @@ -4,6 +4,7 @@ public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Functions public import Foundation.FirstOrder.Arithmetic.TA.Basic @[expose] public section + /-! # Induction schemata of Arithmetic -/ @@ -25,11 +26,11 @@ variable (L) def InductionScheme (Γ : Semiformula L ℕ 1 → Prop) : Theory L := { ψ | ∃ φ : Semiformula L ℕ 1, Γ φ ∧ ψ = .univCl (succInd φ) } -abbrev IOpen : ArithmeticTheory := 𝗣𝗔⁻ + InductionScheme ℒₒᵣ Semiformula.Open +abbrev IOpen : ArithmeticTheory := 𝗣𝗔⁻ ∪ InductionScheme ℒₒᵣ Semiformula.Open notation "𝗜𝗢𝗽𝗲𝗻" => IOpen -abbrev InductionOnHierarchy (Γ : Polarity) (k : ℕ) : ArithmeticTheory := 𝗣𝗔⁻ + InductionScheme ℒₒᵣ (Arithmetic.Hierarchy Γ k) +abbrev InductionOnHierarchy (Γ : Polarity) (k : ℕ) : ArithmeticTheory := 𝗣𝗔⁻ ∪ InductionScheme ℒₒᵣ (Arithmetic.Hierarchy Γ k) prefix:max "𝗜𝗡𝗗 " => InductionOnHierarchy @@ -49,7 +50,7 @@ notation "𝗜𝚺₁" => ISigma 1 notation "𝗜𝚷₁" => IPi 1 -abbrev Peano : ArithmeticTheory := 𝗣𝗔⁻ + InductionScheme ℒₒᵣ Set.univ +abbrev Peano : ArithmeticTheory := 𝗣𝗔⁻ ∪ InductionScheme ℒₒᵣ Set.univ notation "𝗣𝗔" => Peano @@ -66,12 +67,12 @@ lemma ISigma_subset_mono {s₁ s₂} (h : s₁ ≤ s₂) : 𝗜𝚺 s₁ ⊆ lemma ISigma_weakerThan_of_le {s₁ s₂} (h : s₁ ≤ s₂) : 𝗜𝚺 s₁ ⪯ 𝗜𝚺 s₂ := Entailment.WeakerThan.ofSubset (ISigma_subset_mono h) -instance : 𝗘𝗤 ⪯ 𝗜𝗡𝗗 Γ n := - have : 𝗘𝗤 ⪯ 𝗣𝗔⁻ := inferInstance +instance : 𝗘𝗤 ℒₒᵣ ⪯ 𝗜𝗡𝗗 Γ n := + have : 𝗘𝗤 ℒₒᵣ ⪯ 𝗣𝗔⁻ := inferInstance Entailment.WeakerThan.trans this inferInstance -instance : 𝗘𝗤 ⪯ 𝗜𝗢𝗽𝗲𝗻 := - have : 𝗘𝗤 ⪯ 𝗣𝗔⁻ := inferInstance +instance : 𝗘𝗤 ℒₒᵣ ⪯ 𝗜𝗢𝗽𝗲𝗻 := + have : 𝗘𝗤 ℒₒᵣ ⪯ 𝗣𝗔⁻ := inferInstance Entailment.WeakerThan.trans this inferInstance instance : 𝗜𝗢𝗽𝗲𝗻 ⪯ 𝗜𝗡𝗗 Γ n := @@ -104,21 +105,20 @@ variable {V : Type*} [ORingStructure V] namespace InductionScheme -variable {C : Semiformula ℒₒᵣ ℕ 1 → Prop} [V ⊧ₘ* InductionScheme ℒₒᵣ C] +variable {C : Semiformula ℒₒᵣ ℕ 1 → Prop} [V↓[ℒₒᵣ] ⊧* InductionScheme ℒₒᵣ C] -private lemma induction_eval {φ : Semiformula ℒₒᵣ ℕ 1} (hp : C φ) (v) : - Semiformula.Evalm V ![0] v φ → - (∀ x, Semiformula.Evalm V ![x] v φ → Semiformula.Evalm V ![x + 1] v φ) → - ∀ x, Semiformula.Evalm V ![x] v φ := by - have : V ⊧ₘ .univCl (succInd φ) := - ModelsTheory.models (T := InductionScheme _ C) V (by simpa using mem_InductionScheme_of_mem hp) +private lemma induction_eval {φ : Semiformula ℒₒᵣ ℕ 1} (hp : C φ) (v : ℕ → V) : + φ.Eval ![0] v → + (∀ x, φ.Eval ![x] v → φ.Eval ![x + 1] v) → + ∀ x, φ.Eval ![x] v := by + have : V↓[ℒₒᵣ] ⊧ .univCl (succInd φ) := + Theory.models (T := InductionScheme _ C) V (by simpa using mem_InductionScheme_of_mem hp) revert v - simpa [models_iff, Semiformula.eval_univCl, succInd, Semiformula.eval_substs, - Semiformula.eval_rew_q Rew.toS, Function.comp, Matrix.constant_eq_singleton] using this + simpa [models_iff, Semiformula.eval_univCl, succInd, Semiformula.eval_substs, Matrix.constant_eq_singleton] using this @[elab_as_elim] lemma succ_induction {P : V → Prop} - (hP : ∃ e : ℕ → V, ∃ φ : Semiformula ℒₒᵣ ℕ 1, C φ ∧ ∀ x, P x ↔ Semiformula.Evalm V ![x] e φ) : + (hP : ∃ e : ℕ → V, ∃ φ : Semiformula ℒₒᵣ ℕ 1, C φ ∧ ∀ x, P x ↔ φ.Eval ![x] e) : P 0 → (∀ x, P x → P (x + 1)) → ∀ x, P x := by rcases hP with ⟨e, φ, Cp, hp⟩; simpa [←hp] using induction_eval (V := V) Cp e @@ -128,16 +128,16 @@ namespace InductionOnHierarchy section -variable (Γ : Polarity) (m : ℕ) [V ⊧ₘ* 𝗜𝗡𝗗 Γ m] +variable (Γ : Polarity) (m : ℕ) [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m] -instance : V ⊧ₘ* InductionScheme ℒₒᵣ (Hierarchy Γ m) := - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance +instance : V↓[ℒₒᵣ] ⊧* InductionScheme ℒₒᵣ (Hierarchy Γ m) := + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance models_of_subtheory this lemma succ_induction {P : V → Prop} (hP : Γ-[m].DefinablePred P) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance - have : V ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory this + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance + have : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory this InductionScheme.succ_induction (P := P) (C := Hierarchy Γ m) (by rcases hP with ⟨φ, hp⟩ haveI : Inhabited V := Classical.inhabited_of_nonempty' @@ -147,8 +147,8 @@ lemma succ_induction {P : V → Prop} (hP : Γ-[m].DefinablePred P) lemma order_induction {P : V → Prop} (hP : Γ-[m].DefinablePred P) (ind : ∀ x, (∀ y < x, P y) → P x) : ∀ x, P x := by - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance - have : V ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory this + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance + have : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory this suffices ∀ x, ∀ y < x, P y by intro x; exact this (x + 1) x (by simp only [lt_add_iff_pos_right, lt_one_iff_eq_zero]) intro x; induction x using succ_induction @@ -166,8 +166,8 @@ lemma order_induction {P : V → Prop} (hP : Γ-[m].DefinablePred P) private lemma neg_succ_induction {P : V → Prop} (hP : Γ-[m].DefinablePred P) (nzero : ¬P 0) (nsucc : ∀ x, ¬P x → ¬P (x + 1)) : ∀ x, ¬P x := by - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance - have : V ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory this + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance + have : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory this by_contra A have : ∃ x, P x := by simpa using A rcases this with ⟨a, ha⟩ @@ -192,13 +192,13 @@ private lemma neg_succ_induction {P : V → Prop} (hP : Γ-[m].DefinablePred P) have : P 0 := by simpa using this a (by rfl) contradiction -instance models_InductionScheme_alt : V ⊧ₘ* InductionScheme ℒₒᵣ (Arithmetic.Hierarchy Γ.alt m) := by +instance models_InductionScheme_alt : V↓[ℒₒᵣ] ⊧* InductionScheme ℒₒᵣ (Arithmetic.Hierarchy Γ.alt m) := by suffices ∀ (φ : Semiformula ℒₒᵣ ℕ 1), Hierarchy Γ.alt m φ → ∀ (f : ℕ → V), - Semiformula.Evalm V ![0] f φ → - (∀ x, Semiformula.Evalm V ![x] f φ → Semiformula.Evalm V ![x + 1] f φ) → - ∀ x, Semiformula.Evalm V ![x] f φ by + φ.Eval ![0] f → + (∀ x, φ.Eval ![x] f → φ.Eval ![x + 1] f) → + ∀ x, φ.Eval ![x] f by simp only [InductionScheme, Semantics.ModelsSet.setOf_iff, forall_exists_index, and_imp] rintro _ φ hφ rfl simpa [models_iff, Semiformula.eval_univCl, succInd, Semiformula.eval_rew_q, @@ -206,19 +206,19 @@ instance models_InductionScheme_alt : V ⊧ₘ* InductionScheme ℒₒᵣ (Arith using this φ hφ intro φ hp v simpa using - neg_succ_induction Γ m (P := fun x ↦ ¬Semiformula.Evalm V ![x] v φ) + neg_succ_induction Γ m (P := fun x ↦ ¬φ.Eval ![x] v) (.mkPolarity (∼(Rew.rewriteMap v ▹ φ)) (by simpa using hp) (by intro x; simp [←Matrix.fun_eq_vec_one, Semiformula.eval_rewriteMap])) -instance models_alt : V ⊧ₘ* 𝗜𝗡𝗗 Γ.alt m := by - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance - have : V ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory this - simp only [InductionOnHierarchy, ModelsTheory.add_iff]; constructor <;> infer_instance +instance models_alt : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ.alt m := by + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance + have : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory this + simp only [InductionOnHierarchy, Semantics.ModelsSet.union_iff]; constructor <;> infer_instance lemma least_number {P : V → Prop} (hP : Γ-[m].DefinablePred P) {x} (h : P x) : ∃ y, P y ∧ ∀ z < y, ¬P z := by - have : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := inferInstance - have : V ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory this + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := inferInstance + have : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory this by_contra A have A : ∀ z, P z → ∃ w < z, P w := by simpa using A have : ∀ z, ∀ w < z, ¬P w := by @@ -245,14 +245,14 @@ end section -variable (Γ : SigmaPiDelta) (m : ℕ) [V ⊧ₘ* 𝗜𝗡𝗗 𝚺 m] +variable (Γ : SigmaPiDelta) (m : ℕ) [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚺 m] lemma succ_induction_sigma {P : V → Prop} (hP : Γ-[m].DefinablePred P) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := match Γ with | 𝚺 => succ_induction 𝚺 m hP zero succ | 𝚷 => - haveI : V ⊧ₘ* 𝗜𝗡𝗗 𝚷 m := models_alt 𝚺 m + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚷 m := models_alt 𝚺 m succ_induction 𝚷 m hP zero succ | 𝚫 => succ_induction 𝚺 m hP.of_delta zero succ @@ -261,7 +261,7 @@ lemma order_induction_sigma {P : V → Prop} (hP : Γ-[m].DefinablePred P) match Γ with | 𝚺 => order_induction 𝚺 m hP ind | 𝚷 => - haveI : V ⊧ₘ* 𝗜𝗡𝗗 𝚷 m := models_alt 𝚺 m + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚷 m := models_alt 𝚺 m order_induction 𝚷 m hP ind | 𝚫 => order_induction 𝚺 m hP.of_delta ind @@ -270,124 +270,122 @@ lemma least_number_sigma {P : V → Prop} (hP : Γ-[m].DefinablePred P) match Γ with | 𝚺 => least_number 𝚺 m hP h | 𝚷 => - haveI : V ⊧ₘ* 𝗜𝗡𝗗 𝚷 m := models_alt 𝚺 m + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚷 m := models_alt 𝚺 m least_number 𝚷 m hP h | 𝚫 => least_number 𝚺 m hP.of_delta h end -instance [V ⊧ₘ* 𝗜𝗡𝗗 𝚺 m] : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := by +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚺 m] : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := by rcases Γ · infer_instance · exact models_alt 𝚺 m -instance [V ⊧ₘ* 𝗜𝗡𝗗 𝚷 m] : V ⊧ₘ* 𝗜𝗡𝗗 Γ m := by +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 𝚷 m] : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ m := by rcases Γ · exact models_alt 𝚷 m · infer_instance -lemma mod_ISigma_of_le {n₁ n₂} (h : n₁ ≤ n₂) [V ⊧ₘ* 𝗜𝚺 n₂] : V ⊧ₘ* 𝗜𝚺 n₁ := - ModelsTheory.of_ss inferInstance (ISigma_subset_mono h) +lemma mod_ISigma_of_le {n₁ n₂} (h : n₁ ≤ n₂) [V↓[ℒₒᵣ] ⊧* 𝗜𝚺 n₂] : V↓[ℒₒᵣ] ⊧* 𝗜𝚺 n₁ := + models_of_ss inferInstance (ISigma_subset_mono h) -instance [V ⊧ₘ* 𝗜𝚺₁] : V ⊧ₘ* 𝗜𝚺₀ := mod_ISigma_of_le (show 0 ≤ 1 from by simp) +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ := mod_ISigma_of_le (show 0 ≤ 1 from by simp) -instance [V ⊧ₘ* 𝗜𝚺n] : V ⊧ₘ* 𝗜𝚷n := inferInstance +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚺n] : V↓[ℒₒᵣ] ⊧* 𝗜𝚷n := inferInstance -instance [V ⊧ₘ* 𝗜𝚷n] : V ⊧ₘ* 𝗜𝚺n := inferInstance +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚷n] : V↓[ℒₒᵣ] ⊧* 𝗜𝚺n := inferInstance -lemma models_ISigma_iff_models_IPi {n} : V ⊧ₘ* 𝗜𝚺 n ↔ V ⊧ₘ* 𝗜𝚷 n := +lemma models_ISigma_iff_models_IPi {n} : V↓[ℒₒᵣ] ⊧* 𝗜𝚺 n ↔ V↓[ℒₒᵣ] ⊧* 𝗜𝚷 n := ⟨fun _ ↦ inferInstance, fun _ ↦ inferInstance⟩ -instance [V ⊧ₘ* 𝗜𝚺 n] : V ⊧ₘ* 𝗜𝗡𝗗 Γ n := +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚺 n] : V↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ n := match Γ with | 𝚺 => inferInstance | 𝚷 => inferInstance end InductionOnHierarchy -@[elab_as_elim] lemma ISigma0.succ_induction [V ⊧ₘ* 𝗜𝚺₀] +@[elab_as_elim] lemma ISigma0.succ_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] {P : V → Prop} (hP : 𝚺₀.DefinablePred P) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := InductionOnHierarchy.succ_induction 𝚺 0 hP zero succ -@[elab_as_elim] lemma ISigma1.sigma1_succ_induction [V ⊧ₘ* 𝗜𝚺₁] +@[elab_as_elim] lemma ISigma1.sigma1_succ_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚺₁-Predicate P) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := InductionOnHierarchy.succ_induction 𝚺 1 hP zero succ -@[elab_as_elim] lemma ISigma1.pi1_succ_induction [V ⊧ₘ* 𝗜𝚺₁] +@[elab_as_elim] lemma ISigma1.pi1_succ_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚷₁-Predicate P) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := InductionOnHierarchy.succ_induction 𝚷 1 hP zero succ -@[elab_as_elim] lemma ISigma0.order_induction [V ⊧ₘ* 𝗜𝚺₀] +@[elab_as_elim] lemma ISigma0.order_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] {P : V → Prop} (hP : 𝚺₀-Predicate P) (ind : ∀ x, (∀ y < x, P y) → P x) : ∀ x, P x := InductionOnHierarchy.order_induction 𝚺 0 hP ind -@[elab_as_elim] lemma ISigma1.sigma1_order_induction [V ⊧ₘ* 𝗜𝚺₁] +@[elab_as_elim] lemma ISigma1.sigma1_order_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚺₁-Predicate P) (ind : ∀ x, (∀ y < x, P y) → P x) : ∀ x, P x := InductionOnHierarchy.order_induction 𝚺 1 hP ind -@[elab_as_elim] lemma ISigma1.pi1_order_induction [V ⊧ₘ* 𝗜𝚺₁] +@[elab_as_elim] lemma ISigma1.pi1_order_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {P : V → Prop} (hP : 𝚷₁-Predicate P) (ind : ∀ x, (∀ y < x, P y) → P x) : ∀ x, P x := InductionOnHierarchy.order_induction 𝚷 1 hP ind -lemma ISigma0.least_number [V ⊧ₘ* 𝗜𝚺₀] {P : V → Prop} (hP : 𝚺₀-Predicate P) +lemma ISigma0.least_number [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] {P : V → Prop} (hP : 𝚺₀-Predicate P) {x} (h : P x) : ∃ y, P y ∧ ∀ z < y, ¬P z := InductionOnHierarchy.least_number 𝚺 0 hP h -@[elab_as_elim] lemma ISigma1.succ_induction [V ⊧ₘ* 𝗜𝚺₁] (Γ) +@[elab_as_elim] lemma ISigma1.succ_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] (Γ) {P : V → Prop} (hP : Γ-[1]-Predicate P) (zero : P 0) (succ : ∀ x, P x → P (x + 1)) : ∀ x, P x := InductionOnHierarchy.succ_induction_sigma Γ 1 hP zero succ -@[elab_as_elim] lemma ISigma1.order_induction [V ⊧ₘ* 𝗜𝚺₁] (Γ) +@[elab_as_elim] lemma ISigma1.order_induction [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] (Γ) {P : V → Prop} (hP : Γ-[1]-Predicate P) (ind : ∀ x, (∀ y < x, P y) → P x) : ∀ x, P x := InductionOnHierarchy.order_induction_sigma Γ 1 hP ind -instance [V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻] : V ⊧ₘ* 𝗣𝗔⁻ := - have : V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻 := inferInstance +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻] : V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := + have : V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻 := inferInstance models_of_subtheory this -instance [V ⊧ₘ* 𝗜𝚺₀] : V ⊧ₘ* 𝗜𝗢𝗽𝗲𝗻 := - have : V ⊧ₘ* 𝗜𝚺₀ := inferInstance +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀] : V↓[ℒₒᵣ] ⊧* 𝗜𝗢𝗽𝗲𝗻 := + have : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ := inferInstance models_of_subtheory this -instance [V ⊧ₘ* 𝗜𝚺₁] : V ⊧ₘ* 𝗜𝚺₀ := inferInstance +instance [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ := inferInstance -abbrev mod_ISigma_of_le {n₁ n₂} (h : n₁ ≤ n₂) [V ⊧ₘ* 𝗜𝚺 n₂] : V ⊧ₘ* 𝗜𝚺 n₁ := - ModelsTheory.of_ss inferInstance (ISigma_subset_mono h) +abbrev mod_ISigma_of_le {n₁ n₂} (h : n₁ ≤ n₂) [V↓[ℒₒᵣ] ⊧* 𝗜𝚺 n₂] : V↓[ℒₒᵣ] ⊧* 𝗜𝚺 n₁ := + models_of_ss inferInstance (ISigma_subset_mono h) end models -lemma models_succInd (φ : Semiformula ℒₒᵣ ℕ 1) : ℕ ⊧ₘ (succInd φ).univCl := by +lemma models_succInd (φ : Semiformula ℒₒᵣ ℕ 1) : ℕ↓[ℒₒᵣ] ⊧ (succInd φ).univCl := by suffices ∀ f : ℕ → ℕ, - Semiformula.Evalm ℕ ![0] f φ → - (∀ x, Semiformula.Evalm ℕ ![x] f φ → Semiformula.Evalm ℕ ![x + 1] f φ) → - ∀ x, Semiformula.Evalm ℕ ![x] f φ by + φ.Eval ![0] f → (∀ x, φ.Eval ![x] f → φ.Eval ![x + 1] f) → ∀ x, φ.Eval ![x] f by simpa [Semiformula.eval_univCl, succInd, models_iff, Matrix.constant_eq_singleton, Semiformula.eval_substs] intro e hzero hsucc x; induction' x with x ih · exact hzero · exact hsucc x ih -instance models_ISigma (Γ k) : ℕ ⊧ₘ* 𝗜𝗡𝗗 Γ k := by - simp only [ModelsTheory.add_iff, PeanoMinus.instModelsTheoryNat, InductionScheme, - Semantics.ModelsSet.setOf_iff, forall_exists_index, and_imp, true_and] - rintro _ φ _ rfl; simp [models_succInd] +instance models_ISigma (Γ k) : ℕ↓[ℒₒᵣ] ⊧* 𝗜𝗡𝗗 Γ k := by + have : ∀ φ, ℕ↓[ℒₒᵣ] ⊧ (succInd φ).univCl := models_succInd + simp [InductionScheme] + grind -instance models_ISigmaZero : ℕ ⊧ₘ* 𝗜𝚺₀ := inferInstance +instance models_ISigmaZero : ℕ↓[ℒₒᵣ] ⊧* 𝗜𝚺₀ := inferInstance -instance models_ISigmaOne : ℕ ⊧ₘ* 𝗜𝚺₁ := inferInstance +instance models_ISigmaOne : ℕ↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := inferInstance -instance models_Peano : ℕ ⊧ₘ* 𝗣𝗔 := by - simp only [Peano, InductionScheme, ModelsTheory.add_iff, PeanoMinus.instModelsTheoryNat, - Semantics.ModelsSet.setOf_iff, forall_exists_index, and_imp, true_and] - rintro _ φ _ rfl; simp [models_succInd] +instance models_Peano : ℕ↓[ℒₒᵣ] ⊧* 𝗣𝗔 := by + have : ∀ φ, ℕ↓[ℒₒᵣ] ⊧ (succInd φ).univCl := models_succInd + simp [Peano, InductionScheme] + grind instance : Entailment.Consistent (𝗜𝗡𝗗 Γ k) := (𝗜𝗡𝗗 Γ k).consistent_of_sound (Eq ⊥) rfl diff --git a/Foundation/FirstOrder/Arithmetic/TA/Basic.lean b/Foundation/FirstOrder/Arithmetic/TA/Basic.lean index 757126f25..6c34158da 100644 --- a/Foundation/FirstOrder/Arithmetic/TA/Basic.lean +++ b/Foundation/FirstOrder/Arithmetic/TA/Basic.lean @@ -11,16 +11,16 @@ notation "𝗧𝗔" => FirstOrderTrueArith namespace TA -instance : ℕ ⊧ₘ* 𝗧𝗔 := - modelsTheory_iff.mpr fun {φ} ↦ by simp +instance : ℕ↓[ℒₒᵣ] ⊧* 𝗧𝗔 := + models_theory_iff.mpr fun {φ} ↦ by simp lemma provable_iff {φ : Sentence ℒₒᵣ} : - 𝗧𝗔 ⊢ φ ↔ ℕ ⊧ₘ φ := - ⟨fun h ↦ consequence_iff'.mp (smallSound! h) ℕ, fun h ↦ Entailment.by_axm _ h⟩ + 𝗧𝗔 ⊢ φ ↔ ℕ↓[ℒₒᵣ] ⊧ φ := + ⟨fun h ↦ consequence_iff'.mp (Theory.Proof.sound h) ℕ, fun h ↦ Entailment.by_axm h⟩ -instance (T : Theory ℒₒᵣ) [ℕ ⊧ₘ* T] : T ⪯ 𝗧𝗔 := ⟨by +instance (T : Theory ℒₒᵣ) [ℕ↓[ℒₒᵣ] ⊧* T] : T ⪯ 𝗧𝗔 := ⟨by rintro φ h - have : ℕ ⊧ₘ φ := consequence_iff'.mp (smallSound! h) ℕ + have : ℕ↓[ℒₒᵣ] ⊧ φ := consequence_iff'.mp (Theory.Proof.sound h) ℕ exact provable_iff.mpr this⟩ end TA diff --git a/Foundation/FirstOrder/Arithmetic/TA/Nonstandard.lean b/Foundation/FirstOrder/Arithmetic/TA/Nonstandard.lean index 7d345ffae..20561145d 100644 --- a/Foundation/FirstOrder/Arithmetic/TA/Nonstandard.lean +++ b/Foundation/FirstOrder/Arithmetic/TA/Nonstandard.lean @@ -13,15 +13,15 @@ local notation "ℒₒᵣ⋆" => withStar def starUnbounded (c : ℕ) : Theory ℒₒᵣ⋆ := Set.range fun n : Fin c ↦ “!!(Semiterm.Operator.numeral ℒₒᵣ⋆ n) < ⋆” def trueArithWithStarUnbounded (n : ℕ) : Theory ℒₒᵣ⋆ := - 𝗘𝗤 ∪ (Semiformula.lMap (Language.Hom.add₁ _ _) '' 𝗧𝗔) ∪ starUnbounded n + 𝗘𝗤 ℒₒᵣ⋆ ∪ (Semiformula.lMap (Language.Hom.add₁ _ _) '' 𝗧𝗔) ∪ starUnbounded n lemma trueArithWithStarUnbounded.cumulative : Cumulative trueArithWithStarUnbounded := fun c => Set.union_subset_union_right _ <| Set.range_subset_range_iff_exists_comp.mpr ⟨Fin.castSucc, by simp [Function.comp_def]⟩ -def modelStar (c : ℕ) : Structure Language.unit ℕ where - func := fun _ ⟨⟨⟩⟩ _ => c - rel := fun _ r _ => PEmpty.elim r +abbrev modelStar (c : ℕ) : Structure Language.unit ℕ where + func := fun _ ⟨⟨⟩⟩ _ ↦ c + rel := fun _ r _ ↦ PEmpty.elim r lemma satisfiable_trueArithWithStarUnbounded (c : ℕ) : Satisfiable (trueArithWithStarUnbounded c) := by letI : Structure Language.unit ℕ := modelStar c @@ -30,10 +30,10 @@ lemma satisfiable_trueArithWithStarUnbounded (c : ℕ) : Satisfiable (trueArithW haveI : Structure.Add ℒₒᵣ⋆ ℕ := ⟨fun _ _ => rfl⟩ haveI : Structure.Eq ℒₒᵣ⋆ ℕ := ⟨fun _ _ => iff_of_eq rfl⟩ haveI : Structure.LT ℒₒᵣ⋆ ℕ := ⟨fun _ _ => iff_of_eq rfl⟩ - have : ℕ ⊧ₘ* starUnbounded c := by - have : ∀ (i : Fin c), (↑i : ℕ) < Semiterm.Operator.val (L := ℒₒᵣ⋆) Semiterm.Operator.Star.star ![] := Fin.prop + have : ℕ↓[ℒₒᵣ⋆] ⊧* starUnbounded c := by + have : ∀ (i : Fin c), (↑i : ℕ) < Semiterm.Operator.Star.star.val (L := ℒₒᵣ⋆) ![] := Fin.prop simp [starUnbounded, models_iff, this] - have : ℕ ⊧ₘ* trueArithWithStarUnbounded c := by + have : ℕ↓[ℒₒᵣ⋆] ⊧* trueArithWithStarUnbounded c := by simpa [trueArithWithStarUnbounded, models_iff] using this exact satisfiable_intro ℕ this @@ -42,7 +42,7 @@ lemma satisfiable_union_trueArithWithStarUnbounded : (Compact.compact_cumulative trueArithWithStarUnbounded.cumulative).mpr satisfiable_trueArithWithStarUnbounded -instance trueArithWithStarUnbounded.eqTheory : 𝗘𝗤 ⪯ (⋃ c, trueArithWithStarUnbounded c) := +instance trueArithWithStarUnbounded.eqTheory : 𝗘𝗤 ℒₒᵣ⋆ ⪯ (⋃ c, trueArithWithStarUnbounded c) := Entailment.WeakerThan.ofSubset <| Set.subset_iUnion_of_subset 0 (Set.subset_union_of_subset_left (by simp) _) @@ -54,14 +54,14 @@ namespace Nonstandard notation "ℕ⋆" => Nonstandard -def star : ℕ⋆ := Semiterm.Operator.val (L := ℒₒᵣ⋆) Semiterm.Operator.Star.star ![] +def star : ℕ⋆ := Semiterm.Operator.Star.star.val (L := ℒₒᵣ⋆) ![] local notation "⋆" => star -lemma models_union_trueArithWithStarUnbounded : ℕ⋆ ⊧ₘ* ⋃ c, trueArithWithStarUnbounded c := ModelOfSatEq.models _ +lemma models_union_trueArithWithStarUnbounded : ℕ⋆↓[ℒₒᵣ⋆] ⊧* ⋃ c, trueArithWithStarUnbounded c := ModelOfSatEq.models _ -instance : ℕ⋆ ⊧ₘ* 𝗧𝗔 := ⟨by - have : ℕ⋆ ⊧ₘ* Semiformula.lMap (Language.Hom.add₁ _ _) '' 𝗧𝗔 := +instance : ℕ⋆↓[ℒₒᵣ] ⊧* 𝗧𝗔 := ⟨by + have : ℕ⋆↓[ℒₒᵣ⋆] ⊧* Semiformula.lMap (Language.Hom.add₁ _ _) '' 𝗧𝗔 := Semantics.ModelsSet.of_subset models_union_trueArithWithStarUnbounded (Set.subset_iUnion_of_subset 0 $ Set.subset_union_of_subset_left (by simp) _) intro σ hσ @@ -80,11 +80,11 @@ instance : ℕ⋆ ⊧ₘ* 𝗧𝗔 := ⟨by have : s.toStruc ⊧ σ := Semiformula.models_lMap.mp (this.models _ (Set.mem_image_of_mem _ hσ)) exact e ▸ this⟩ -instance : ℕ⋆ ⊧ₘ* 𝗣𝗔⁻ := - ModelsTheory.of_ss (U := 𝗧𝗔) inferInstance (Structure.subset_of_models.mpr inferInstance) +instance : ℕ⋆↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := + models_of_ss (U := 𝗧𝗔) inferInstance (Structure.subset_of_models.mpr inferInstance) lemma star_unbounded (n : ℕ) : n < ⋆ := by - have : ℕ⋆ ⊧ₘ (“!!(Semiterm.Operator.numeral ℒₒᵣ⋆ n) < ⋆” : Sentence ℒₒᵣ⋆) := + have : ℕ⋆↓[ℒₒᵣ⋆] ⊧ (“!!(Semiterm.Operator.numeral ℒₒᵣ⋆ n) < ⋆” : Sentence ℒₒᵣ⋆) := models_union_trueArithWithStarUnbounded.models _ <| Set.mem_iUnion_of_mem (n + 1) <| Set.mem_union_right _ diff --git a/Foundation/FirstOrder/Basic/Calculus.lean b/Foundation/FirstOrder/Basic/Calculus.lean index 63e679b20..de15f1eee 100644 --- a/Foundation/FirstOrder/Basic/Calculus.lean +++ b/Foundation/FirstOrder/Basic/Calculus.lean @@ -39,6 +39,10 @@ def embed (Γ : List (Sentence L)) : Sequent L := List.map Rewriting.emb Γ @[simp] lemma embed_cons {φ : Sentence L} {Γ : List (Sentence L)} : embed (φ :: Γ) = (↑φ :: embed Γ) := rfl +@[simp] lemma embed_append (Γ Δ : List (Sentence L)) : + embed (Γ ++ Δ) = embed Γ ++ embed Δ := by + simp [embed] + @[simp] lemma embed_shift (Γ : List (Sentence L)) : (embed Γ)⁺ = embed Γ := by simp [embed, Rewriting.shifts] @@ -51,7 +55,7 @@ end Sequent inductive Derivation : Sequent L → Type _ | identity (r : L.Rel k) (v) : Derivation [.rel r v, .nrel r v] | cut : Derivation (φ :: Γ) → Derivation (∼φ :: Δ) → Derivation (Γ ++ Δ) -| wk : Derivation Δ → Δ ⊆ Γ → Derivation Γ +| contraction : Derivation Δ → Δ ⊆ Γ → Derivation Γ | verum : Derivation [⊤] | or : Derivation (φ :: ψ :: Γ) → Derivation (φ ⋎ ψ :: Γ) | and : Derivation (φ :: Γ) → Derivation (ψ :: Γ) → Derivation (φ ⋏ ψ :: Γ) @@ -65,14 +69,14 @@ namespace Derivation open Rewriting LawfulSyntacticRewriting def height {Δ : Sequent L} : ⊢ᴸᴷ¹ Δ → ℕ - | identity _ _ => 0 - | cut dp dn => max dp.height dn.height + 1 - | wk d _ => d.height + 1 - | verum => 0 - | or d => d.height + 1 - | and dp dq => max (height dp) (height dq) + 1 - | all d => d.height + 1 - | exs d => d.height + 1 + | identity _ _ => 0 + | cut dp dn => max dp.height dn.height + 1 + | contraction d _ => d.height + 1 + | verum => 0 + | or d => d.height + 1 + | and dp dq => max (height dp) (height dq) + 1 + | all d => d.height + 1 + | exs d => d.height + 1 section height @@ -82,7 +86,7 @@ section height @[simp] lemma height_cut {φ} (dp : ⊢ᴸᴷ¹ φ :: Δ) (dn : ⊢ᴸᴷ¹ (∼φ) :: Δ) : height (cut dp dn) = (max (height dp) (height dn)).succ := rfl -@[simp] lemma height_wk (d : ⊢ᴸᴷ¹ Δ) (h : Δ ⊆ Γ) : height (wk d h) = d.height.succ := rfl +@[simp] lemma height_contraction (d : ⊢ᴸᴷ¹ Δ) (h : Δ ⊆ Γ) : height (contraction d h) = d.height.succ := rfl @[simp] lemma height_verum : height (verum : ⊢ᴸᴷ¹ ([⊤] : Sequent L)) = 0 := rfl @@ -102,16 +106,16 @@ protected abbrev cast (d : ⊢ᴸᴷ¹ Δ) (e : Δ = Γ := by simp) : ⊢ᴸᴷ @[simp] lemma height_cast (d : ⊢ᴸᴷ¹ Δ) (e : Δ = Γ) : height (Derivation.cast d e) = height d := by rcases e with rfl; simp [Derivation.cast] -def weakening (d : ⊢ᴸᴷ¹ Δ) (h : Δ ⊆ Γ := by simp) : ⊢ᴸᴷ¹ Γ := wk d h +def contra (d : ⊢ᴸᴷ¹ Δ) (h : Δ ⊆ Γ := by simp) : ⊢ᴸᴷ¹ Γ := contraction d h -def top (h : ⊤ ∈ Δ := by simp) : ⊢ᴸᴷ¹ Δ := verum.wk (by simp [h]) +def top (h : ⊤ ∈ Δ := by simp) : ⊢ᴸᴷ¹ Δ := verum.contraction (by simp [h]) def identity' (r : L.Rel k) (v) (hpos : Semiformula.rel r v ∈ Δ := by simp) (hneg : Semiformula.nrel r v ∈ Δ := by simp) : ⊢ᴸᴷ¹ Δ := - (identity r v).wk (by simp [hpos, hneg]) + (identity r v).contraction (by simp [hpos, hneg]) -def tensor {φ ψ} (dφ : ⊢ᴸᴷ¹ φ :: Γ) (dψ : ⊢ᴸᴷ¹ ψ :: Δ) : ⊢ᴸᴷ¹ φ ⋏ ψ :: (Γ ++ Δ) := and dφ.weakening dψ.weakening +def tensor {φ ψ} (dφ : ⊢ᴸᴷ¹ φ :: Γ) (dψ : ⊢ᴸᴷ¹ ψ :: Δ) : ⊢ᴸᴷ¹ φ ⋏ ψ :: (Γ ++ Δ) := and dφ.contra dψ.contra -def rotate (d : ⊢ᴸᴷ¹ φ :: Γ) : ⊢ᴸᴷ¹ Γ ++ [φ] := d.weakening +def rotate (d : ⊢ᴸᴷ¹ φ :: Γ) : ⊢ᴸᴷ¹ Γ ++ [φ] := d.contra def eta : (φ : Proposition L) → ⊢ᴸᴷ¹ [φ, ∼φ] | .rel R v | .nrel R v => identity' R v @@ -129,7 +133,7 @@ def eta : (φ : Proposition L) → ⊢ᴸᴷ¹ [φ, ∼φ] termination_by φ => φ.complexity def close (φ : Proposition L) (hp : φ ∈ Δ := by simp) (hn : ∼φ ∈ Δ := by simp) : ⊢ᴸᴷ¹ Δ := - eta φ |>.weakening (by simp [hp, hn]) + eta φ |>.contra (by simp [hp, hn]) lemma of_isClosed {Γ : Sequent L} (h : Γ.IsClosed) : Nonempty (⊢ᴸᴷ¹ Γ) := by rcases h with ⟨φ, hp, hn⟩ @@ -139,7 +143,7 @@ instance : OneSidedLK (Derivation (L := L)) where verum := verum and d₁ d₂ := d₁.and d₂ or d := d.or - wk d ss := d.wk ss + contraction d ss := d.contraction ss identity φ := eta φ instance : OneSidedLK.Cut (Derivation (L := L)) where @@ -151,7 +155,7 @@ def rewrite {Γ} (f : ℕ → SyntacticTerm L) : ⊢ᴸᴷ¹ Γ → ⊢ᴸᴷ¹ have d₁ : ⊢ᴸᴷ¹ Rew.rewrite f ▹ φ :: Γ.map (app (Rew.rewrite f)) := (d₁.rewrite f).cast have d₂ : ⊢ᴸᴷ¹ ∼(Rew.rewrite f ▹ φ) :: Δ.map (app (Rew.rewrite f)) := (d₂.rewrite f).cast d₁.cut d₂ |>.cast - | wk d ss => d.rewrite f |>.wk (List.map_subset _ ss) + | contraction d ss => d.rewrite f |>.contraction (List.map_subset _ ss) | verum => verum | or d => (d.rewrite f).or | and d₁ d₂ => (d₁.rewrite f).and (d₂.rewrite f) @@ -189,7 +193,7 @@ def lMap (Φ : L₁ →ᵥ L₂) {Γ} : ⊢ᴸᴷ¹ Γ → ⊢ᴸᴷ¹ Γ.map (. have : ⊢ᴸᴷ¹ (Γ.map (.lMap Φ) ++ Δ.map (.lMap Φ) : Sequent L₂) := cut (φ := .lMap Φ φ) (Derivation.cast (lMap Φ d) (by simp)) (Derivation.cast (lMap Φ dn) (by simp)) Derivation.cast this (by simp) - | wk (Δ := Δ) (Γ := Γ) d ss => (lMap Φ d).wk (List.map_subset _ ss) + | contraction (Δ := Δ) (Γ := Γ) d ss => (lMap Φ d).contraction (List.map_subset _ ss) | verum => by simpa using verum | or (Γ := Γ) (φ := φ) (ψ := ψ) d => by have : ⊢ᴸᴷ¹ (.lMap Φ φ ⋎ .lMap Φ ψ :: Γ.map (.lMap Φ) : Sequent L₂) := @@ -233,17 +237,17 @@ def genelalizeByNewver {φ : Semiproposition L 1} (hp : ¬φ.FVar? m) (hΔ : ∀ def exOfInstances (v : List (SyntacticTerm L)) (φ : Semiproposition L 1) (h : ⊢ᴸᴷ¹ v.map (φ/[·]) ++ Γ) : ⊢ᴸᴷ¹ (∃⁰ φ) :: Γ := by induction' v with t v ih generalizing Γ - · exact weakening h (List.subset_cons_self _ _) - · exact (ih (Γ := (∃⁰ φ) :: Γ) ((exs h).wk (by simp))).wk (by simp) + · exact contra h (List.subset_cons_self _ _) + · exact (ih (Γ := (∃⁰ φ) :: Γ) ((exs h).contraction (by simp))).contraction (by simp) def exOfInstances' (v : List (SyntacticTerm L)) (φ : Semiproposition L 1) (h : ⊢ᴸᴷ¹ (∃⁰ φ) :: v.map (φ/[·]) ++ Γ) : ⊢ᴸᴷ¹ (∃⁰ φ) :: Γ := - (exOfInstances (Γ := (∃⁰ φ) :: Γ) v φ (h.wk <| by simp)).wk (by simp) + (exOfInstances (Γ := (∃⁰ φ) :: Γ) v φ (h.contraction <| by simp)).contraction (by simp) def allNvar {Δ : Sequent L} {φ} (h : ∀⁰ φ ∈ Δ) : ⊢ᴸᴷ¹ φ/[&Δ.newVar] :: Δ → ⊢ᴸᴷ¹ Δ := fun b ↦ let b : ⊢ᴸᴷ¹ (∀⁰ φ) :: Δ := b.genelalizeByNewver (by simpa [Semiformula.FVar?] using Sequent.not_fvar?_newVar h) (fun _ ↦ Sequent.not_fvar?_newVar) - b.wk (by simp [h]) + b.contraction (by simp [h]) end Derivation @@ -355,6 +359,18 @@ lemma of_LK_provable {T : Theory L} {φ : Sentence L} : 𝐋𝐊¹ ⊢ (φ : Pro have : pullback 𝐋𝐊¹[L] (Rewriting.emb : Sentence L → Proposition L) ⊢ φ := h OneSidedLK.ContextualEntailment.of_principal_provable this +lemma specialize {T : Theory L} (φ : Semisentence L 1) (t : ClosedTerm L) : + T ⊢ ∀⁰ φ 🡒 Semiformula.subst φ ![t] := by + apply of_LK_provable + refine ⟨?_⟩ + let φt : Sentence L := Semiformula.subst φ ![t] + have d : ⊢ᴸᴷ¹ [∼(φt : Proposition L), φt] := (Derivation.eta (φt : Proposition L)).rotate.cast (by simp) + have d₀ : ⊢ᴸᴷ¹ [(∼(φ : Semiproposition L 1))/[Rew.emb t], (φt : Proposition L)] := by + simpa [φt, Semiformula.coe_subst_eq_subst_coe₁] using d + have d' : ⊢ᴸᴷ¹ [∃⁰ ∼(φ : Semiproposition L 1), (φt : Proposition L)] := + Derivation.exs (φ := ∼(φ : Semiproposition L 1)) (Γ := [(φt : Proposition L)]) (t := Rew.emb t) d₀ + exact d'.or.cast (by simp [Semiformula.imp_eq, φt]) + open Classical in noncomputable instance : Entailment.Deduction (Theory L) := OneSidedLK.ContextualEntailment.deduction (pullback 𝐋𝐊¹[L] (Rewriting.emb : Sentence L → Proposition L)) diff --git a/Foundation/FirstOrder/Basic/Calculus2.lean b/Foundation/FirstOrder/Basic/Calculus2.lean index 06839c941..190a11278 100644 --- a/Foundation/FirstOrder/Basic/Calculus2.lean +++ b/Foundation/FirstOrder/Basic/Calculus2.lean @@ -4,98 +4,182 @@ public import Foundation.FirstOrder.Basic.Calculus /-! # Alternative definition of proof -/ -/- - namespace LO.FirstOrder variable {L : Language} [L.DecidableEq] section derivation2 -inductive Derivation2 : Finset (Proposition L) → Type _ -| wk {Δ Γ} : Derivation2 Δ → Δ ⊆ Γ → Derivation2 Γ -| shift {Γ} : Derivation2 Γ → Derivation2 (Γ.image Rewriting.shift) -| identity (Γ) (φ : Proposition L) : φ ∈ Γ → ∼φ ∈ Γ → Derivation2 Γ -| cut {Γ φ} : Derivation2 (insert φ Γ) → Derivation2 (insert (∼φ) Δ) → Derivation2 (Γ ∪ Δ) -| verum {Γ} : ⊤ ∈ Γ → Derivation2 Γ -| and {Γ} {φ ψ : Proposition L} : φ ⋏ ψ ∈ Γ → Derivation2 (insert φ Γ) → Derivation2 (insert ψ Γ) → Derivation2 Γ -| or {Γ} {φ ψ : Proposition L} : φ ⋎ ψ ∈ Γ → Derivation2 (insert φ (insert ψ Γ)) → Derivation2 Γ -| all {Γ} {φ : Semiproposition L 1} : ∀⁰ φ ∈ Γ → Derivation2 (insert (Rewriting.free φ) (Γ.image Rewriting.shift)) → Derivation2 Γ -| exs {Γ} {φ : Semiproposition L 1} : ∃⁰ φ ∈ Γ → (t : SyntacticTerm L) → Derivation2 (insert (φ/[t]) Γ) → Derivation2 Γ - +inductive Derivation2 (T : Theory L) : Finset (Proposition L) → Type _ +| closed (Γ) (φ : Proposition L) : φ ∈ Γ → ∼φ ∈ Γ → Derivation2 T Γ +| axm {Γ} (φ : Sentence L) : φ ∈ T → (φ : Proposition L) ∈ Γ → Derivation2 T Γ +| verum {Γ} : ⊤ ∈ Γ → Derivation2 T Γ +| and {Γ} {φ ψ : Proposition L} : φ ⋏ ψ ∈ Γ → Derivation2 T (insert φ Γ) → Derivation2 T (insert ψ Γ) → Derivation2 T Γ +| or {Γ} {φ ψ : Proposition L} : φ ⋎ ψ ∈ Γ → Derivation2 T (insert φ (insert ψ Γ)) → Derivation2 T Γ +| all {Γ} {φ : Semiproposition L 1} : ∀⁰ φ ∈ Γ → Derivation2 T (insert (Rewriting.free φ) (Γ.image Rewriting.shift)) → Derivation2 T Γ +| exs {Γ} {φ : Semiproposition L 1} : ∃⁰ φ ∈ Γ → (t : SyntacticTerm L) → Derivation2 T (insert (φ/[t]) Γ) → Derivation2 T Γ +| wk {Δ Γ} : Derivation2 T Δ → Δ ⊆ Γ → Derivation2 T Γ +| shift {Γ} : Derivation2 T Γ → Derivation2 T (Γ.image Rewriting.shift) +| cut {Γ φ} : Derivation2 T (insert φ Γ) → Derivation2 T (insert (∼φ) Γ) → Derivation2 T Γ scoped infix:45 " ⟹₂" => Derivation2 -abbrev Derivable2 (𝓢 : Schema L) (Γ : Finset (Proposition L)) := Nonempty (𝓢 ⟹₂ Γ) +abbrev Derivable2 (T : Theory L) (Γ : Finset (Proposition L)) := Nonempty (T ⟹₂ Γ) scoped infix:45 " ⟹₂! " => Derivable2 -abbrev Derivable2SingleConseq (𝓢 : Schema L) (φ : Proposition L) : Prop := 𝓢 ⟹₂! {φ} +abbrev _root_.LO.FirstOrder.Theory.Proof2 (T : Theory L) (φ : Proposition L) := T ⟹₂ {φ} -scoped infix: 45 " ⊢!₂! " => Derivable2SingleConseq +scoped infix: 45 " ⊢!₂! " => Theory.Proof2 -variable {𝓢 : Schema L} +variable {T : Theory L} lemma shifts_toFinset_eq_image_shift (Γ : Sequent L) : (Rewriting.shifts Γ).toFinset = Γ.toFinset.image Rewriting.shift := by ext φ; simp [Rewriting.shifts] -def Derivation.toDerivation2 (𝓢) {Γ : Sequent L} : 𝓢 ⟹ Γ → 𝓢 ⟹₂ Γ.toFinset - | Derivation.axL R v => Derivation2.closed _ (Semiformula.rel R v) (by simp) (by simp) - | Derivation.axm (φ := φ) h => Derivation2.axm φ h (by simp) +def Derivation.toDerivation2 (T) {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → T ⟹₂ Γ.toFinset + | Derivation.identity R v => Derivation2.closed _ (Semiformula.rel R v) (by simp) (by simp) | Derivation.verum => Derivation2.verum (by simp) | Derivation.and (Γ := Γ) (φ := φ) (ψ := ψ) dp dq => Derivation2.and (φ := φ) (ψ := ψ) (by simp) - (Derivation2.wk (Derivation.toDerivation2 𝓢 dp) (by simp)) - (Derivation2.wk (Derivation.toDerivation2 𝓢 dq) (by simp)) + (Derivation2.wk (Derivation.toDerivation2 T dp) (by simp)) + (Derivation2.wk (Derivation.toDerivation2 T dq) (by simp)) | Derivation.or (Γ := Γ) (φ := φ) (ψ := ψ) dpq => Derivation2.or (φ := φ) (ψ := ψ) (by simp) - (Derivation2.wk (Derivation.toDerivation2 𝓢 dpq) + (Derivation2.wk (Derivation.toDerivation2 T dpq) (by simp)) | Derivation.all (Γ := Γ) (φ := φ) dp => Derivation2.all (φ := φ) (by simp) - (Derivation2.wk (Derivation.toDerivation2 𝓢 dp) - (by simpa using Finset.insert_subset_insert _ (by simp [shifts_toFinset_eq_image_shift]))) - | Derivation.exs (Γ := Γ) (φ := φ) t dp => + (Derivation2.wk (Derivation.toDerivation2 T dp) + (by simp [shifts_toFinset_eq_image_shift])) + | Derivation.exs (Γ := Γ) (φ := φ) (t := t) dp => Derivation2.exs (φ := φ) (by simp) t - (Derivation2.wk (Derivation.toDerivation2 𝓢 dp) (by simp)) - | Derivation.wk d h => - Derivation2.wk (Derivation.toDerivation2 𝓢 d) (List.toFinset_mono h) - | Derivation.cut (Γ := Γ) (φ := φ) d₁ d₂ => + (Derivation2.wk (Derivation.toDerivation2 T dp) (by simp)) + | Derivation.contraction d h => + Derivation2.wk (Derivation.toDerivation2 T d) (List.toFinset_mono h) + | Derivation.cut (Γ := Γ) (Δ := Δ) (φ := φ) d₁ d₂ => Derivation2.cut (φ := φ) - (Derivation2.wk (Derivation.toDerivation2 𝓢 d₁) (by simp)) - (Derivation2.wk (Derivation.toDerivation2 𝓢 d₂) (by simp)) - -noncomputable def Derivation2.toDerivation {Γ : Finset (Proposition L)} : 𝓢 ⟹₂ Γ → 𝓢 ⟹ Γ.toList - | Derivation2.closed Γ φ hp hn => Derivation.em (φ := φ) (by simp [hp]) (by simp [hn]) - | Derivation2.axm φ hp h => Tait.wk (Derivation.axm hp) (by simp_all) - | Derivation2.verum h => Tait.verum' (by simp [h]) - | Derivation2.and (φ := φ) (ψ := ψ) h dp dq => - Tait.and' (φ := φ) (ψ := ψ) (by simp [h]) - (Tait.wk dp.toDerivation <| by intro x; simp) - (Tait.wk dq.toDerivation <| by intro x; simp) - | Derivation2.or (φ := φ) (ψ := ψ) h dpq => - Tait.or' (φ := φ) (ψ := ψ) (by simp [h]) (Tait.wk dpq.toDerivation <| by intro x; simp) - | Derivation2.all (φ := φ) h d => - Derivation.all' (φ := φ) (by simp [h]) (Tait.wk d.toDerivation <| by intro x; simp [Rewriting.shifts]) - | Derivation2.exs (φ := φ) h t d => - Derivation.exs' (φ := φ) (by simp [h]) t (Tait.wk d.toDerivation <| by intro x; simp) - | Derivation2.wk d h => - Tait.wk d.toDerivation (by intro x; simpa using @h x) - | Derivation2.shift d => - Tait.wk (Derivation.shift d.toDerivation) <| by intro x; simp [Rewriting.shifts] - | Derivation2.cut (φ := φ) d dn => - Tait.cut (φ := φ) - (Tait.wk d.toDerivation <| by intro x; simp) - (Tait.wk dn.toDerivation <| by intro x; simp) - -lemma derivable_iff_derivable2 {Γ : List (Proposition L)} : 𝓢 ⟹! Γ ↔ 𝓢 ⟹₂! Γ.toFinset := by + (Derivation2.wk (Derivation.toDerivation2 T d₁) (List.subset_def.mpr <| by simp_all)) + (Derivation2.wk (Derivation.toDerivation2 T d₂) (List.subset_def.mpr <| by simp_all)) + +namespace Derivation2 + +structure ProofData (T : Theory L) (Γ : Finset (Proposition L)) where + axioms : List (Sentence L) + axioms_mem : ∀ ψ ∈ axioms, ψ ∈ T + derivation : ⊢ᴸᴷ¹ Γ.toList ++ ∼Sequent.embed axioms + +noncomputable def cast {Γ Δ : Finset (Proposition L)} (d : T ⟹₂ Γ) (h : Γ = Δ := by simp) : T ⟹₂ Δ := by + rcases h; exact d + +omit [L.DecidableEq] in +private lemma exists_shift_mem_embed_of_mem {A : List (Sentence L)} {φ : Proposition L} + (h : φ ∈ Sequent.embed A) : ∃ ψ ∈ Sequent.embed A, Rewriting.shift ψ = φ := by + simp [Sequent.embed] at h ⊢ + grind + +omit [L.DecidableEq] in +private lemma mem_embed_of_exists_shift_mem {A : List (Sentence L)} {φ : Proposition L} + (h : ∃ ψ ∈ Sequent.embed A, Rewriting.shift ψ = φ) : φ ∈ Sequent.embed A := by + simp [Sequent.embed] at h ⊢ + grind + +@[reducible] noncomputable def cutManyProof : (A : List (Sentence L)) → (∀ ψ ∈ A, ψ ∈ T) → + T ⟹₂ (insert (φ : Proposition L) (∼Sequent.embed A).toFinset) → T ⟹₂ {φ} + | [], _, d => d + | ψ :: A, hA, d => + have ax : T ⟹₂ insert (ψ : Proposition L) (insert φ (∼Sequent.embed A).toFinset) := + Derivation2.axm ψ (hA ψ (by simp)) (by simp) + have dn : T ⟹₂ insert (∼(ψ : Proposition L)) (insert φ (∼Sequent.embed A).toFinset) := by + refine Derivation2.cast d ?_ + ext x; simp [List.toFinset_cons]; grind + have c : T ⟹₂ insert φ (∼Sequent.embed A).toFinset := by + refine Derivation2.cast (Derivation2.cut ax dn) ?_ + ext x; simp + cutManyProof A (by simp_all) c + +@[reducible] noncomputable def cutMany (A : List (Sentence L)) (hA : ∀ ψ ∈ A, ψ ∈ T) + (d : T ⟹₂! (insert (φ : Proposition L) (∼Sequent.embed A).toFinset)) : T ⟹₂! {φ} := + d.elim fun d ↦ ⟨cutManyProof A hA d⟩ + +noncomputable def toProofData : {Γ : Finset (Proposition L)} → T ⟹₂ Γ → + ProofData T Γ + | Γ, closed _ φ hp hn => + ⟨[], by simp, (Derivation.eta φ).contra <| List.subset_def.mpr (by simp_all)⟩ + | Γ, axm φ hT hΓ => + ⟨[φ], by simp [hT], (Derivation.eta (φ : Proposition L)).contra <| List.subset_def.mpr (by simp_all)⟩ + | Γ, verum h => + ⟨[], by simp, Derivation.verum.contra <| List.subset_def.mpr (by simp_all)⟩ + | Γ, and (φ := φ) (ψ := ψ) h dφ dψ => by + rcases toProofData dφ with ⟨A, hA, bφ⟩ + rcases toProofData dψ with ⟨B, hB, bψ⟩ + refine ⟨A ++ B, by simp; grind, ?_⟩ + have bφ' : ⊢ᴸᴷ¹ φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := + bφ.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) + have bψ' : ⊢ᴸᴷ¹ ψ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := + bψ.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) + exact (Derivation.and bφ' bψ').contra <| List.subset_def.mpr (by simp_all) + | Γ, or (φ := φ) (ψ := ψ) h d => by + rcases toProofData d with ⟨A, hA, b⟩ + refine ⟨A, hA, ?_⟩ + have b' : ⊢ᴸᴷ¹ φ :: ψ :: Γ.toList ++ ∼Sequent.embed A := + b.contra <| List.subset_def.mpr (by simp_all; grind) + exact (Derivation.or b').contra <| List.subset_def.mpr (by simp_all) + | Γ, all (φ := φ) h d => by + rcases toProofData d with ⟨A, hA, b⟩ + refine ⟨A, hA, ?_⟩ + have b' : ⊢ᴸᴷ¹ Rewriting.free φ :: (Γ.toList ++ ∼Sequent.embed A)⁺ := + b.contra <| List.subset_def.mpr (by simp_all [Rewriting.shifts]; grind [exists_shift_mem_embed_of_mem]) + exact (Derivation.all b').contra <| List.subset_def.mpr (by simp_all) + | Γ, exs (φ := φ) h t d => by + rcases toProofData d with ⟨A, hA, b⟩ + refine ⟨A, hA, ?_⟩ + have b' : ⊢ᴸᴷ¹ φ/[t] :: Γ.toList ++ ∼Sequent.embed A := + b.contra <| List.subset_def.mpr (by simp_all; grind) + exact (Derivation.exs (t := t) b').contra <| List.subset_def.mpr (by simp_all) + | Γ, wk d h => by + rcases toProofData d with ⟨A, hA, b⟩ + refine ⟨A, hA, b.contra <| List.subset_def.mpr (by simp_all; grind)⟩ + | _, shift (Γ := Γ) d => by + rcases toProofData d with ⟨A, hA, b⟩ + refine ⟨A, hA, ?_⟩ + exact b.shift.contra <| List.subset_def.mpr (by simp_all [Rewriting.shifts]; grind [mem_embed_of_exists_shift_mem]) + | Γ, cut (φ := φ) d dn => by + rcases toProofData d with ⟨A, hA, b⟩ + rcases toProofData dn with ⟨B, hB, bn⟩ + refine ⟨A ++ B, by simp; grind, ?_⟩ + have b' : ⊢ᴸᴷ¹ φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := + b.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) + have bn' : ⊢ᴸᴷ¹ ∼φ :: Γ.toList ++ ∼Sequent.embed (A ++ B) := + bn.contra <| List.subset_def.mpr (by simp_all [Sequent.embed_append]; grind) + exact (Derivation.cut + b' bn').contra <| List.subset_def.mpr (by simp_all; grind) + +noncomputable def toProof (d : T ⟹₂ Γ) : + ∃ A : List (Sentence L), (∀ ψ ∈ A, ψ ∈ T) ∧ Nonempty (⊢ᴸᴷ¹ Γ.toList ++ ∼Sequent.embed A) := by + rcases toProofData d with ⟨A, hA, b⟩ + exact ⟨A, hA, ⟨b⟩⟩ + +end Derivation2 + +namespace Theory + +noncomputable def Proof.toProof2 {φ : Sentence L} (b : T ⊢! φ) : T ⊢!₂! (φ : Proposition L) := + Derivation2.cutManyProof b.axioms b.axioms_mem <| + Derivation2.cast (Derivation.toDerivation2 T b.derivation) (by ext x; simp [List.toFinset_cons, Sequent.embed]) + +noncomputable def Proof2.toProof {φ : Sentence L} (d : T ⊢!₂! (φ : Proposition L)) : T ⊢! φ := by + rcases Derivation2.toProofData d with ⟨A, hA, b⟩ + exact ⟨A, hA, b.contra <| List.subset_def.mpr (by simp [Sequent.embed])⟩ + +end Theory + +lemma provable_iff_derivable2 {φ : Sentence L} : T ⊢ φ ↔ Nonempty (T ⊢!₂! (φ : Proposition L)) := by constructor - · rintro ⟨d⟩; exact ⟨by simpa using Derivation.toDerivation2 𝓢 d⟩ - · rintro ⟨d⟩; exact ⟨.wk d.toDerivation (by intro x; simp)⟩ - -def provable_iff_derivable2 {φ} : 𝓢 ⊢ φ ↔ 𝓢 ⊢!₂! φ := derivable_iff_derivable2 + · exact fun h ↦ ⟨h.get.toProof2⟩ + · rintro ⟨h⟩ + exact ⟨h.toProof⟩ end derivation2 end LO.FirstOrder --/ diff --git a/Foundation/FirstOrder/Basic/CutFree.lean b/Foundation/FirstOrder/Basic/CutFree.lean index 4b200bdcb..17c71875d 100644 --- a/Foundation/FirstOrder/Basic/CutFree.lean +++ b/Foundation/FirstOrder/Basic/CutFree.lean @@ -22,7 +22,7 @@ inductive IsCutFree : {Γ : Sequent L} → ⊢ᴸᴷ¹ Γ → Prop | and {dφ : ⊢ᴸᴷ¹ φ :: Γ} {dψ : ⊢ᴸᴷ¹ ψ :: Γ} : IsCutFree dφ → IsCutFree dψ → IsCutFree (dφ.and dψ) | all {d : ⊢ᴸᴷ¹ Rewriting.free φ :: Γ⁺} : IsCutFree d → IsCutFree d.all | exs (t) {d : ⊢ᴸᴷ¹ φ/[t] :: Γ} : IsCutFree d → IsCutFree d.exs -| wk {d : ⊢ᴸᴷ¹ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.wk ss) +| contraction {d : ⊢ᴸᴷ¹ Δ} (ss : Δ ⊆ Γ) : IsCutFree d → IsCutFree (d.contraction ss) attribute [simp] IsCutFree.identity IsCutFree.verum @@ -41,8 +41,8 @@ variable {Γ Δ : Sequent L} @[simp] lemma isCutFree_exs_iff {d : ⊢ᴸᴷ¹ φ/[t] :: Γ} : IsCutFree d.exs ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .exs t⟩ -@[simp] lemma isCutFree_wk_iff {d : ⊢ᴸᴷ¹ Δ} {ss : Δ ⊆ Γ} : - IsCutFree (d.wk ss) ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .wk _⟩ +@[simp] lemma isCutFree_contraction_iff {d : ⊢ᴸᴷ¹ Δ} {ss : Δ ⊆ Γ} : + IsCutFree (d.contraction ss) ↔ IsCutFree d := ⟨by rintro ⟨⟩; assumption, .contraction _⟩ @[simp] lemma IsCutFree.cast {d : ⊢ᴸᴷ¹ Γ} {e : Γ = Δ} : IsCutFree (.cast d e) ↔ IsCutFree d := by rcases e; rfl diff --git a/Foundation/FirstOrder/Basic/Definability.lean b/Foundation/FirstOrder/Basic/Definability.lean index b422d7b66..59778fb58 100644 --- a/Foundation/FirstOrder/Basic/Definability.lean +++ b/Foundation/FirstOrder/Basic/Definability.lean @@ -175,6 +175,19 @@ notation L "-function₄[" N "] " f => DefinableFunction₄ (M := N) L f end Language +namespace IsDefinedBy + +lemma of_vec_one {R : (Fin 1 → M) → Prop} {φ : Semisentence L 1} (h : ∀ x, Semiformula.Evalb ![x] φ ↔ R ![x]) : IsDefinedBy R φ := by + intro v; simpa [←Matrix.fun_eq_vec_one] using h (v 0) + +lemma of_vec_two {R : (Fin 2 → M) → Prop} {φ : Semisentence L 2} (h : ∀ x y, Semiformula.Evalb ![x, y] φ ↔ R ![x, y]) : IsDefinedBy R φ := by + intro v; simpa [←Matrix.fun_eq_vec_two] using h (v 0) (v 1) + +lemma of_vec_three {R : (Fin 3 → M) → Prop} {φ : Semisentence L 3} (h : ∀ x y z, Semiformula.Evalb ![x, y, z] φ ↔ R ![x, y, z]) : IsDefinedBy R φ := by + intro v; simpa [←Matrix.fun_eq_vec_three] using h (v 0) (v 1) (v 2) + +end IsDefinedBy + namespace Defined lemma to_definable {R : (Fin k → M) → Prop} {φ : Semisentence L k} (hR : Defined R φ) : L.Definable R := diff --git a/Foundation/FirstOrder/Basic/Operator.lean b/Foundation/FirstOrder/Basic/Operator.lean index 9b89376e4..c2c0d9e81 100644 --- a/Foundation/FirstOrder/Basic/Operator.lean +++ b/Foundation/FirstOrder/Basic/Operator.lean @@ -601,51 +601,54 @@ attribute [simp] Zero.zero One.one Add.add Mul.mul Exp.exp Eq.eq LT.lt LE.le Mem instance [L.Eq] [L.LT] [Structure.Eq L M] [PartialOrder M] [Structure.LT L M] : Structure.LE L M := ⟨by intro a b; simpa [Operator.LE.def_of_Eq_of_LT] using le_iff_eq_or_lt.symm⟩ -variable {L} +variable {L M} -@[simp] lemma zero_eq_of_lang [L.Zero] [Zero M] [Structure.Zero L M] : - Structure.func (L := L) Language.Zero.zero ![] = (0 : M) := by - simpa [Semiterm.Operator.val, Semiterm.Operator.Zero.zero, val_func, ←Matrix.fun_eq_vec_two] using +@[simp] lemma zero_eq_of_lang [L.Zero] [Zero M] [Structure.Zero L M] (v : Fin 0 → M) : + Structure.func (L := L) Language.Zero.zero v = (0 : M) := by + simpa [Matrix.empty_eq, Semiterm.Operator.val, Semiterm.Operator.Zero.zero, ←Matrix.fun_eq_vec_two] using Structure.Zero.zero (L := L) (M := M) -@[simp] lemma one_eq_of_lang [L.One] [One M] [Structure.One L M] : - Structure.func (L := L) Language.One.one ![] = (1 : M) := by - simpa [Semiterm.Operator.val, Semiterm.Operator.One.one, val_func, ←Matrix.fun_eq_vec_two] using +@[simp] lemma one_eq_of_lang [L.One] [One M] [Structure.One L M] (v : Fin 0 → M) : + Structure.func (L := L) Language.One.one v = (1 : M) := by + simpa [Matrix.empty_eq, Semiterm.Operator.val, Semiterm.Operator.One.one, ←Matrix.fun_eq_vec_two] using Structure.One.one (L := L) (M := M) @[simp] lemma add_eq_of_lang [L.Add] [Add M] [Structure.Add L M] {v : Fin 2 → M} : Structure.func (L := L) Language.Add.add v = v 0 + v 1 := by - simpa [val_func, ←Matrix.fun_eq_vec_two] using - Structure.Add.add (L := L) (v 0) (v 1) + simpa [←Matrix.fun_eq_vec_two] using Structure.Add.add (L := L) (v 0) (v 1) @[simp] lemma mul_eq_of_lang [L.Mul] [Mul M] [Structure.Mul L M] {v : Fin 2 → M} : Structure.func (L := L) Language.Mul.mul v = v 0 * v 1 := by - simpa [val_func, ←Matrix.fun_eq_vec_two] using - Structure.Mul.mul (L := L) (v 0) (v 1) + simpa [←Matrix.fun_eq_vec_two] using Structure.Mul.mul (L := L) (v 0) (v 1) @[simp] lemma exp_eq_of_lang [L.Exp] [Exp M] [Structure.Exp L M] {v : Fin 1 → M} : Structure.func (L := L) Language.Exp.exp v = LO.Exp.exp (v 0) := by - simpa [val_func, ←Matrix.fun_eq_vec_one] using - Structure.Exp.exp (L := L) (v 0) + simpa [←Matrix.fun_eq_vec_one] using Structure.Exp.exp (L := L) (v 0) + +@[simp] lemma eq_iff_eq [Operator.Eq L] [Structure.Eq L M] {v : Fin 2 →M} : + (@Operator.Eq.eq L _).val v ↔ v 0 = v 1 := by + rw [Matrix.fun_eq_vec_two v]; simp + +@[simp] lemma lt_iff_lt [Operator.LT L] [LT M] [Structure.LT L M] {v : Fin 2 →M} : + (@Operator.LT.lt L _).val v ↔ v 0 < v 1 := by + rw [Matrix.fun_eq_vec_two v]; simp + +@[simp] lemma mem_iff_mem [Operator.Mem L] [Membership M M] [Structure.Mem L M] {v : Fin 2 →M} : + (@Operator.Mem.mem L _).val v ↔ v 0 ∈ v 1 := by + rw [Matrix.fun_eq_vec_two v]; simp lemma le_iff_of_eq_of_lt [Operator.Eq L] [Operator.LT L] [LT M] [Structure.Eq L M] [Structure.LT L M] {a b : M} : (@Operator.LE.le L _).val ![a, b] ↔ a = b ∨ a < b := by simp [Operator.LE.def_of_Eq_of_LT] @[simp] lemma eq_lang [L.Eq] [Structure.Eq L M] {v : Fin 2 → M} : - Structure.rel (L := L) Language.Eq.eq v ↔ v 0 = v 1 := by - simpa [Semiformula.Operator.Eq.sentence_eq, eval_rel, ←Matrix.fun_eq_vec_two] using - Structure.Eq.eq (L := L) (v 0) (v 1) + Structure.rel (L := L) Language.Eq.eq v ↔ v 0 = v 1 := by simpa [-eq_iff_eq] using eq_iff_eq (L := L) (v := v) @[simp] lemma lt_lang [L.LT] [LT M] [Structure.LT L M] {v : Fin 2 → M} : - Structure.rel (L := L) Language.LT.lt v ↔ v 0 < v 1 := by - simpa [Semiformula.Operator.LT.sentence_eq, eval_rel, ←Matrix.fun_eq_vec_two] using - Structure.LT.lt (L := L) (v 0) (v 1) + Structure.rel (L := L) Language.LT.lt v ↔ v 0 < v 1 := by simpa [-lt_iff_lt] using lt_iff_lt (L := L) (v := v) @[simp] lemma mem_lang [L.Mem] [Membership M M] [Structure.Mem L M] {v : Fin 2 → M} : - Structure.rel (L := L) Language.Mem.mem v ↔ v 0 ∈ v 1 := by - simpa [Semiformula.Operator.Mem.sentence_eq, eval_rel, ←Matrix.fun_eq_vec_two] using - Structure.Mem.mem (L := L) (v 0) (v 1) + Structure.rel (L := L) Language.Mem.mem v ↔ v 0 ∈ v 1 := by simpa [-mem_iff_mem] using mem_iff_mem (L := L) (v := v) lemma operator_val_ofEquiv_iff (φ : M ≃ N) {k : ℕ} {o : Semiformula.Operator L k} {v : Fin k → N} : letI : Structure L N := ofEquiv φ diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index 741b99d0f..ad45b38b9 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -238,6 +238,8 @@ abbrev Evalf [s : Structure L M] (f : ξ → M) : Formula L ξ →ˡᶜ Prop := abbrev Evalb [s : Structure L M] (b : Fin n → M) : Semiformula L Empty n →ˡᶜ Prop := Eval b Empty.elim +notation:max M:90 " ⊧/" e:max => @Evalb _ M _ _ e + abbrev Realize (M : Type*) [s : Structure L M] : Sentence L →ˡᶜ Prop := Eval (s := s) ![] Empty.elim @@ -364,7 +366,7 @@ lemma eval_bShift' (φ : Semiformula L ξ n) : simp [IsEmpty.eq_elim] @[simp] lemma eval_embSubsts {ξ} {f : ξ → M} {k} (w : Fin k → Semiterm L ξ n) (σ : Semisentence L k) : - Eval b f ((@Rew.embSubsts L ξ n k w) ▹ σ) ↔ σ.Evalb (Semiterm.val b f ∘ w) := by + Eval b f ((@Rew.embSubsts L ξ n k w) ▹ σ) ↔ M ⊧/(Semiterm.val b f ∘ w) σ := by simp [eval_rew, Function.comp_def, Empty.eq_elim] section Syntactic @@ -523,6 +525,8 @@ lemma struc_models_iff_models {s : Struc L} : s ⊧ σ ↔ s.Dom↓[L] ⊧ σ := lemma models_iff : M↓[L] ⊧ σ ↔ σ.Realize M := by rfl +lemma notModels_iff : M↓[L] ⊭ σ ↔ ¬σ.Realize M := by rfl + lemma models_iff_proposition {φ : Proposition L} : M↓[L] ⊧ φ.univCl ↔ ∀ f : ℕ → M, φ.Evalf f := by simp [models_iff] diff --git a/Foundation/FirstOrder/Basic/Soundness.lean b/Foundation/FirstOrder/Basic/Soundness.lean index ee8d80f1f..b414756d6 100644 --- a/Foundation/FirstOrder/Basic/Soundness.lean +++ b/Foundation/FirstOrder/Basic/Soundness.lean @@ -47,7 +47,7 @@ lemma sound {M : Type*} [s : Structure L M] [Nonempty M] (f : ℕ → M) {Γ : S rcases this with (hp | ⟨ψ, hq, hhq⟩) · exact ⟨∃⁰ φ, by simp, t.val ![] f, hp⟩ · exact ⟨ψ, by simp [hq], hhq⟩ - | wk (Δ := Δ) (Γ := Γ) d ss => by + | contraction (Δ := Δ) (Γ := Γ) d ss => by have : ∃ φ ∈ Δ, Evalf f φ := sound f d rcases this with ⟨φ, hp, h⟩ exact ⟨φ, ss hp, h⟩ diff --git a/Foundation/FirstOrder/Basic/Syntax/Formula.lean b/Foundation/FirstOrder/Basic/Syntax/Formula.lean index fa61b5ed0..0c903ed3f 100644 --- a/Foundation/FirstOrder/Basic/Syntax/Formula.lean +++ b/Foundation/FirstOrder/Basic/Syntax/Formula.lean @@ -88,7 +88,7 @@ instance : DeMorgan (Semiformula L ξ n) where and := fun _ _ => rfl or := fun _ _ => rfl -instance : NegInvolutive (Semiformula L ξ n) where +instance : TildeInvolutive (Semiformula L ξ n) where neg_involutive := neg_neg instance : Quantifier (Semiformula L ξ) where diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean index 01dacaf26..7dffa59ae 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D1.lean @@ -11,27 +11,27 @@ namespace LO.FirstOrder.Arithmetic.Bootstrapping open Classical FirstOrder -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] variable {T : Theory L} [T.Δ₁] -lemma derivable_quote {Γ : Finset (Proposition L)} (d : T ⟹₂ Γ) : T.Derivable (⌜Γ⌝ : V) := +lemma derivable_quote {Γ : Finset (Proposition L)} (d : T ⟹₂ Γ) : Derivable T (⌜Γ⌝ : V) := ⟨⌜d⌝, by simpa [Semiformula.quote_def] using (⌜d⌝ : Theory.internalize V T ⊢!ᵈᵉʳ ⌜Γ⌝).derivationOf⟩ /-- Hilbert–Bernays provability condition D1 -/ -theorem internalize_provability {φ} : T ⊢ φ → T.Provable (⌜φ⌝ : V) := fun h ↦ by +theorem internalize_provability {φ} : T ⊢ φ → Provable T (⌜φ⌝ : V) := fun h ↦ by simpa using derivable_quote (V := V) (provable_iff_derivable2.mp h).some theorem internal_provable_of_outer_provable {φ} : T ⊢ φ → T.internalize V ⊢ ⌜φ⌝ := fun h ↦ by simpa [TProvable.iff_provable] using internalize_provability (V := V) h -@[simp] lemma _root_.LO.FirstOrder.Theory.Provable.complete {φ : Sentence L} : +@[simp] lemma Provable.complete {φ : Sentence L} : T.internalize ℕ ⊢ ⌜φ⌝ ↔ T ⊢ φ := - ⟨by simpa [TProvable.iff_provable] using Theory.Provable.sound, internal_provable_of_outer_provable⟩ + ⟨by simpa [TProvable.iff_provable] using Provable.sound, internal_provable_of_outer_provable⟩ @[simp] lemma provable_iff_provable {T : Theory L} [T.Δ₁] {φ : Sentence L} : - T.Provable (⌜φ⌝ : ℕ) ↔ T ⊢ φ := by simpa [TProvable.iff_provable] using Theory.Provable.complete + Provable T (⌜φ⌝ : ℕ) ↔ T ⊢ φ := by simpa [TProvable.iff_provable] using Provable.complete end LO.FirstOrder.Arithmetic.Bootstrapping diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean index 579824621..65ade2ae9 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D2.lean @@ -11,22 +11,22 @@ namespace LO.FirstOrder.Arithmetic.Bootstrapping open FirstOrder -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] variable (T : Theory L) [T.Δ₁] /-- Hilbert–Bernays provability condition D2 -/ -theorem modus_ponens {φ ψ : Proposition L} (hφψ : T.Provable (⌜φ 🡒 ψ⌝ : V)) (hφ : T.Provable (⌜φ⌝ : V)) : - T.Provable (⌜ψ⌝ : V) := by +theorem modus_ponens {φ ψ : Proposition L} (hφψ : Provable T (⌜φ 🡒 ψ⌝ : V)) (hφ : Provable T (⌜φ⌝ : V)) : + Provable T (⌜ψ⌝ : V) := by apply (tprovable_tquote_iff_provable_quote (L := L)).mp have hφψ : Theory.internalize V T ⊢ ⌜φ⌝ 🡒 ⌜ψ⌝ := by simpa using (tprovable_tquote_iff_provable_quote (L := L)).mpr hφψ have hφ : Theory.internalize V T ⊢ ⌜φ⌝ := (tprovable_tquote_iff_provable_quote (L := L)).mpr hφ exact hφψ ⨀ hφ -theorem modus_ponens_sentence {σ τ : Sentence L} (hστ : T.Provable (⌜σ 🡒 τ⌝ : V)) (hσ : T.Provable (⌜σ⌝ : V)) : - T.Provable (⌜τ⌝ : V) := by +theorem modus_ponens_sentence {σ τ : Sentence L} (hστ : Provable T (⌜σ 🡒 τ⌝ : V)) (hσ : Provable T (⌜σ⌝ : V)) : + Provable T (⌜τ⌝ : V) := by apply (tprovable_tquote_iff_provable_quote (L := L)).mp have hστ : Theory.internalize V T ⊢ ⌜σ⌝ 🡒 ⌜τ⌝ := by simpa using (tprovable_tquote_iff_provable_quote (L := L)).mpr hστ have hσ : Theory.internalize V T ⊢ ⌜σ⌝ := (tprovable_tquote_iff_provable_quote (L := L)).mpr hσ diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D3.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D3.lean index 11bbb240a..32b915c37 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D3.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/D3.lean @@ -13,7 +13,7 @@ open Classical open LO.Entailment LO.Entailment.FiniteContext -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] local prefix:max "#'" => Semiterm.bvar (V := V) (L := ℒₒᵣ) @@ -39,7 +39,7 @@ noncomputable abbrev toNumVec (w : Fin n → V) : SemitermVec V ℒₒᵣ n k := variable (T) theorem term_complete {n : ℕ} (t : FirstOrder.ClosedSemiterm ℒₒᵣ n) (w : Fin n → V) : - T.internalize V ⊢ (toNumVec w ⤕ ⌜t⌝) ≐ 𝕹 (t.valbm V w) := + T.internalize V ⊢ (toNumVec w ⤕ ⌜t⌝) ≐ 𝕹 (t.valb w) := match t with | #z => by simp | &x => Empty.elim x @@ -47,21 +47,21 @@ theorem term_complete {n : ℕ} (t : FirstOrder.ClosedSemiterm ℒₒᵣ n) (w : | .func Language.One.one v => by simp | .func Language.Add.add v => by suffices - T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) + (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹 ((v 0).valbm V w + (v 1).valbm V w) by + T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) + (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹 ((v 0).valb w + (v 1).valb w) by simpa [Rew.func, Semiterm.val_func] - have ih : T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) + (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹((v 0).valbm V w) + 𝕹((v 1).valbm V w) := + have ih : T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) + (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹((v 0).valb w) + 𝕹((v 1).valb w) := subst_add_eq_add T _ _ _ _ ⨀ term_complete (v 0) w ⨀ term_complete (v 1) w - have : T.internalize V ⊢ 𝕹((v 0).valbm V w) + 𝕹((v 1).valbm V w) ≐ 𝕹((v 0).valbm V w + (v 1).valbm V w) := numeral_add T _ _ + have : T.internalize V ⊢ 𝕹((v 0).valb w) + 𝕹((v 1).valb w) ≐ 𝕹((v 0).valb w + (v 1).valb w) := numeral_add T _ _ exact eq_trans ih this | .func Language.Mul.mul v => by suffices - T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) * (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹((v 0).valbm V w * (v 1).valbm V w) by + T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) * (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹((v 0).valb w * (v 1).valb w) by simpa [Rew.func, Semiterm.val_func] have ih : - T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) * (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹((v 0).valbm V w) * 𝕹((v 1).valbm V w) := + T.internalize V ⊢ (toNumVec w ⤕ ⌜v 0⌝) * (toNumVec w ⤕ ⌜v 1⌝) ≐ 𝕹((v 0).valb w) * 𝕹((v 1).valb w) := subst_mul_eq_mul T _ _ _ _ ⨀ term_complete (v 0) w ⨀ term_complete (v 1) w have : - T.internalize V ⊢ 𝕹((v 0).valbm V w) * 𝕹((v 1).valbm V w) ≐ 𝕹((v 0).valbm V w * (v 1).valbm V w) := numeral_mul T _ _ + T.internalize V ⊢ 𝕹((v 0).valb w) * 𝕹((v 1).valb w) ≐ 𝕹((v 0).valb w * (v 1).valb w) := numeral_mul T _ _ exact eq_trans ih this open FirstOrder.Arithmetic @@ -76,37 +76,37 @@ theorem bold_sigma_one_complete {n} {φ : Semisentence ℒₒᵣ n} (hp : Hierar intro n t₁ t₂ w h suffices T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ (toNumVec w ⤕ ⌜t₂⌝) by simpa [Sentence.typed_quote_def] - have : t₁.valbm V w = t₂.valbm V w := by simpa using h - have h₀ : T.internalize V ⊢ 𝕹(t₁.valbm V w) ≐ 𝕹(t₂.valbm V w) := by simp [this] - have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valbm V w) := term_complete T t₁ w - have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valbm V w) := term_complete T t₂ w + have : t₁.valb w = t₂.valb w := by simpa using h + have h₀ : T.internalize V ⊢ 𝕹(t₁.valb w) ≐ 𝕹(t₂.valb w) := by simp [this] + have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valb w) := term_complete T t₁ w + have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valb w) := term_complete T t₂ w exact eq_trans (eq_trans h₁ h₀) (eq_comm h₂) case hNEQ => intro n t₁ t₂ w h suffices T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≉ (toNumVec w ⤕ ⌜t₂⌝) by simpa [Sentence.typed_quote_def] - have : t₁.valbm V w ≠ t₂.valbm V w := by simpa using h - have h₀ : T.internalize V ⊢ 𝕹(t₁.valbm V w) ≉ 𝕹(t₂.valbm V w) := by simpa using numeral_ne T this - have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valbm V w) := term_complete T t₁ w - have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valbm V w) := term_complete T t₂ w + have : t₁.valb w ≠ t₂.valb w := by simpa using h + have h₀ : T.internalize V ⊢ 𝕹(t₁.valb w) ≉ 𝕹(t₂.valb w) := by simpa using numeral_ne T this + have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valb w) := term_complete T t₁ w + have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valb w) := term_complete T t₂ w exact subst_ne T _ _ _ _ ⨀ eq_comm h₁ ⨀ eq_comm h₂ ⨀ h₀ case hLT => intro n t₁ t₂ w h suffices T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) <' (toNumVec w ⤕ ⌜t₂⌝) by simpa [Sentence.typed_quote_def] - have : t₁.valbm V w < t₂.valbm V w := by simpa using h - have h₀ : T.internalize V ⊢ 𝕹(t₁.valbm V w) <' 𝕹(t₂.valbm V w) := by simpa using numeral_lt T this - have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valbm V w) := term_complete T t₁ w - have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valbm V w) := term_complete T t₂ w + have : t₁.valb w < t₂.valb w := by simpa using h + have h₀ : T.internalize V ⊢ 𝕹(t₁.valb w) <' 𝕹(t₂.valb w) := by simpa using numeral_lt T this + have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valb w) := term_complete T t₁ w + have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valb w) := term_complete T t₂ w exact subst_lt T _ _ _ _ ⨀ eq_comm h₁ ⨀ eq_comm h₂ ⨀ h₀ case hNLT => intro n t₁ t₂ w h suffices T.internalize V ⊢ ((toNumVec w ⤕ ⌜t₁⌝) ≮' (toNumVec w ⤕ ⌜t₂⌝)) by simpa [Sentence.typed_quote_def] - have : t₁.valbm V w ≥ t₂.valbm V w := by simpa using h - have h₀ : T.internalize V ⊢ 𝕹(t₁.valbm V w) ≮' 𝕹(t₂.valbm V w) := by simpa using numeral_nlt T this - have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valbm V w) := term_complete T t₁ w - have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valbm V w) := term_complete T t₂ w + have : t₁.valb w ≥ t₂.valb w := by simpa using h + have h₀ : T.internalize V ⊢ 𝕹(t₁.valb w) ≮' 𝕹(t₂.valb w) := by simpa using numeral_nlt T this + have h₁ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₁⌝) ≐ 𝕹(t₁.valb w) := term_complete T t₁ w + have h₂ : T.internalize V ⊢ (toNumVec w ⤕ ⌜t₂⌝) ≐ 𝕹(t₂.valb w) := term_complete T t₂ w exact subst_nlt T _ _ _ _ ⨀ eq_comm h₁ ⨀ eq_comm h₂ ⨀ h₀ case hAnd => intro n φ ψ _ _ ihφ ihψ w h @@ -121,11 +121,11 @@ theorem bold_sigma_one_complete {n} {φ : Semisentence ℒₒᵣ n} (hp : Hierar · apply A!_intro_right (ihψ h) case hBall => intro n t φ _ ih w h - have h : ∀ i < t.valbm V w, V ⊧/(i :> w) φ := by + have h : ∀ i < t.valb w, V ⊧/(i :> w) φ := by simpa using h suffices T.internalize V ⊢ ((toNumVec w).q ⤔ ⌜φ⌝).ball (toNumVec w ⤕ ⌜t⌝) by simpa [Semiterm.empty_typed_quote_def, ←Rew.emb_bShift_term, Semiformula.ball, ball, Semiformula.imp_def] - have : T.internalize V ⊢ ((toNumVec w).q ⤔ ⌜φ⌝).ball 𝕹(t.valbm V w) := by + have : T.internalize V ⊢ ((toNumVec w).q ⤔ ⌜φ⌝).ball 𝕹(t.valb w) := by apply ball_intro intro i hi suffices T.internalize V ⊢ (toNumVec (i :> w) ⤔ ⌜φ⌝) by @@ -143,7 +143,7 @@ theorem bold_sigma_one_complete {n} {φ : Semisentence ℒₒᵣ n} (hp : Hierar exact ih hφ theorem sigma_one_provable_of_models {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : - V ⊧ₘ σ → T.internalize V ⊢ ⌜σ⌝ := by + V↓[ℒₒᵣ] ⊧ σ → T.internalize V ⊢ ⌜σ⌝ := by intro h have : T.internalize V ⊢ (toNumVec ![] ⤔ ⌜σ⌝) := bold_sigma_one_complete T hσ (by simpa [models_iff] using h) @@ -151,12 +151,12 @@ theorem sigma_one_provable_of_models {σ : Sentence ℒₒᵣ} (hσ : Hierarchy /-- Hilbert–Bernays provability condition D3 -/ theorem sigma_one_complete {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : - V ⊧ₘ σ → T.Provable (⌜σ⌝ : V) := fun h ↦ by + V↓[ℒₒᵣ] ⊧ σ → Provable T (⌜σ⌝ : V) := fun h ↦ by simpa [tprovable_iff_provable] using Bootstrapping.Arithmetic.sigma_one_provable_of_models T hσ h theorem provable_internalize {σ : Sentence ℒₒᵣ} : - T.Provable (⌜σ⌝ : V) → T.Provable (⌜T.provabilityPred σ⌝ : V) := by - simpa [models_iff] using sigma_one_complete (V := V) (σ := T.provabilityPred σ) T (by simp) + Provable T (⌜σ⌝ : V) → Provable T (⌜provabilityPred T σ⌝ : V) := by + simpa [models_iff] using sigma_one_complete (V := V) (T := T) (σ := provabilityPred T σ) (by simp) end LO.FirstOrder.Arithmetic.Bootstrapping.Arithmetic diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/EquationalTheory.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/EquationalTheory.lean index b758d23d9..07f5d0b1a 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/EquationalTheory.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/EquationalTheory.lean @@ -1,6 +1,7 @@ module public import Foundation.Meta.ClProver +public import Foundation.FirstOrder.Arithmetic.Basic.Model public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D1 @[expose] public section @@ -12,7 +13,7 @@ namespace LO.FirstOrder.Arithmetic.Bootstrapping open Classical Entailment -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] namespace Arithmetic @@ -24,31 +25,31 @@ local postfix:max "⇞" => Semiterm.shift local postfix:max "⤉" => Semiformula.shift -variable (T : ArithmeticTheory) [Theory.Δ₁ T] [𝗘𝗤 ⪯ T] +variable (T : ArithmeticTheory) [Theory.Δ₁ T] [𝗘𝗤 _ ⪯ T] open Entailment Entailment.FiniteContext Semiformula @[simp] lemma eq_refl (t : Term V ℒₒᵣ) : T.internalize V ⊢ t ≐ t := by - have : T ⊢ “∀ x, x = x” := provable_of_models.{0} _ _ fun _ _ _ ↦ by simp [models_iff] + have : T ⊢ “∀ x, x = x” := complete.{0} T _ fun (M : Type) _ _ ↦ by simp [models_iff] have : T.internalize V ⊢ ∀⁰ (#'0 ≐ #'0) := by simpa using internal_provable_of_outer_provable this simpa using TProof.specialize! this t @[simp] lemma eq_symm (t u : Term V ℒₒᵣ) : T.internalize V ⊢ (t ≐ u) 🡒 (u ≐ t) := by - have : T ⊢ “∀ x y, x = y → y = x” := provable_of_models.{0} _ _ fun _ _ _ ↦ by simp [models_iff] + have : T ⊢ “∀ x y, x = y → y = x” := complete.{0} T _ fun (M : Type) _ _ ↦ by simp [models_iff] have : T.internalize V ⊢ ∀⁰ ∀⁰ ((#'1 ≐ #'0) 🡒 (#'0 ≐ #'1)) := by simpa using internal_provable_of_outer_provable this simpa using TProof.specialize₂! this u t @[simp] lemma ne_symm (t u : Term V ℒₒᵣ) : T.internalize V ⊢ (t ≉ u) 🡒 (u ≉ t) := by - have : T ⊢ “∀ x y, x ≠ y → y ≠ x” := provable_of_models.{0} _ _ fun _ _ _ ↦ by + have : T ⊢ “∀ x y, x ≠ y → y ≠ x” := complete.{0} T _ fun (M : Type) _ _ ↦ by simp [models_iff, ne_comm] have : T.internalize V ⊢ ∀⁰ ∀⁰ ((#'1 ≉ #'0) 🡒 (#'0 ≉ #'1)) := by simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize₂! this u t @[simp] lemma eq_uniform_trans (t₁ t₂ t₃ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (t₂ ≐ t₃) 🡒 (t₁ ≐ t₃) := by - have : T ⊢ “∀ x y z, x = y → y = z → x = z” := provable_of_models.{0} _ _ fun _ _ _ ↦ by simp [models_iff] + have : T ⊢ “∀ x y z, x = y → y = z → x = z” := complete.{0} T _ fun (M : Type) _ _ ↦ by simp [models_iff] have : T.internalize V ⊢ ∀⁰ ∀⁰ ∀⁰ ((#'2 ≐ #'1) 🡒 (#'1 ≐ #'0) 🡒 (#'2 ≐ #'0)) := by simpa using internal_provable_of_outer_provable this simpa using TProof.specialize₃! this t₃ t₂ t₁ @@ -70,36 +71,36 @@ section replace open LO.Entailment lemma subst_eq (t₁ t₂ u₁ u₂ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (u₁ ≐ u₂) 🡒 (t₁ ≐ u₁) 🡒 (t₂ ≐ u₂) := by - have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ = y₁ → x₂ = y₂” := provable_of_models.{0} _ _ fun _ _ _ ↦ by simp [models_iff] + have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ = y₁ → x₂ = y₂” := complete.{0} T _ fun (M : Type) _ _ ↦ by simp [models_iff] have := by simpa using internal_provable_of_outer_provable this (V := V) simpa using TProof.specialize₄! this u₂ u₁ t₂ t₁ lemma subst_lt (t₁ t₂ u₁ u₂ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (u₁ ≐ u₂) 🡒 (t₁ <' u₁) 🡒 (t₂ <' u₂) := by - have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ < y₁ → x₂ < y₂” := provable_of_models.{0} _ _ fun _ _ _ ↦ by + have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ < y₁ → x₂ < y₂” := complete.{0} T _ fun (M : Type) _ _ ↦ by simpa [models_iff] using fun a b c e h ↦ e ▸ h have := by simpa using internal_provable_of_outer_provable this (V := V) simpa using TProof.specialize₄! this u₂ u₁ t₂ t₁ lemma subst_ne (t₁ t₂ u₁ u₂ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (u₁ ≐ u₂) 🡒 (t₁ ≉ u₁) 🡒 (t₂ ≉ u₂) := by - have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ ≠ y₁ → x₂ ≠ y₂” := provable_of_models.{0} _ _ fun _ _ _ ↦ by + have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ ≠ y₁ → x₂ ≠ y₂” := complete.{0} T _ fun (M : Type) _ _ ↦ by simpa [models_iff] using fun a b c e h ↦ e ▸ h have := by simpa using internal_provable_of_outer_provable this (V := V) simpa using TProof.specialize₄! this u₂ u₁ t₂ t₁ lemma subst_nlt (t₁ t₂ u₁ u₂ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (u₁ ≐ u₂) 🡒 (t₁ ≮' u₁) 🡒 (t₂ ≮' u₂) := by - have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ ≮ y₁ → x₂ ≮ y₂” := provable_of_models.{0} _ _ fun _ _ _ ↦ by + have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ ≮ y₁ → x₂ ≮ y₂” := complete.{0} T _ fun (M : Type) _ _ ↦ by simpa [models_iff] using fun a b c e h ↦ e ▸ h have := by simpa using internal_provable_of_outer_provable this (V := V) simpa using TProof.specialize₄! this u₂ u₁ t₂ t₁ lemma subst_add_eq_add (t₁ t₂ u₁ u₂ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (u₁ ≐ u₂) 🡒 (t₁ + u₁ ≐ t₂ + u₂) := by - have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ + y₁ = x₂ + y₂” := provable_of_models.{0} _ _ fun _ _ _ ↦ by + have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ + y₁ = x₂ + y₂” := complete.{0} T _ fun (M : Type) _ _ ↦ by simpa [models_iff] using fun a b c e ↦ by simp [e] have := by simpa using internal_provable_of_outer_provable this (V := V) simpa using TProof.specialize₄! this u₂ u₁ t₂ t₁ lemma subst_mul_eq_mul (t₁ t₂ u₁ u₂ : Term V ℒₒᵣ) : T.internalize V ⊢ (t₁ ≐ t₂) 🡒 (u₁ ≐ u₂) 🡒 (t₁ * u₁ ≐ t₂ * u₂) := by - have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ * y₁ = x₂ * y₂” := provable_of_models.{0} _ _ fun _ _ _ ↦ by + have : T ⊢ “∀ x₁ x₂ y₁ y₂, x₁ = x₂ → y₁ = y₂ → x₁ * y₁ = x₂ * y₂” := complete.{0} T _ fun (M : Type) _ _ ↦ by simpa [models_iff] using fun a b c e ↦ by simp [e] have := by simpa using internal_provable_of_outer_provable this (V := V) simpa using TProof.specialize₄! this u₂ u₁ t₂ t₁ @@ -112,7 +113,7 @@ lemma vec2_eq {v : V} (h : len v = 2) : ?[v.[0], v.[1]] = v := lemma term_replace_aux (t : V) : IsSemiterm ℒₒᵣ 1 t → - T.Provable (^∀ ^∀ imp ℒₒᵣ (^#1 ^= ^#0) (termSubst ℒₒᵣ (^#1 ∷ 0) t ^= termSubst ℒₒᵣ (^#0 ∷ 0) t)) := by + Provable T (^∀ ^∀ imp ℒₒᵣ (^#1 ^= ^#0) (termSubst ℒₒᵣ (^#1 ∷ 0) t ^= termSubst ℒₒᵣ (^#0 ∷ 0) t)) := by apply IsSemiterm.sigma1_induction · definability case hfunc => @@ -199,7 +200,7 @@ lemma term_replace_aux (t : V) : suffices T.internalize V ⊢ ∀⁰ ∀⁰ ((#'1 ≐ #'0) 🡒 (#'1 ≐ #'0)) by have := (tprovable_iff_provable (T := T)).mp this simpa [-substs_equals, val_all] using this - have : T ⊢ “∀ x y, (x = y → x = y)” := provable_of_models.{0} _ _ fun _ _ _ ↦ by simp [models_iff] + have : T ⊢ “∀ x y, (x = y → x = y)” := complete.{0} T _ fun (M : Type) _ _ ↦ by simp [models_iff] simpa using internal_provable_of_outer_provable this (V := V) case hfvar => intro x @@ -326,7 +327,7 @@ lemma replace_nlt (t u : Semiterm V ℒₒᵣ 1) : lemma replace_aux (φ : V) : IsSemiformula ℒₒᵣ 1 φ → - T.Provable (^∀ ^∀ imp ℒₒᵣ (^#1 ^= ^#0) (imp ℒₒᵣ (subst ℒₒᵣ (^#1 ∷ 0) φ) (subst ℒₒᵣ (^#0 ∷ 0) φ))) := by + Provable T (^∀ ^∀ imp ℒₒᵣ (^#1 ^= ^#0) (imp ℒₒᵣ (subst ℒₒᵣ (^#1 ∷ 0) φ) (subst ℒₒᵣ (^#0 ∷ 0) φ))) := by apply IsFormula.sigma1_structural_induction₂_ss · definability case hand => diff --git a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/PeanoMinus.lean b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/PeanoMinus.lean index 183c24e48..555388f6d 100644 --- a/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/PeanoMinus.lean +++ b/Foundation/FirstOrder/Bootstrapping/DerivabilityCondition/PeanoMinus.lean @@ -9,7 +9,7 @@ public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.Equation namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗣𝗔⁻] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] lemma lt_add_self_add_one (a b : V) : a < b + a + 1 := lt_succ_iff_le.mpr <| le_add_self @@ -22,7 +22,7 @@ namespace LO.FirstOrder.Arithmetic.Bootstrapping.Arithmetic open Classical LO.Entailment -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] local prefix:max "#'" => Semiterm.bvar (V := V) (L := ℒₒᵣ) @@ -36,15 +36,15 @@ variable (T : ArithmeticTheory) [Theory.Δ₁ T] [𝗣𝗔⁻ ⪯ T] open Entailment Entailment.FiniteContext Semiformula -instance : 𝗘𝗤 ⪯ T := +instance : 𝗘𝗤 _ ⪯ T := have : 𝗣𝗔⁻ ⪯ T := inferInstance WeakerThan.trans inferInstance this lemma term_add_assoc (t₁ t₂ t₃ : Term V ℒₒᵣ) : T.internalize V ⊢ t₁ + (t₂ + t₃) ≐ (t₁ + t₂) + t₃ := by have : T ⊢ “∀ x y z, x + (y + z) = (x + y) + z” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff, add_assoc] have : T.internalize V ⊢ ∀⁰ ∀⁰ ∀⁰ (#'2 + (#'1 + #'0) ≐ #'2 + #'1 + #'0) := by simpa using internal_provable_of_outer_provable (V := V) this @@ -58,8 +58,8 @@ lemma numeral_add (n m : V) : case zero => have : T.internalize V ⊢ ∀⁰ ((#'0 + 𝕹 0) ≐ #'0) := by have : T ⊢ “∀ x, x + 0 = x” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] have := internal_provable_of_outer_provable (V := V) this simpa using this @@ -68,8 +68,8 @@ lemma numeral_add (n m : V) : rcases eq_zero_or_pos n with (rfl | pos) · have : T.internalize V ⊢ (𝕹 0 + 𝕹 1) ≐ 𝕹 1 := by have : T ⊢ “0 + 1 = 1” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] simpa using internal_provable_of_outer_provable (V := V) this simpa using this @@ -79,7 +79,7 @@ lemma numeral_add (n m : V) : T.internalize V ⊢ 𝕹 n + (𝕹 (m + 1) + 𝕹 1) ≐ 𝕹 (n + m + 1) + 𝕹 1 by simpa [←one_add_one_eq_two, ←add_assoc] have e1 : T.internalize V ⊢ 𝕹 n + (𝕹 (m + 1) + 𝕹 1) ≐ (𝕹 n + 𝕹 (m + 1)) + 𝕹 1 := term_add_assoc T _ _ _ have e2 : T.internalize V ⊢ (𝕹 n + 𝕹 (m + 1)) + 𝕹 1 ≐ 𝕹 (n + (m + 1)) + 𝕹 1 := - subst_add_eq_add T _ _ _ _ ⨀! ih ⨀! (eq_refl T (𝕹 1)) + subst_add_eq_add T _ _ _ _ ⨀ ih ⨀ (eq_refl T (𝕹 1)) simpa [add_assoc] using eq_trans e1 e2 lemma numeral_mul (n m : V) : @@ -90,8 +90,8 @@ lemma numeral_mul (n m : V) : case zero => have : T.internalize V ⊢ ∀⁰ ((#'0 * 𝕹 0) ≐ 𝕹 0) := by have : T ⊢ “∀ x, x * 0 = 0” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] have := internal_provable_of_outer_provable (V := V) this simpa using this @@ -99,8 +99,8 @@ lemma numeral_mul (n m : V) : case one => have : T.internalize V ⊢ ∀⁰ ((#'0 * 𝕹 1) ≐ #'0) := by have : T ⊢ “∀ x, x * 1 = x” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] have := internal_provable_of_outer_provable (V := V) this simpa using this @@ -111,13 +111,13 @@ lemma numeral_mul (n m : V) : simpa [←one_add_one_eq_two, ←add_assoc, mul_add] have e1 : T.internalize V ⊢ 𝕹 n * (𝕹(m + 1) + 𝕹 1) ≐ 𝕹 n * 𝕹(m + 1) + 𝕹 n := by have : T ⊢ “∀ x y, x * (y + 1) = x * y + x” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff, mul_add] have := by simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize₂! this 𝕹(m + 1) (𝕹 n) have e2 : T.internalize V ⊢ 𝕹 n * 𝕹(m + 1) + 𝕹 n ≐ 𝕹 (n * (m + 1)) + 𝕹 n := - subst_add_eq_add T _ _ _ _ ⨀! ih ⨀! (eq_refl T (𝕹 n)) + subst_add_eq_add T _ _ _ _ ⨀ ih ⨀ (eq_refl T (𝕹 n)) have e3 : T.internalize V ⊢ 𝕹 (n * (m + 1)) + 𝕹 n ≐ 𝕹 (n * (m + 1) + n) := numeral_add T _ _ exact eq_trans (eq_trans e1 e2) e3 @@ -133,8 +133,8 @@ lemma numeral_lt {n m : V} : suffices T.internalize V ⊢ 𝕹 n <' 𝕹 (d + n + 1) by simpa [hm] have l₁ : T.internalize V ⊢ 𝕹 n <' 𝕹 d + 𝕹 n + 𝕹 1 := by have : T ⊢ “∀ x y, x < y + x + 1” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff, Arithmetic.lt_add_self_add_one] have := by simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize₂! this (𝕹 d) (𝕹 n) @@ -154,8 +154,8 @@ lemma numeral_ne {n m : V} : have l₁ : T.internalize V ⊢ 𝕹 n <' 𝕹 m := numeral_lt T hnm have l₂ : T.internalize V ⊢ (𝕹 n <' 𝕹 m) 🡒 (𝕹 n ≉ 𝕹 m) := by have : T ⊢ “∀ x y, x < y → x ≠ y” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simpa [models_iff] using fun _ _ ↦ ne_of_lt have := by simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize₂! this (𝕹 m) (𝕹 n) @@ -165,16 +165,16 @@ lemma numeral_nlt {n m : V} : n ≥ m → T.internalize V ⊢ 𝕹 n ≮' 𝕹 m := fun h ↦ by rcases eq_or_lt_of_le h with (rfl | lt) · have : T ⊢ “∀ x, x ≮ x” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] have := by simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize! this (𝕹 m) · have l₁ : T.internalize V ⊢ 𝕹 m <' 𝕹 n := numeral_lt T lt have l₂ : T.internalize V ⊢ (𝕹 m <' 𝕹 n) 🡒 (𝕹 n ≮' 𝕹 m) := by have : T ⊢ “∀ x y, x < y → y ≮ x” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simpa [models_iff] using fun _ _ ↦ le_of_lt have := by simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize₂! this (𝕹 n) (𝕹 m) @@ -192,8 +192,8 @@ lemma lt_iff_substItrDisj (t : Term V ℒₒᵣ) (m : V) : suffices T.internalize V ⊢ (t <' 𝕹 0) 🡘 ⊥ by simpa have : T.internalize V ⊢ ∀⁰ ((#'0 <' 𝕹 0) 🡘 ⊥) := by have : T ⊢ “∀ x, x < 0 ↔ ⊥” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize! this t @@ -201,8 +201,8 @@ lemma lt_iff_substItrDisj (t : Term V ℒₒᵣ) (m : V) : suffices T.internalize V ⊢ (t <' 𝕹 1) 🡘 (t ≐ 𝕹 0) ⋎ ⊥ by simpa have : T.internalize V ⊢ ∀⁰ ((#'0 <' 𝕹 1) 🡘 (#'0 ≐ 𝕹 0) ⋎ ⊥) := by have : T ⊢ “∀ x, x < 1 ↔ x = 0 ∨ ⊥” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff] simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize! this t @@ -214,8 +214,8 @@ lemma lt_iff_substItrDisj (t : Term V ℒₒᵣ) (m : V) : have : T.internalize V ⊢ (t <' 𝕹(m + 1) + 𝕹 1) 🡘 (t ≐ 𝕹(m + 1)) ⋎ (t <' 𝕹(m + 1)) := by have : T.internalize V ⊢ ∀⁰ ∀⁰ ((#'0 <' #'1 + 𝕹 1) 🡘 (#'0 ≐ #'1) ⋎ (#'0 <' #'1)) := by have : T ⊢ “∀ m x, x < m + 1 ↔ x = m ∨ x < m” := - provable_of_models.{0} _ _ fun M _ hM ↦ by - have : M ⊧ₘ* 𝗣𝗔⁻ := models_of_subtheory hM + complete.{0} T _ fun (M : Type) _ (hM : M↓[ℒₒᵣ] ⊧* T) ↦ by + have : M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻ := models_of_subtheory hM simp [models_iff, Arithmetic.lt_succ_iff_eq_or_succ] simpa using internal_provable_of_outer_provable (V := V) this simpa using TProof.specialize₂! this t 𝕹(m + 1) diff --git a/Foundation/FirstOrder/Bootstrapping/FixedPoint.lean b/Foundation/FirstOrder/Bootstrapping/FixedPoint.lean index 4d3b469b5..44781c7c1 100644 --- a/Foundation/FirstOrder/Bootstrapping/FixedPoint.lean +++ b/Foundation/FirstOrder/Bootstrapping/FixedPoint.lean @@ -1,5 +1,6 @@ module +public import Foundation.FirstOrder.Arithmetic.Basic.Model public import Foundation.FirstOrder.Bootstrapping.Syntax @[expose] public section @@ -7,7 +8,7 @@ open Classical namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] namespace Bootstrapping.Arithmetic @@ -119,9 +120,9 @@ noncomputable def fixedpoint (θ : Semisentence ℒₒᵣ 1) : Sentence ℒₒ theorem diagonal (θ : Semisentence ℒₒᵣ 1) : T ⊢ fixedpoint θ 🡘 θ/[⌜fixedpoint θ⌝] := - haveI : 𝗘𝗤 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance - provable_of_models _ _ fun (V : Type) _ _ ↦ by - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance + haveI : 𝗘𝗤 _ ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance + complete.{0} T _ fun (V : Type) _ _ ↦ by + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance suffices V ⊧/![] (fixedpoint θ) ↔ V ⊧/![⌜fixedpoint θ⌝] θ by simpa [models_iff, Matrix.constant_eq_singleton] let t : V := ⌜diag θ⌝ @@ -129,8 +130,8 @@ theorem diagonal (θ : Semisentence ℒₒᵣ 1) : simp [t, fixedpoint, substNumeral_app_quote] calc V ⊧/![] (fixedpoint θ) - _ ↔ V ⊧/![t] (diag θ) := by simp [fixedpoint, Matrix.constant_eq_singleton, t] - _ ↔ V ⊧/![substNumeral t t] θ := by simp [diag, Matrix.constant_eq_singleton] + _ ↔ V ⊧/![t] (diag θ) := by simp [fixedpoint, t] + _ ↔ V ⊧/![substNumeral t t] θ := by simp [diag] _ ↔ V ⊧/![⌜fixedpoint θ⌝] θ := by simp [ht] end Diagonalization @@ -147,17 +148,18 @@ noncomputable def multifixedpoint (θ : Fin k → Semisentence ℒₒᵣ k) (i : theorem multidiagonal (θ : Fin k → Semisentence ℒₒᵣ k) : T ⊢ multifixedpoint θ i 🡘 (Rew.subst fun j ↦ ⌜multifixedpoint θ j⌝) ▹ (θ i) := - haveI : 𝗘𝗤 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance - provable_of_models _ _ fun (V : Type) _ _ ↦ by - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance - suffices V ⊧/![] (multifixedpoint θ i) ↔ V ⊧/(fun i ↦ ⌜multifixedpoint θ i⌝) (θ i) by simpa [models_iff] + haveI : 𝗘𝗤 _ ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance + complete.{0} T _ fun (V : Type) _ _ ↦ by + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance + suffices V ⊧/![] (multifixedpoint θ i) ↔ V ⊧/(fun i ↦ ⌜multifixedpoint θ i⌝) (θ i) by + simpa [models_iff, Function.comp_def, Matrix.empty_eq] let t : Fin k → V := fun i ↦ ⌜multidiag (θ i)⌝ have ht : ∀ i, substNumerals (t i) t = ⌜multifixedpoint θ i⌝ := by intro i; simp [t, multifixedpoint, substNumerals_app_quote_quote] calc V ⊧/![] (multifixedpoint θ i) - ↔ V ⊧/t (multidiag (θ i)) := by simp [t, multifixedpoint] - _ ↔ V ⊧/(fun i ↦ substNumerals (t i) t) (θ i) := by simp [multidiag, ← funext_iff] + ↔ V ⊧/t (multidiag (θ i)) := by simp [t, multifixedpoint, Function.comp_def] + _ ↔ V ⊧/(fun i ↦ substNumerals (t i) t) (θ i) := by simp [multidiag, ← funext_iff, Function.comp_def] _ ↔ V ⊧/(fun i ↦ ⌜multifixedpoint θ i⌝) (θ i) := by simp [ht] noncomputable def exclusiveMultifixedpoint (θ : Fin k → Semisentence ℒₒᵣ k) (i : Fin k) : Sentence ℒₒᵣ := @@ -197,21 +199,21 @@ noncomputable def parameterizedFixedpoint (θ : Semisentence ℒₒᵣ (k + 1)) theorem parameterized_diagonal (θ : Semisentence ℒₒᵣ (k + 1)) : T ⊢ ∀⁰* (parameterizedFixedpoint θ 🡘 “!θ !!(⌜parameterizedFixedpoint θ⌝) ⋯”) := - haveI : 𝗘𝗤 ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance - provable_of_models _ _ fun (V : Type) _ _ ↦ by - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance + haveI : 𝗘𝗤 _ ⪯ T := Entailment.WeakerThan.trans (𝓣 := 𝗜𝚺₁) inferInstance inferInstance + complete.{0} T _ fun (V : Type) _ _ ↦ by + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance suffices ∀ params : Fin k → V, V ⊧/params (parameterizedFixedpoint θ) ↔ V ⊧/(⌜parameterizedFixedpoint θ⌝ :> params) θ by - simpa [models_iff, Matrix.comp_vecCons', BinderNotation.finSuccItr] + simpa [models_iff, Matrix.comp_vecCons', BinderNotation.finSuccItr, Function.comp_def, Matrix.empty_eq] intro params let t : V := ⌜parameterizedDiag θ⌝ have ht : substNumeralParams k t t = ⌜parameterizedFixedpoint θ⌝ := by simp [t, substNumeralParams_app_quote, parameterizedFixedpoint] calc V ⊧/params (parameterizedFixedpoint θ) - ↔ V ⊧/(t :> params) (parameterizedDiag θ) := by simp [parameterizedFixedpoint, Matrix.comp_vecCons', t] - _ ↔ V ⊧/(substNumeralParams k t t :> params) θ := by simp [parameterizedDiag, Matrix.comp_vecCons', BinderNotation.finSuccItr] + ↔ V ⊧/(t :> params) (parameterizedDiag θ) := by simp [parameterizedFixedpoint, Matrix.comp_vecCons', t, Function.comp_def] + _ ↔ V ⊧/(substNumeralParams k t t :> params) θ := by simp [parameterizedDiag, Matrix.comp_vecCons', BinderNotation.finSuccItr, Function.comp_def] _ ↔ V ⊧/(⌜parameterizedFixedpoint θ⌝ :> params) θ := by simp [ht] theorem parameterized_diagonal₁ (θ : Semisentence ℒₒᵣ 2) : diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Basic.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Basic.lean index 4e0600f6a..359769ba7 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Basic.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Basic.lean @@ -6,7 +6,7 @@ public import Foundation.FirstOrder.Arithmetic.Induction @[expose] public section namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] @@ -759,8 +759,8 @@ variable (c β) lemma graph_defined : 𝚺₁-Relation₃ c.Graph L via β.graph L := .mk fun v ↦ by simp [Blueprint.graph, (c.construction L).fixpoint_defined.iff, Matrix.empty_eq]; rfl -@[simp] lemma eval_graphDef (v) : - Semiformula.Evalbm V v (β.graph L).val ↔ c.Graph L (v 0) (v 1) (v 2) := (graph_defined β c).iff +@[simp] lemma eval_graphDef (v : Fin 3 → V) : + (β.graph L).val.Evalb v ↔ c.Graph L (v 0) (v 1) (v 2) := (graph_defined β c).iff instance graph_definable : 𝚺-[0 + 1]-Relation₃ c.Graph L := c.graph_defined.to_definable diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean index a7da578e6..0d381160b 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Coding.lean @@ -41,7 +41,7 @@ end LO namespace LO -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] @@ -92,8 +92,8 @@ noncomputable instance : LCWQIsoGödelQuote (Semiproposition L) (Bootstrapping.S @[simp] lemma typed_quote_shift (φ : Semiproposition L n) : (⌜Rewriting.shift φ⌝ : Bootstrapping.Semiformula V L n) = Bootstrapping.Semiformula.shift ⌜φ⌝ := by induction φ using Semiformula.rec' - case hrel => simp [rew_rel, *]; rfl - case hnrel => simp [rew_nrel, *]; rfl + case hrel => simp [*]; rfl + case hnrel => simp [*]; rfl case hverum => simp case hfalsum => simp case hand => simp [*] @@ -104,8 +104,8 @@ noncomputable instance : LCWQIsoGödelQuote (Semiproposition L) (Bootstrapping.S @[simp] lemma typed_quote_substs {n m} (w : Fin n → SyntacticSemiterm L m) (φ : Semiproposition L n) : (⌜φ ⇜ w⌝ : Bootstrapping.Semiformula V L m) = Bootstrapping.Semiformula.subst (fun i ↦ ⌜w i⌝) ⌜φ⌝ := by induction φ using Semiformula.rec' generalizing m - case hrel => simp [rew_rel, *]; rfl - case hnrel => simp [rew_nrel, *]; rfl + case hrel => simp [*]; rfl + case hnrel => simp [*]; rfl case hverum => simp case hfalsum => simp case hand => simp [*] @@ -298,8 +298,8 @@ lemma quote_eq_encode (σ : Semisentence L n) : (⌜σ⌝ : V) = ↑(encode σ) lemma coe_quote_eq_quote (σ : Semisentence L n) : (↑(⌜σ⌝ : ℕ) : V) = ⌜σ⌝ := by simp [quote_eq_encode] -@[simp] lemma val_quote {ξ n e ε} (σ : Semisentence L n) : - Semiterm.valm V e ε (⌜σ⌝ : Semiterm ℒₒᵣ ξ m) = ⌜σ⌝ := by +@[simp] lemma val_quote {bv : Fin m → V} {fv : ξ → V} (σ : Semisentence L n) : + (⌜σ⌝ : Semiterm ℒₒᵣ ξ m).val bv fv = ⌜σ⌝ := by simp [gödelNumber'_def, quote_eq_encode, numeral_eq_natCast] @[simp] lemma coe_quote {ξ n} (σ : Semisentence L n) : ↑(⌜σ⌝ : ℕ) = (⌜σ⌝ : Semiterm ℒₒᵣ ξ m) := by diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Functions.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Functions.lean index 63b36d166..727dd6d79 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Functions.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Functions.lean @@ -6,7 +6,7 @@ public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Functions @[expose] public section namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Iteration.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Iteration.lean index 8affae9b0..b7a093ef1 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Iteration.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Iteration.lean @@ -21,7 +21,7 @@ end LO.FirstOrder.Semiformula namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Typed.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Typed.lean index 948cb1137..0d073f57f 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Typed.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Formula/Typed.lean @@ -10,7 +10,7 @@ public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Iteration namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] @@ -133,7 +133,7 @@ instance : DeMorgan (Semiformula V L n) where or _ _ := by ext; simp imply _ _ := by ext; simp; rfl -instance : NegInvolutive (Semiformula V L n) where +instance : TildeInvolutive (Semiformula V L n) where neg_involutive _ := by ext; simp @[simp] lemma neg_all (φ : Semiformula V L (n + 1)) : ∼(∀⁰ φ) = ∃⁰ (∼φ) := by ext; simp diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Language.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Language.lean index 8282ecdd8..d338cdfa2 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Language.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Language.lean @@ -40,11 +40,11 @@ lemma isFunc_def (k f : V) : L.IsFunc k f ↔ V ⊧/![k, f] L.isFunc.val := by r lemma isRel_def (k R : V) : L.IsRel k R ↔ V ⊧/![k, R] L.isRel.val := by rfl -@[simp] lemma eval_func (v) : - Semiformula.Evalbm V v L.isFunc.val ↔ L.IsFunc (v 0) (v 1) := by simp [Language.IsFunc, ← Matrix.fun_eq_vec_two] +@[simp] lemma eval_func (v : Fin 2 → V) : + L.isFunc.val.Evalb v ↔ L.IsFunc (v 0) (v 1) := by simp [Language.IsFunc, ← Matrix.fun_eq_vec_two] -@[simp] lemma eval_rel_iff (v) : - Semiformula.Evalbm V v L.isRel.val ↔ L.IsRel (v 0) (v 1) := by simp [Language.IsRel, ← Matrix.fun_eq_vec_two] +@[simp] lemma eval_rel_iff (v : Fin 2 → V) : + L.isRel.val.Evalb v ↔ L.IsRel (v 0) (v 1) := by simp [Language.IsRel, ← Matrix.fun_eq_vec_two] instance _root_.LO.FirstOrder.Language.IsFunc.defined : 𝚺₀-Relation (L.IsFunc (V := V)) via L.isFunc := .mk fun v ↦ by simp @@ -62,7 +62,7 @@ instance _root_.LO.FirstOrder.Language.IsRel.definable : 𝚺₀-Relation (L.IsR section -variable [V ⊧ₘ* 𝗣𝗔⁻] +variable [V↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] instance gödelQuoteFunc (k) : GödelQuote (L.Func k) V := ⟨fun f ↦ ↑(Encodable.encode f)⟩ @@ -147,7 +147,7 @@ instance : (ℒₒᵣ).LORDefinable where namespace Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] def zeroIndex : ℕ := Encodable.encode (Language.Zero.zero : (ℒₒᵣ : FirstOrder.Language).Func 0) diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean index bc2bb6646..9ccbad744 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Basic.lean @@ -7,7 +7,7 @@ namespace LO open FirstOrder Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] @@ -450,121 +450,121 @@ end Derivation end FirstOrder.Arithmetic.Bootstrapping -namespace FirstOrder.Theory +namespace FirstOrder.Arithmetic.Bootstrapping -open PeanoMinus ISigma0 ISigma1 Bootstrapping Derivation +open PeanoMinus ISigma0 ISigma1 Derivation variable (T) def Derivation : V → Prop := (construction T).Fixpoint ![] -def DerivationOf (d s : V) : Prop := fstIdx d = s ∧ T.Derivation d +def DerivationOf (d s : V) : Prop := fstIdx d = s ∧ Derivation T d -def Derivable (s : V) : Prop := ∃ d, T.DerivationOf d s +def Derivable (s : V) : Prop := ∃ d, DerivationOf T d s -def Proof (d φ : V) : Prop := T.DerivationOf d {φ} +def Proof (d φ : V) : Prop := DerivationOf T d {φ} -def Provable (φ : V) : Prop := ∃ d, T.Proof d φ +def Provable (φ : V) : Prop := ∃ d, Proof T d φ noncomputable def derivation : 𝚫₁.Semisentence 1 := (blueprint T).fixpointDefΔ₁ noncomputable def derivationOf : 𝚫₁.Semisentence 2 := .mkDelta - (.mkSigma “d s. !fstIdxDef s d ∧ !T.derivation.sigma d”) - (.mkPi “d s. !fstIdxDef s d ∧ !T.derivation.pi d”) + (.mkSigma “d s. !fstIdxDef s d ∧ !(derivation T).sigma d”) + (.mkPi “d s. !fstIdxDef s d ∧ !(derivation T).pi d”) noncomputable def derivable : 𝚺₁.Semisentence 1 := .mkSigma - “Γ. ∃ d, !T.derivationOf.sigma d Γ” + “Γ. ∃ d, !(derivationOf T).sigma d Γ” noncomputable def proof : 𝚫₁.Semisentence 2 := .mkDelta - (.mkSigma “d φ. ∃ s, !insertDef s φ 0 ∧ !T.derivationOf.sigma d s”) - (.mkPi “d φ. ∀ s, !insertDef s φ 0 → !T.derivationOf.pi d s”) + (.mkSigma “d φ. ∃ s, !insertDef s φ 0 ∧ !(derivationOf T).sigma d s”) + (.mkPi “d φ. ∀ s, !insertDef s φ 0 → !(derivationOf T).pi d s”) noncomputable def provable : 𝚺₁.Semisentence 1 := .mkSigma - “φ. ∃ d, !T.proof.sigma d φ” + “φ. ∃ d, !(proof T).sigma d φ” -noncomputable abbrev provabilityPred (σ : Sentence L) : Sentence ℒₒᵣ := T.provable.val/[⌜σ⌝] +noncomputable abbrev provabilityPred (σ : Sentence L) : Sentence ℒₒᵣ := (provable T).val/[⌜σ⌝] noncomputable def provabilityPred' (σ : Sentence L) : 𝚺₁.Sentence := .mkSigma - “!T.provable !!(⌜σ⌝)” + “!(provable T) !!(⌜σ⌝)” -@[simp] lemma provabilityPred'_val (σ : Sentence L) : (T.provabilityPred' σ).val = T.provabilityPred σ := by rfl +@[simp] lemma provabilityPred'_val (σ : Sentence L) : (provabilityPred' T σ).val = provabilityPred T σ := by rfl variable {T} section -instance Derivation.defined : 𝚫₁-Predicate[V] T.Derivation via T.derivation := (construction T).fixpoint_definedΔ₁ +instance Derivation.defined : 𝚫₁-Predicate[V] Derivation T via derivation T := (construction T).fixpoint_definedΔ₁ -instance Derivation.definable : 𝚫₁-Predicate[V] T.Derivation := Derivation.defined.to_definable +instance Derivation.definable : 𝚫₁-Predicate[V] Derivation T := Derivation.defined.to_definable -instance Derivation.definable' : Γ-[m + 1]-Predicate[V] T.Derivation := Derivation.definable.of_deltaOne +instance Derivation.definable' : Γ-[m + 1]-Predicate[V] Derivation T := Derivation.definable.of_deltaOne -instance DerivationOf.defined : 𝚫₁-Relation[V] T.DerivationOf via T.derivationOf := .mk - ⟨by intro v; simp [Theory.derivationOf], by intro v; simp [Theory.derivationOf, eq_comm (b := fstIdx (v 0))]; rfl⟩ +instance DerivationOf.defined : 𝚫₁-Relation[V] DerivationOf T via derivationOf T := .mk + ⟨by intro v; simp [derivationOf], by intro v; simp [derivationOf, eq_comm (b := fstIdx (v 0))]; rfl⟩ -instance DerivationOf.definable : 𝚫₁-Relation[V] T.DerivationOf := DerivationOf.defined.to_definable +instance DerivationOf.definable : 𝚫₁-Relation[V] DerivationOf T := DerivationOf.defined.to_definable -instance DerivationOf.definable' : Γ-[m + 1]-Relation[V] T.DerivationOf := DerivationOf.definable.of_deltaOne +instance DerivationOf.definable' : Γ-[m + 1]-Relation[V] DerivationOf T := DerivationOf.definable.of_deltaOne -instance Derivable.defined : 𝚺₁-Predicate[V] T.Derivable via T.derivable := .mk fun v ↦ by simp [Theory.derivable, Theory.Derivable] +instance Derivable.defined : 𝚺₁-Predicate[V] Derivable T via derivable T := .mk fun v ↦ by simp [derivable, Derivable] -instance Derivable.definable : 𝚺₁-Predicate[V] T.Derivable := Derivable.defined.to_definable +instance Derivable.definable : 𝚺₁-Predicate[V] Derivable T := Derivable.defined.to_definable /-- instance for definability tactic-/ -instance Derivable.definable' : 𝚺-[0 + 1]-Predicate[V] T.Derivable := Derivable.definable +instance Derivable.definable' : 𝚺-[0 + 1]-Predicate[V] Derivable T := Derivable.definable -instance Proof.defined : 𝚫₁-Relation[V] T.Proof via T.proof := .mk - ⟨by intro v; simp [Theory.proof], by intro v; simp [Theory.Proof, Theory.proof, singleton_eq_insert, emptyset_def]⟩ +instance Proof.defined : 𝚫₁-Relation[V] Proof T via proof T := .mk + ⟨by intro v; simp [proof], by intro v; simp [Proof, proof, singleton_eq_insert, emptyset_def]⟩ -instance Proof.definable : 𝚫₁-Relation[V] T.Proof := Proof.defined.to_definable +instance Proof.definable : 𝚫₁-Relation[V] Proof T := Proof.defined.to_definable -instance Proof.definable' : Γ-[m + 1]-Relation[V] T.Proof := Proof.definable.of_deltaOne +instance Proof.definable' : Γ-[m + 1]-Relation[V] Proof T := Proof.definable.of_deltaOne -instance Provable.defined : 𝚺₁-Predicate[V] T.Provable via T.provable := .mk fun v ↦ by simp [Theory.provable, Theory.Provable] +instance Provable.defined : 𝚺₁-Predicate[V] Provable T via provable T := .mk fun v ↦ by simp [provable, Provable] -instance Provable.definable : 𝚺₁-Predicate[V] T.Provable := Provable.defined.to_definable +instance Provable.definable : 𝚺₁-Predicate[V] Provable T := Provable.defined.to_definable /-- instance for definability tactic-/ -instance Provable.definable' : 𝚺-[0 + 1]-Predicate[V] T.Provable := Provable.definable +instance Provable.definable' : 𝚺-[0 + 1]-Predicate[V] Provable T := Provable.definable end namespace Derivation lemma case_iff {d : V} : - T.Derivation d ↔ + Derivation T d ↔ IsFormulaSet L (fstIdx d) ∧ ( (∃ s p, d = Bootstrapping.axL s p ∧ p ∈ s ∧ neg L p ∈ s) ∨ (∃ s, d = verumIntro s ∧ ^⊤ ∈ s) ∨ - (∃ s p q dp dq, d = andIntro s p q dp dq ∧ p ^⋏ q ∈ s ∧ T.DerivationOf dp (insert p s) ∧ T.DerivationOf dq (insert q s)) ∨ - (∃ s p q dpq, d = orIntro s p q dpq ∧ p ^⋎ q ∈ s ∧ T.DerivationOf dpq (insert p (insert q s))) ∨ - (∃ s p dp, d = allIntro s p dp ∧ ^∀ p ∈ s ∧ T.DerivationOf dp (insert (free L p) (setShift L s))) ∨ - (∃ s p t dp, d = exsIntro s p t dp ∧ ^∃ p ∈ s ∧ IsTerm L t ∧ T.DerivationOf dp (insert (substs1 L t p) s)) ∨ - (∃ s d', d = wkRule s d' ∧ fstIdx d' ⊆ s ∧ T.Derivation d') ∨ - (∃ s d', d = shiftRule s d' ∧ s = setShift L (fstIdx d') ∧ T.Derivation d') ∨ - (∃ s p d₁ d₂, d = cutRule s p d₁ d₂ ∧ T.DerivationOf d₁ (insert p s) ∧ T.DerivationOf d₂ (insert (neg L p) s)) ∨ + (∃ s p q dp dq, d = andIntro s p q dp dq ∧ p ^⋏ q ∈ s ∧ DerivationOf T dp (insert p s) ∧ DerivationOf T dq (insert q s)) ∨ + (∃ s p q dpq, d = orIntro s p q dpq ∧ p ^⋎ q ∈ s ∧ DerivationOf T dpq (insert p (insert q s))) ∨ + (∃ s p dp, d = allIntro s p dp ∧ ^∀ p ∈ s ∧ DerivationOf T dp (insert (free L p) (setShift L s))) ∨ + (∃ s p t dp, d = exsIntro s p t dp ∧ ^∃ p ∈ s ∧ IsTerm L t ∧ DerivationOf T dp (insert (substs1 L t p) s)) ∨ + (∃ s d', d = wkRule s d' ∧ fstIdx d' ⊆ s ∧ Derivation T d') ∨ + (∃ s d', d = shiftRule s d' ∧ s = setShift L (fstIdx d') ∧ Derivation T d') ∨ + (∃ s p d₁ d₂, d = cutRule s p d₁ d₂ ∧ DerivationOf T d₁ (insert p s) ∧ DerivationOf T d₂ (insert (neg L p) s)) ∨ (∃ s p, d = axm s p ∧ p ∈ s ∧ p ∈ T.Δ₁Class) ) := (construction T).case -alias ⟨case, _root_.LO.FirstOrder.Theory.Derivation.mk⟩ := case_iff +alias ⟨case, _root_.LO.FirstOrder.Arithmetic.Bootstrapping.Derivation.mk⟩ := case_iff lemma induction1 (Γ) {P : V → Prop} (hP : Γ-[1]-Predicate P) - {d} (hd : T.Derivation d) + {d} (hd : Derivation T d) (hAxL : ∀ s, IsFormulaSet L s → ∀ p ∈ s, neg L p ∈ s → P (axL s p)) (hVerumIntro : ∀ s, IsFormulaSet L s → ^⊤ ∈ s → P (verumIntro s)) - (hAnd : ∀ s, IsFormulaSet L s → ∀ p q dp dq, p ^⋏ q ∈ s → T.DerivationOf dp (insert p s) → T.DerivationOf dq (insert q s) → + (hAnd : ∀ s, IsFormulaSet L s → ∀ p q dp dq, p ^⋏ q ∈ s → DerivationOf T dp (insert p s) → DerivationOf T dq (insert q s) → P dp → P dq → P (andIntro s p q dp dq)) - (hOr : ∀ s, IsFormulaSet L s → ∀ p q d, p ^⋎ q ∈ s → T.DerivationOf d (insert p (insert q s)) → + (hOr : ∀ s, IsFormulaSet L s → ∀ p q d, p ^⋎ q ∈ s → DerivationOf T d (insert p (insert q s)) → P d → P (orIntro s p q d)) - (hAll : ∀ s, IsFormulaSet L s → ∀ p d, ^∀ p ∈ s → T.DerivationOf d (insert (free L p) (setShift L s)) → + (hAll : ∀ s, IsFormulaSet L s → ∀ p d, ^∀ p ∈ s → DerivationOf T d (insert (free L p) (setShift L s)) → P d → P (allIntro s p d)) - (hExs : ∀ s, IsFormulaSet L s → ∀ p t d, ^∃ p ∈ s → IsTerm L t → T.DerivationOf d (insert (substs1 L t p) s) → + (hExs : ∀ s, IsFormulaSet L s → ∀ p t d, ^∃ p ∈ s → IsTerm L t → DerivationOf T d (insert (substs1 L t p) s) → P d → P (exsIntro s p t d)) - (hWk : ∀ s, IsFormulaSet L s → ∀ d, fstIdx d ⊆ s → T.Derivation d → + (hWk : ∀ s, IsFormulaSet L s → ∀ d, fstIdx d ⊆ s → Derivation T d → P d → P (wkRule s d)) - (hShift : ∀ s, IsFormulaSet L s → ∀ d, s = setShift L (fstIdx d) → T.Derivation d → + (hShift : ∀ s, IsFormulaSet L s → ∀ d, s = setShift L (fstIdx d) → Derivation T d → P d → P (shiftRule s d)) - (hCut : ∀ s, IsFormulaSet L s → ∀ p d₁ d₂, T.DerivationOf d₁ (insert p s) → T.DerivationOf d₂ (insert (neg L p) s) → + (hCut : ∀ s, IsFormulaSet L s → ∀ p d₁ d₂, DerivationOf T d₁ (insert p s) → DerivationOf T d₂ (insert (neg L p) s) → P d₁ → P d₂ → P (cutRule s p d₁ d₂)) (hRoot : ∀ s, IsFormulaSet L s → ∀ p, p ∈ s → p ∈ T.Δ₁Class → P (axm s p)) : P d := (construction T).induction (v := ![]) hP (by @@ -586,76 +586,76 @@ lemma induction1 (Γ) {P : V → Prop} (hP : Γ-[1]-Predicate P) · exact hCut s (by simpa using hds) p d₁ d₂ ⟨h₁, (ih d₁ hC₁).1⟩ ⟨h₂, (ih d₂ hC₂).1⟩ (ih d₁ hC₁).2 (ih d₂ hC₂).2 · exact hRoot s (by simpa using hds) p hs hT) d hd -lemma isFormulaSet {d : V} (h : T.Derivation d) : IsFormulaSet L (fstIdx d) := (h : T.Derivation d).case.1 +lemma isFormulaSet {d : V} (h : Derivation T d) : IsFormulaSet L (fstIdx d) := (h : Derivation T d).case.1 -lemma _root_.LO.FirstOrder.Theory.DerivationOf.isFormulaSet {d s : V} (h : T.DerivationOf d s) : IsFormulaSet L s := by +lemma _root_.LO.FirstOrder.Arithmetic.Bootstrapping.DerivationOf.isFormulaSet {d s : V} (h : DerivationOf T d s) : IsFormulaSet L s := by simpa [h.1] using h.2.case.1 -lemma axL {s p : V} (hs : IsFormulaSet L s) (h : p ∈ s) (hn : neg L p ∈ s) : T.Derivation (axL s p) := - Theory.Derivation.mk ⟨by simpa using hs, Or.inl ⟨s, p, rfl, h, hn⟩⟩ +lemma axL {s p : V} (hs : IsFormulaSet L s) (h : p ∈ s) (hn : neg L p ∈ s) : Derivation T (axL s p) := + Bootstrapping.Derivation.mk ⟨by simpa using hs, Or.inl ⟨s, p, rfl, h, hn⟩⟩ lemma verumIntro {s : V} (hs : IsFormulaSet L s) (h : ^⊤ ∈ s) : - T.Derivation (verumIntro s) := - Theory.Derivation.mk ⟨by simpa using hs, Or.inr <| Or.inl ⟨s, rfl, h⟩⟩ + Derivation T (verumIntro s) := + Bootstrapping.Derivation.mk ⟨by simpa using hs, Or.inr <| Or.inl ⟨s, rfl, h⟩⟩ lemma andIntro {s p q dp dq : V} (h : p ^⋏ q ∈ s) - (hdp : T.DerivationOf dp (insert p s)) (hdq : T.DerivationOf dq (insert q s)) : - T.Derivation (andIntro s p q dp dq) := - Theory.Derivation.mk ⟨by simp only [fstIdx_andIntro]; intro r hr; exact hdp.isFormulaSet r (by simp [hr]), + (hdp : DerivationOf T dp (insert p s)) (hdq : DerivationOf T dq (insert q s)) : + Derivation T (andIntro s p q dp dq) := + Bootstrapping.Derivation.mk ⟨by simp only [fstIdx_andIntro]; intro r hr; exact hdp.isFormulaSet r (by simp [hr]), Or.inr <| Or.inr <| Or.inl ⟨s, p, q, dp, dq, rfl, h, hdp, hdq⟩⟩ lemma orIntro {s p q dpq : V} (h : p ^⋎ q ∈ s) - (hdpq : T.DerivationOf dpq (insert p (insert q s))) : - T.Derivation (orIntro s p q dpq) := - Theory.Derivation.mk ⟨by simp only [fstIdx_orIntro]; intro r hr; exact hdpq.isFormulaSet r (by simp [hr]), + (hdpq : DerivationOf T dpq (insert p (insert q s))) : + Derivation T (orIntro s p q dpq) := + Bootstrapping.Derivation.mk ⟨by simp only [fstIdx_orIntro]; intro r hr; exact hdpq.isFormulaSet r (by simp [hr]), Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, q, dpq, rfl, h, hdpq⟩⟩ lemma allIntro {s p dp : V} (h : ^∀ p ∈ s) - (hdp : T.DerivationOf dp (insert (free L p) (setShift L s))) : - T.Derivation (allIntro s p dp) := - Theory.Derivation.mk + (hdp : DerivationOf T dp (insert (free L p) (setShift L s))) : + Derivation T (allIntro s p dp) := + Bootstrapping.Derivation.mk ⟨by simp only [fstIdx_allIntro]; intro q hq; simpa using hdp.isFormulaSet (shift L q) (by simp [shift_mem_setShift hq]), Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, dp, rfl, h, hdp⟩⟩ lemma exsIntro {s p t dp : V} (h : ^∃ p ∈ s) (ht : IsTerm L t) - (hdp : T.DerivationOf dp (insert (substs1 L t p) s)) : - T.Derivation (exsIntro s p t dp) := - Theory.Derivation.mk + (hdp : DerivationOf T dp (insert (substs1 L t p) s)) : + Derivation T (exsIntro s p t dp) := + Bootstrapping.Derivation.mk ⟨by simp only [fstIdx_exsIntro]; intro q hq; exact hdp.isFormulaSet q (by simp [hq]), Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, t, dp, rfl, h, ht, hdp⟩⟩ lemma wkRule {s s' d : V} (hs : IsFormulaSet L s) - (h : s' ⊆ s) (hd : T.DerivationOf d s') : T.Derivation (wkRule s d) := - Theory.Derivation.mk + (h : s' ⊆ s) (hd : DerivationOf T d s') : Derivation T (wkRule s d) := + Bootstrapping.Derivation.mk ⟨by simpa using hs, Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, d, rfl, by simp [hd.1, h], hd.2⟩⟩ lemma shiftRule {s d : V} - (hd : T.DerivationOf d s) : T.Derivation (shiftRule (setShift L s) d) := - Theory.Derivation.mk + (hd : DerivationOf T d s) : Derivation T (shiftRule (setShift L s) d) := + Bootstrapping.Derivation.mk ⟨by simp [hd.isFormulaSet], Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨setShift L s, d, rfl, by simp [hd.1], hd.2⟩⟩ lemma cutRule {s p d₁ d₂ : V} - (hd₁ : T.DerivationOf d₁ (insert p s)) - (hd₂ : T.DerivationOf d₂ (insert (neg L p) s)) : - T.Derivation (cutRule s p d₁ d₂) := - Theory.Derivation.mk + (hd₁ : DerivationOf T d₁ (insert p s)) + (hd₂ : DerivationOf T d₂ (insert (neg L p) s)) : + Derivation T (cutRule s p d₁ d₂) := + Bootstrapping.Derivation.mk ⟨by simp only [fstIdx_cutRule]; intro q hq; exact hd₁.isFormulaSet q (by simp [hq]), Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inl ⟨s, p, d₁, d₂, rfl, hd₁, hd₂⟩⟩ lemma axm {s p : V} (hs : IsFormulaSet L s) (hp : p ∈ s) (hT : p ∈ T.Δ₁Class) : - T.Derivation (axm s p) := - Theory.Derivation.mk + Derivation T (axm s p) := + Bootstrapping.Derivation.mk ⟨by simpa using hs, Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr <| Or.inr ⟨s, p, rfl, hp, hT⟩⟩ variable {U : Theory L} [U.Δ₁] -lemma of_ss (h : T.Δ₁Class (V := V) ⊆ U.Δ₁Class) {d : V} : T.Derivation d → U.Derivation d := by +lemma of_ss (h : T.Δ₁Class (V := V) ⊆ U.Δ₁Class) {d : V} : Derivation T d → Derivation U d := by intro hd - apply Theory.Derivation.induction1 𝚺 ?_ hd + apply Bootstrapping.Derivation.induction1 𝚺 ?_ hd · intro s hs p hp hn; apply Derivation.axL hs hp hn · intro s hs hv; apply Derivation.verumIntro hs hv · intro s _ p q dp dq hpq hdp hdq ihp ihq @@ -680,94 +680,94 @@ end Derivation namespace Derivable -lemma isFormulaSet {s : V} (h : T.Derivable s) : IsFormulaSet L s := by +lemma isFormulaSet {s : V} (h : Derivable T s) : IsFormulaSet L s := by rcases h with ⟨d, hd⟩; exact hd.isFormulaSet lemma em {s : V} (hs : IsFormulaSet L s) (p) (h : p ∈ s) (hn : neg L p ∈ s) : - T.Derivable s := ⟨axL s p, by simp, Derivation.axL hs h hn⟩ + Derivable T s := ⟨axL s p, by simp, Derivation.axL hs h hn⟩ lemma verum {s : V} (hs : IsFormulaSet L s) (h : ^⊤ ∈ s) : - T.Derivable s := ⟨verumIntro s, by simp, Derivation.verumIntro hs h⟩ + Derivable T s := ⟨verumIntro s, by simp, Derivation.verumIntro hs h⟩ -lemma and_m {s p q : V} (h : p ^⋏ q ∈ s) (hp : T.Derivable (insert p s)) (hq : T.Derivable (insert q s)) : - T.Derivable s := by +lemma and_m {s p q : V} (h : p ^⋏ q ∈ s) (hp : Derivable T (insert p s)) (hq : Derivable T (insert q s)) : + Derivable T s := by rcases hp with ⟨dp, hdp⟩; rcases hq with ⟨dq, hdq⟩ exact ⟨andIntro s p q dp dq, by simp, Derivation.andIntro h hdp hdq⟩ -lemma or_m {s p q : V} (h : p ^⋎ q ∈ s) (hpq : T.Derivable (insert p (insert q s))) : - T.Derivable s := by +lemma or_m {s p q : V} (h : p ^⋎ q ∈ s) (hpq : Derivable T (insert p (insert q s))) : + Derivable T s := by rcases hpq with ⟨dpq, hdpq⟩ exact ⟨orIntro s p q dpq, by simp, Derivation.orIntro h hdpq⟩ -lemma all_m {s p : V} (h : ^∀ p ∈ s) (hp : T.Derivable (insert (free L p) (setShift L s))) : - T.Derivable s := by +lemma all_m {s p : V} (h : ^∀ p ∈ s) (hp : Derivable T (insert (free L p) (setShift L s))) : + Derivable T s := by rcases hp with ⟨dp, hdp⟩ exact ⟨allIntro s p dp, by simp, Derivation.allIntro h hdp⟩ -lemma ex_m {s p t : V} (h : ^∃ p ∈ s) (ht : IsTerm L t) (hp : T.Derivable (insert (substs1 L t p) s)) : - T.Derivable s := by +lemma ex_m {s p t : V} (h : ^∃ p ∈ s) (ht : IsTerm L t) (hp : Derivable T (insert (substs1 L t p) s)) : + Derivable T s := by rcases hp with ⟨dp, hdp⟩ exact ⟨exsIntro s p t dp, by simp, Derivation.exsIntro h ht hdp⟩ -lemma wk {s s' : V} (hs : IsFormulaSet L s) (h : s' ⊆ s) (hd : T.Derivable s') : - T.Derivable s := by +lemma wk {s s' : V} (hs : IsFormulaSet L s) (h : s' ⊆ s) (hd : Derivable T s') : + Derivable T s := by rcases hd with ⟨d, hd⟩ exact ⟨wkRule s d, by simp, Derivation.wkRule hs h hd⟩ -lemma shift {s : V} (hd : T.Derivable s) : - T.Derivable (setShift L s) := by +lemma shift {s : V} (hd : Derivable T s) : + Derivable T (setShift L s) := by rcases hd with ⟨d, hd⟩ exact ⟨shiftRule (setShift L s) d, by simp, Derivation.shiftRule hd⟩ -lemma ofSetEq {s s' : V} (h : ∀ x, x ∈ s' ↔ x ∈ s) (hd : T.Derivable s') : - T.Derivable s := by +lemma ofSetEq {s s' : V} (h : ∀ x, x ∈ s' ↔ x ∈ s) (hd : Derivable T s') : + Derivable T s := by have : s' = s := mem_ext h rcases this; exact hd -lemma exchange {s p q : V} (h : T.Derivable (insert p <| insert q s)) : - T.Derivable (insert q <| insert p s) := h.ofSetEq (fun x ↦ by simp; tauto) +lemma exchange {s p q : V} (h : Derivable T (insert p <| insert q s)) : + Derivable T (insert q <| insert p s) := h.ofSetEq (fun x ↦ by simp; tauto) -lemma cut {s : V} (p) (hd₁ : T.Derivable (insert p s)) (hd₂ : T.Derivable (insert (neg L p) s)) : - T.Derivable s := by +lemma cut {s : V} (p) (hd₁ : Derivable T (insert p s)) (hd₂ : Derivable T (insert (neg L p) s)) : + Derivable T s := by rcases hd₁ with ⟨d₁, hd₁⟩; rcases hd₂ with ⟨d₂, hd₂⟩ exact ⟨cutRule s p d₁ d₂, by simp, Derivation.cutRule hd₁ hd₂⟩ lemma by_axm {s : V} (hs : IsFormulaSet L s) (p) (hp : p ∈ s) (hT : p ∈ T.Δ₁Class) : - T.Derivable s := by + Derivable T s := by exact ⟨Bootstrapping.axm s p, by simp, Derivation.axm hs hp hT⟩ -lemma of_ss (h : T.Δ₁Class (V := V) ⊆ U.Δ₁Class) {s : V} : T.Derivable s → U.Derivable s := by +lemma of_ss (h : T.Δ₁Class (V := V) ⊆ U.Δ₁Class) {s : V} : Derivable T s → Derivable U s := by rintro ⟨d, hd⟩; exact ⟨d, hd.1, hd.2.of_ss h⟩ -lemma and {s p q : V} (hp : T.Derivable (insert p s)) (hq : T.Derivable (insert q s)) : - T.Derivable (insert (p ^⋏ q) s) := +lemma and {s p q : V} (hp : Derivable T (insert p s)) (hq : Derivable T (insert q s)) : + Derivable T (insert (p ^⋏ q) s) := and_m (p := p) (q := q) (by simp) (wk (by simp [hp.isFormulaSet.insert, hq.isFormulaSet.insert]) (insert_subset_insert_of_subset _ <| by simp) hp) (wk (by simp [hp.isFormulaSet.insert, hq.isFormulaSet.insert]) (insert_subset_insert_of_subset _ <| by simp) hq) -lemma or {s p q : V} (hpq : T.Derivable (insert p (insert q s))) : - T.Derivable (insert (p ^⋎ q) s) := +lemma or {s p q : V} (hpq : Derivable T (insert p (insert q s))) : + Derivable T (insert (p ^⋎ q) s) := or_m (p := p) (q := q) (by simp) (wk (by simp [hpq.isFormulaSet.insert, hpq.isFormulaSet.insert.2.insert]) (insert_subset_insert_of_subset _ <| insert_subset_insert_of_subset _ <| by simp) hpq) /-- Crucial inducion for formalized $\Sigma_1$-completeness. -/ lemma conj (ps : V) {s : V} (hs : IsFormulaSet L s) - (ds : ∀ i < len ps, T.Derivable (insert ps.[i] s)) : T.Derivable (insert (^⋀ ps) s) := by - have : ∀ k ≤ len ps, T.Derivable (insert (^⋀ (takeLast ps k)) s) := by + (ds : ∀ i < len ps, Derivable T (insert ps.[i] s)) : Derivable T (insert (^⋀ ps) s) := by + have : ∀ k ≤ len ps, Derivable T (insert (^⋀ (takeLast ps k)) s) := by intro k hk induction k using ISigma1.sigma1_succ_induction · definability case zero => simpa using verum (by simp [hs]) (by simp) case succ k ih => - have ih : T.Derivable (insert (^⋀ takeLast ps k) s) := ih (le_trans le_self_add hk) - have : T.Derivable (insert ps.[len ps - (k + 1)] s) := ds (len ps - (k + 1)) ((tsub_lt_iff_left hk).mpr (by simp)) + have ih : Derivable T (insert (^⋀ takeLast ps k) s) := ih (le_trans le_self_add hk) + have : Derivable T (insert ps.[len ps - (k + 1)] s) := ds (len ps - (k + 1)) ((tsub_lt_iff_left hk).mpr (by simp)) simpa [takeLast_succ_of_lt (succ_le_iff_lt.mp hk)] using this.and ih simpa using this (len ps) (by rfl) -lemma disjDistr (ps s : V) (d : T.Derivable (vecToSet ps ∪ s)) : T.Derivable (insert (^⋁ ps) s) := by +lemma disjDistr (ps s : V) (d : Derivable T (vecToSet ps ∪ s)) : Derivable T (insert (^⋁ ps) s) := by have : ∀ k ≤ len ps, ∀ s' ≤ vecToSet ps, s' ⊆ vecToSet ps → - (∀ i < len ps - k, ps.[i] ∈ s') → T.Derivable (insert (^⋁ takeLast ps k) (s' ∪ s)) := by + (∀ i < len ps - k, ps.[i] ∈ s') → Derivable T (insert (^⋁ takeLast ps k) (s' ∪ s)) := by intro k hk induction k using ISigma1.sigma1_succ_induction · apply HierarchySymbol.Definable.imp (by definability) @@ -796,7 +796,7 @@ lemma disjDistr (ps s : V) (d : T.Derivable (vecToSet ps ∪ s)) : T.Derivable ( rintro (rfl | h) · exact mem_vecToSet_iff.mpr ⟨_, by simp [tsub_lt_iff_left hk], rfl⟩ · exact ss h - have : T.Derivable (insert (^⋁ takeLast ps k) (s'' ∪ s)) := by + have : Derivable T (insert (^⋁ takeLast ps k) (s'' ∪ s)) := by refine ih (le_trans (by simp) hk) s'' (le_of_subset hs'') hs'' ?_ intro i hi have : i ≤ len ps - (k + 1) := by @@ -808,7 +808,7 @@ lemma disjDistr (ps s : V) (d : T.Derivable (vecToSet ps ∪ s)) : T.Derivable ( simpa using this (len ps) (by rfl) ∅ (by simp [emptyset_def]) (by simp) (by simp) lemma disj (ps s : V) {i} (hps : ∀ i < len ps, IsFormula L ps.[i]) - (hi : i < len ps) (d : T.Derivable (insert ps.[i] s)) : T.Derivable (insert (^⋁ ps) s) := + (hi : i < len ps) (d : Derivable T (insert ps.[i] s)) : Derivable T (insert (^⋁ ps) s) := disjDistr ps s <| wk (by suffices IsFormulaSet L (vecToSet ps) by simpa [by simpa using d.isFormulaSet] intro x hx; rcases mem_vecToSet_iff.mp hx with ⟨i, hi, rfl⟩; exact hps i hi) @@ -818,16 +818,16 @@ lemma disj (ps s : V) {i} (hps : ∀ i < len ps, IsFormula L ps.[i]) · left; exact mem_vecToSet_iff.mpr ⟨i, hi, rfl⟩ · right; exact hx) d -lemma all {p s : V} (hp : IsSemiformula L 1 p) (dp : T.Derivable (insert (free L p) (setShift L s))) : T.Derivable (insert (^∀ p) s) := +lemma all {p s : V} (hp : IsSemiformula L 1 p) (dp : Derivable T (insert (free L p) (setShift L s))) : Derivable T (insert (^∀ p) s) := all_m (p := p) (by simp) (wk (by simp [hp, by simpa using dp.isFormulaSet]) (by intro x; simp; tauto) dp) lemma exs {p t s : V} (hp : IsSemiformula L 1 p) (ht : IsTerm L t) - (dp : T.Derivable (insert (substs1 L t p) s)) : T.Derivable (insert (^∃ p) s) := + (dp : Derivable T (insert (substs1 L t p) s)) : Derivable T (insert (^∃ p) s) := ex_m (p := p) (by simp) ht <| wk (by simp [hp, by simpa using dp.isFormulaSet]) (by intro x; simp; tauto) dp end Derivable -lemma internal_provable_iff_internal_derivable {φ : V} : T.Provable φ ↔ T.Derivable (insert φ ∅ : V) := by +lemma internal_provable_iff_internal_derivable {φ : V} : Provable T φ ↔ Derivable T (insert φ ∅ : V) := by constructor · rintro ⟨b, hb⟩ exact ⟨b, by simpa using hb⟩ @@ -839,13 +839,13 @@ alias ⟨Provable.toDerivable, Derivable.toProvable⟩ := internal_provable_iff_ namespace Provable lemma conj (ps : V) - (ds : ∀ i < len ps, T.Provable ps.[i]) : T.Provable (^⋀ ps) := + (ds : ∀ i < len ps, Provable T ps.[i]) : Provable T (^⋀ ps) := Derivable.toProvable <| Derivable.conj _ (by simp) fun i hi ↦ (ds i hi).toDerivable lemma disj (ps : V) {i} (hps : ∀ i < len ps, IsFormula L ps.[i]) - (hi : i < len ps) (d : T.Provable ps.[i]) : T.Provable (^⋁ ps) := + (hi : i < len ps) (d : Provable T ps.[i]) : Provable T (^⋁ ps) := Derivable.toProvable <| Derivable.disj _ _ hps hi d.toDerivable end Provable -end LO.FirstOrder.Theory +end LO.FirstOrder.Arithmetic.Bootstrapping diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean index ac5f43a1c..8de393fd3 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Coding.lean @@ -8,7 +8,7 @@ namespace LO.FirstOrder open Arithmetic Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.DecidableEq] [L.Encodable] [L.LORDefinable] @@ -18,8 +18,6 @@ namespace Derivation2 variable (V) -def cast [L.DecidableEq] {T : Theory L} {Γ Δ : Finset (Proposition L)} (d : T ⟹₂ Γ) (h : Γ = Δ) : T ⟹₂ Δ := h ▸ d - noncomputable def Sequent.quote (Γ : Finset (Proposition L)) : V := ∑ φ ∈ Γ, Exp.exp (⌜φ⌝ : V) noncomputable instance : GödelQuote (Finset (Proposition L)) V := ⟨Sequent.quote V⟩ @@ -160,11 +158,10 @@ variable (V) noncomputable def typedQuote {Γ : Finset (Proposition L)} : T ⟹₂ Γ → T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝ | closed Δ φ h hn => TDerivation.em ⌜φ⌝ (by simpa) (by simpa using Sequent.quote_mem_quote.mpr hn) - | axm φ hT _ => TDerivation.byAxm ⌜φ⌝ (by - have : ∃ σ ∈ T, ↑σ = φ := by simpa [Theory.toSchema] using hT - rcases this with ⟨σ, hT', rfl⟩ + | axm φ hT hΓ => TDerivation.byAxm ⌜φ⌝ (by simp only [tmem, internalize_theory] - apply (Δ₁Class.mem_iff'' (T := T) (φ := σ)).mpr hT') (by simpa) + exact (Δ₁Class.mem_iff'' (T := T) (φ := φ)).mpr hT) (by + simpa using Sequent.quote_mem_quote.mpr hΓ) | verum h => TDerivation.verum (by simpa using Sequent.quote_mem_quote.mpr h) | and (φ := φ) (ψ := ψ) h bp bq => TDerivation.and' (show ⌜φ⌝ ⋏ ⌜ψ⌝ ∈ ⌜Γ⌝ by simpa using Sequent.quote_mem_quote.mpr h) (bp.typedQuote.cast (by simp)) (bq.typedQuote.cast (by simp)) @@ -183,15 +180,15 @@ noncomputable instance (Γ : Finset (Proposition L)) : GödelQuote (T ⟹₂ Γ) noncomputable instance (Γ : Finset (Proposition L)) : GödelQuote (T ⟹₂ Γ) V := ⟨fun d ↦ (⌜d⌝ : T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝).val⟩ -lemma quote_def (d : (T : Schema L) ⟹₂ Γ) : (⌜d⌝ : V) = (⌜d⌝ : T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝).val := rfl +lemma quote_def (d : T ⟹₂ Γ) : (⌜d⌝ : V) = (⌜d⌝ : T.internalize V ⊢!ᵈᵉʳ ⌜Γ⌝).val := rfl set_option backward.isDefEq.respectTransparency false in -lemma coe_typedQuote_val_eq (d : (T : Schema L) ⟹₂ Γ) : ↑(d.typedQuote ℕ).val = (d.typedQuote V).val := +lemma coe_typedQuote_val_eq (d : T ⟹₂ Γ) : ↑(d.typedQuote ℕ).val = (d.typedQuote V).val := match d with | closed Δ φ h hn => by simp [typedQuote, axL, nat_cast_pair, Sequent.coe_eq, Semiformula.coe_quote_eq_quote'] | axm φ hT _ => by - simp [typedQuote, Bootstrapping.axm, nat_cast_pair, Sequent.coe_eq, Semiformula.coe_quote_eq_quote'] + simpa [typedQuote, Bootstrapping.axm, nat_cast_pair, Sequent.coe_eq] using Sentence.coe_quote_eq_quote (V := V) φ | verum h => by simp [typedQuote, Bootstrapping.verumIntro, nat_cast_pair, Sequent.coe_eq] | and h b₁ b₂ => by @@ -216,38 +213,40 @@ lemma coe_typedQuote_val_eq (d : (T : Schema L) ⟹₂ Γ) : ↑(d.typedQuote simp [typedQuote, Bootstrapping.cutRule, nat_cast_pair, Sequent.coe_eq, Semiformula.coe_quote_eq_quote', b₁.coe_typedQuote_val_eq, b₂.coe_typedQuote_val_eq] -lemma coe_quote_eq (d : (T : Schema L) ⟹₂ Γ) : (↑(⌜d⌝ : ℕ) : V) = ⌜d⌝ := coe_typedQuote_val_eq V d +lemma coe_quote_eq (d : T ⟹₂ Γ) : (↑(⌜d⌝ : ℕ) : V) = ⌜d⌝ := coe_typedQuote_val_eq V d end Derivation2 -noncomputable instance (Γ : Sequent L) : GödelQuote ((T : Schema L) ⟹ Γ) V := ⟨fun b ↦ ⌜Derivation.toDerivation2 (T : Schema L) b⌝⟩ +noncomputable instance (Γ : Sequent L) : GödelQuote (⊢ᴸᴷ¹ Γ) V := ⟨fun b ↦ ⌜Derivation.toDerivation2 (∅ : Theory L) b⌝⟩ noncomputable instance (φ : Sentence L) : GödelQuote (T ⊢! φ) V := ⟨fun b ↦ - let b : (T : Schema L) ⟹ [↑φ] := b - ⌜b⌝⟩ + ⌜b.toProof2⌝⟩ -lemma quote_derivation_def {Γ : Sequent L} (b : (T : Schema L) ⟹ Γ) : (⌜b⌝ : V) = ⌜Derivation.toDerivation2 (T : Schema L) b⌝ := rfl +lemma quote_derivation_def {Γ : Sequent L} (b : ⊢ᴸᴷ¹ Γ) : (⌜b⌝ : V) = ⌜Derivation.toDerivation2 (∅ : Theory L) b⌝ := rfl -lemma quote_proof_def {φ : Sentence L} (b : T ⊢! φ) : (⌜b⌝ : V) = ⌜Derivation.toDerivation2 (T : Schema L) b⌝ := rfl +lemma quote_proof_def {φ : Sentence L} (b : T ⊢! φ) : (⌜b⌝ : V) = ⌜b.toProof2⌝ := rfl -@[simp] lemma derivation_of_quote_derivation {Γ : Sequent L} (b : (T : Schema L) ⟹ Γ) : T.DerivationOf (⌜b⌝ : V) ⌜Γ.toFinset⌝ := by - let x := Derivation2.typedQuote V (Derivation.toDerivation2 (T : Schema L) b) - suffices T.DerivationOf x.val ⌜List.toFinset Γ⌝ from this - simpa using x.derivationOf +@[simp] lemma derivation_of_quote_derivation {Γ : Sequent L} (b : ⊢ᴸᴷ¹ Γ) : DerivationOf T (⌜b⌝ : V) ⌜Γ.toFinset⌝ := by + let x := Derivation2.typedQuote V (Derivation.toDerivation2 (∅ : Theory L) b) + suffices DerivationOf T x.val ⌜List.toFinset Γ⌝ from this + exact ⟨x.derivationOf.1, x.derivationOf.2.of_ss (by + intro p hp + change V ⊧/![p] (⊥ : 𝚫₁.Semisentence 1).val at hp + simp at hp)⟩ -@[simp] lemma proof_of_quote_proof {φ : Sentence L} (b : T ⊢! φ) : T.Proof (⌜b⌝ : V) ⌜φ⌝ := by - let x := Derivation2.typedQuote V (Derivation.toDerivation2 (T : Schema L) b) - suffices T.Proof x.val ⌜φ⌝ from this +@[simp] lemma proof_of_quote_proof {φ : Sentence L} (b : T ⊢! φ) : Proof T (⌜b⌝ : V) ⌜φ⌝ := by + let x := Derivation2.typedQuote V b.toProof2 + suffices Proof T x.val ⌜φ⌝ from this simpa using x.derivationOf lemma coe_quote_proof_eq (d : T ⊢! φ) : (↑(⌜d⌝ : ℕ) : V) = ⌜d⌝ := by simp [quote_proof_def, Derivation2.coe_quote_eq] -namespace Theory +namespace Arithmetic.Bootstrapping open Derivation2 -lemma Derivation.sound {d : ℕ} (h : T.Derivation d) : ∃ Γ, ⌜Γ⌝ = fstIdx d ∧ (T : Schema L) ⟹₂! Γ := by +lemma Derivation.sound {d : ℕ} (h : Derivation T d) : ∃ Γ, ⌜Γ⌝ = fstIdx d ∧ T ⟹₂! Γ := by induction d using Nat.strongRec case ind d ih => rcases h.case with ⟨hs, H⟩ @@ -322,16 +321,20 @@ lemma Derivation.sound {d : ℕ} (h : T.Derivation d) : ∃ Γ, ⌜Γ⌝ = fstId rcases this with ⟨σ, hσ, rfl⟩ refine ⟨Derivation2.axm σ (by simp [hσ]) hφ⟩ -lemma Provable.sound2 {φ : Proposition L} (h : T.Provable (⌜φ⌝ : ℕ)) : T ⊢!₂! φ := by - rcases h with ⟨d, hp, hd⟩ - rcases hd.sound with ⟨Γ, e, b⟩ - have : Γ = {φ} := Sequent.quote_inj (V := ℕ) <| by simp [e, hp] - rcases this - exact b - -lemma Provable.sound {φ : Sentence L} (h : T.Provable (⌜φ⌝ : ℕ)) : T ⊢ φ := - provable_iff_derivable2.mpr <| Theory.Provable.sound2 (by simpa using h) - -end Theory +noncomputable def Provable.sound2 {φ : Proposition L} (h : Provable T (⌜φ⌝ : ℕ)) : T ⊢!₂! φ := by + let d := Classical.choose h + have hd : Proof T d (⌜φ⌝ : ℕ) := Classical.choose_spec h + let Γ := Classical.choose hd.2.sound + have hΓ := Classical.choose_spec hd.2.sound + rcases hΓ with ⟨e, b⟩ + have hΓ : Γ = {φ} := Sequent.quote_inj (V := ℕ) <| by + rw [e, hd.1] + simp + exact Derivation2.cast (Classical.choice b) hΓ + +lemma Provable.sound {φ : Sentence L} (h : Provable T (⌜φ⌝ : ℕ)) : T ⊢ φ := + provable_iff_derivable2.mpr ⟨Provable.sound2 (by simpa using h)⟩ + +end Arithmetic.Bootstrapping end LO.FirstOrder diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean index 282a61687..1885452be 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Proof/Typed.lean @@ -11,7 +11,7 @@ namespace LO open FirstOrder Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] @@ -117,12 +117,12 @@ def _root_.LO.FirstOrder.Theory.internalize (T : Theory L) [T.Δ₁] : InternalT variable {V} -omit [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] in +omit [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] in @[simp] lemma internalize_theory (T : Theory L) [T.Δ₁] : (T.internalize V).theory = T := rfl structure TDerivation (T : InternalTheory V L) (Γ : Sequent V L) where val : V - derivationOf : T.theory.DerivationOf val Γ.val + derivationOf : DerivationOf T.theory val Γ.val attribute [simp] TDerivation.derivationOf @@ -136,33 +136,33 @@ instance : HasSubset (InternalTheory V L) := ⟨fun T U ↦ T.theory.Δ₁Class variable {T U : InternalTheory V L} -noncomputable def _root_.LO.FirstOrder.Theory.Derivable.toTDerivation (Γ : Sequent V L) (h : T.theory.Derivable Γ.val) : T ⊢!ᵈᵉʳ Γ := by +noncomputable def _root_.LO.FirstOrder.Arithmetic.Bootstrapping.Derivable.toTDerivation (Γ : Sequent V L) (h : Derivable T.theory Γ.val) : T ⊢!ᵈᵉʳ Γ := by choose a ha using h; choose d hd using ha.2 exact ⟨a, ha.1, d, hd⟩ -lemma TDerivation.toDerivable {Γ : (Sequent V L)} (d : T ⊢!ᵈᵉʳ Γ) : T.theory.Derivable Γ.val := +lemma TDerivation.toDerivable {Γ : (Sequent V L)} (d : T ⊢!ᵈᵉʳ Γ) : Derivable T.theory Γ.val := ⟨d.val, d.derivationOf⟩ lemma TProvable.iff_provable {σ : Formula V L} : - T ⊢ σ ↔ T.theory.Provable σ.val := by + T ⊢ σ ↔ Provable T.theory σ.val := by constructor · intro b simpa [←singleton_eq_insert] using TDerivation.toDerivable b.get · intro h - exact ⟨Theory.Derivable.toTDerivation _ <| by simpa [←singleton_eq_insert] using h⟩ + exact ⟨Derivable.toTDerivation _ <| by simpa [←singleton_eq_insert] using h⟩ -alias ⟨toProvable, _root_.LO.FirstOrder.Theory.Provable.toTProvable⟩ := TProvable.iff_provable +alias ⟨toProvable, _root_.LO.FirstOrder.Arithmetic.Bootstrapping.Provable.toTProvable⟩ := TProvable.iff_provable def proof_to_tDerivation {σ : Formula V L} : T ⊢! σ → T ⊢!ᵈᵉʳ insert σ ∅ := fun x ↦ x lemma tprovable_iff_provable {T : Theory L} [T.Δ₁] {σ : Formula V L} : - T.internalize V ⊢ σ ↔ T.Provable σ.val := TProvable.iff_provable + T.internalize V ⊢ σ ↔ Provable T σ.val := TProvable.iff_provable lemma tprovable_tquote_iff_provable_quote {T : Theory L} [T.Δ₁] {φ : Proposition L} : - T.internalize V ⊢ ⌜φ⌝ ↔ T.Provable (⌜φ⌝ : V) := TProvable.iff_provable + T.internalize V ⊢ ⌜φ⌝ ↔ Provable T (⌜φ⌝ : V) := TProvable.iff_provable lemma tprovable_tquote_iff_provable_quote_sentence {T : Theory L} [T.Δ₁] {σ : Sentence L} : - T.internalize V ⊢ ⌜σ⌝ ↔ T.Provable (⌜σ⌝ : V) := TProvable.iff_provable + T.internalize V ⊢ ⌜σ⌝ ↔ Provable T (⌜σ⌝ : V) := TProvable.iff_provable def TDerivation.toTProof {φ} (d : T ⊢!ᵈᵉʳ insert φ ∅) : T ⊢! φ := d @@ -181,78 +181,78 @@ protected noncomputable def cast {Γ Δ : Bootstrapping.Sequent V L} (e : Γ = (TDerivation.cast e d).val = d.val := by rcases e; simp [TDerivation.cast] noncomputable def byAxm (φ) (h : φ ∈' T.theory) (hΓ : φ ∈ Γ) : T ⊢!ᵈᵉʳ Γ := - ⟨Bootstrapping.axm Γ.val φ.val, by simp, Theory.Derivation.axm (by simp) (by simpa) h⟩ + ⟨Bootstrapping.axm Γ.val φ.val, by simp, Derivation.axm (by simp) (by simpa) h⟩ @[simp] lemma byAxm_val (φ) (h : φ ∈' T.theory) (hΓ : φ ∈ Γ) : (byAxm φ h hΓ).val = Bootstrapping.axm Γ.val φ.val := rfl noncomputable def em (φ) (h : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : T ⊢!ᵈᵉʳ Γ := - ⟨axL Γ.val φ.val, by simp, Theory.Derivation.axL (by simp) h hn⟩ + ⟨axL Γ.val φ.val, by simp, Derivation.axL (by simp) h hn⟩ @[simp] lemma em_val (φ) (h : φ ∈ Γ) (hn : ∼φ ∈ Γ) : (em φ h hn : T ⊢!ᵈᵉʳ Γ).val = Bootstrapping.axL Γ.val φ.val := rfl noncomputable def verum (h : ⊤ ∈ Γ := by simp) : T ⊢!ᵈᵉʳ Γ := - ⟨verumIntro Γ.val, by simp, Theory.Derivation.verumIntro (by simp) h⟩ + ⟨verumIntro Γ.val, by simp, Derivation.verumIntro (by simp) h⟩ @[simp] lemma verum_val (h : ⊤ ∈ Γ) : (verum h : T ⊢!ᵈᵉʳ Γ).val = Bootstrapping.verumIntro Γ.val := rfl noncomputable def and' (H : φ ⋏ ψ ∈ Γ) (dp : T ⊢!ᵈᵉʳ insert φ Γ) (dq : T ⊢!ᵈᵉʳ insert ψ Γ) : T ⊢!ᵈᵉʳ Γ := ⟨andIntro Γ.val φ.val ψ.val dp.val dq.val, by simp, - Theory.Derivation.andIntro (by simpa) (by simpa using dp.derivationOf) (by simpa using dq.derivationOf)⟩ + Derivation.andIntro (by simpa) (by simpa using dp.derivationOf) (by simpa using dq.derivationOf)⟩ @[simp] lemma and'_val (H : φ ⋏ ψ ∈ Γ) (dp : T ⊢!ᵈᵉʳ insert φ Γ) (dq : T ⊢!ᵈᵉʳ insert ψ Γ) : (and' H dp dq : T ⊢!ᵈᵉʳ Γ).val = andIntro Γ.val φ.val ψ.val dp.val dq.val := rfl noncomputable def or' (H : φ ⋎ ψ ∈ Γ) (dpq : T ⊢!ᵈᵉʳ insert φ (insert ψ Γ)) : T ⊢!ᵈᵉʳ Γ := - ⟨orIntro Γ.val φ.val ψ.val dpq.val, by simp, Theory.Derivation.orIntro (by simpa) (by simpa using dpq.derivationOf)⟩ + ⟨orIntro Γ.val φ.val ψ.val dpq.val, by simp, Derivation.orIntro (by simpa) (by simpa using dpq.derivationOf)⟩ @[simp] lemma or'_val (H : φ ⋎ ψ ∈ Γ) (dpq : T ⊢!ᵈᵉʳ insert φ (insert ψ Γ)) : (or' H dpq : T ⊢!ᵈᵉʳ Γ).val = orIntro Γ.val φ.val ψ.val dpq.val := rfl noncomputable def all' {φ : Semiformula V L 1} (H : ∀⁰ φ ∈ Γ) (dp : T ⊢!ᵈᵉʳ insert φ.free Γ.shift) : T ⊢!ᵈᵉʳ Γ := - ⟨allIntro Γ.val φ.val dp.val, by simp, Theory.Derivation.allIntro (by simpa) (by simpa using dp.derivationOf)⟩ + ⟨allIntro Γ.val φ.val dp.val, by simp, Derivation.allIntro (by simpa) (by simpa using dp.derivationOf)⟩ @[simp] lemma all'_val {φ : Semiformula V L 1} (H : ∀⁰ φ ∈ Γ) (dp : T ⊢!ᵈᵉʳ insert φ.free Γ.shift) : (all' H dp : T ⊢!ᵈᵉʳ Γ).val = allIntro Γ.val φ.val dp.val := rfl noncomputable def exs' {φ : Semiformula V L 1} (H : ∃⁰ φ ∈ Γ) (t : Term V L) (dp : T ⊢!ᵈᵉʳ insert (φ.subst ![t]) Γ) : T ⊢!ᵈᵉʳ Γ := - ⟨exsIntro Γ.val φ.val t.val dp.val, by simp, Theory.Derivation.exsIntro (by simpa) (by simp) (by simpa using dp.derivationOf)⟩ + ⟨exsIntro Γ.val φ.val t.val dp.val, by simp, Derivation.exsIntro (by simpa) (by simp) (by simpa using dp.derivationOf)⟩ @[simp] lemma exs'_val {φ : Semiformula V L 1} (H : ∃⁰ φ ∈ Γ) (t : Term V L) (dp : T ⊢!ᵈᵉʳ insert (φ.subst ![t]) Γ) : (exs' H t dp : T ⊢!ᵈᵉʳ Γ).val = exsIntro Γ.val φ.val t.val dp.val := rfl noncomputable def wk (d : T ⊢!ᵈᵉʳ Δ) (h : Δ ⊆ Γ) : T ⊢!ᵈᵉʳ Γ := - ⟨wkRule Γ.val d.val, by simp, Theory.Derivation.wkRule (s' := Δ.val) (by simp) (by simpa) (by simp)⟩ + ⟨wkRule Γ.val d.val, by simp, Derivation.wkRule (s' := Δ.val) (by simp) (by simpa) (by simp)⟩ @[simp] lemma wk_val (d : T ⊢!ᵈᵉʳ Δ) (h : Δ ⊆ Γ) : (wk d h).val = wkRule Γ.val d.val := rfl noncomputable def shift (d : T ⊢!ᵈᵉʳ Γ) : T ⊢!ᵈᵉʳ Γ.shift := - ⟨shiftRule Γ.shift.val d.val, by simp, Theory.Derivation.shiftRule (by simp)⟩ + ⟨shiftRule Γ.shift.val d.val, by simp, Derivation.shiftRule (by simp)⟩ @[simp] lemma shift_val (d : T ⊢!ᵈᵉʳ Γ) : (shift d).val = shiftRule Γ.shift.val d.val := rfl noncomputable def cut (d₁ : T ⊢!ᵈᵉʳ insert φ Γ) (d₂ : T ⊢!ᵈᵉʳ insert (∼φ) Γ) : T ⊢!ᵈᵉʳ Γ := - ⟨cutRule Γ.val φ.val d₁.val d₂.val, by simp, Theory.Derivation.cutRule (by simpa using d₁.derivationOf) (by simpa using d₂.derivationOf)⟩ + ⟨cutRule Γ.val φ.val d₁.val d₂.val, by simp, Derivation.cutRule (by simpa using d₁.derivationOf) (by simpa using d₂.derivationOf)⟩ @[simp] lemma cut_val (d₁ : T ⊢!ᵈᵉʳ insert φ Γ) (d₂ : T ⊢!ᵈᵉʳ insert (∼φ) Γ) : (cut d₁ d₂).val = cutRule Γ.val φ.val d₁.val d₂.val := rfl noncomputable def and (dp : T ⊢!ᵈᵉʳ insert φ Γ) (dq : T ⊢!ᵈᵉʳ insert ψ Γ) : T ⊢!ᵈᵉʳ insert (φ ⋏ ψ) Γ := - Theory.Derivable.toTDerivation _ - <| by simpa using Theory.Derivable.and (by simpa using dp.toDerivable) (by simpa using dq.toDerivable) + Derivable.toTDerivation _ + <| by simpa using Derivable.and (by simpa using dp.toDerivable) (by simpa using dq.toDerivable) noncomputable def or (dpq : T ⊢!ᵈᵉʳ insert φ (insert ψ Γ)) : T ⊢!ᵈᵉʳ insert (φ ⋎ ψ) Γ := - Theory.Derivable.toTDerivation _ <| by simpa using Theory.Derivable.or (by simpa using dpq.toDerivable) + Derivable.toTDerivation _ <| by simpa using Derivable.or (by simpa using dpq.toDerivable) noncomputable def all {φ : Semiformula V L 1} (dp : T ⊢!ᵈᵉʳ insert φ.free Γ.shift) : T ⊢!ᵈᵉʳ insert (∀⁰ φ) Γ := - Theory.Derivable.toTDerivation _ <| by - simpa using Theory.Derivable.all (by simp) (by simpa using dp.toDerivable) + Derivable.toTDerivation _ <| by + simpa using Derivable.all (by simp) (by simpa using dp.toDerivable) noncomputable def exs {φ : Semiformula V L 1} (t : Term V L) (dp : T ⊢!ᵈᵉʳ insert (φ.subst ![t]) Γ) : T ⊢!ᵈᵉʳ insert (∃⁰ φ) Γ := - Theory.Derivable.toTDerivation _ <| by - simpa using Theory.Derivable.exs (by simp) t.isSemiterm (by simpa using dp.toDerivable) + Derivable.toTDerivation _ <| by + simpa using Derivable.exs (by simp) t.isSemiterm (by simpa using dp.toDerivable) def ofSubset (h : T ⊆ U) (d : T ⊢!ᵈᵉʳ Γ) : U ⊢!ᵈᵉʳ Γ where val := d.val @@ -536,14 +536,14 @@ variable (A : InternalTheory V ℒₒᵣ) open Bootstrapping.Arithmetic -open Entailment Theory.Derivation +open Entailment lemma substItrDisj_right {i z : V} (w : TermVec V ℒₒᵣ m) (φ : Semiformula V ℒₒᵣ (m + 1)) (hi : i < z) : - A ⊢ φ.subst (𝕹 i :> w) 🡒 φ.substItrDisj w z := Theory.Provable.toTProvable <| Theory.Derivable.toProvable <| by - apply Theory.Derivable.or - apply Theory.Derivable.exchange - apply Theory.Derivable.disj (L := ℒₒᵣ) (i := z - (i + 1)) _ + A ⊢ φ.subst (𝕹 i :> w) 🡒 φ.substItrDisj w z := Provable.toTProvable <| Derivable.toProvable <| by + apply Derivable.or + apply Derivable.exchange + apply Derivable.disj (L := ℒₒᵣ) (i := z - (i + 1)) _ · intro i hi have hi : i < z := by simpa using hi rw [substItr_nth _ _ _ hi] @@ -554,7 +554,7 @@ lemma substItrDisj_right {i z : V} have : z - (z - (i + 1) + 1) = i := sub_succ_lt_selfs hi simp only [this, Nat.succ_eq_add_one, Semiformula.val_substs, SemitermVec.val_succ, Matrix.head_cons, Matrix.tail_cons] - apply Theory.Derivable.em (L := ℒₒᵣ) (p := subst ℒₒᵣ (numeral i ∷ SemitermVec.val w) φ.val) + apply Derivable.em (L := ℒₒᵣ) (p := subst ℒₒᵣ (numeral i ∷ SemitermVec.val w) φ.val) · simpa using φ.isSemiformula_succ.subst (w.isSemitermVec.adjoin (numeral_semiterm 0 i)) · simp · simp @@ -566,15 +566,15 @@ lemma substItrDisj_right_intro {ψ} {i z : V} {w : TermVec V ℒₒᵣ m} {φ : lemma substItrConj_right_intro {ψ} {w : TermVec V ℒₒᵣ m} {φ : Semiformula V ℒₒᵣ (m + 1)} {z : V} (h : ∀ i < z, A ⊢ ψ 🡒 φ.subst (𝕹 i :> w)) : - A ⊢ ψ 🡒 φ.substItrConj w z := Theory.Provable.toTProvable <| Theory.Derivable.toProvable <| by - apply Theory.Derivable.or - apply Theory.Derivable.exchange - apply Theory.Derivable.conj + A ⊢ ψ 🡒 φ.substItrConj w z := Provable.toTProvable <| Derivable.toProvable <| by + apply Derivable.or + apply Derivable.exchange + apply Derivable.conj · simp · intro i hi have hi : i < z := by simpa using hi rw [substItr_nth _ _ _ hi] - apply Theory.Derivable.exchange + apply Derivable.exchange suffices A ⊢!ᵈᵉʳ (∼ψ ⫽ φ.subst (𝕹 (z - (i + 1)) :> w) ⫽ ∅) by simpa using this.toDerivable have : A ⊢ ∼ψ ⋎ Semiformula.subst (typedNumeral (z - (i + 1)) :> w) φ := h (z - (i + 1)) (by simp [pos_of_gt hi]) diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Basic.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Basic.lean index 149e2c004..5b4b929e0 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Basic.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Basic.lean @@ -5,7 +5,7 @@ public import Foundation.FirstOrder.Bootstrapping.Syntax.Language @[expose] public section namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] @@ -408,8 +408,8 @@ variable (c) lemma graph_defined : 𝚺₁.Defined (fun v ↦ c.Graph L (v ·.succ.succ) (v 0) (v 1)) (β.graph L) := .mk fun v ↦ by simp [Blueprint.graph, (c.construction L).fixpoint_defined.iff, Graph] -@[simp] lemma eval_graphDef (v) : - Semiformula.Evalbm V v (β.graph L).val ↔ c.Graph L (v ·.succ.succ) (v 0) (v 1) := (graph_defined c).iff +@[simp] lemma eval_graphDef (v : Fin (arity + 2) → V) : + (β.graph L).val.Evalb v ↔ c.Graph L (v ·.succ.succ) (v 0) (v 1) := (graph_defined c).iff instance graph_definable : 𝚺₁.Definable fun v ↦ c.Graph L (v ·.succ.succ) (v 0) (v 1) := (graph_defined c).to_definable @@ -587,8 +587,8 @@ lemma result_defined : 𝚺₁.DefinedFunction (fun v ↦ c.result L (v ·.succ) simp [Blueprint.result, HierarchySymbol.Semiformula.val_sigma, IsUTerm.defined.proper.iff', c.eval_graphDef, result, Classical.choose!_eq_iff_right] -@[simp] lemma result_graphDef (v) : - Semiformula.Evalbm V v (β.result L).val ↔ v 0 = c.result L (v ·.succ.succ) (v 1) := (result_defined c).iff +@[simp] lemma result_graphDef (v : Fin (arity + 2) → V) : + (β.result L).val.Evalb v ↔ v 0 = c.result L (v ·.succ.succ) (v 1) := (result_defined c).iff private lemma resultVec_graph {w' k w} : w' = c.resultVec L param k w ↔ @@ -602,8 +602,7 @@ lemma resultVec_defined : 𝚺₁.DefinedFunction (fun v ↦ c.resultVec L (v · c.eval_graphDef] using c.resultVec_graph lemma eval_resultVec (v : Fin (arity + 3) → V) : - Semiformula.Evalbm V v (β.resultVec L).val ↔ - v 0 = c.resultVec L (v ·.succ.succ.succ) (v 1) (v 2) := c.resultVec_defined.iff + (β.resultVec L).val.Evalb v ↔ v 0 = c.resultVec L (v ·.succ.succ.succ) (v 1) (v 2) := c.resultVec_defined.iff end diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Coding.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Coding.lean index 77318e6f8..6b2230890 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Coding.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Coding.lean @@ -8,7 +8,7 @@ open Encodable LO FirstOrder Arithmetic PeanoMinus Bootstrapping namespace LO.FirstOrder.Semiterm -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Functions.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Functions.lean index b5fae8971..f7577a520 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Functions.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Functions.lean @@ -5,7 +5,7 @@ public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Basic @[expose] public section namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] section diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Typed.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Typed.lean index 705019aa9..8f7d429e2 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Typed.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Term/Typed.lean @@ -11,7 +11,7 @@ public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Functions namespace LO.FirstOrder.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] noncomputable def matrixToVec (v : Fin k → V) : V := Matrix.foldr (fun t w ↦ t ∷ w) 0 v diff --git a/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean b/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean index cf0fef538..4975c8bc5 100644 --- a/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean +++ b/Foundation/FirstOrder/Bootstrapping/Syntax/Theory.lean @@ -5,7 +5,7 @@ public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Coding @[expose] public section namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] @@ -25,10 +25,10 @@ instance Δ₁Class.defined : 𝚫₁-Predicate[V] (· ∈ T.Δ₁Class) via T. constructor · intro v have : V ⊧/![v 0] (Theory.Δ₁.ch T).sigma.val ↔ V ⊧/![v 0] (Theory.Δ₁.ch T).pi.val := by - have := (consequence_iff (T := 𝗜𝚺₁)).mp (sound! <| FirstOrder.Theory.Δ₁.isDelta1 (T := T)) V inferInstance + have := (consequence_iff (T := 𝗜𝚺₁)).mp (Theory.Proof.sound <| FirstOrder.Theory.Δ₁.isDelta1 (T := T)) V inferInstance simp [models_iff] at this ⊢ simpa [Matrix.constant_eq_singleton] using this ![v 0] - rwa [show v = ![v 0] from Matrix.fun_eq_vec_one] + rwa [Matrix.fun_eq_vec_one v] · intro v; simp [←Matrix.fun_eq_vec_one, Theory.Δ₁Class] instance Δ₁Class.definable : 𝚫₁-Predicate[V] (· ∈ T.Δ₁Class) := Δ₁Class.defined.to_definable @@ -63,11 +63,11 @@ namespace Δ₁ open Arithmetic.HierarchySymbol.Semiformula LO.FirstOrder.Theory -instance add (dT : T.Δ₁) (dU : U.Δ₁) : (T + U).Δ₁ where +instance add (dT : T.Δ₁) (dU : U.Δ₁) : (T ∪ U).Δ₁ where ch := T.Δ₁ch ⋎ U.Δ₁ch mem_iff {φ} := by simp only [Nat.succ_eq_add_one, Nat.reduceAdd, val_or, LogicalConnective.HomClass.map_or, - FirstOrder.Arithmetic.Bootstrapping.Δ₁Class.mem_iff'_s, LogicalConnective.Prop.or_eq, add_def, Set.mem_union] + FirstOrder.Arithmetic.Bootstrapping.Δ₁Class.mem_iff'_s, LogicalConnective.Prop.or_eq, Set.mem_union] grind isDelta1 := ProvablyProperOn.ofProperOn.{0} _ fun V _ _ ↦ ProperOn.or (by simp) (by simp) @@ -76,23 +76,6 @@ abbrev ofEq (dT : T.Δ₁) (h : T = U) : U.Δ₁ where mem_iff := by rcases h; exact dT.mem_iff isDelta1 := by rcases h; exact dT.isDelta1 -/- -def add_subset_left (dT : T.Δ₁) (dU : U.Δ₁) : - haveI := dT.add dU - T.codeIn V ⊆ (T + U).codeIn V := by - intro p hp - apply FirstOrder.Semiformula.curve_mem_left - simpa [val_sigma] using hp - -def add_subset_right (dT : T.Δ₁) (dU : U.Δ₁) : - haveI := dT.add dU - U.codeIn V ⊆ (T + U).codeIn V := by - intro p hp - apply FirstOrder.Semiformula.curve_mem_right - simpa [val_sigma] using hp --/ - - instance empty : Theory.Δ₁ (∅ : Theory L) where ch := ⊥ mem_iff {ψ} := by simp @@ -110,15 +93,15 @@ abbrev singleton (φ : Sentence L) : Theory.Δ₁ {φ} where abbrev ofList (l : List (Sentence L)) : Δ₁ {φ | φ ∈ l} := match l with | [] => empty.ofEq (by ext; simp) - | φ :: l => ((singleton φ).add (ofList l)).ofEq (by ext; simp [Theory.add_def]) + | φ :: l => ((singleton φ).add (ofList l)).ofEq (by ext; simp) noncomputable abbrev ofFinite (T : Theory L) (h : Set.Finite T) : T.Δ₁ := (ofList h.toFinset.toList).ofEq (by ext; simp) -instance [T.Δ₁] [U.Δ₁] : (T + U).Δ₁ := add inferInstance inferInstance +instance [T.Δ₁] [U.Δ₁] : (T ∪ U).Δ₁ := add inferInstance inferInstance instance (φ : Sentence L) : Theory.Δ₁ {φ} := singleton φ -instance insert [d : T.Δ₁] : (insert φ T).Δ₁ := (d.add (singleton φ)).ofEq (by ext; simp [Theory.add_def]) +instance insert [d : T.Δ₁] : (insert φ T).Δ₁ := (d.add (singleton φ)).ofEq (by ext; simp) end Δ₁ diff --git a/Foundation/FirstOrder/Hauptsatz.lean b/Foundation/FirstOrder/Hauptsatz.lean index 7f3c48edc..83db9baba 100644 --- a/Foundation/FirstOrder/Hauptsatz.lean +++ b/Foundation/FirstOrder/Hauptsatz.lean @@ -17,7 +17,7 @@ variable {L : Language} inductive Positive (Ξ : Sequent L) : Sequent L → Type _ | or : Positive Ξ (φ :: ψ :: Γ) → Positive Ξ (φ ⋎ ψ :: Γ) | exs : Positive Ξ (φ/[t] :: Γ) → Positive Ξ ((∃⁰ φ) :: Γ) -| wk : Positive Ξ Δ → Δ ⊆ Γ → Positive Ξ Γ +| contraction : Positive Ξ Δ → Δ ⊆ Γ → Positive Ξ Γ | protected id : Positive Ξ Ξ infix:45 " ⟶⁺ " => Positive @@ -26,22 +26,22 @@ namespace Positive variable {Ξ Γ Δ : Sequent L} -def ofSubset (ss : Ξ ⊆ Γ) : Ξ ⟶⁺ Γ := wk .id ss +def ofSubset (ss : Ξ ⊆ Γ) : Ξ ⟶⁺ Γ := contraction .id ss def trans {Ξ Γ Δ : Sequent L} : Ξ ⟶⁺ Γ → Γ ⟶⁺ Δ → Ξ ⟶⁺ Δ | b, or d => or (b.trans d) | b, exs d => exs (b.trans d) - | b, wk d h => wk (b.trans d) h + | b, contraction d h => contraction (b.trans d) h | b, .id => b def cons {Ξ Γ : Sequent L} (φ) : Ξ ⟶⁺ Γ → φ :: Ξ ⟶⁺ φ :: Γ | or (Γ := Γ) (φ := ψ) (ψ := χ) d => - have : φ :: Ξ ⟶⁺ ψ :: χ :: φ :: Γ := wk (cons φ d) (by simp; tauto) - wk (or this) (by simp) + have : φ :: Ξ ⟶⁺ ψ :: χ :: φ :: Γ := contraction (cons φ d) (by simp; tauto) + contraction (or this) (by simp) | exs (Ξ := Ξ) (Γ := Γ) (φ := ψ) (t := t) d => - have : φ :: Ξ ⟶⁺ ψ/[t] :: φ :: Γ := wk (cons φ d) (by simp) - wk this.exs (by simp) - | wk d h => wk (d.cons φ) (by simp [h]) + have : φ :: Ξ ⟶⁺ ψ/[t] :: φ :: Γ := contraction (cons φ d) (by simp) + contraction this.exs (by simp) + | contraction d h => contraction (d.cons φ) (by simp [h]) | .id => .id def append {Ξ Γ : Sequent L} : (Δ : Sequent L) → Ξ ⟶⁺ Γ → Δ ++ Ξ ⟶⁺ Δ ++ Γ @@ -51,13 +51,13 @@ def append {Ξ Γ : Sequent L} : (Δ : Sequent L) → Ξ ⟶⁺ Γ → Δ ++ Ξ def add {Γ Δ Ξ Θ : Sequent L} : Γ ⟶⁺ Δ → Ξ ⟶⁺ Θ → Γ ++ Ξ ⟶⁺ Δ ++ Θ | or d, b => or (d.add b) | exs d, b => exs (d.add b) - | wk d h, b => wk (d.add b) (by simp [h]) + | contraction d h, b => contraction (d.add b) (by simp [h]) | .id, b => b.append Γ def graft {Ξ Γ : Sequent L} (b : ⊢ᴸᴷ¹ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴸᴷ¹ Γ | or d => .or (d.graft b) | exs d => .exs (d.graft b) - | wk d h => .wk (d.graft b) h + | contraction d h => .contraction (d.graft b) h | .id => b lemma graft_isCutFree_of_isCutFree {b : ⊢ᴸᴷ¹ Ξ} {d : Ξ ⟶⁺ Γ} (hb : Derivation.IsCutFree b) : Derivation.IsCutFree (d.graft b) := by @@ -103,7 +103,7 @@ def minLeLeft (p q : ℙ) : p ⊓ q ≼ p := ofSubset (by simp [inf_def]) def minLeRight (p q : ℙ) : p ⊓ q ≼ q := ofSubset (by simp [inf_def]) def leMinOfle (srp : r ≼ p) (srq : r ≼ q) : r ≼ p ⊓ q := ⟨ - let d : ∼p ++ ∼q ⟶⁺ ∼r := .wk (srp.val.add srq.val) (by simp) + let d : ∼p ++ ∼q ⟶⁺ ∼r := .contraction (srp.val.add srq.val) (by simp) neg_inf_p_eq _ _ ▸ d⟩ def leMinRightOfLe (s : q ≼ p) : q ≼ p ⊓ q := leMinOfle s (.refl q) @@ -187,7 +187,7 @@ def explosion {p : ℙ} (b : p ⊩ ⊥) : (φ : Propositionᵢ L) → p ⊩ φ | ⊥ => b | .rel R v => let ⟨d, hd⟩ := b.falsumEquiv - relEquiv.symm ⟨.wk d (by simp), by simp [hd]⟩ + relEquiv.symm ⟨.contraction d (by simp), by simp [hd]⟩ | φ ⋏ ψ => andEquiv.symm ⟨b.explosion φ, b.explosion ψ⟩ | φ ⋎ ψ => orEquiv.symm <| .inl <| b.explosion φ | φ 🡒 ψ => implyEquiv.symm fun q sqp dφ ↦ (b.monotone sqp).explosion ψ diff --git a/Foundation/FirstOrder/Incompleteness/Consistency.lean b/Foundation/FirstOrder/Incompleteness/Consistency.lean index 8573a3925..404be5f95 100644 --- a/Foundation/FirstOrder/Incompleteness/Consistency.lean +++ b/Foundation/FirstOrder/Incompleteness/Consistency.lean @@ -11,7 +11,7 @@ open Classical namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] section WitnessComparisons @@ -21,26 +21,26 @@ section variable (T : Theory L) [T.Δ₁] (V) -def _root_.LO.FirstOrder.Theory.Consistent : Prop := ¬T.Provable (⌜(⊥ : Sentence L)⌝ : V) +def _root_.LO.FirstOrder.Theory.Consistent : Prop := ¬Provable T (⌜(⊥ : Sentence L)⌝ : V) variable {V} -def _root_.LO.FirstOrder.Theory.ConsistentWith (φ : V) : Prop := ¬T.Provable (neg L φ) +def _root_.LO.FirstOrder.Theory.ConsistentWith (φ : V) : Prop := ¬Provable T (neg L φ) lemma _root_.LO.FirstOrder.Theory.ConsistentWith.quote_iff {σ : Sentence L} : - T.ConsistentWith (⌜σ⌝ : V) ↔ ¬T.Provable (⌜∼σ⌝ : V) := by + T.ConsistentWith (⌜σ⌝ : V) ↔ ¬Provable T (⌜∼σ⌝ : V) := by simp [Theory.ConsistentWith, Sentence.quote_def, Semiformula.quote_def] section noncomputable def _root_.LO.FirstOrder.Theory.consistent : 𝚷₁.Sentence := - .mkPi (∼T.provabilityPred ⊥) + .mkPi (∼provabilityPred T ⊥) -@[simp] lemma consistent.defined : Semiformula.Evalbm V ![] (T.consistent : Sentence ℒₒᵣ) ↔ T.Consistent V := by +@[simp] lemma consistent.defined : _root_.LO.FirstOrder.Semiformula.Evalb (M := V) ![] (T.consistent : Sentence ℒₒᵣ) ↔ T.Consistent V := by simp [Theory.consistent, Theory.Consistent] noncomputable def _root_.LO.FirstOrder.Theory.consistentWith : 𝚷₁.Semisentence 1 := .mkPi - “φ. ∀ nφ, !(negGraph L) nφ φ → ¬!T.provable nφ” + “φ. ∀ nφ, !(negGraph L) nφ φ → ¬!(provable T) nφ” instance consistentWith.defined : 𝚷₁-Predicate (T.ConsistentWith : V → Prop) via T.consistentWith := .mk fun v ↦ by simp [Theory.ConsistentWith, Theory.consistentWith] @@ -85,7 +85,7 @@ open Entailment variable (T : ArithmeticTheory) [𝗜𝚺₁ ⪯ T] [T.Δ₁] -instance [ℕ ⊧ₘ* T] : ℕ ⊧ₘ* T + T.Con := by +instance [ℕ↓[ℒₒᵣ] ⊧* T] : ℕ↓[ℒₒᵣ] ⊧* (T ∪ T.Con) := by have : 𝗥₀ ⪯ 𝗜𝚺₁ := inferInstance have : 𝗥₀ ⪯ T := Entailment.WeakerThan.trans this inferInstance have : Entailment.Consistent T := ArithmeticTheory.consistent_of_sound T (Eq ⊥) rfl diff --git a/Foundation/FirstOrder/Incompleteness/First.lean b/Foundation/FirstOrder/Incompleteness/First.lean index b4237cbd7..e651d5a42 100644 --- a/Foundation/FirstOrder/Incompleteness/First.lean +++ b/Foundation/FirstOrder/Incompleteness/First.lean @@ -17,7 +17,7 @@ lemma re_iff_sigma1 {P : ℕ → Prop} : REPred P ↔ 𝚺₁-Predicate P := by intro v simpa [←Matrix.fun_eq_vec_one] using codeOfREPred_spec h (x := v 0) · rintro ⟨φ, hφ⟩ - have : REPred fun x ↦ (Semiformula.Evalm ℕ (x ::ᵥ List.Vector.nil).get id) _ := + have : REPred fun x ↦ (Semiformula.Eval (x ::ᵥ List.Vector.nil).get id) _ := (sigma1_re id (φ.sigma_prop)).comp (Primrec.to_comp <| Primrec.vector_cons.comp .id <| .const _) exact this.of_eq <| by intro x; simpa [List.Vector.cons_get, Matrix.empty_eq] using hφ ![x] @@ -29,10 +29,10 @@ theorem incomplete (T : ArithmeticTheory) [T.Δ₁] [𝗥₀ ⪯ T] [T.SoundOnHi Incomplete T := by have con : Consistent T := inferInstance let D : ℕ → Prop := fun φ : ℕ ↦ - IsSemiformula ℒₒᵣ 1 φ ∧ T.Provable (neg ℒₒᵣ <| subst ℒₒᵣ ?[numeral φ] φ) + IsSemiformula ℒₒᵣ 1 φ ∧ Provable T (neg ℒₒᵣ <| subst ℒₒᵣ ?[numeral φ] φ) have D_re : REPred D := by have : 𝚺₁-Predicate fun φ : ℕ ↦ - IsSemiformula ℒₒᵣ 1 φ ∧ T.Provable (neg ℒₒᵣ <| subst ℒₒᵣ ?[numeral φ] φ) := by + IsSemiformula ℒₒᵣ 1 φ ∧ Provable T (neg ℒₒᵣ <| subst ℒₒᵣ ?[numeral φ] φ) := by definability exact re_iff_sigma1.mpr this have D_spec (φ : Semisentence ℒₒᵣ 1) : D ⌜φ⌝ ↔ T ⊢ ∼φ/[⌜φ⌝] := by @@ -57,13 +57,13 @@ theorem incomplete (T : ArithmeticTheory) [T.Δ₁] [𝗥₀ ⪯ T] [T.SoundOnHi theorem exists_true_but_unprovable_sentence (T : ArithmeticTheory) [T.Δ₁] [𝗥₀ ⪯ T] [T.SoundOnHierarchy 𝚺 1] : - ∃ δ : Sentence ℒₒᵣ, ℕ ⊧ₘ δ ∧ T ⊬ δ := by + ∃ δ : Sentence ℒₒᵣ, ℕ↓[ℒₒᵣ] ⊧ δ ∧ T ⊬ δ := by obtain ⟨δ, hδ⟩ := incomplete_def.mp $ Arithmetic.incomplete T; - by_cases ℕ ⊧ₘ δ + by_cases ℕ↓[ℒₒᵣ] ⊧ δ . exact ⟨δ, by assumption, hδ.1⟩ . exact ⟨∼δ, by simpa, hδ.2⟩ -instance {T : ArithmeticTheory} [ℕ ⊧ₘ* T] [T.Δ₁] [𝗥₀ ⪯ T] [T.SoundOnHierarchy 𝚺 1] : T ⪱ 𝗧𝗔 := by +instance {T : ArithmeticTheory} [ℕ↓[ℒₒᵣ] ⊧* T] [T.Δ₁] [𝗥₀ ⪯ T] [T.SoundOnHierarchy 𝚺 1] : T ⪱ 𝗧𝗔 := by constructor; . infer_instance . obtain ⟨δ, δTrue, δUnprov⟩ := exists_true_but_unprovable_sentence T; diff --git a/Foundation/FirstOrder/Incompleteness/Halting.lean b/Foundation/FirstOrder/Incompleteness/Halting.lean index a7ce6a86e..62f72ab9e 100644 --- a/Foundation/FirstOrder/Incompleteness/Halting.lean +++ b/Foundation/FirstOrder/Incompleteness/Halting.lean @@ -23,14 +23,14 @@ lemma incomplete_of_REPred_not_ComputablePred_Nat' {P : ℕ → Prop} (hRE : REP constructor; . assumption; . suffices REPred fun a : ℕ ↦ T ⊬ φ/[a] by simpa [hP] using this; - have : 𝚺₁-Predicate fun b : ℕ ↦ T.Provable (Bootstrapping.neg ℒₒᵣ <| Bootstrapping.subst ℒₒᵣ ?[Bootstrapping.Arithmetic.numeral b] ⌜φ⌝) := by clear hP; definability; + have : 𝚺₁-Predicate fun b : ℕ ↦ Provable T (Bootstrapping.neg ℒₒᵣ <| Bootstrapping.subst ℒₒᵣ ?[Bootstrapping.Arithmetic.numeral b] ⌜φ⌝) := by clear hP; definability; apply REPred.of_eq (re_iff_sigma1.mpr this); intro a; push Not at h; apply Iff.trans ?_ $ show T ⊢ ∼φ/[a] ↔ ¬T ⊢ φ/[a] by simpa [hP] using h a |>.symm; constructor; . rintro hP - apply Theory.Provable.sound + apply Bootstrapping.Provable.sound simpa [Sentence.quote_def, Semiformula.quote_def, Rewriting.emb_subst_eq_subst_coe₁] using hP; . rintro hφ simpa [Sentence.quote_def, Semiformula.quote_def, Rewriting.emb_subst_eq_subst_coe₁] using diff --git a/Foundation/FirstOrder/Incompleteness/Jeroslow.lean b/Foundation/FirstOrder/Incompleteness/Jeroslow.lean index 4d4f450d3..cc7dcddd8 100644 --- a/Foundation/FirstOrder/Incompleteness/Jeroslow.lean +++ b/Foundation/FirstOrder/Incompleteness/Jeroslow.lean @@ -33,17 +33,17 @@ section variable [L.Encodable] [L.LORDefinable] {T : Theory L} [T.Δ₁] -def Refutable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] (T : Theory L) [T.Δ₁] (φ : V) : Prop - := T.Provable (neg L φ) +def Refutable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] (T : Theory L) [T.Δ₁] (φ : V) : Prop + := Provable T (neg L φ) noncomputable def refutable (T : Theory L) [T.Δ₁] : 𝚺₁.Semisentence 1 - := .mkSigma “φ. ∃ nφ, !(negGraph L) nφ φ ∧ !T.provable nφ” + := .mkSigma “φ. ∃ nφ, !(negGraph L) nφ φ ∧ !(provable T) nφ” section -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] -lemma Refutable.quote_iff {σ : Sentence L} : T.Refutable (⌜σ⌝ : V) ↔ T.Provable (⌜∼σ⌝ : V) := by +lemma Refutable.quote_iff {σ : Sentence L} : T.Refutable (⌜σ⌝ : V) ↔ Provable T (⌜∼σ⌝ : V) := by simp [Theory.Refutable, Sentence.quote_def, Semiformula.quote_def] instance refutable_defined : 𝚺₁-Predicate[V] T.Refutable via T.refutable := .mk fun v ↦ by @@ -62,7 +62,7 @@ variable {T U : ArithmeticTheory} [T.Δ₁] noncomputable abbrev standardRefutability (T : ArithmeticTheory) [T.Δ₁] : Refutability 𝗜𝚺₁ T where refu := T.refutable.val - refu_def {σ} h := provable_of_models _ _ fun (V : Type) _ _ ↦ by + refu_def {σ} h := complete 𝗜𝚺₁ _ fun (V : Type) _ _ ↦ by simpa [models_iff, Refutable.quote_iff] using internalize_provability h (V := V) noncomputable abbrev jeroslow (T : ArithmeticTheory) [T.Δ₁] : ArithmeticSentence := fixedpoint T.refutable @@ -122,7 +122,7 @@ theorem unprovable_jeroslow [𝗜𝚺₁ ⪯ T] [T.SoundOnHierarchy 𝚺 1] is not provable in `T` itself. -/ theorem unprovable_formalized_law_of_noncontradiction [𝗜𝚺₁ ⪯ T] [Entailment.Consistent T] - : T ⊬ (∀⁰ ∼(T.provable ⋏ T.refutable) : ArithmeticSentence) := by + : T ⊬ (∀⁰ ∼(provable T ⋏ T.refutable) : ArithmeticSentence) := by simpa [flon, safe, -DeMorgan.and] using ProvabilityAbstraction.unprovable_flon (𝔅 := T.standardProvability) (𝔚 := T.standardRefutability) diff --git "a/Foundation/FirstOrder/Incompleteness/L\303\266b.lean" "b/Foundation/FirstOrder/Incompleteness/L\303\266b.lean" index 7281af3c6..87ac98921 100644 --- "a/Foundation/FirstOrder/Incompleteness/L\303\266b.lean" +++ "b/Foundation/FirstOrder/Incompleteness/L\303\266b.lean" @@ -9,14 +9,14 @@ public import Foundation.FirstOrder.Incompleteness.StandardProvability namespace LO.FirstOrder.Arithmetic -open LO.Entailment ProvabilityAbstraction +open LO.Entailment Bootstrapping ProvabilityAbstraction variable {T : ArithmeticTheory} [T.Δ₁] [𝗜𝚺₁ ⪯ T] {σ : ArithmeticSentence} -theorem löb_theorem : T ⊢ T.provabilityPred σ 🡒 σ → T ⊢ σ := +theorem löb_theorem : T ⊢ provabilityPred T σ 🡒 σ → T ⊢ σ := ProvabilityAbstraction.löb_theorem (𝔅 := T.standardProvability) -theorem formalized_löb_theorem : 𝗜𝚺₁ ⊢ T.provabilityPred (T.provabilityPred σ 🡒 σ) 🡒 T.provabilityPred σ := +theorem formalized_löb_theorem : 𝗜𝚺₁ ⊢ provabilityPred T (provabilityPred T σ 🡒 σ) 🡒 provabilityPred T σ := ProvabilityAbstraction.formalized_löb_theorem (𝔅 := T.standardProvability) end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Basic.lean b/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Basic.lean index 78523350d..e1ff4b549 100644 --- a/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Basic.lean +++ b/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Basic.lean @@ -101,14 +101,17 @@ class SoundOn [L.ReferenceableBy L₀] {T₀ : Theory L₀} {T : Theory L} (𝔅 : Provability T₀ T) (M : outParam Type*) [Nonempty M] [Structure L₀ M] where - sound_on {σ} : M ⊧ₘ 𝔅 σ → T ⊢ σ + sound_on {σ : Sentence L} : M↓[L₀] ⊧ (𝔅 σ : Sentence L₀) → T ⊢ σ export SoundOn (sound_on) attribute [simp, grind .] sound_on -lemma syntactical_sound (M) [Nonempty M] [Structure L M] [SoundOn 𝔅 M] [M ⊧ₘ* T₀] : ∀ {σ}, T₀ ⊢ 𝔅 σ → T ⊢ σ := by +omit [L.ReferenceableBy L₀] in +lemma syntactical_sound {T₀ T : Theory L} {𝔅 : Provability T₀ T} + (M : Type*) [Nonempty M] [Structure L M] [SoundOn 𝔅 M] [M↓[L] ⊧* T₀] : + ∀ {σ : Sentence L}, T₀ ⊢ 𝔅 σ → T ⊢ σ := by intro σ h; apply 𝔅.sound_on; - apply models_of_provable (T := T₀); + apply models_of_provable (L := L) (T := T₀); . infer_instance; . exact h; diff --git a/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Refutability.lean b/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Refutability.lean index a36ad305c..b428edd50 100644 --- a/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Refutability.lean +++ b/Foundation/FirstOrder/Incompleteness/ProvabilityAbstraction/Refutability.lean @@ -117,7 +117,7 @@ lemma jeroslow_not_safe [𝔅.FormalizedCompleteOn 𝐉] : T ⊢ 𝐉 🡒 (𝔅 lemma unprovable_flon [consis : Consistent T] [𝔅.FormalizedCompleteOn 𝐉] : T ⊬ flon 𝔅 𝔚 := by contrapose! consis; replace consis : T ⊢ ∀⁰ safe 𝔅 𝔚 := by simpa [flon] using consis; - have h₁ : T ⊢ ∼(𝔅 𝐉 ⋏ 𝔚 𝐉) := by simpa [safe] using FirstOrder.Theory.specialize _ _ ⨀ consis; + have h₁ : T ⊢ ∼(𝔅 𝐉 ⋏ 𝔚 𝐉) := by simpa [safe] using FirstOrder.Theory.Proof.specialize _ _ ⨀ consis; have h₂ : T ⊢ ∼𝐉 := (contra! jeroslow_not_safe) ⨀ h₁; have h₃ : T ⊢ 𝐉 🡘 𝔚 𝐉 := jeroslow_def'; have h₄ : T ⊢ 𝔚 𝐉 := R1' h₂; diff --git a/Foundation/FirstOrder/Incompleteness/RestrictedProvability.lean b/Foundation/FirstOrder/Incompleteness/RestrictedProvability.lean index 04a052e0a..4fb0906b0 100644 --- a/Foundation/FirstOrder/Incompleteness/RestrictedProvability.lean +++ b/Foundation/FirstOrder/Incompleteness/RestrictedProvability.lean @@ -16,15 +16,15 @@ open PeanoMinus ISigma0 ISigma1 Bootstrapping Derivation namespace Theory -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] variable {T U : Theory L} [T.Δ₁] [U.Δ₁] /-- Provability with restriction of proof size -/ -def RestrictedProvable (e : ℕ) (T : Theory L) [T.Δ₁] (φ : V) := ∃ d < Exp.exp (ORingStructure.numeral e), T.Proof d φ +def RestrictedProvable (e : ℕ) (T : Theory L) [T.Δ₁] (φ : V) := ∃ d < Exp.exp (ORingStructure.numeral e), Arithmetic.Bootstrapping.Proof T d φ -noncomputable def restrictedProvable (e : ℕ) : 𝚷₁.Semisentence 1 := .mkPi “φ. ∀ E, !expDef E !e → ∃ d < E, !T.proof.pi d φ” +noncomputable def restrictedProvable (e : ℕ) : 𝚷₁.Semisentence 1 := .mkPi “φ. ∀ E, !expDef E !e → ∃ d < E, !(proof T).pi d φ” noncomputable abbrev restrictedProvabilityPred (e : ℕ) (σ : Sentence L) : ArithmeticSentence := (T.restrictedProvable e).val/[⌜σ⌝] @@ -43,7 +43,7 @@ end Theory namespace Arithmetic -variable {V : Type} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {T U : ArithmeticTheory} [T.Δ₁] -- [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] variable {e : ℕ} @@ -59,22 +59,22 @@ private lemma provable_E_restrictedGödel_restrictedGödel' [𝗜𝚺₁ ⪯ U] private lemma iff_provable_restrictedGödel_provable_restrictedGödel' [𝗜𝚺₁ ⪯ U] : U ⊢ (T.restrictedGödel e) ↔ U ⊢ (T.restrictedGödel' e) := by apply Entailment.iff_of_E! provable_E_restrictedGödel_restrictedGödel'; -private lemma iff_true_restrictedGödel_true_restrictedGödel' : ℕ ⊧ₘ (T.restrictedGödel e) ↔ ℕ ⊧ₘ (T.restrictedGödel' e) := by +private lemma iff_true_restrictedGödel_true_restrictedGödel' : ℕ↓[ℒₒᵣ] ⊧ (T.restrictedGödel e) ↔ ℕ↓[ℒₒᵣ] ⊧ (T.restrictedGödel' e) := by apply Semantics.models_iff.mp; apply models_of_provable (T := 𝗜𝚺₁) inferInstance; apply provable_E_restrictedGödel_restrictedGödel'; -lemma models_restrictedGödel : V ⊧ₘ T.restrictedGödel e ↔ ∀ x : V, x < Exp.exp (ORingStructure.numeral e) → ¬T.Proof x (⌜T.restrictedGödel e⌝) := by +lemma models_restrictedGödel : V↓[ℒₒᵣ] ⊧ T.restrictedGödel e ↔ ∀ x : V, x < Exp.exp (ORingStructure.numeral e) → ¬Arithmetic.Bootstrapping.Proof T x (⌜T.restrictedGödel e⌝) := by apply Iff.trans $ Semantics.models_iff.mp $ models_of_provable (T := 𝗜𝚺₁) inferInstance $ def_restrictedGödel; simp [models_iff, Theory.RestrictedProvable] -private lemma models_neg_restrictedGödel : ¬V ⊧ₘ T.restrictedGödel e ↔ ∃ x : V, x < Exp.exp (ORingStructure.numeral e) ∧ T.Proof x (⌜T.restrictedGödel e⌝) := by +private lemma models_neg_restrictedGödel : ¬V↓[ℒₒᵣ] ⊧ T.restrictedGödel e ↔ ∃ x : V, x < Exp.exp (ORingStructure.numeral e) ∧ Arithmetic.Bootstrapping.Proof T x (⌜T.restrictedGödel e⌝) := by simpa using models_restrictedGödel.not; variable [𝗜𝚺₁ ⪯ T] [T.SoundOnHierarchy 𝚺 1] /- Gödel sentence by restricted provability is true. -/ -theorem true_restrictedGödel : ℕ ⊧ₘ T.restrictedGödel e := by +theorem true_restrictedGödel : ℕ↓[ℒₒᵣ] ⊧ T.restrictedGödel e := by by_contra hC; obtain ⟨e, _, he⟩ := models_neg_restrictedGödel (e := e) |>.mp hC; apply hC; diff --git a/Foundation/FirstOrder/Incompleteness/RosserProvability.lean b/Foundation/FirstOrder/Incompleteness/RosserProvability.lean index 2024802d4..335200dbb 100644 --- a/Foundation/FirstOrder/Incompleteness/RosserProvability.lean +++ b/Foundation/FirstOrder/Incompleteness/RosserProvability.lean @@ -9,7 +9,7 @@ public import Foundation.FirstOrder.Incompleteness.WitnessComparison namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {L : Language} [L.Encodable] [L.LORDefinable] @@ -42,20 +42,20 @@ lemma rosser_quote₀ {φ : Sentence L} : T.RosserProvable (V := V) ⌜φ⌝ ↔ simpa [Sentence.quote_def] using rosser_quote lemma rosser_quote_def {φ : Proposition L} : - T.RosserProvable (V := V) ⌜φ⌝ ↔ ∃ b : V, T.Proof b ⌜φ⌝ ∧ ∀ b' < b, ¬T.Proof b' ⌜∼φ⌝ := rosser_quote + T.RosserProvable (V := V) ⌜φ⌝ ↔ ∃ b : V, Proof T b ⌜φ⌝ ∧ ∀ b' < b, ¬Proof T b' ⌜∼φ⌝ := rosser_quote lemma rosser_quote_def₀ {φ : Sentence L} : - T.RosserProvable (V := V) ⌜φ⌝ ↔ ∃ b : V, T.Proof b ⌜φ⌝ ∧ ∀ b' < b, ¬T.Proof b' ⌜∼φ⌝ := by simpa [Sentence.quote_def] using rosser_quote + T.RosserProvable (V := V) ⌜φ⌝ ↔ ∃ b : V, Proof T b ⌜φ⌝ ∧ ∀ b' < b, ¬Proof T b' ⌜∼φ⌝ := by simpa [Sentence.quote_def] using rosser_quote -def RosserProvable.to_provable {φ : V} : T.RosserProvable φ → T.Provable φ := ProvabilityComparison.le_to_provable +def RosserProvable.to_provable {φ : V} : T.RosserProvable φ → Provable T φ := ProvabilityComparison.le_to_provable -lemma provable_of_standard_proof {n : ℕ} {φ : Sentence L} : T.Proof (n : V) ⌜φ⌝ → T ⊢ φ := fun h ↦ by - have : T.Proof n ⌜φ⌝ ↔ T.Proof (↑n : V) ⌜φ⌝ := by +lemma provable_of_standard_proof {n : ℕ} {φ : Sentence L} : Proof T (n : V) ⌜φ⌝ → T ⊢ φ := fun h ↦ by + have : Proof T n ⌜φ⌝ ↔ Proof T (↑n : V) ⌜φ⌝ := by simpa [Sentence.coe_quote_eq_quote] using - Defined.shigmaOne_absolute V (φ := T.proof) - (R := fun v ↦ T.Proof (v 0) (v 1)) (R' := fun v ↦ T.Proof (v 0) (v 1)) - Theory.Proof.defined Theory.Proof.defined ![n, ⌜φ⌝] - have : T.Provable (⌜φ⌝ : ℕ) := ⟨n, this.mpr h⟩ + Defined.shigmaOne_absolute V (φ := proof T) + (R := fun v ↦ Proof T (v 0) (v 1)) (R' := fun v ↦ Proof T (v 0) (v 1)) + Proof.defined Proof.defined ![n, ⌜φ⌝] + have : Provable T (⌜φ⌝ : ℕ) := ⟨n, this.mpr h⟩ exact provable_iff_provable.mp this open Classical @@ -63,7 +63,7 @@ open Classical def rosser_internalize [Entailment.Consistent T] {φ : Sentence L} : T ⊢ φ → T.RosserProvable (⌜φ⌝ : V) := by intro h let n : ℕ := ⌜h.get⌝ - have hn : T.Proof (↑n : V) ⌜φ⌝ := by simp [n, coe_quote_proof_eq] + have hn : Proof T (↑n : V) ⌜φ⌝ := by simp [n, coe_quote_proof_eq] refine rosser_quote_def₀.mpr ⟨n, hn, ?_⟩ intro b hb Hb rcases eq_nat_of_lt_nat hb with ⟨b, rfl⟩ @@ -79,7 +79,7 @@ open Classical in def not_rosserProvable [Entailment.Consistent T] {φ : Sentence L} : T ⊢ ∼φ → ¬T.RosserProvable (⌜φ⌝ : V) := by rintro h r let n : ℕ := ⌜h.get⌝ - have hn : T.Proof (↑n : V) ⌜∼φ⌝ := by simp [n, coe_quote_proof_eq] + have hn : Proof T (↑n : V) ⌜∼φ⌝ := by simp [n, coe_quote_proof_eq] rcases rosser_quote₀.mp r with ⟨b, hb, Hb⟩ have : b ≤ n := by grind; rcases eq_nat_of_le_nat this with ⟨b, rfl⟩ @@ -106,11 +106,11 @@ variable {T : Theory L} [T.Δ₁] [Entailment.Consistent T] local prefix:90 "𝗥" => T.rosserPred theorem rosserProvable_D1 {σ} : T ⊢ σ → 𝗜𝚺₁ ⊢ 𝗥σ := fun h ↦ - provable_of_models _ _ fun (V : Type) _ _ ↦ by + complete 𝗜𝚺₁ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using rosser_internalize_sentence h theorem rosserProvable_rosser {σ} : T ⊢ ∼σ → 𝗜𝚺₁ ⊢ ∼𝗥σ := fun h ↦ - provable_of_models _ _ fun (V : Type) _ _ ↦ by + complete 𝗜𝚺₁ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using not_rosserProvable_sentence h end diff --git a/Foundation/FirstOrder/Incompleteness/Second.lean b/Foundation/FirstOrder/Incompleteness/Second.lean index 78fe53208..a835ffb90 100644 --- a/Foundation/FirstOrder/Incompleteness/Second.lean +++ b/Foundation/FirstOrder/Incompleteness/Second.lean @@ -28,11 +28,11 @@ theorem inconsistent_independent [ArithmeticTheory.SoundOnHierarchy T 𝚺 1] : instance [Consistent T] : T ⪱ T + T.Con := StrictlyWeakerThan.of_unprovable_provable (φ := ↑T.consistent) (consistent_unprovable T) - (Entailment.by_axm _ (by simp [Theory.add_def])) + (Entailment.by_axm (by simp [Theory.add_def])) instance [ArithmeticTheory.SoundOnHierarchy T 𝚺 1] : T ⪱ T + T.Incon := StrictlyWeakerThan.of_unprovable_provable (φ := ∼↑T.consistent) (inconsistent_unprovable T) - (Entailment.by_axm _ (by simp [Theory.add_def])) + (Entailment.by_axm (by simp [Theory.add_def])) end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Incompleteness/StandardProvability.lean b/Foundation/FirstOrder/Incompleteness/StandardProvability.lean index 856ccce79..e666b03f5 100644 --- a/Foundation/FirstOrder/Incompleteness/StandardProvability.lean +++ b/Foundation/FirstOrder/Incompleteness/StandardProvability.lean @@ -23,27 +23,27 @@ section variable {L : Language} [L.Encodable] [L.LORDefinable] {T : Theory L} [T.Δ₁] -local prefix:90 "□" => T.provabilityPred +local prefix:90 "□" => provabilityPred T /-- The derivability condition D1. -/ theorem provable_D1 {σ} : T ⊢ σ → 𝗜𝚺₁ ⊢ □σ := fun h ↦ - provable_of_models _ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using internalize_provability (V := V) h + complete 𝗜𝚺₁ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using internalize_provability (V := V) h /-- The derivability condition D2. -/ theorem provable_D2 {σ π} : 𝗜𝚺₁ ⊢ □(σ 🡒 π) 🡒 □σ 🡒 □π := - provable_of_models _ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using modus_ponens_sentence T + complete 𝗜𝚺₁ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using modus_ponens_sentence T variable (T) noncomputable abbrev _root_.LO.FirstOrder.Theory.standardProvability : Provability 𝗜𝚺₁ T where - prov := T.provable + prov := provable T bew_def := provable_D1 variable {T} instance : T.standardProvability.HBL2 := ⟨provable_D2⟩ -lemma standardProvability_def (σ : Sentence L) : T.standardProvability σ = T.provabilityPred σ := rfl +lemma standardProvability_def (σ : Sentence L) : T.standardProvability σ = provabilityPred T σ := rfl instance [T.Δ₁] : T.standardProvability.SoundOn ℕ := ⟨fun h ↦ by simpa [Arithmetic.standardProvability_def, models_iff] using h⟩ @@ -54,11 +54,11 @@ section arithmetic variable {T U : ArithmeticTheory} [T.Δ₁] -local prefix:90 "□" => T.provabilityPred +local prefix:90 "□" => provabilityPred T lemma provable_sigma_one_complete [𝗣𝗔⁻ ⪯ T] {σ : Sentence ℒₒᵣ} (hσ : Hierarchy 𝚺 1 σ) : 𝗜𝚺₁ ⊢ σ 🡒 □σ := - provable_of_models _ _ fun (V : Type) _ _ ↦ by + complete 𝗜𝚺₁ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using Bootstrapping.Arithmetic.sigma_one_complete (T := T) (V := V) hσ /-- The derivability condition D3. -/ @@ -68,13 +68,13 @@ theorem provable_D3 [𝗣𝗔⁻ ⪯ T] {σ : Sentence ℒₒᵣ} : open LO.Entailment LO.Entailment.FiniteContext lemma provable_D2_context [𝗜𝚺₁ ⪯ U] {Γ σ π} (hσπ : Γ ⊢[U] □(σ 🡒 π)) (hσ : Γ ⊢[U] □σ) : - Γ ⊢[U] □π := FiniteContext.of'! (weakening inferInstance provable_D2) ⨀! hσπ ⨀! hσ + Γ ⊢[U] □π := FiniteContext.of'! (weakening inferInstance provable_D2) ⨀ hσπ ⨀ hσ lemma provable_D3_context [𝗣𝗔⁻ ⪯ T] [𝗜𝚺₁ ⪯ U] {Γ σ} (hσπ : Γ ⊢[U] □σ) : - Γ ⊢[U] □□σ := FiniteContext.of'! (weakening inferInstance provable_D3) ⨀! hσπ + Γ ⊢[U] □□σ := FiniteContext.of'! (weakening inferInstance provable_D3) ⨀ hσπ lemma provable_sound [U.SoundOnHierarchy 𝚺 1] {σ} : U ⊢ □σ → T ⊢ σ := fun h ↦ by - have : ℕ ⊧ₘ T.provabilityPred σ := ArithmeticTheory.SoundOn.sound (F := Arithmetic.Hierarchy 𝚺 1) h (by simp) + have : ℕ↓[ℒₒᵣ] ⊧ provabilityPred T σ := ArithmeticTheory.SoundOn.sound (F := Arithmetic.Hierarchy 𝚺 1) h (by simp) simpa [models_iff] using this lemma provable_complete [U.SoundOnHierarchy 𝚺 1] [𝗜𝚺₁ ⪯ U] {σ} : T ⊢ σ ↔ U ⊢ □σ := diff --git a/Foundation/FirstOrder/Incompleteness/Tarski.lean b/Foundation/FirstOrder/Incompleteness/Tarski.lean index 69a55126e..a410e1ce6 100644 --- a/Foundation/FirstOrder/Incompleteness/Tarski.lean +++ b/Foundation/FirstOrder/Incompleteness/Tarski.lean @@ -18,7 +18,7 @@ lemma not_exists_tarski_predicate : ¬∃ τ : Semisentence ℒₒᵣ 1, ∀ σ, cl_prover [h₁, h₂]; /-- Tarski's Undefinability of Truth Theorem. -/ -theorem undefinability_of_truth : ¬∃ τ : Semisentence ℒₒᵣ 1, ∀ σ : Sentence ℒₒᵣ, ℕ ⊧ₘ σ ↔ ℕ ⊧ₘ τ/[⌜σ⌝] := by +theorem undefinability_of_truth : ¬∃ τ : Semisentence ℒₒᵣ 1, ∀ σ : Sentence ℒₒᵣ, ℕ↓[ℒₒᵣ] ⊧ σ ↔ ℕ↓[ℒₒᵣ] ⊧ τ/[⌜σ⌝] := by have := not_exists_tarski_predicate (T := 𝗧𝗔); contrapose! this; obtain ⟨τ, hτ⟩ := this; diff --git a/Foundation/FirstOrder/Incompleteness/WitnessComparison.lean b/Foundation/FirstOrder/Incompleteness/WitnessComparison.lean index 1266e6145..94a5d6bf2 100644 --- a/Foundation/FirstOrder/Incompleteness/WitnessComparison.lean +++ b/Foundation/FirstOrder/Incompleteness/WitnessComparison.lean @@ -9,7 +9,7 @@ public import Foundation.FirstOrder.Incompleteness.StandardProvability namespace LO.FirstOrder.Arithmetic.Bootstrapping -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] section WitnessComparisons @@ -18,15 +18,15 @@ variable {L : Language} [L.Encodable] [L.LORDefinable] variable (T : Theory L) [T.Δ₁] def _root_.LO.FirstOrder.Theory.ProvabilityComparisonLE (φ ψ : V) : Prop := - ∃ b, T.Proof b φ ∧ ∀ b' < b, ¬T.Proof b' ψ + ∃ b, Proof T b φ ∧ ∀ b' < b, ¬Proof T b' ψ def _root_.LO.FirstOrder.Theory.ProvabilityComparisonLT (φ ψ : V) : Prop := - ∃ b, T.Proof b φ ∧ ∀ b' ≤ b, ¬T.Proof b' ψ + ∃ b, Proof T b φ ∧ ∀ b' ≤ b, ¬Proof T b' ψ section noncomputable def _root_.LO.FirstOrder.Theory.provabilityComparisonLE : 𝚺₁.Semisentence 2 := .mkSigma - “φ ψ. ∃ b, !T.proof.sigma b φ ∧ ∀ b' < b, ¬!T.proof.pi b' ψ” + “φ ψ. ∃ b, !(proof T).sigma b φ ∧ ∀ b' < b, ¬!(proof T).pi b' ψ” instance _root_.LO.FirstOrder.Theory.provability_comparison_le_defined : 𝚺₁-Relation[V] T.ProvabilityComparisonLE via T.provabilityComparisonLE := .mk fun v ↦ by @@ -41,7 +41,7 @@ instance _root_.LO.FirstOrder.Theory.provability_comparison_le_definable' : noncomputable def _root_.LO.FirstOrder.Theory.provabilityComparisonLT : 𝚺₁.Semisentence 2 := .mkSigma - “φ ψ. ∃ b, !T.proof.sigma b φ ∧ ∀ b' <⁺ b, ¬!T.proof.pi b' ψ” + “φ ψ. ∃ b, !(proof T).sigma b φ ∧ ∀ b' <⁺ b, ¬!(proof T).pi b' ψ” instance _root_.LO.FirstOrder.Theory.provability_comparison_lt_defined : 𝚺₁-Relation[V] T.ProvabilityComparisonLT via T.provabilityComparisonLT := .mk fun v ↦ by @@ -64,7 +64,7 @@ variable {φ ψ χ : V} local infixl:50 "≼" => T.ProvabilityComparisonLE local infixl:50 "≺" => T.ProvabilityComparisonLT -local prefix:50 "□" => T.Provable +local prefix:50 "□" => Provable T @[grind =>] lemma le_of_lt : φ ≺ ψ → φ ≼ ψ := by rintro ⟨b, _⟩; exact ⟨b, by grind⟩ @@ -82,7 +82,7 @@ lemma le_antisymm : φ ≼ ψ → ψ ≼ φ → φ = ψ := by by_contra ne wlog lt : b < d · grind; - have : ¬T.Proof b φ := Hd b lt + have : ¬Proof T b φ := Hd b lt contradiction have : ({φ} : V) = {ψ} := by simp [←hb.1, ←hd.1, this] simpa using this @@ -92,13 +92,13 @@ lemma iff_le_refl_provable : φ ≼ φ ↔ □φ := by constructor · exact le_to_provable · rintro ⟨b, hb⟩ - have : ∃ b, T.Proof b φ ∧ ∀ z < b, ¬T.Proof z φ := - InductionOnHierarchy.least_number_sigma 𝚺 1 (P := (T.Proof · φ)) (by definability) hb + have : ∃ b, Proof T b φ ∧ ∀ z < b, ¬Proof T z φ := + InductionOnHierarchy.least_number_sigma 𝚺 1 (P := (Proof T · φ)) (by definability) hb rcases this with ⟨b, bd, h⟩ exact ⟨b, bd, h⟩ @[grind .] -lemma lt_irrefl : ¬φ ≺ φ := by rintro ⟨b, hb, h⟩; have : ¬T.Proof b φ := h b (by simp); contradiction +lemma lt_irrefl : ¬φ ≺ φ := by rintro ⟨b, hb, h⟩; have : ¬Proof T b φ := h b (by simp); contradiction @[grind =>] lemma lt_trans : φ ≺ ψ → ψ ≺ χ → φ ≺ χ := by rintro ⟨b, hb, h⟩ ⟨d, hd, H⟩; use b; grind; @@ -110,10 +110,10 @@ lemma not_lt_of_le : φ ≼ ψ → ¬ψ ≺ φ := by grind; lemma find_minimal_proof_fintype [Fintype ι] (φ : ι → V) (H : □(φ i)) : ∃ j, ∀ k, (φ j) ≼ (φ k) := by - rcases show ∃ dᵢ, T.Proof dᵢ (φ i)from H with ⟨dᵢ, Hdᵢ⟩ - have : ∃ z, (∃ j, T.Proof z (φ j)) ∧ ∀ w < z, ∀ x, ¬T.Proof w (φ x) := by + rcases show ∃ dᵢ, Proof T dᵢ (φ i)from H with ⟨dᵢ, Hdᵢ⟩ + have : ∃ z, (∃ j, Proof T z (φ j)) ∧ ∀ w < z, ∀ x, ¬Proof T w (φ x) := by simpa using - InductionOnHierarchy.least_number_sigma 𝚺 1 (P := fun z ↦ ∃ j, T.Proof z (φ j)) + InductionOnHierarchy.least_number_sigma 𝚺 1 (P := fun z ↦ ∃ j, Proof T z (φ j)) (HierarchySymbol.Definable.fintype_exs fun j ↦ by definability) (x := dᵢ) ⟨i, Hdᵢ⟩ rcases this with ⟨z, ⟨j, hj⟩, H⟩ exact ⟨j, fun k ↦ ⟨z, hj, fun w hw ↦ H w hw k⟩⟩ diff --git a/Foundation/FirstOrder/Incompleteness/Yablo.lean b/Foundation/FirstOrder/Incompleteness/Yablo.lean index 0a180ff85..365d229e8 100644 --- a/Foundation/FirstOrder/Incompleteness/Yablo.lean +++ b/Foundation/FirstOrder/Incompleteness/Yablo.lean @@ -13,7 +13,7 @@ namespace LO.FirstOrder.Arithmetic open ORingStructure -variable {M : Type*} [ORingStructure M] [M ⊧ₘ* 𝗣𝗔⁻] +variable {M : Type*} [ORingStructure M] [M↓[ℒₒᵣ] ⊧* 𝗣𝗔⁻] lemma numeral_lt_of_numeral_succ_lt {n : ℕ} {m : M} : (numeral (n + 1) : M) < m → (numeral n < m) := by apply Arithmetic.lt_trans; @@ -23,7 +23,7 @@ end LO.FirstOrder.Arithmetic namespace LO.FirstOrder.Arithmetic.Bootstrapping.Arithmetic -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] lemma substNumeral_app_quote_nat_model (σ : Semisentence ℒₒᵣ 1) (n : ℕ) : substNumeral ⌜σ⌝ (n : V) = ⌜(σ/[.numeral n] : Sentence ℒₒᵣ)⌝ := by @@ -47,12 +47,12 @@ open FirstOrder Arithmetic Bootstrapping Bootstrapping.Arithmetic namespace Theory -variable {V} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] {T U : ArithmeticTheory} [T.Δ₁] +variable {V} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] {T U : ArithmeticTheory} [T.Δ₁] -def YabloSystem (T : ArithmeticTheory) [T.Δ₁] (φ n : V) : Prop := ∀ m, n < m → ¬T.Provable (substNumeral φ m) +def YabloSystem (T : ArithmeticTheory) [T.Δ₁] (φ n : V) : Prop := ∀ m, n < m → ¬Provable T (substNumeral φ m) noncomputable def yabloSystem (T : ArithmeticTheory) [T.Δ₁] : 𝚷₁.Semisentence 2 := .mkPi - “φ n. ∀ m, n < m → ∀ nσ, !ssnum nσ φ m → ¬!T.provable (nσ)” + “φ n. ∀ m, n < m → ∀ nσ, !ssnum nσ φ m → ¬!(provable T) (nσ)” instance yabloSystem.defined : 𝚷₁-Relation[V] (T.YabloSystem) via T.yabloSystem := .mk fun f ↦ by simp [Theory.YabloSystem, Theory.yabloSystem]; @@ -74,48 +74,49 @@ open Theory -- Lemmata section -variable {V : Type} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] variable {U : ArithmeticTheory} [𝗜𝚺₁ ⪯ U] lemma yablo_diagonal : U ⊢ ∀⁰ (T.yablo 🡘 (T.yabloSystem)/[⌜T.yablo⌝, #0]) := parameterized_diagonal₁ _ -lemma yablo_diagonal_modeled (n : V) : V ⊧/![n] (T.yablo) ↔ ∀ m, n < m → ¬T.Provable (substNumeral ⌜T.yablo⌝ m) := by - have : V ⊧ₘ ∀⁰ (T.yablo 🡘 ↑(T.yabloSystem)/[⌜T.yablo⌝, #0]) := models_of_provable (T := 𝗜𝚺₁) (by assumption) $ yablo_diagonal; +lemma yablo_diagonal_modeled (n : V) : V ⊧/![n] (T.yablo) ↔ ∀ m, n < m → ¬Provable T (substNumeral ⌜T.yablo⌝ m) := by + have : V↓[ℒₒᵣ] ⊧ ∀⁰ (T.yablo 🡘 ↑(T.yabloSystem)/[⌜T.yablo⌝, #0]) := models_of_provable (T := 𝗜𝚺₁) (by assumption) $ yablo_diagonal; have : ∀ (n : V), V ⊧/![n] (T.yablo) ↔ T.YabloSystem ⌜T.yablo⌝ n := by simpa [models_iff, Matrix.comp_vecCons'] using this; apply this; -lemma yablo_diagonal_neg_modeled (n : V) : ¬V ⊧/![n] (T.yablo) ↔ ∃ m, n < m ∧ T.Provable (substNumeral ⌜T.yablo⌝ m) := by +lemma yablo_diagonal_neg_modeled (n : V) : ¬V ⊧/![n] (T.yablo) ↔ ∃ m, n < m ∧ Provable T (substNumeral ⌜T.yablo⌝ m) := by simpa using yablo_diagonal_modeled n |>.not; -lemma iff_yablo_provable (n : ℕ) : U ⊢ T.yabloPred n ↔ U ⊢ “∀ m, ↑n < m → ∀ nσ, !ssnum nσ ⌜T.yablo⌝ m → ¬!T.provable (nσ)” := by - suffices U ⊢ T.yablo/[n] 🡘 “∀ m, ↑n < m → ∀ nσ, !ssnum nσ ⌜T.yablo⌝ m → ¬!T.provable (nσ)” by +lemma iff_yablo_provable (n : ℕ) : U ⊢ T.yabloPred n ↔ U ⊢ “∀ m, ↑n < m → ∀ nσ, !ssnum nσ ⌜T.yablo⌝ m → ¬!(provable T) (nσ)” := by + suffices U ⊢ T.yablo/[n] 🡘 “∀ m, ↑n < m → ∀ nσ, !ssnum nσ ⌜T.yablo⌝ m → ¬!(provable T) (nσ)” by constructor <;> . intro h; cl_prover [h, this]; - apply provable_of_models.{0}; + apply complete.{0} U _; intro V _ _; - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; haveI : V ⊧/![ORingStructure.numeral n] (T.yablo) ↔ T.YabloSystem ⌜T.yablo⌝ (ORingStructure.numeral n) := yablo_diagonal_modeled _; simpa [models_iff, Matrix.constant_eq_singleton, Matrix.comp_vecCons'] using this; -lemma iff_neg_yablo_provable (n : ℕ) : U ⊢ ∼(T.yabloPred n) ↔ U ⊢ “∃ m, ↑n < m ∧ ∃ nσ, !ssnum nσ ⌜T.yablo⌝ m ∧ !T.provable (nσ)” := by - suffices U ⊢ ∼T.yablo/[n] 🡘 “∃ m, ↑n < m ∧ ∃ nσ, !ssnum nσ ⌜T.yablo⌝ m ∧ !T.provable (nσ)” by +lemma iff_neg_yablo_provable (n : ℕ) : U ⊢ ∼(T.yabloPred n) ↔ U ⊢ “∃ m, ↑n < m ∧ ∃ nσ, !ssnum nσ ⌜T.yablo⌝ m ∧ !(provable T) (nσ)” := by + suffices U ⊢ ∼T.yablo/[n] 🡘 “∃ m, ↑n < m ∧ ∃ nσ, !ssnum nσ ⌜T.yablo⌝ m ∧ !(provable T) (nσ)” by constructor <;> . intro h; cl_prover [h, this]; - apply provable_of_models.{0}; + apply complete.{0} U _; intro V _ _; - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; haveI : ¬V ⊧/![ORingStructure.numeral n] (T.yablo) ↔ ∃ m, ORingStructure.numeral n < m ∧ Provable T (substNumeral ⌜T.yablo⌝ m) := yablo_diagonal_neg_modeled _; simpa [models_iff, Matrix.constant_eq_singleton, Matrix.comp_vecCons'] using this; lemma provable_greater_yablo {n m : ℕ} (hnm : n < m) : U ⊢ T.yabloPred n 🡒 T.yabloPred m := by - apply provable_of_models.{0}; + apply complete.{0} U _; intro V _ _; - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; - suffices - (∀ m, ORingStructure.numeral n < m → ¬Provable T (substNumeral ⌜yablo T⌝ m)) → - (∀ k, ORingStructure.numeral m < k → ¬Provable T (substNumeral ⌜yablo T⌝ k)) - by simpa [models_iff, Matrix.constant_eq_singleton, Matrix.comp_vecCons', yablo_diagonal_modeled] using this; - intro h k hmk; - apply h; - apply Arithmetic.lt_trans _ _ _ (by simpa) hmk; + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ U inferInstance; + apply Semantics.Imp.models_imply.mpr + intro h + have hn : V ⊧/![ORingStructure.numeral n] T.yablo := by simpa [models_iff] using h + have hm : V ⊧/![ORingStructure.numeral m] T.yablo := (yablo_diagonal_modeled (T := T) (n := (ORingStructure.numeral m : V))).mpr <| by + intro k hmk + exact (yablo_diagonal_modeled (T := T) (n := (ORingStructure.numeral n : V))).mp hn k + (Arithmetic.lt_trans _ _ _ (by simpa) hmk) + simpa [models_iff] using hm end @@ -126,17 +127,17 @@ variable [𝗜𝚺₁ ⪯ T] {n : ℕ} theorem yablo_unprovable [Entailment.Consistent T] : T ⊬ (T.yabloPred n) := by by_contra! hC; - have H₁ : T ⊢ T.provabilityPred (T.yabloPred (n + 1)) := by + have H₁ : T ⊢ provabilityPred T (T.yabloPred (n + 1)) := by apply Entailment.WeakerThan.pbl $ provable_D1 (T := T) ?_; apply provable_greater_yablo (show n < n + 1 by omega) ⨀ hC; - have H₂ : T ⊢ ∼T.provabilityPred (T.yabloPred (n + 1)) := by - apply provable_of_models.{0}; + have H₂ : T ⊢ ∼provabilityPred T (T.yabloPred (n + 1)) := by + apply complete.{0} T _; intro V _ _; - haveI : V ⊧ₘ* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance; - suffices ¬T.Provable (substNumeral ⌜T.yablo⌝ (n + 1 : V)) by + haveI : V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := ModelsTheory.of_provably_subtheory V 𝗜𝚺₁ T inferInstance; + suffices ¬Provable T (substNumeral ⌜T.yablo⌝ (n + 1 : V)) by simpa [provabilityPred, models_iff, ←substNumeral_app_quote_nat_model]; - have : ∀ (x : V), ORingStructure.numeral n < x → ¬T.Provable (substNumeral ⌜T.yablo⌝ x) := by - have : V ⊧ₘ “∀ m, ↑n < m → ∀ nσ, !ssnum nσ ⌜T.yablo⌝ m → ¬!T.provable (nσ)” := + have : ∀ (x : V), ORingStructure.numeral n < x → ¬Provable T (substNumeral ⌜T.yablo⌝ x) := by + have : V↓[ℒₒᵣ] ⊧ “∀ m, ↑n < m → ∀ nσ, !ssnum nσ ⌜T.yablo⌝ m → ¬!(provable T) (nσ)” := models_of_provable (T := T) (by assumption) $ (iff_yablo_provable n |>.mp hC); simpa [models_iff, Matrix.comp_vecCons'] using this; apply this (n + 1) (by simp [numeral_eq_natCast]); diff --git a/Foundation/FirstOrder/Interpretation.lean b/Foundation/FirstOrder/Interpretation.lean index 5cf6235bb..86be389c5 100644 --- a/Foundation/FirstOrder/Interpretation.lean +++ b/Foundation/FirstOrder/Interpretation.lean @@ -397,7 +397,7 @@ abbrev Model (M : Type*) [Structure L₁ M] : Type _ := π.trln.Model M open Classical in instance model_models_theory {M : Type v} [Nonempty M] [Structure L₁ M] [Structure.Eq L₁ M] (hT : M ⊧ₘ* T) : π.Model M ⊧ₘ* U := - modelsTheory_iff.mpr fun {σ} hσ ↦ + models_theory_iff.mpr fun {σ} hσ ↦ Model.translate_iff.mp <| consequence_iff'.mp (sound! (π.interpret_theory σ hσ)) M open Classical in @@ -413,7 +413,7 @@ abbrev ofWeakerThan {L : Language} [L.Eq] (T U : Theory L) [𝗘𝗤 ⪯ T] [U have : U ⪯ T := inferInstance Model.translate_iff.mpr <| by suffices M ⊧/ ![] φ by simpa [models_iff, Empty.eq_elim, Matrix.empty_eq] - have : T ⊢ φ := Entailment.weakerThan_iff.mp this (Entailment.by_axm _ (by simp [hφ])) + have : T ⊢ φ := Entailment.weakerThan_iff.mp this (Entailment.by_axm (by simp [hφ])) exact models_of_provable hT this protected instance refl {L : Language} [L.Eq] (T : Theory L) [𝗘𝗤 ⪯ T] : T ⊳ T := ofWeakerThan T T @@ -561,7 +561,7 @@ protected abbrev comp (τ : T₂ ⊳ T₃) (π : T₁ ⊳ T₂) : T₁ ⊳ T₃ suffices τ.Model (π.Model M) ⊧ₘ φ by apply Model.translate_iff.mpr <| (compDirectTranslation_Model_equiv τ.trln π).models.mpr this have : τ.Model (π.Model M) ⊧ₘ* T₃ := inferInstance - exact modelsTheory_iff.mp this hφ + exact models_theory_iff.mp this hφ end composition diff --git a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean index f2c064447..08cf69e94 100644 --- a/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean +++ b/Foundation/FirstOrder/NegationTranslation/GoedelGentzen.lean @@ -182,7 +182,7 @@ def gödelGentzen {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → (∼Γ)ᴺ ⊢[Λ]! ⊥ FiniteContext.weakening (by simp) <| Entailment.C_trans (of <| Entailment.K_left (negDoubleNegation φ)) (deduct ihp) have b₂ : (∼(Γ ++ Δ))ᴺ ⊢[Λ]! ∼φᴺ := FiniteContext.weakening (by simp) <| deduct ihn b₁ ⨀ b₂ - | wk (Γ := Γ) (Δ := Δ) d h => + | contraction (Γ := Γ) (Δ := Δ) d h => FiniteContext.weakening (List.map_subset _ <| List.map_subset _ h) (gödelGentzen d) diff --git a/Foundation/FirstOrder/Order/Le.lean b/Foundation/FirstOrder/Order/Le.lean index 872088afc..dc3b192f1 100644 --- a/Foundation/FirstOrder/Order/Le.lean +++ b/Foundation/FirstOrder/Order/Le.lean @@ -1,6 +1,6 @@ module -public import Foundation.FirstOrder.Completeness.Corollaries +public import Foundation.FirstOrder.Completeness @[expose] public section namespace LO @@ -17,20 +17,20 @@ lemma le_eq (t₁ t₂ : Semiterm L μ n) : LT.le.operator ![t₁, t₂] = “!! simp [Operator.operator, Operator.or, LT.le, ←TransitiveRewriting.comp_app] namespace Order -variable {T : Theory L} [𝗘𝗤 ⪯ T] +variable {T : Theory L} [𝗘𝗤 L ⪯ T] noncomputable def leIffEqOrLt : T ⊢ “∀ x y, x ≤ y ↔ x = y ∨ x < y” := - complete - (consequence_iff.mpr $ fun _ _ _ _ => by simp [models_iff, Semiformula.Operator.LE.def_of_Eq_of_LT]) + Theory.Proof.small_complete + <| consequence_iff.mpr fun _ ↦ by simp [models_iff, Semiformula.Operator.LE.def_of_Eq_of_LT] -lemma provOf (φ : Sentence L) +lemma complete (φ : Sentence L) (H : ∀ (M : Type (max u w)) - [Nonempty M] [LT M] - [Structure L M] [Structure.Eq L M] [Structure.LT L M] - [M ⊧ₘ* T], - M ⊧ₘ φ) : - T ⊨ φ := consequence_iff_consequence.{u, w}.mp <| consequence_iff_eq.mpr fun M _ _ _ hT => - letI : (Structure.Model L M) ⊧ₘ* T := Structure.ElementaryEquiv.modelsTheory.mp hT + [Nonempty M] [LT M] + [Structure L M] [Structure.Eq L M] [Structure.LT L M] + [M↓[L] ⊧* T], + M↓[L] ⊧ φ) : + T ⊢ φ := Theory.Proof.complete <| consequence_iff_eq.mpr fun M _ _ _ hT ↦ + letI : (Structure.Model L M)↓[L] ⊧* T := Structure.ElementaryEquiv.modelsTheory.mp hT Structure.ElementaryEquiv.models.mpr (H (Structure.Model L M)) end Order diff --git a/Foundation/FirstOrder/SetTheory/Universe.lean b/Foundation/FirstOrder/SetTheory/Universe.lean index 2d61e8e71..9e8fc615b 100644 --- a/Foundation/FirstOrder/SetTheory/Universe.lean +++ b/Foundation/FirstOrder/SetTheory/Universe.lean @@ -227,7 +227,7 @@ instance models_zf : Universe.{u} ⊧ₘ* 𝗭𝗙 where rcases hφ case axiom_of_equality h => have : Universe.{u} ⊧ₘ* (𝗘𝗤 : Theory ℒₛₑₜ) := inferInstance - simpa [models_iff] using modelsTheory_iff.mp this h + simpa [models_iff] using models_theory_iff.mp this h case axiom_of_empty_set => suffices ∃ x, ∀ y, y ∉ x by simpa [models_iff, Axiom.empty] exact ⟨empty, by simp⟩ @@ -311,7 +311,7 @@ instance models_ac : Universe.{u} ⊧ₘ* 𝗔𝗖 where instance models_zfc : Universe.{u} ⊧ₘ* 𝗭𝗙𝗖 := inferInstance -instance models_z : Universe.{u} ⊧ₘ* 𝗭 := ModelsTheory.of_ss inferInstance z_subset_zf +instance models_z : Universe.{u} ⊧ₘ* 𝗭 := models_of_ss inferInstance z_subset_zf instance models_zc : Universe.{u} ⊧ₘ* 𝗭𝗖 := inferInstance diff --git a/Foundation/FirstOrder/SetTheory/Z.lean b/Foundation/FirstOrder/SetTheory/Z.lean index 973c7363a..f89dae431 100644 --- a/Foundation/FirstOrder/SetTheory/Z.lean +++ b/Foundation/FirstOrder/SetTheory/Z.lean @@ -18,7 +18,7 @@ variable {V : Type*} [SetStructure V] [Nonempty V] [V ⊧ₘ* 𝗭] /-! ## Axiom of extentionality -/ lemma mem_ext_iff {x y : V} : x = y ↔ ∀ z, z ∈ x ↔ z ∈ y := by - have := by simpa [models_iff, Axiom.extentionality] using ModelsTheory.models V Zermelo.axiom_of_extentionality + have := by simpa [models_iff, Axiom.extentionality] using Theory.models V Zermelo.axiom_of_extentionality exact this x y alias ⟨_, mem_ext⟩ := mem_ext_iff @@ -51,7 +51,7 @@ lemma SSubset.of_subset_of_not_mem_of_mem {x y z : V} (ss : x ⊆ y) (hzx : z /-! ## Axiom of empty set -/ -lemma empty_exists : ∃ e : V, IsEmpty e := by simpa [models_iff] using ModelsTheory.models V Zermelo.axiom_of_empty_set +lemma empty_exists : ∃ e : V, IsEmpty e := by simpa [models_iff] using Theory.models V Zermelo.axiom_of_empty_set lemma empty_existsUnique : ∃! e : V, IsEmpty e := by rcases empty_exists (V := V) with ⟨e, he⟩ @@ -86,7 +86,7 @@ lemma eq_empty_or_isNonempty (x : V) : x = ∅ ∨ IsNonempty x := by /-! ## Axiom of pairing -/ lemma pairing_exists : ∀ x y : V, ∃ z : V, ∀ w, w ∈ z ↔ w = x ∨ w = y := by - simpa [models_iff, Axiom.pairing] using ModelsTheory.models V Zermelo.axiom_of_pairing + simpa [models_iff, Axiom.pairing] using Theory.models V Zermelo.axiom_of_pairing lemma pairing_existsUnique (x y : V) : ∃! z : V, ∀ w, w ∈ z ↔ w = x ∨ w = y := by rcases pairing_exists x y with ⟨p, hp⟩ @@ -132,7 +132,7 @@ instance singleton.definable : ℒₛₑₜ-function₁[V] Singleton.singleton : /-! ## Axiom of union -/ lemma union_exists : ∀ x : V, ∃ y : V, ∀ z, z ∈ y ↔ ∃ w ∈ x, z ∈ w := by - simpa [models_iff, Axiom.union] using ModelsTheory.models V Zermelo.axiom_of_union + simpa [models_iff, Axiom.union] using Theory.models V Zermelo.axiom_of_union lemma union_existsUnique (x : V) : ∃! y : V, ∀ z, z ∈ y ↔ ∃ w ∈ x, z ∈ w := by rcases union_exists x with ⟨u, hu⟩ @@ -245,7 +245,7 @@ lemma pair_eq_doubleton (x y : V) : {x, y} = doubleton x y := by ext; simp /-! ## Axiom of power set -/ lemma power_exists : ∀ x : V, ∃ y : V, ∀ z, z ∈ y ↔ z ⊆ x := by - simpa [models_iff, Axiom.power] using ModelsTheory.models V Zermelo.axiom_of_power_set + simpa [models_iff, Axiom.power] using Theory.models V Zermelo.axiom_of_power_set lemma power_existsUnique (x : V) : ∃! y : V, ∀ z, z ∈ y ↔ z ⊆ x := by rcases power_exists x with ⟨p, hp⟩ @@ -280,7 +280,7 @@ lemma separation_exists_eval (x : V) (φ : Semiformula ℒₛₑₜ V 1) : ∃ y have : Inhabited V := inhabited_of_nonempty inferInstance let f := φ.enumarateFVar let ψ := (Rew.rewriteMap φ.idxOfFVar) ▹ φ - have := by simpa [models_iff, Semiformula.eval_univCl, Axiom.separationSchema] using ModelsTheory.models V (Zermelo.axiom_of_separation ψ) + have := by simpa [models_iff, Semiformula.eval_univCl, Axiom.separationSchema] using Theory.models V (Zermelo.axiom_of_separation ψ) simpa [ψ, f, Semiformula.eval_rewriteMap, Matrix.constant_eq_singleton] using this f x lemma separation_exists (x : V) (P : V → Prop) (hP : ℒₛₑₜ-predicate P) : ∃ y : V, ∀ z : V, z ∈ y ↔ z ∈ x ∧ P z := by @@ -619,7 +619,7 @@ lemma IsInductive.zero {I : V} (hI : IsInductive I) : ∅ ∈ I := hI.1 lemma IsInductive.succ {I : V} (hI : IsInductive I) {x : V} (hx : x ∈ I) : succ x ∈ I := hI.2 x hx lemma isInductive_exists : ∃ I : V, IsInductive I := by - simpa [models_iff, Axiom.infinity] using ModelsTheory.models V Zermelo.axiom_of_infinity + simpa [models_iff, Axiom.infinity] using Theory.models V Zermelo.axiom_of_infinity lemma omega_existsUnique : ∃! ω : V, ∀ x, x ∈ ω ↔ ∀ I : V, IsInductive I → x ∈ I := by rcases isInductive_exists (V := V) with ⟨I, hI⟩ @@ -729,7 +729,7 @@ lemma naturalNumber_induction (P : V → Prop) (hP : ℒₛₑₜ-predicate P) /-! ## Axiom of foundation -/ lemma foundation : ∀ x : V, [IsNonempty x] → ∃ y ∈ x, ∀ z ∈ x, z ∉ y := by - simpa [models_iff, Axiom.foundation] using ModelsTheory.models V Zermelo.axiom_of_foundation + simpa [models_iff, Axiom.foundation] using Theory.models V Zermelo.axiom_of_foundation lemma foundation' (x : V) [IsNonempty x] : ∃ y ∈ x, x ∩ y = ∅ := by rcases foundation x with ⟨y, hyx, H⟩ diff --git a/Foundation/LinearLogic/FirstOrder/Formula.lean b/Foundation/LinearLogic/FirstOrder/Formula.lean index 103b4a2a6..2c7667f62 100644 --- a/Foundation/LinearLogic/FirstOrder/Formula.lean +++ b/Foundation/LinearLogic/FirstOrder/Formula.lean @@ -155,7 +155,7 @@ lemma neg_neg {n} (φ : Semiformula L ξ n) : ∼∼φ = φ := by | ∀⁰ φ => simp [neg_neg φ] | ∃⁰ φ => simp [neg_neg φ] -instance : NegInvolutive (Semiformula L ξ n) := ⟨neg_neg⟩ +instance : TildeInvolutive (Semiformula L ξ n) := ⟨neg_neg⟩ /-- Usual logical connectives are defined to align with `⊤` and `⊥` -/ instance : LogicalConnective (Semiformula L ξ n) where diff --git a/Foundation/LinearLogic/MLL.lean b/Foundation/LinearLogic/MLL.lean index de52ae7aa..68650514b 100644 --- a/Foundation/LinearLogic/MLL.lean +++ b/Foundation/LinearLogic/MLL.lean @@ -58,7 +58,7 @@ instance : MultiplicativeConnective.DeMorgan Formula where | φ ⅋ ψ => simp [neg_neg φ, neg_neg ψ] | φ ⨂ ψ => simp [neg_neg φ, neg_neg ψ] -instance : NegInvolutive Formula where +instance : TildeInvolutive Formula where neg_involutive := neg_neg lemma lolli_def (φ ψ : Formula) : φ ⊸ ψ = ∼φ ⅋ ψ := rfl diff --git a/Foundation/Logic/Calculus.lean b/Foundation/Logic/Calculus.lean index 55a6addad..2b09c10c4 100644 --- a/Foundation/Logic/Calculus.lean +++ b/Foundation/Logic/Calculus.lean @@ -18,41 +18,41 @@ namespace LO /-! ## One-sided $\mathbf{LK}$ -/ -class OneSidedLK {F : Type*} [LogicalConnective F] [DeMorgan F] [NegInvolutive F] (𝔇 : List F → Type*) where +class OneSidedLK {F : Type*} [LogicalConnective F] [DeMorgan F] [TildeInvolutive F] (𝔇 : List F → Type*) where identity (φ) : 𝔇 [φ, ∼φ] - wk : 𝔇 Δ → Δ ⊆ Γ → 𝔇 Γ + contraction : 𝔇 Δ → Δ ⊆ Γ → 𝔇 Γ verum : 𝔇 [⊤] and : 𝔇 (φ :: Γ) → 𝔇 (ψ :: Γ) → 𝔇 (φ ⋏ ψ :: Γ) or : 𝔇 (φ :: ψ :: Γ) → 𝔇 (φ ⋎ ψ :: Γ) class OneSidedLK.Cut - {F : Type*} [LogicalConnective F] [DeMorgan F] [NegInvolutive F] (𝔇 : List F → Type*) extends OneSidedLK 𝔇 where + {F : Type*} [LogicalConnective F] [DeMorgan F] [TildeInvolutive F] (𝔇 : List F → Type*) extends OneSidedLK 𝔇 where cut : 𝔇 (φ :: Γ) → 𝔇 (∼φ :: Δ) → 𝔇 (Γ ++ Δ) namespace OneSidedLK -variable {F : Type*} [LogicalConnective F] [DeMorgan F] [NegInvolutive F] {𝔇 : List F → Type*} [OneSidedLK 𝔇] +variable {F : Type*} [LogicalConnective F] [DeMorgan F] [TildeInvolutive F] {𝔇 : List F → Type*} [OneSidedLK 𝔇] def cast (b : 𝔇 Γ) (h : Γ = Δ := by simp) : 𝔇 Δ := h ▸ b -def weakening (d : 𝔇 Γ) (h : Γ ⊆ Δ := by simp) : 𝔇 Δ := wk d (by simp [h]) +def contra (d : 𝔇 Γ) (h : Γ ⊆ Δ := by simp) : 𝔇 Δ := contraction d (by simp [h]) -def rotate (d : 𝔇 (φ :: Γ)) : 𝔇 (Γ ++ [φ]) := weakening d +def rotate (d : 𝔇 (φ :: Γ)) : 𝔇 (Γ ++ [φ]) := contra d -def close (φ : F) (hp : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : 𝔇 Γ := wk (identity φ) (by simp_all) +def close (φ : F) (hp : φ ∈ Γ := by simp) (hn : ∼φ ∈ Γ := by simp) : 𝔇 Γ := contraction (identity φ) (by simp_all) -def top (h : ⊤ ∈ Γ := by simp) : 𝔇 Γ := wk verum (by simp [h]) +def top (h : ⊤ ∈ Γ := by simp) : 𝔇 Γ := contraction verum (by simp [h]) def tensor {φ ψ : F} (dφ : 𝔇 (φ :: Γ)) (dψ : 𝔇 (ψ :: Δ)) : 𝔇 (φ ⋏ ψ :: Γ ++ Δ) := - and (wk dφ (by simp)) (wk dψ (by simp)) + and (contraction dφ (by simp)) (contraction dψ (by simp)) -def swap₁ (d : 𝔇 (φ₂ :: φ₁ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: Γ) := wk d (by simp) +def swap₁ (d : 𝔇 (φ₂ :: φ₁ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: Γ) := contraction d (by simp) def swap₂ (d : 𝔇 (φ₃ :: φ₁ :: φ₂ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: φ₃ :: Γ) := - wk d (by grind) + contraction d (by grind) def swap₃ (d : 𝔇 (φ₄ :: φ₁ :: φ₂ :: φ₃ :: Γ)) : 𝔇 (φ₁ :: φ₂ :: φ₃ :: φ₄ :: Γ) := - wk d (by grind) + contraction d (by grind) alias cut := OneSidedLK.Cut.cut @@ -60,7 +60,7 @@ def eCut [Cut 𝔇] (d₁ : 𝔇 (φ :: Γ)) (d₂ : 𝔇 (ψ :: Δ)) (e : ∼φ def disj₂ {Γ Δ : List F} [Cut 𝔇] : 𝔇 (Γ ++ Δ) → 𝔇 (⋁Γ :: Δ) := fun d ↦ match Γ with - | [] => weakening d + | [] => contra d | [φ] => d | [φ, ψ] => or d | φ :: ψ :: χ :: Γ => by @@ -69,7 +69,7 @@ def disj₂ {Γ Δ : List F} [Cut 𝔇] : 𝔇 (Γ ++ Δ) → 𝔇 (⋁Γ :: Δ) have d₁ : 𝔇 ((φ ⋎ ψ) ⋎ Φ :: Δ) := disj₂ this have d₂ : 𝔇 [(∼φ ⋏ ∼ψ) ⋏ ∼Φ, φ ⋎ ψ ⋎ Φ] := have : 𝔇 [φ, ψ ⋎ Φ, (∼φ ⋏ ∼ψ) ⋏ ∼Φ] := - weakening <| or <| rotate <| rotate <| + contra <| or <| rotate <| rotate <| tensor (tensor (rotate (identity (𝔇 := 𝔇) φ)) (rotate (identity ψ))) (rotate (identity Φ)) rotate <| or <| this exact eCut d₂ d₁ @@ -77,7 +77,7 @@ def disj₂ {Γ Δ : List F} [Cut 𝔇] : 𝔇 (Γ ++ Δ) → 𝔇 (⋁Γ :: Δ) def conj₂ {Γ Δ : List F} (d : (φ : F) → φ ∈ Γ → 𝔇 (φ :: Δ)) : 𝔇 (⋀Γ :: Δ) := match Γ with - | [] => weakening verum + | [] => contra verum | [φ] => d φ (by simp) | φ :: ψ :: Γ => have : 𝔇 (⋀(ψ :: Γ) :: Δ) := conj₂ (Γ := ψ :: Γ) (fun χ h ↦ d χ (by simp_all)) @@ -93,7 +93,7 @@ namespace PrincipalEntailment variable {P : Type*} [Entailment P F] {𝓟 : P} [PrincipalEntailment 𝔇 𝓟] -omit [LogicalConnective F] [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] in +omit [LogicalConnective F] [DeMorgan F] [TildeInvolutive F] [OneSidedLK 𝔇] in lemma provable_iff : 𝓟 ⊢ φ ↔ Nonempty (𝔇 [φ]) := by simpa using OneSidedLK.PrincipalEntailment.equiv.nonempty_congr @@ -105,8 +105,8 @@ instance : Entailment.ModusPonens 𝓟 where let b₁ := equiv b₁ let b₂ := equiv b₂ have : 𝔇 [∼(φ 🡒 ψ), ∼φ, ψ] := cast (tensor (𝔇 := 𝔇) (identity φ) (identity (∼ψ))) (by simp [DeMorgan.imply]) - have : 𝔇 [∼φ, ψ] := wk (cut b₁ this) (by simp) - have : 𝔇 [ψ] := wk (cut b₂ this) (by simp) + have : 𝔇 [∼φ, ψ] := contraction (cut b₁ this) (by simp) + have : 𝔇 [ψ] := contraction (cut b₂ this) (by simp) equiv.symm <| cast this instance : Entailment.Cl 𝓟 where @@ -167,7 +167,7 @@ abbrev Pullback (𝔇 : List F → Type*) {G : Type*} [LogicalConnective G] (f : namespace Pullback -variable {G : Type*} [LogicalConnective G] [DeMorgan G] [NegInvolutive G] {f : G →ˡᶜ F} +variable {G : Type*} [LogicalConnective G] [DeMorgan G] [TildeInvolutive G] {f : G →ˡᶜ F} def cast (d : 𝔇 Δ) (h : Δ = Γ.map f := by simp) : Pullback 𝔇 f Γ := by unfold Pullback @@ -177,7 +177,7 @@ def uncast (d : Pullback 𝔇 f Γ) (h : Δ = Γ.map f := by simp) : 𝔇 Δ := instance oneSidedLK [OneSidedLK 𝔇] : OneSidedLK (Pullback 𝔇 f) where identity φ := cast <| identity (f φ) - wk {Δ Γ} d h := cast (wk d (List.map_subset f h) : 𝔇 (Γ.map f)) (by simp) + contraction {Δ Γ} d h := cast (contraction d (List.map_subset f h) : 𝔇 (Γ.map f)) (by simp) verum := cast verum and d₁ d₂ := cast <| and d₁ d₂ or d := cast <| or d @@ -192,10 +192,10 @@ instance {P : Type*} [Entailment P F] (𝓟 : P) [PrincipalEntailment 𝔇 𝓟] PrincipalEntailment (Pullback 𝔇 f) (Entailment.pullback 𝓟 f) where equiv {φ} := PrincipalEntailment.equiv (φ := f φ) -omit [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] [DeMorgan G] [NegInvolutive G] in +omit [DeMorgan F] [TildeInvolutive F] [OneSidedLK 𝔇] [DeMorgan G] [TildeInvolutive G] in @[simp] lemma nonempty_iff {Γ} : Nonempty (Pullback 𝔇 f Γ) ↔ Nonempty (𝔇 (Γ.map f)) := by simp [Pullback] -omit [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] [DeMorgan G] [NegInvolutive G] in +omit [DeMorgan F] [TildeInvolutive F] [OneSidedLK 𝔇] [DeMorgan G] [TildeInvolutive G] in @[simp] lemma isEmpty_iff {Γ} : IsEmpty (Pullback 𝔇 f Γ) ↔ IsEmpty (𝔇 (Γ.map f)) := by simp [Pullback] end Pullback @@ -208,7 +208,7 @@ namespace ContextualEntailment variable {S : Type*} [Entailment S F] [AdjunctiveSet F S] [ContextualEntailment 𝔇 S] -omit [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] in +omit [DeMorgan F] [TildeInvolutive F] [OneSidedLK 𝔇] in lemma provable_iff {𝓢 : S} : 𝓢 ⊢ φ ↔ ∃ Γ : List F, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (𝔇 (φ :: ∼Γ)) := by simpa using equiv.nonempty_congr @@ -234,8 +234,8 @@ instance (𝓢 : S) : Entailment.ModusPonens 𝓢 where let ⟨Γ₁, b₁⟩ := equiv b₁ let ⟨Γ₂, b₂⟩ := equiv b₂ have : 𝔇 [∼(φ 🡒 ψ), ∼φ, ψ] := cast (tensor (𝔇 := 𝔇) (identity φ) (identity (∼ψ))) (by simp [DeMorgan.imply]) - have : 𝔇 (∼φ :: ψ :: ∼↑Γ₁) := wk (cut b₁ this) (by simp) - have : 𝔇 (ψ :: ∼↑Γ₁ ++ ∼↑Γ₂) := wk (cut b₂ this) (by simp) + have : 𝔇 (∼φ :: ψ :: ∼↑Γ₁) := contraction (cut b₁ this) (by simp) + have : 𝔇 (ψ :: ∼↑Γ₁ ++ ∼↑Γ₂) := contraction (cut b₂ this) (by simp) equiv.symm ⟨⟨Γ₁ ++ Γ₂, by simp; grind⟩, cast this⟩ instance : Entailment.StrongCut S S where @@ -258,7 +258,7 @@ instance : Entailment.DeductiveExplosion S where equiv.symm ⟨ Γ, have : 𝔇 [∼⊥] := cast verum (by simp) - wk (cut b this) (by simp) ⟩ + contraction (cut b this) (by simp) ⟩ lemma inconsistent_iff {𝓢 : S} : Entailment.Inconsistent 𝓢 ↔ ∃ Γ : List F, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (𝔇 (∼Γ)) := calc @@ -270,7 +270,7 @@ lemma inconsistent_iff {𝓢 : S} : have : 𝔇 [(∼⊥ : F)] := cast verum exact ⟨Γ, hΓ, ⟨cast (cut d this)⟩⟩ · rintro ⟨Γ, hΓ, ⟨d⟩⟩ - exact ⟨Γ, hΓ, ⟨wk d (by simp)⟩⟩ + exact ⟨Γ, hΓ, ⟨contraction d (by simp)⟩⟩ instance cl (𝓢 : S) : Entailment.Cl 𝓢 where negEquiv {φ} := Entailment.cast @@ -334,7 +334,7 @@ lemma iff_context {𝓢 : S} {𝓟 : P} [PrincipalEntailment 𝔇 𝓟] : · rintro h have ⟨Γ, hΓ, ⟨d⟩⟩ := provable_iff.mp h have : 𝓟 ⊢ ⋀Γ 🡒 φ := by - have : 𝔇 (∼Γ ++ [φ]) := weakening d + have : 𝔇 (∼Γ ++ [φ]) := contra d have : Nonempty (𝔇 [⋀Γ 🡒 φ]) := by simpa [DeMorgan.imply] using Nonempty.intro (or <| disj₂ this) exact PrincipalEntailment.provable_iff.mpr this refine ⟨⟨Γ, by simpa using hΓ, this.some⟩⟩ @@ -343,7 +343,7 @@ lemma iff_context {𝓢 : S} {𝓟 : P} [PrincipalEntailment 𝔇 𝓟] : have d : 𝔇 [⋁(∼Γ) ⋎ φ] := cast (PrincipalEntailment.equiv this) (by simp [DeMorgan.imply]) have : 𝔇 (⋀Γ ⋏ ∼φ :: φ :: ∼Γ) := have : 𝔇 (⋀Γ :: ∼Γ) := conj₂ fun φ h ↦ close φ (by simp) (by simp [h]) - weakening <| tensor this (rotate <| identity φ) + contra <| tensor this (rotate <| identity φ) have : 𝔇 (φ :: ∼Γ) := eCut d this refine provable_iff.mpr ⟨Γ, h, ⟨this⟩⟩ diff --git a/Foundation/Logic/LogicSymbol.lean b/Foundation/Logic/LogicSymbol.lean index 43f300fcd..118f6acb4 100644 --- a/Foundation/Logic/LogicSymbol.lean +++ b/Foundation/Logic/LogicSymbol.lean @@ -23,7 +23,7 @@ namespace LO class LogicalConnective (α : Type*) extends Top α, Bot α, Tilde α, Arrow α, Wedge α, Vee α -class NegInvolutive (F : Type*) [Tilde F] where +class TildeInvolutive (F : Type*) [Tilde F] where neg_involutive (φ : F) : ∼∼φ = φ class DeMorgan (F : Type*) [LogicalConnective F] where @@ -33,9 +33,10 @@ class DeMorgan (F : Type*) [LogicalConnective F] where and (φ ψ : F) : ∼(φ ⋏ ψ) = ∼φ ⋎ ∼ψ or (φ ψ : F) : ∼(φ ⋎ ψ) = ∼φ ⋏ ∼ψ -alias DeMorgan.neg := NegInvolutive.neg_involutive +alias DeMorgan.neg := TildeInvolutive.neg_involutive -attribute [simp] NegInvolutive.neg_involutive DeMorgan.verum DeMorgan.falsum DeMorgan.and DeMorgan.or +attribute [simp, grind =] TildeInvolutive.neg_involutive +attribute [simp, grind =] DeMorgan.verum DeMorgan.falsum DeMorgan.and DeMorgan.or /-- Introducing `∼φ` as an abbreviation of `φ 🡒 ⊥`. -/ class NegAbbrev (F : Type*) [Tilde F] [Arrow F] [Bot F] where @@ -51,6 +52,20 @@ class ŁukasiewiczAbbrev (F : Type*) [LogicalConnective F] extends NegAbbrev F w attribute [grind =] ŁukasiewiczAbbrev.and ŁukasiewiczAbbrev.or ŁukasiewiczAbbrev.top +section tilde + +variable {α : Type*} [Tilde α] [TildeInvolutive α] + +@[simp] lemma TildeInvolutive.tilde_injective : Function.Injective (Tilde.tilde : α → α) := by + intro φ ψ h + simpa using congr_arg (∼·) h + +def Tilde.invol : α ↪ α := ⟨Tilde.tilde, TildeInvolutive.tilde_injective⟩ + +@[simp] lemma Tilde.invol_app (φ : α) : Tilde.invol φ = ∼φ := rfl + +end tilde + namespace LogicalConnective section @@ -92,7 +107,7 @@ instance : DeMorgan Prop where and := fun _ _ => by simp [-not_and, not_and_or] or := fun _ _ => by simp [not_or] -instance : NegInvolutive Prop where +instance : TildeInvolutive Prop where neg_involutive := fun _ => by simp class HomClass (F : Type*) (α β : outParam Type*) [LogicalConnective α] [LogicalConnective β] [FunLike F α β] where @@ -103,7 +118,7 @@ class HomClass (F : Type*) (α β : outParam Type*) [LogicalConnective α] [Logi map_and : ∀ (f : F) (φ ψ : α), f (φ ⋏ ψ) = f φ ⋏ f ψ map_or : ∀ (f : F) (φ ψ : α), f (φ ⋎ ψ) = f φ ⋎ f ψ -attribute [simp] HomClass.map_top HomClass.map_bot HomClass.map_neg HomClass.map_imply HomClass.map_and HomClass.map_or +attribute [simp, grind =] HomClass.map_top HomClass.map_bot HomClass.map_neg HomClass.map_imply HomClass.map_and HomClass.map_or namespace HomClass @@ -355,7 +370,7 @@ lemma tilde_def (l : List α) : ∼l = l.map (∼·) := rfl | nil => simp [*] | cons a as ih => simp [*, List.cons_append] -@[simp] lemma mem_tilde_iff [NegInvolutive α] {a : α} {l : List α} : a ∈ ∼l ↔ ∼a ∈ l := by +@[simp] lemma mem_tilde_iff [TildeInvolutive α] {a : α} {l : List α} : a ∈ ∼l ↔ ∼a ∈ l := by induction l with | nil => simp [*] | cons b bs ih => @@ -363,12 +378,12 @@ lemma tilde_def (l : List α) : ∼l = l.map (∼·) := rfl simp [ih, this] constructor <;> {rintro rfl; simp} -instance [NegInvolutive α] : NegInvolutive (List α) where +instance [TildeInvolutive α] : TildeInvolutive (List α) where neg_involutive l := by induction l with | nil => simp [*] | cons a as ih => - simp [ih, NegInvolutive.neg_involutive a] + simp [ih, TildeInvolutive.neg_involutive a] end tilde @@ -551,6 +566,30 @@ open Classical variable {α : Type*} +section tilde + +variable [Tilde α] [TildeInvolutive α] + +instance : Tilde (Finset α) := ⟨fun l ↦ l.map Tilde.invol⟩ + +lemma tilde_def (s : Finset α) : ∼s = s.map Tilde.invol := rfl + +@[simp] lemma mem_tilde_iff {a : α} {s : Finset α} : a ∈ ∼s ↔ ∼a ∈ s := by + simp [tilde_def]; grind + +instance : TildeInvolutive (Finset α) where + neg_involutive s := by ext a; simp + +@[simp] lemma tilde_empty : ∼(∅ : Finset α) = ∅ := rfl + +@[simp] lemma tilde_insert (a : α) (s : Finset α) : ∼(insert a s) = insert (∼a) (∼s) := by + simp [tilde_def] + +@[simp] lemma tilde_union (s t : Finset α) : ∼(s ∪ t) = ∼s ∪ ∼t := by + simp [tilde_def, Finset.map_union] + +end tilde + noncomputable def conj [Top α] [Wedge α] (s : Finset α) : α := s.toList.conj₂ noncomputable def conj' [Top α] [Wedge α] (s : Finset ι) (f : ι → α) : α := s.toList.conj' f diff --git a/Foundation/Modal/Entailment/Basic.lean b/Foundation/Modal/Entailment/Basic.lean index c9093124d..f8a462c46 100644 --- a/Foundation/Modal/Entailment/Basic.lean +++ b/Foundation/Modal/Entailment/Basic.lean @@ -697,7 +697,7 @@ variable [DecidableEq F] variable {φ ψ χ : F} {Γ Δ : List F} variable {𝓢 : S} -instance [Entailment.Minimal 𝓢] [ModalDeMorgan F] [NegInvolutive F] [HasAxiomDNE 𝓢] : HasDiaDuality 𝓢 := ⟨by +instance [Entailment.Minimal 𝓢] [ModalDeMorgan F] [TildeInvolutive F] [HasAxiomDNE 𝓢] : HasDiaDuality 𝓢 := ⟨by intro φ; rw [Axioms.DiaDuality, ModalDeMorgan.neg_box, DeMorgan.neg]; exact E_Id; diff --git a/Foundation/Modal/Formula/NNFormula.lean b/Foundation/Modal/Formula/NNFormula.lean index f7abd635d..1da385fd4 100644 --- a/Foundation/Modal/Formula/NNFormula.lean +++ b/Foundation/Modal/Formula/NNFormula.lean @@ -103,7 +103,7 @@ instance : ModalDeMorgan (NNFormula α) where neg_dia := by tauto; neg_box := by tauto; -instance : NegInvolutive (NNFormula α) where +instance : TildeInvolutive (NNFormula α) where neg_involutive := by grind; section toString diff --git a/Foundation/Propositional/Boolean/NNFormula.lean b/Foundation/Propositional/Boolean/NNFormula.lean index 69286d5fc..786a0b2cf 100644 --- a/Foundation/Propositional/Boolean/NNFormula.lean +++ b/Foundation/Propositional/Boolean/NNFormula.lean @@ -16,7 +16,7 @@ namespace NNFormula section val -variable {F : Type*} [LogicalConnective F] [DeMorgan F] [NegInvolutive F] (v : α → F) +variable {F : Type*} [LogicalConnective F] [DeMorgan F] [TildeInvolutive F] (v : α → F) def valAux : NNFormula α → F | .atom a => v a diff --git a/Foundation/Propositional/Formula/NNFormula.lean b/Foundation/Propositional/Formula/NNFormula.lean index 321c35db8..ed5e483a8 100644 --- a/Foundation/Propositional/Formula/NNFormula.lean +++ b/Foundation/Propositional/Formula/NNFormula.lean @@ -93,7 +93,7 @@ instance : DeMorgan (NNFormula α) where or := by simp imply := by simp [imp_eq] -instance : NegInvolutive (NNFormula α) where +instance : TildeInvolutive (NNFormula α) where neg_involutive := by simp def complexity : NNFormula α → ℕ diff --git a/Foundation/ProvabilityLogic/SolovaySentences.lean b/Foundation/ProvabilityLogic/SolovaySentences.lean index 25a1c8734..1cb40a91f 100644 --- a/Foundation/ProvabilityLogic/SolovaySentences.lean +++ b/Foundation/ProvabilityLogic/SolovaySentences.lean @@ -142,7 +142,7 @@ variable {F : Kripke.Frame} [Fintype F] [F.IsIrreflexive] [F.IsTransitive] [F.Is section model -variable (T) {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable (T) {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] def NegativeSuccessor (φ ψ : V) : Prop := T.ProvabilityComparisonLE (neg ℒₒᵣ φ) (neg ℒₒᵣ ψ) @@ -254,7 +254,7 @@ section model variable (T) -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] +variable {V : Type*} [ORingStructure V] [V↓[ℒₒᵣ] ⊧* 𝗜𝚺₁] open Modal ProvabilityLogic Kripke diff --git a/Foundation/SecondOrder/Syntax/Formula.lean b/Foundation/SecondOrder/Syntax/Formula.lean index b71e6ee6a..b9c9b27ba 100644 --- a/Foundation/SecondOrder/Syntax/Formula.lean +++ b/Foundation/SecondOrder/Syntax/Formula.lean @@ -138,7 +138,7 @@ lemma neg_neg (φ : Semiformula L Ξ ξ N n) : ∼∼φ = φ := | ∀¹ φ => by simp [neg_neg φ] | ∃¹ φ => by simp [neg_neg φ] -instance : NegInvolutive (Semiformula L Ξ ξ N n) := ⟨neg_neg⟩ +instance : TildeInvolutive (Semiformula L Ξ ξ N n) := ⟨neg_neg⟩ @[simp] lemma and_inj {φ₁ φ₂ ψ₁ ψ₂ : Semiformula L Ξ ξ N n} : φ₁ ⋏ φ₂ = ψ₁ ⋏ ψ₂ ↔ φ₁ = ψ₁ ∧ φ₂ = ψ₂ := iff_of_eq (by apply and.injEq) From 9e38753ba8ad697c3b3d6393c2937f6417b3d924 Mon Sep 17 00:00:00 2001 From: palalansouki Date: Fri, 26 Jun 2026 05:35:12 +0900 Subject: [PATCH 53/61] fix --- Foundation.lean | 172 +++++++-------- Foundation/FirstOrder/Basic/Definability.lean | 8 +- Foundation/FirstOrder/Basic/Model.lean | 14 +- Foundation/FirstOrder/Basic/Operator.lean | 2 +- .../FirstOrder/Basic/Semantics/Semantics.lean | 2 +- .../Incompleteness/Consistency.lean | 2 +- Foundation/FirstOrder/Interpretation.lean | 202 ++++++++++-------- .../FirstOrder/SetTheory/Basic/Axioms.lean | 20 +- .../FirstOrder/SetTheory/Basic/Misc.lean | 22 +- .../FirstOrder/SetTheory/Basic/Model.lean | 6 +- Foundation/FirstOrder/SetTheory/Function.lean | 2 +- .../SetTheory/LoewenheimSkolem.lean | 2 +- Foundation/FirstOrder/SetTheory/Ordinal.lean | 16 +- Foundation/FirstOrder/SetTheory/Universe.lean | 26 +-- Foundation/FirstOrder/SetTheory/Z.lean | 20 +- Foundation/FirstOrder/Skolemization/Hull.lean | 7 +- 16 files changed, 278 insertions(+), 245 deletions(-) diff --git a/Foundation.lean b/Foundation.lean index 66d0922e2..de41e3735 100644 --- a/Foundation.lean +++ b/Foundation.lean @@ -1,41 +1,41 @@ module -- shake: keep-all --- public import Foundation.FirstOrder.Arithmetic.Basic --- public import Foundation.FirstOrder.Arithmetic.Basic.Hierarchy --- public import Foundation.FirstOrder.Arithmetic.Basic.Misc --- public import Foundation.FirstOrder.Arithmetic.Basic.Model --- public import Foundation.FirstOrder.Arithmetic.Basic.Monotone --- public import Foundation.FirstOrder.Arithmetic.Definability --- public import Foundation.FirstOrder.Arithmetic.Definability.Absoluteness --- public import Foundation.FirstOrder.Arithmetic.Definability.BoundedDefinable --- public import Foundation.FirstOrder.Arithmetic.Definability.Definable --- public import Foundation.FirstOrder.Arithmetic.Definability.Hierarchy --- public import Foundation.FirstOrder.Arithmetic.Exponential --- public import Foundation.FirstOrder.Arithmetic.Exponential.Bit --- public import Foundation.FirstOrder.Arithmetic.Exponential.Exp --- public import Foundation.FirstOrder.Arithmetic.Exponential.Log --- public import Foundation.FirstOrder.Arithmetic.Exponential.PPow2 --- public import Foundation.FirstOrder.Arithmetic.Exponential.Pow2 --- public import Foundation.FirstOrder.Arithmetic.HFS --- public import Foundation.FirstOrder.Arithmetic.HFS.Basic --- public import Foundation.FirstOrder.Arithmetic.HFS.Coding --- public import Foundation.FirstOrder.Arithmetic.HFS.Fixpoint --- public import Foundation.FirstOrder.Arithmetic.HFS.PRF --- public import Foundation.FirstOrder.Arithmetic.HFS.Seq --- public import Foundation.FirstOrder.Arithmetic.HFS.Vec --- public import Foundation.FirstOrder.Arithmetic.IOpen.Basic --- public import Foundation.FirstOrder.Arithmetic.Induction --- public import Foundation.FirstOrder.Arithmetic.Omega1.Basic --- public import Foundation.FirstOrder.Arithmetic.Omega1.Nuon --- public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Basic --- public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Functions --- public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Q --- public import Foundation.FirstOrder.Arithmetic.Q.Basic --- public import Foundation.FirstOrder.Arithmetic.R0.Basic --- public import Foundation.FirstOrder.Arithmetic.R0.Representation --- public import Foundation.FirstOrder.Arithmetic.Schemata --- public import Foundation.FirstOrder.Arithmetic.TA.Basic --- public import Foundation.FirstOrder.Arithmetic.TA.Nonstandard +public import Foundation.FirstOrder.Arithmetic.Basic +public import Foundation.FirstOrder.Arithmetic.Basic.Hierarchy +public import Foundation.FirstOrder.Arithmetic.Basic.Misc +public import Foundation.FirstOrder.Arithmetic.Basic.Model +public import Foundation.FirstOrder.Arithmetic.Basic.Monotone +public import Foundation.FirstOrder.Arithmetic.Definability +public import Foundation.FirstOrder.Arithmetic.Definability.Absoluteness +public import Foundation.FirstOrder.Arithmetic.Definability.BoundedDefinable +public import Foundation.FirstOrder.Arithmetic.Definability.Definable +public import Foundation.FirstOrder.Arithmetic.Definability.Hierarchy +public import Foundation.FirstOrder.Arithmetic.Exponential +public import Foundation.FirstOrder.Arithmetic.Exponential.Bit +public import Foundation.FirstOrder.Arithmetic.Exponential.Exp +public import Foundation.FirstOrder.Arithmetic.Exponential.Log +public import Foundation.FirstOrder.Arithmetic.Exponential.PPow2 +public import Foundation.FirstOrder.Arithmetic.Exponential.Pow2 +public import Foundation.FirstOrder.Arithmetic.HFS +public import Foundation.FirstOrder.Arithmetic.HFS.Basic +public import Foundation.FirstOrder.Arithmetic.HFS.Coding +public import Foundation.FirstOrder.Arithmetic.HFS.Fixpoint +public import Foundation.FirstOrder.Arithmetic.HFS.PRF +public import Foundation.FirstOrder.Arithmetic.HFS.Seq +public import Foundation.FirstOrder.Arithmetic.HFS.Vec +public import Foundation.FirstOrder.Arithmetic.IOpen.Basic +public import Foundation.FirstOrder.Arithmetic.Induction +public import Foundation.FirstOrder.Arithmetic.Omega1.Basic +public import Foundation.FirstOrder.Arithmetic.Omega1.Nuon +public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Basic +public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Functions +public import Foundation.FirstOrder.Arithmetic.PeanoMinus.Q +public import Foundation.FirstOrder.Arithmetic.Q.Basic +public import Foundation.FirstOrder.Arithmetic.R0.Basic +public import Foundation.FirstOrder.Arithmetic.R0.Representation +public import Foundation.FirstOrder.Arithmetic.Schemata +public import Foundation.FirstOrder.Arithmetic.TA.Basic +public import Foundation.FirstOrder.Arithmetic.TA.Nonstandard public import Foundation.FirstOrder.Basic public import Foundation.FirstOrder.Basic.AesopInit public import Foundation.FirstOrder.Basic.BinderNotation @@ -53,49 +53,50 @@ public import Foundation.FirstOrder.Basic.Semantics.Semantics public import Foundation.FirstOrder.Basic.Soundness public import Foundation.FirstOrder.Basic.Syntax.Formula public import Foundation.FirstOrder.Basic.Syntax.Rew --- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D1 --- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D2 --- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D3 --- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.EquationalTheory --- public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.PeanoMinus --- public import Foundation.FirstOrder.Bootstrapping.FixedPoint --- public import Foundation.FirstOrder.Bootstrapping.Syntax --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Basic --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Coding --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Functions --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Iteration --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Typed --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Language --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Proof.Basic --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Proof.Coding --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Proof.Typed --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Basic --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Coding --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Functions --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Typed --- public import Foundation.FirstOrder.Bootstrapping.Syntax.Theory +public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D1 +public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D2 +public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.D3 +public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.EquationalTheory +public import Foundation.FirstOrder.Bootstrapping.DerivabilityCondition.PeanoMinus +public import Foundation.FirstOrder.Bootstrapping.FixedPoint +public import Foundation.FirstOrder.Bootstrapping.Syntax +public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Basic +public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Coding +public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Functions +public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Iteration +public import Foundation.FirstOrder.Bootstrapping.Syntax.Formula.Typed +public import Foundation.FirstOrder.Bootstrapping.Syntax.Language +public import Foundation.FirstOrder.Bootstrapping.Syntax.Proof.Basic +public import Foundation.FirstOrder.Bootstrapping.Syntax.Proof.Coding +public import Foundation.FirstOrder.Bootstrapping.Syntax.Proof.Typed +public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Basic +public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Coding +public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Functions +public import Foundation.FirstOrder.Bootstrapping.Syntax.Term.Typed +public import Foundation.FirstOrder.Bootstrapping.Syntax.Theory +public import Foundation.FirstOrder.Completeness public import Foundation.FirstOrder.Completeness.CanonicalModel public import Foundation.FirstOrder.Completeness.CountableSublanguage public import Foundation.FirstOrder.Completeness.CounterModel --- public import Foundation.FirstOrder.Hauptsatz --- public import Foundation.FirstOrder.Incompleteness.Consistency --- public import Foundation.FirstOrder.Incompleteness.Dense +public import Foundation.FirstOrder.Hauptsatz +public import Foundation.FirstOrder.Incompleteness.Consistency +public import Foundation.FirstOrder.Incompleteness.Dense -- public import Foundation.FirstOrder.Incompleteness.Examples --- public import Foundation.FirstOrder.Incompleteness.First --- public import Foundation.FirstOrder.Incompleteness.GödelRosser +public import Foundation.FirstOrder.Incompleteness.First +public import Foundation.FirstOrder.Incompleteness.GödelRosser -- public import Foundation.FirstOrder.Incompleteness.Halting --- public import Foundation.FirstOrder.Incompleteness.Jeroslow --- public import Foundation.FirstOrder.Incompleteness.Löb --- public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Basic +public import Foundation.FirstOrder.Incompleteness.Jeroslow +public import Foundation.FirstOrder.Incompleteness.Löb +public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Basic -- public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Height --- public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Refutability --- public import Foundation.FirstOrder.Incompleteness.RestrictedProvability --- public import Foundation.FirstOrder.Incompleteness.RosserProvability +public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Refutability +public import Foundation.FirstOrder.Incompleteness.RestrictedProvability +public import Foundation.FirstOrder.Incompleteness.RosserProvability -- public import Foundation.FirstOrder.Incompleteness.Second --- public import Foundation.FirstOrder.Incompleteness.StandardProvability --- public import Foundation.FirstOrder.Incompleteness.Tarski --- public import Foundation.FirstOrder.Incompleteness.WitnessComparison --- public import Foundation.FirstOrder.Incompleteness.Yablo +public import Foundation.FirstOrder.Incompleteness.StandardProvability +public import Foundation.FirstOrder.Incompleteness.Tarski +public import Foundation.FirstOrder.Incompleteness.WitnessComparison +public import Foundation.FirstOrder.Incompleteness.Yablo -- public import Foundation.FirstOrder.Interpretation public import Foundation.FirstOrder.Intuitionistic.Deduction public import Foundation.FirstOrder.Intuitionistic.Formula @@ -104,7 +105,7 @@ public import Foundation.FirstOrder.Kripke.Basic public import Foundation.FirstOrder.Kripke.Intuitionistic -- public import Foundation.FirstOrder.Kripke.WeakForcing public import Foundation.FirstOrder.NegationTranslation.GoedelGentzen --- public import Foundation.FirstOrder.Order.Le +public import Foundation.FirstOrder.Order.Le public import Foundation.FirstOrder.Polarity -- public import Foundation.FirstOrder.SetTheory.Basic -- public import Foundation.FirstOrder.SetTheory.Basic.Axioms @@ -185,12 +186,12 @@ public import Foundation.InterpretabilityLogic.Veltman.Logic.IL_P₀ public import Foundation.InterpretabilityLogic.Veltman.Logic.IL_R public import Foundation.InterpretabilityLogic.Veltman.Logic.IL_R_W public import Foundation.InterpretabilityLogic.Veltman.Logic.IL_W --- public import Foundation.LinearLogic.FirstOrder.Calculus +public import Foundation.LinearLogic.FirstOrder.Calculus -- public import Foundation.LinearLogic.FirstOrder.ClassicalEmbedding --- public import Foundation.LinearLogic.FirstOrder.Formula --- public import Foundation.LinearLogic.FirstOrder.Rew --- public import Foundation.LinearLogic.LogicSymbol --- public import Foundation.LinearLogic.MLL +public import Foundation.LinearLogic.FirstOrder.Formula +public import Foundation.LinearLogic.FirstOrder.Rew +public import Foundation.LinearLogic.LogicSymbol +public import Foundation.LinearLogic.MLL public import Foundation.Logic.Calculus public import Foundation.Logic.Decidability public import Foundation.Logic.Disjunctive @@ -208,14 +209,14 @@ public import Foundation.Meta.Test public import Foundation.Meta.TwoSided public import Foundation.Modal.Algebra.Basic public import Foundation.Modal.Axioms --- public import Foundation.Modal.Boxdot.Basic --- public import Foundation.Modal.Boxdot.GLPoint3_GrzPoint3 --- public import Foundation.Modal.Boxdot.GL_Grz +public import Foundation.Modal.Boxdot.Basic +public import Foundation.Modal.Boxdot.GLPoint3_GrzPoint3 +public import Foundation.Modal.Boxdot.GL_Grz -- public import Foundation.Modal.Boxdot.GL_S -- public import Foundation.Modal.Boxdot.Grz_S --- public import Foundation.Modal.Boxdot.Jerabek --- public import Foundation.Modal.Boxdot.K4_S4 --- public import Foundation.Modal.Boxdot.Ver_Triv +public import Foundation.Modal.Boxdot.Jerabek +public import Foundation.Modal.Boxdot.K4_S4 +public import Foundation.Modal.Boxdot.Ver_Triv public import Foundation.Modal.ComplementClosedConsistentFinset public import Foundation.Modal.Entailment.AxiomGeach public import Foundation.Modal.Entailment.Basic @@ -474,7 +475,7 @@ public import Foundation.Propositional.Translation -- public import Foundation.ProvabilityLogic.S.Completeness -- public import Foundation.ProvabilityLogic.S.Soundness -- public import Foundation.ProvabilityLogic.SolovaySentences --- public import Foundation.SecondOrder.Derivation +public import Foundation.SecondOrder.Derivation -- public import Foundation.SecondOrder.Semantics -- public import Foundation.SecondOrder.Syntax.Formula -- public import Foundation.SecondOrder.Syntax.Rew @@ -515,6 +516,7 @@ public import Foundation.Vorspiel.Option public import Foundation.Vorspiel.Order.Dense public import Foundation.Vorspiel.Order.Heyting public import Foundation.Vorspiel.Order.Ideal +public import Foundation.Vorspiel.Order.Lattice public import Foundation.Vorspiel.Order.LowerSet public import Foundation.Vorspiel.Order.Regular public import Foundation.Vorspiel.Part diff --git a/Foundation/FirstOrder/Basic/Definability.lean b/Foundation/FirstOrder/Basic/Definability.lean index 59778fb58..5d1deeb18 100644 --- a/Foundation/FirstOrder/Basic/Definability.lean +++ b/Foundation/FirstOrder/Basic/Definability.lean @@ -17,7 +17,7 @@ namespace LO.FirstOrder variable {L : Language} {M : Type*} [Structure L M] abbrev IsDefinedBy (R : (Fin k → M) → Prop) (φ : Semisentence L k) : Prop := - ∀ v, Semiformula.Evalb v φ ↔ R v + ∀ v, φ.Evalb v ↔ R v class Defined (R : outParam ((Fin k → M) → Prop)) (φ : Semisentence L k) : Prop where iff : IsDefinedBy R φ @@ -177,13 +177,13 @@ end Language namespace IsDefinedBy -lemma of_vec_one {R : (Fin 1 → M) → Prop} {φ : Semisentence L 1} (h : ∀ x, Semiformula.Evalb ![x] φ ↔ R ![x]) : IsDefinedBy R φ := by +lemma of_vec_one {R : (Fin 1 → M) → Prop} {φ : Semisentence L 1} (h : ∀ x, φ.Evalb ![x] ↔ R ![x]) : IsDefinedBy R φ := by intro v; simpa [←Matrix.fun_eq_vec_one] using h (v 0) -lemma of_vec_two {R : (Fin 2 → M) → Prop} {φ : Semisentence L 2} (h : ∀ x y, Semiformula.Evalb ![x, y] φ ↔ R ![x, y]) : IsDefinedBy R φ := by +lemma of_vec_two {R : (Fin 2 → M) → Prop} {φ : Semisentence L 2} (h : ∀ x y, φ.Evalb ![x, y] ↔ R ![x, y]) : IsDefinedBy R φ := by intro v; simpa [←Matrix.fun_eq_vec_two] using h (v 0) (v 1) -lemma of_vec_three {R : (Fin 3 → M) → Prop} {φ : Semisentence L 3} (h : ∀ x y z, Semiformula.Evalb ![x, y, z] φ ↔ R ![x, y, z]) : IsDefinedBy R φ := by +lemma of_vec_three {R : (Fin 3 → M) → Prop} {φ : Semisentence L 3} (h : ∀ x y z, φ.Evalb ![x, y, z] ↔ R ![x, y, z]) : IsDefinedBy R φ := by intro v; simpa [←Matrix.fun_eq_vec_three] using h (v 0) (v 1) (v 2) end IsDefinedBy diff --git a/Foundation/FirstOrder/Basic/Model.lean b/Foundation/FirstOrder/Basic/Model.lean index 22c1517ed..47a2bb172 100644 --- a/Foundation/FirstOrder/Basic/Model.lean +++ b/Foundation/FirstOrder/Basic/Model.lean @@ -123,13 +123,13 @@ variable {L₁ L₂ M} induction t <;> simp [Language.Hom.func_add₂, Function.comp_def, *] @[simp] lemma eval_lMap_add₁ {n} (φ : Semiformula L₁ μ n) (e : Fin n → M) (f : μ → M) : - Semiformula.Eval (s := add L₁ L₂ M) e f (Semiformula.lMap (Language.Hom.add₁ L₁ L₂) φ) - ↔ Semiformula.Eval (s := str₁) e f φ := by + (Semiformula.lMap (Language.Hom.add₁ L₁ L₂) φ).Eval (s := add L₁ L₂ M) e f + ↔ φ.Eval (s := str₁) e f := by induction φ using Semiformula.rec' <;> simp [*, Language.Hom.rel_add₁, Function.comp_def] @[simp] lemma eval_lMap_add₂ {n} (φ : Semiformula L₂ μ n) (e : Fin n → M) (f : μ → M) : - Semiformula.Eval (s := add L₁ L₂ M) e f (Semiformula.lMap (Language.Hom.add₂ L₁ L₂) φ) - ↔ Semiformula.Eval (s := str₂) e f φ := by + (Semiformula.lMap (Language.Hom.add₂ L₁ L₂) φ).Eval (s := add L₁ L₂ M) e f + ↔ φ.Eval (s := str₂) e f := by induction φ using Semiformula.rec' <;> simp [*, Language.Hom.rel_add₂, Function.comp_def] end add @@ -151,8 +151,8 @@ instance sigma : Structure (Language.sigma L) M where induction t <;> simp [*, Language.Hom.func_sigma, Function.comp_def] @[simp] lemma eval_lMap_sigma {n} (φ : Semiformula (L i) μ n) (e : Fin n → M) (f : μ → M) : - Semiformula.Eval (s := sigma L M) e f (Semiformula.lMap (Language.Hom.sigma L i) φ) - ↔ Semiformula.Eval (s := str i) e f φ := by + (Semiformula.lMap (Language.Hom.sigma L i) φ).Eval (s := sigma L M) e f + ↔ φ.Eval (s := str i) e f := by induction φ using Semiformula.rec' <;> simp [*, Language.Hom.rel_sigma, Function.comp_def] end sigma @@ -178,7 +178,7 @@ lemma Semiterm.val_uLift {e : Fin n → ULift.{v'} M} {f : ξ → ULift.{v'} M} induction t <;> simp [*, Function.comp_def] lemma Semiformula.eval_uLift {e : Fin n → ULift.{v'} M} {f : ξ → ULift.{v'} M} {φ : Semiformula L ξ n} : - Semiformula.Eval e f φ ↔ Semiformula.Eval (ULift.down ∘ e) (ULift.down ∘ f) φ := by + φ.Eval e f ↔ φ.Eval (ULift.down ∘ e) (ULift.down ∘ f) := by induction φ using Semiformula.rec' <;> simp [*, Semiterm.val_uLift, Matrix.comp_vecCons', Function.comp_def] diff --git a/Foundation/FirstOrder/Basic/Operator.lean b/Foundation/FirstOrder/Basic/Operator.lean index c2c0d9e81..0052b06a0 100644 --- a/Foundation/FirstOrder/Basic/Operator.lean +++ b/Foundation/FirstOrder/Basic/Operator.lean @@ -407,7 +407,7 @@ variable {L : Language} end Operator def Operator.val {M : Type w} [s : Structure L M] {k} (v : Fin k → M) (o : Operator L k) : Prop := - Semiformula.Eval v Empty.elim o.sentence + o.sentence.Eval v Empty.elim section diff --git a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean index ad45b38b9..cc67ba187 100644 --- a/Foundation/FirstOrder/Basic/Semantics/Semantics.lean +++ b/Foundation/FirstOrder/Basic/Semantics/Semantics.lean @@ -454,7 +454,7 @@ lemma eval_toEmpty [DecidableEq ξ] {n} {φ : Semiformula L ξ n} (hp : φ.freeV simp [Semiformula.univCl, ←eval_toEmpty (f := default)] @[simp] lemma eval_enumarateFVar_idxOfFVar_eq_id [DecidableEq M] [Inhabited M] (φ : Semiformula L M n) (v) : - Semiformula.Eval v (fun x ↦ φ.enumarateFVar (φ.idxOfFVar x)) φ ↔ Semiformula.Eval v id φ := + φ.Eval v (fun x ↦ φ.enumarateFVar (φ.idxOfFVar x)) ↔ φ.Eval v id := Semiformula.eval_iff_of_funEqOn _ <| by intro x hx; simp [Semiformula.enumarateFVar_idxOfFVar (Semiformula.mem_fvarList_iff_fvar?.mpr hx)] diff --git a/Foundation/FirstOrder/Incompleteness/Consistency.lean b/Foundation/FirstOrder/Incompleteness/Consistency.lean index 404be5f95..a525784d5 100644 --- a/Foundation/FirstOrder/Incompleteness/Consistency.lean +++ b/Foundation/FirstOrder/Incompleteness/Consistency.lean @@ -36,7 +36,7 @@ section noncomputable def _root_.LO.FirstOrder.Theory.consistent : 𝚷₁.Sentence := .mkPi (∼provabilityPred T ⊥) -@[simp] lemma consistent.defined : _root_.LO.FirstOrder.Semiformula.Evalb (M := V) ![] (T.consistent : Sentence ℒₒᵣ) ↔ T.Consistent V := by +@[simp] lemma consistent.defined : (T.consistent : Sentence ℒₒᵣ).Evalb (M := V) ![] ↔ T.Consistent V := by simp [Theory.consistent, Theory.Consistent] noncomputable def _root_.LO.FirstOrder.Theory.consistentWith : 𝚷₁.Semisentence 1 := .mkPi diff --git a/Foundation/FirstOrder/Interpretation.lean b/Foundation/FirstOrder/Interpretation.lean index 86be389c5..ad4fbaa0b 100644 --- a/Foundation/FirstOrder/Interpretation.lean +++ b/Foundation/FirstOrder/Interpretation.lean @@ -1,6 +1,6 @@ module -public import Foundation.FirstOrder.Completeness.Corollaries +public import Foundation.FirstOrder.Completeness.CounterModel public import Foundation.Vorspiel.ExistsUnique @[expose] public section @@ -11,7 +11,7 @@ public import Foundation.Vorspiel.ExistsUnique namespace LO.FirstOrder @[ext] -structure DirectTranslation {L₁ : Language} [L₁.Eq] (T : Theory L₁) [𝗘𝗤 ⪯ T] (L₂ : Language) [L₂.Eq] where +structure DirectTranslation {L₁ : Language} [L₁.Eq] (T : Theory L₁) [𝗘𝗤 _ ⪯ T] (L₂ : Language) [L₂.Eq] where domain : Semisentence L₁ 1 rel {k} : L₂.Rel k → Semisentence L₁ k func {k} : L₂.Func k → Semisentence L₁ (k + 1) @@ -24,7 +24,7 @@ structure DirectTranslation {L₁ : Language} [L₁.Eq] (T : Theory L₁) [𝗘 namespace DirectTranslation -variable {L₁ L₂ : Language} [L₁.Eq] [L₂.Eq] {T : Theory L₁} [𝗘𝗤 ⪯ T] +variable {L₁ L₂ : Language} [L₁.Eq] [L₂.Eq] {T : Theory L₁} [𝗘𝗤 _ ⪯ T] variable (π : DirectTranslation T L₂) @@ -108,7 +108,7 @@ variable {π} lemma dom_iff {x : M} : π.Dom x ↔ M ⊧/![x] π.domain := iff_of_eq rfl -lemma domain_exists [Nonempty M] [M ⊧ₘ* T] : ∃ x : M, π.Dom x := by +lemma domain_exists [Nonempty M] [M↓[L₁] ⊧* T] : ∃ x : M, π.Dom x := by simpa [models_iff] using models_of_provable (M := M) inferInstance π.domain_nonempty variable (π M) @@ -128,7 +128,7 @@ namespace Model @[simp] lemma pval_sub_domain (x : π.Model M) : M ⊧/![x] π.domain := x.dom -instance [Nonempty M] [M ⊧ₘ* T] : Nonempty (π.Model M) := by +instance [Nonempty M] [M↓[L₁] ⊧* T] : Nonempty (π.Model M) := by rcases π.domain_exists (M := M) with ⟨x, hx⟩; exact ⟨⟨x, hx⟩⟩ @[simp] lemma coe_mem_domain (x : π.Model M) : π.Dom (x : M) := x.dom @@ -144,25 +144,27 @@ instance [Nonempty M] [M ⊧ₘ* T] : Nonempty (π.Model M) := by (⟨x, hx⟩ : π.Model M) = (⟨y, hy⟩ : π.Model M) ↔ x = y := by simp @[simp] lemma eval_fal {φ : Semiformula L₁ ξ (n + 1)} : - Evalm M e ε (∀_[π] φ) ↔ ∀ x : π.Model M, Evalm M (x :> e) ε φ := by - suffices (∀ x, π.Dom x → Evalm M (x :> e) ε φ) ↔ ∀ x : π.Model M, (Evalm M (↑x :> e) ε) φ by + Semiformula.Eval (M := M) e ε (∀_[π] φ) ↔ ∀ x : π.Model M, Semiformula.Eval (M := M) (x :> e) ε φ := by + suffices (∀ x, π.Dom x → Semiformula.Eval (M := M) (x :> e) ε φ) ↔ + ∀ x : π.Model M, Semiformula.Eval (M := M) (↑x :> e) ε φ by simpa [fal, ←dom_iff, Matrix.constant_eq_singleton] constructor · intro h x; exact h x x.dom · intro h x hx; simpa using h ⟨x, hx⟩ @[simp] lemma eval_exs {φ : Semiformula L₁ ξ (n + 1)} : - Evalm M e ε (∃_[π] φ) ↔ ∃ x : π.Model M, Evalm M (x :> e) ε φ := by - suffices (∃ x, π.Dom x ∧ Evalm M (x :> e) ε φ) ↔ ∃ x : π.Model M, (Evalm M (↑x :> e) ε) φ by + Semiformula.Eval (M := M) e ε (∃_[π] φ) ↔ ∃ x : π.Model M, Semiformula.Eval (M := M) (x :> e) ε φ := by + suffices (∃ x, π.Dom x ∧ Semiformula.Eval (M := M) (x :> e) ε φ) ↔ + ∃ x : π.Model M, Semiformula.Eval (M := M) (↑x :> e) ε φ by simpa [exs, ←dom_iff, Matrix.constant_eq_singleton] constructor · rintro ⟨x, hx, H⟩; exact ⟨⟨x, hx⟩, by simpa using H⟩ · rintro ⟨x, H⟩; exact ⟨x, by simp, H⟩ -variable [Nonempty M] [M ⊧ₘ* T] [Structure.Eq L₁ M] +variable [Nonempty M] [M↓[L₁] ⊧* T] [Structure.Eq L₁ M] lemma func_existsUnique_on_dom {k} (f : L₂.Func k) : - ∀ (v : Fin k → M), (∀ i, π.Dom (v i)) → ∃! y, π.Dom y ∧ Evalbm M (y :> v) (π.func f) := by + ∀ (v : Fin k → M), (∀ i, π.Dom (v i)) → ∃! y, π.Dom y ∧ (π.func f).Evalb (y :> v) := by simpa [Dom, models_iff, eval_substs, Matrix.constant_eq_singleton] using models_of_provable (M := M) inferInstance (π.func_defined f) @@ -179,17 +181,17 @@ lemma func_existsUnique {k} (f : L₂.Func k) (v : Fin k → π.Model M) : variable (π M) noncomputable instance struc : Structure L₂ (π.Model M) where - rel _ R v := Semiformula.Evalbm M (fun i ↦ (v i)) (π.rel R) + rel _ R v := (π.rel R).Evalb fun i ↦ (v i : M) func _ f v := Classical.choose! (func_existsUnique (π := π) f v) variable {π M} lemma rel_iff {k} (r : L₂.Rel k) (v : Fin k → π.Model M) : - Structure.rel r v ↔ Semiformula.Evalbm M (fun i ↦ (v i)) (π.rel r) := iff_of_eq rfl + Structure.rel r v ↔ (π.rel r).Evalb (fun i ↦ (v i : M)) := iff_of_eq rfl @[simp] lemma eq_iff' {a b : π.Model M} : M ⊧/![a, b] (π.rel Language.Eq.eq) ↔ a = b := by - have : M ⊧ₘ* T := inferInstance + have : M↓[L₁] ⊧* T := inferInstance have : ∀ x y, π.Dom x → π.Dom y → (M ⊧/![x, y] (π.rel Language.Eq.eq) ↔ x = y) := by simpa [models_iff, Matrix.comp_vecCons', Matrix.constant_eq_singleton, ←dom_iff] using models_of_provable this π.preserve_eq @@ -204,76 +206,81 @@ instance : Structure.Eq L₂ (π.Model M) where eq a b := by simp [Operator.val, Operator.Eq.sentence_eq, eval_rel] lemma func_iff {k} {f : L₂.Func k} {y : π.Model M} {v : Fin k → π.Model M} : - y = Structure.func f v ↔ Evalbm M (y :> fun i ↦ v i) (π.func f) := Classical.choose!_eq_iff_right _ + y = Structure.func f v ↔ (π.func f).Evalb (↑y :> fun i ↦ (v i : M)) := Classical.choose!_eq_iff_right _ lemma func_iff' {k} {f : L₂.Func k} {y : M} {v : Fin k → π.Model M} : - y = Structure.func f v ↔ π.Dom y ∧ Evalbm M (y :> fun i ↦ v i) (π.func f) := by + y = Structure.func f v ↔ π.Dom y ∧ (π.func f).Evalb (y :> fun i ↦ (v i : M)) := by constructor · rintro rfl; simp [←func_iff] · intro h exact (func_existsUnique_on_dom f (fun i ↦ (v i : M)) (by simp)).unique h (by simp [←func_iff]) @[simp] lemma eval_func {k} (f : L₂.Func k) (v : Fin k → π.Model M) : - Evalbm M (↑(Structure.func f v) :> fun i ↦ v i) (π.func f) := by simp [←func_iff] + (π.func f).Evalb (↑(Structure.func f v) :> fun i ↦ (v i : M)) := by simp [←func_iff] lemma eval_varEqual_iff {t : Semiterm L₂ ξ n} {ε : ξ → π.Model M} {y : π.Model M} {x : Fin n → π.Model M} : - Evalm M (y :> fun i ↦ x i) (fun x ↦ ε x) (π.varEqual t) ↔ y = t.valm (π.Model M) x ε := by + Semiformula.Eval (M := M) (y :> fun i ↦ x i) (fun x ↦ ε x) (π.varEqual t) ↔ + y = t.val (M := π.Model M) x ε := by match t with | #_ => simp [varEqual] | &_ => simp [varEqual] | .func (arity := k) f v => suffices - (∀ w : Fin k → M, - (∀ i, π.Dom (w i) ∧ Evalm M (w i :> fun i ↦ x i) (fun x ↦ ε x) (π.varEqual (v i))) → - M ⊧/(y :> w) (π.func f)) ↔ - M ⊧/(y :> fun i ↦ (v i).valm (π.Model M) x ε) (π.func f) by + (∀ w : Fin k → M, + (∀ i, π.Dom (w i) ∧ + Semiformula.Eval (M := M) (w i :> fun i ↦ x i) (fun x ↦ ε x) (π.varEqual (v i))) → + M ⊧/(y :> w) (π.func f)) ↔ + M ⊧/(y :> fun i ↦ (v i).val (M := π.Model M) x ε) (π.func f) by simpa [varEqual, eval_embSubsts, Matrix.comp_vecCons', Matrix.constant_eq_singleton, - Semiterm.val_func, func_iff, ←dom_iff] + Semiterm.val_func, Semiterm.val_rew, func_iff, ←dom_iff, Function.comp_def] constructor · intro h; apply h intro i simp [eval_varEqual_iff (t := v i)] · intro h w hw - suffices w = fun i ↦ ↑((v i).valm (π.Model M) x ε) by rcases this; exact h + suffices w = fun i ↦ ↑((v i).val (M := π.Model M) x ε) by rcases this; exact h ext i let w' : π.Model M := ⟨w i, (hw i).1⟩ - have : Evalm M (w' :> fun i ↦ x i) (fun x ↦ ε x) (π.varEqual (v i)) := by simp [w', hw] + have : Semiformula.Eval (M := M) (w' :> fun i ↦ x i) (fun x ↦ ε x) (π.varEqual (v i)) := by simp [w', hw] simpa [w'] using congr_arg Model.val (eval_varEqual_iff.mp this) lemma eval_translateRel_iff {n k} {ε : ξ → π.Model M} (e : Fin n → π.Model M) (R : L₂.Rel k) (v : Fin k → Semiterm L₂ ξ n) : - Evalm M (fun i ↦ e i) (fun i ↦ ε i) (π.translateRel R v) ↔ Structure.rel R fun i ↦ Semiterm.valm (π.Model M) e ε (v i) := by + Semiformula.Eval (M := M) (fun i ↦ e i) (fun i ↦ ε i) (π.translateRel R v) ↔ + Structure.rel R fun i ↦ (v i).val (M := π.Model M) e ε := by suffices - (∀ w, (∀ i, π.Dom (w i) ∧ (Evalm M (w i :> fun i ↦ ↑(e i)) fun i ↦ ↑(ε i)) (π.varEqual (v i))) → M ⊧/w (π.rel R)) ↔ - M ⊧/(fun i ↦ ↑((v i).valm (π.Model M) e ε)) (π.rel R) by - simpa [translateRel, Matrix.comp_vecCons', rel_iff, eval_embSubsts, Matrix.constant_eq_singleton, ←dom_iff] + (∀ w, (∀ i, π.Dom (w i) ∧ + Semiformula.Eval (M := M) (w i :> fun i ↦ ↑(e i)) (fun i ↦ ↑(ε i)) (π.varEqual (v i))) → M ⊧/w (π.rel R)) ↔ + M ⊧/(fun i ↦ ↑((v i).val (M := π.Model M) e ε)) (π.rel R) by + simpa [translateRel, Matrix.comp_vecCons', rel_iff, eval_embSubsts, + Matrix.constant_eq_singleton, Semiterm.val_rew, ←dom_iff, Function.comp_def] constructor · intro h - exact h (fun i ↦ ↑((v i).valm (π.Model M) e ε)) (fun i ↦ by simp [eval_varEqual_iff]) + exact h (fun i ↦ ↑((v i).val (M := π.Model M) e ε)) (fun i ↦ by simp [eval_varEqual_iff]) · intro h w hw - suffices w = fun i ↦ ↑((v i).valm (π.Model M) e ε) by rcases this; exact h + suffices w = fun i ↦ ↑((v i).val (M := π.Model M) e ε) by rcases this; exact h ext i let w' : π.Model M := ⟨w i, (hw i).1⟩ - have : Evalm M (w' :> fun i ↦ e i) (fun x ↦ ε x) (π.varEqual (v i)) := by simp [w', hw] + have : Semiformula.Eval (M := M) (w' :> fun i ↦ e i) (fun x ↦ ε x) (π.varEqual (v i)) := by simp [w', hw] simpa [w'] using congr_arg Model.val (eval_varEqual_iff.mp this) lemma eval_translate_iff {φ : Semiformula L₂ ξ n} {ε : ξ → π.Model M} {e : Fin n → π.Model M} : - Evalm M (fun i ↦ e i) (fun i ↦ ε i) (π.translate φ) ↔ Evalm (π.Model M) e ε φ := by + Semiformula.Eval (M := M) (fun i ↦ e i) (fun i ↦ ε i) (π.translate φ) ↔ φ.Eval e ε := by match φ with - | .rel R v => simp [eval_rel, eval_translateRel_iff] - | .nrel R v => simp [eval_nrel, eval_translateRel_iff] + | .rel R v => simp [eval_rel, eval_translateRel_iff, Function.comp_def] + | .nrel R v => simp [eval_nrel, eval_translateRel_iff, Function.comp_def] | ⊤ => simp | ⊥ => simp | φ ⋏ ψ => simp [eval_translate_iff (φ := φ), eval_translate_iff (φ := ψ)] | φ ⋎ ψ => simp [eval_translate_iff (φ := φ), eval_translate_iff (φ := ψ)] | ∀⁰ φ => suffices - (∀ a : π.Model M, Evalm M (a :> fun i ↦ ↑(e i)) (fun i ↦ ↑(ε i)) (π.translate φ)) ↔ - (∀ a : π.Model M, Evalm (π.Model M) (a :> e) ε φ) by simpa + (∀ a : π.Model M, Semiformula.Eval (M := M) (a :> fun i ↦ ↑(e i)) (fun i ↦ ↑(ε i)) (π.translate φ)) ↔ + (∀ a : π.Model M, φ.Eval (a :> e) ε) by simpa exact forall_congr' fun a ↦ by simp [←eval_translate_iff (φ := φ), Matrix.comp_vecCons'] | ∃⁰ φ => suffices - (∃ a : π.Model M, Evalm M (a :> fun i ↦ ↑(e i)) (fun i ↦ ↑(ε i)) (π.translate φ)) ↔ - (∃ a : π.Model M, Evalm (π.Model M) (a :> e) ε φ) by simpa + (∃ a : π.Model M, Semiformula.Eval (M := M) (a :> fun i ↦ ↑(e i)) (fun i ↦ ↑(ε i)) (π.translate φ)) ↔ + (∃ a : π.Model M, φ.Eval (a :> e) ε) by simpa exact exists_congr fun a ↦ by simp [←eval_translate_iff (φ := φ), Matrix.comp_vecCons'] lemma evalb_translate_iff {φ : Semisentence L₂ n} {e : Fin n → π.Model M} : @@ -292,7 +299,7 @@ lemma evalb_doubleton_translate_iff {φ : Semisentence L₂ 2} {x y : π.Model M simp [←eval_translate_iff, Empty.eq_elim, Matrix.constant_eq_singleton, Matrix.comp_vecCons'] lemma translate_iff {σ : Sentence L₂} : - M ⊧ₘ π.translate σ ↔ π.Model M ⊧ₘ σ := by + M↓[L₁] ⊧ π.translate σ ↔ (π.Model M)↓[L₂] ⊧ σ := by simpa [models_iff, Matrix.empty_eq, Empty.eq_elim] using eval_translate_iff (M := M) (π := π) (ε := Empty.elim) (e := ![]) (φ := σ) @@ -306,11 +313,19 @@ protected def id : DirectTranslation T L₁ where domain := ⊤ rel R := Semiformula.rel R (#·) func f := “z. z = !!(Semiterm.func f (#·.succ))” - domain_nonempty := complete <| EQ.provOf.{_,0} _ fun _ _ _ _ ↦ (by simp [models_iff]) - func_defined {k} f := complete <| EQ.provOf.{_,0} _ fun _ _ _ _ _ ↦ by - simp [models_iff, Semiterm.val_func] - preserve_eq := complete <| EQ.provOf.{_,0} _ fun M _ _ _ _ ↦ by - simp [models_iff, Matrix.comp_vecCons', Matrix.constant_eq_singleton, Semiformula.eval_rel] + domain_nonempty := by + apply Theory.Proof.complete_on_eq_models.{_, 0} + intro M _ _ _ _ + simp [models_iff] + func_defined {k} f := by + apply Theory.Proof.complete_on_eq_models.{_, 0} + intro M _ _ _ _ + simp [models_iff, Semiterm.val_func, Matrix.comp_vecCons', + Matrix.constant_eq_singleton, Function.comp_def] + preserve_eq := by + apply Theory.Proof.complete_on_eq_models.{_, 0} + intro M _ _ _ _ + simp [models_iff, Semiformula.eval_rel] lemma id_func_def : (DirectTranslation.id T).func f = “z. z = !!(Semiterm.func f (#·.succ))” := rfl @@ -326,27 +341,29 @@ variable {M : Type*} [Structure L₁ M] @[simp] lemma id_Dom (x : M) : (DirectTranslation.id T).Dom x := by simp [dom_iff, DirectTranslation.id] -variable [Nonempty M] [M ⊧ₘ* T] [Structure.Eq L₁ M] +variable [Nonempty M] [M↓[L₁] ⊧* T] [Structure.Eq L₁ M] @[simp] lemma id_val_eq {ε : ξ → (DirectTranslation.id T).Model M} {e : Fin n → (DirectTranslation.id T).Model M} {t : Semiterm L₁ ξ n} : - t.valm ((DirectTranslation.id T).Model M) e ε = t.valm M (fun x ↦ e x) (fun x ↦ ε x) := by + t.val (M := (DirectTranslation.id T).Model M) e ε = + t.val (M := M) (fun x ↦ e x) (fun x ↦ ε x) := by match t with | #x => simp | &x => simp | .func f v => - have : ∀ i, (v i).valm ((DirectTranslation.id T).Model M) e ε = (v i).valm M (fun x ↦ e x) (fun x ↦ ε x) := fun i ↦ + have : ∀ i, (v i).val (M := (DirectTranslation.id T).Model M) e ε = + (v i).val (M := M) (fun x ↦ e x) (fun x ↦ ε x) := fun i ↦ id_val_eq (t := v i) (e := e) (ε := ε) symm - simp [Semiterm.val_func, Model.func_iff', - id_func_def, Semiterm.val_func, this] + simp [Semiterm.val_func, Model.func_iff', id_func_def, this, Function.comp_def] @[simp] lemma id_models_iff {ε : ξ → (DirectTranslation.id T).Model M} {e : Fin n → (DirectTranslation.id T).Model M} {φ : Semiformula L₁ ξ n} : - Evalm ((DirectTranslation.id T).Model M) e ε φ ↔ Evalm M (fun x ↦ e x) (fun x ↦ ε x) φ := by + Semiformula.Eval (M := (DirectTranslation.id T).Model M) e ε φ ↔ + Semiformula.Eval (M := M) (fun x ↦ e x) (fun x ↦ ε x) φ := by match φ with - | .rel R v => simp [eval_rel, Model.rel_iff, id_rel_def] - | .nrel R v => simp [eval_nrel, eval_rel, Model.rel_iff, id_rel_def] + | .rel R v => simp [eval_rel, Model.rel_iff, id_rel_def, Function.comp_def] + | .nrel R v => simp [eval_nrel, eval_rel, Model.rel_iff, id_rel_def, Function.comp_def] | ⊤ => simp | ⊥ => simp | φ ⋏ ψ => simp [id_models_iff (φ := φ), id_models_iff (φ := ψ)] @@ -366,17 +383,17 @@ end semantics end DirectTranslation -class DirectInterpretation {L₁ L₂ : Language} [L₁.Eq] [L₂.Eq] (T : Theory L₁) [𝗘𝗤 ⪯ T] (U : Theory L₂) where +class DirectInterpretation {L₁ L₂ : Language} [L₁.Eq] [L₂.Eq] (T : Theory L₁) [𝗘𝗤 _ ⪯ T] (U : Theory L₂) where trln : DirectTranslation T L₂ interpret_theory : ∀ φ ∈ U, T ⊢ trln.translate φ infix:50 " ⊳ " => DirectInterpretation -abbrev InterpretedBy {L₁ L₂ : Language} [L₁.Eq] [L₂.Eq] (U : Theory L₂) (T : Theory L₁) [𝗘𝗤 ⪯ T] := T ⊳ U +abbrev InterpretedBy {L₁ L₂ : Language} [L₁.Eq] [L₂.Eq] (U : Theory L₂) (T : Theory L₁) [𝗘𝗤 _ ⪯ T] := T ⊳ U infix:50 " ⊲ " => InterpretedBy -class MutualDirectInterpretation {L₁ L₂ : Language} [L₁.Eq] [L₂.Eq] (T : Theory L₁) [𝗘𝗤 ⪯ T] (U : Theory L₂) [𝗘𝗤 ⪯ U] where +class MutualDirectInterpretation {L₁ L₂ : Language} [L₁.Eq] [L₂.Eq] (T : Theory L₁) [𝗘𝗤 _ ⪯ T] (U : Theory L₂) [𝗘𝗤 _ ⪯ U] where r : T ⊳ U l : T ⊲ U @@ -388,46 +405,53 @@ open DirectTranslation section -variable {L₁ L₂ : Language} [L₁.Eq] [L₂.Eq] {T : Theory L₁} [𝗘𝗤 ⪯ T] {U : Theory L₂} (π : T ⊳ U) +variable {L₁ L₂ : Language} [L₁.Eq] [L₂.Eq] {T : Theory L₁} [𝗘𝗤 _ ⪯ T] {U : Theory L₂} (π : T ⊳ U) abbrev translate (φ : Semiformula L₂ ξ n) : Semiformula L₁ ξ n := π.trln.translate φ abbrev Model (M : Type*) [Structure L₁ M] : Type _ := π.trln.Model M open Classical in -instance model_models_theory {M : Type v} [Nonempty M] [Structure L₁ M] [Structure.Eq L₁ M] (hT : M ⊧ₘ* T) : - π.Model M ⊧ₘ* U := +instance model_models_theory {M : Type v} [Nonempty M] [Structure L₁ M] [Structure.Eq L₁ M] (hT : M↓[L₁] ⊧* T) : + (π.Model M)↓[L₂] ⊧* U := models_theory_iff.mpr fun {σ} hσ ↦ - Model.translate_iff.mp <| consequence_iff'.mp (sound! (π.interpret_theory σ hσ)) M + Model.translate_iff.mp <| models_of_provable hT (π.interpret_theory σ hσ) open Classical in lemma of_provability {σ : Sentence L₂} (h : U ⊢ σ) : T ⊢ π.translate σ := - complete <| EQ.provOf.{_,0} _ fun _ _ _ _ hT ↦ + by + apply Theory.Proof.complete_on_eq_models.{_, 0} + intro M _ _ _ hT + exact Model.translate_iff.mpr <| models_of_provable (π.model_models_theory hT) h end -abbrev ofWeakerThan {L : Language} [L.Eq] (T U : Theory L) [𝗘𝗤 ⪯ T] [U ⪯ T] : U ⊲ T where +abbrev ofWeakerThan {L : Language} [L.Eq] (T U : Theory L) [𝗘𝗤 _ ⪯ T] [U ⪯ T] : U ⊲ T where trln := DirectTranslation.id T - interpret_theory φ hφ := complete <| EQ.provOf.{_,0} _ fun M _ _ _ hT ↦ + interpret_theory φ hφ := by + apply Theory.Proof.complete_on_eq_models.{_, 0} + intro M _ _ _ hT have : U ⪯ T := inferInstance - Model.translate_iff.mpr <| by - suffices M ⊧/ ![] φ by simpa [models_iff, Empty.eq_elim, Matrix.empty_eq] + exact Model.translate_iff.mpr <| by + suffices M ⊧/![] φ by simpa [models_iff, Empty.eq_elim, Matrix.empty_eq] have : T ⊢ φ := Entailment.weakerThan_iff.mp this (Entailment.by_axm (by simp [hφ])) exact models_of_provable hT this -protected instance refl {L : Language} [L.Eq] (T : Theory L) [𝗘𝗤 ⪯ T] : T ⊳ T := ofWeakerThan T T +protected instance refl {L : Language} [L.Eq] (T : Theory L) [𝗘𝗤 _ ⪯ T] : T ⊳ T := ofWeakerThan T T section composition -variable {L₁ L₂ L₃ : Language} [L₁.Eq] [L₂.Eq] [L₃.Eq] {T₁ : Theory L₁} {T₂ : Theory L₂} {T₃ : Theory L₃} [𝗘𝗤 ⪯ T₁] [𝗘𝗤 ⪯ T₂] [𝗘𝗤 ⪯ T₃] +variable {L₁ L₂ L₃ : Language} [L₁.Eq] [L₂.Eq] [L₃.Eq] {T₁ : Theory L₁} {T₂ : Theory L₂} {T₃ : Theory L₃} [𝗘𝗤 _ ⪯ T₁] [𝗘𝗤 _ ⪯ T₂] [𝗘𝗤 _ ⪯ T₃] def compDirectTranslation (τ : DirectTranslation T₂ L₃) (π : T₁ ⊳ T₂) : DirectTranslation T₁ L₃ where domain := π.trln.domain ⋏ π.translate τ.domain domain_nonempty := by simpa [exs] using π.of_provability τ.domain_nonempty rel R := π.translate (τ.rel R) func {k} f := π.translate (τ.func f) - func_defined {k} f := complete <| EQ.provOf.{_,0} _ fun M _ _ _ hT ↦ by + func_defined {k} f := by + apply Theory.Proof.complete_on_eq_models.{_, 0} + intro M _ _ _ hT apply models_iff.mpr suffices ∀ w, @@ -437,7 +461,7 @@ def compDirectTranslation (τ : DirectTranslation T₂ L₃) (π : T₁ ⊳ T₂ M ⊧/(x :> w) (π.translate (τ.func f)) by simpa [Matrix.constant_eq_singleton, Model.eval_translate_iff, ←dom_iff] intro w hw - have iT₂ : π.Model M ⊧ₘ* T₂ := π.model_models_theory hT + have iT₂ : (π.Model M)↓[L₂] ⊧* T₂ := π.model_models_theory hT let w' : Fin k → τ.Model (π.Model M) := fun i ↦ ⟨⟨w i, (hw i).1⟩, Model.evalb_translate_iff.mp <| by simpa [Matrix.constant_eq_singleton] using (hw i).2⟩ let y := (Structure.func f w') @@ -448,9 +472,11 @@ def compDirectTranslation (τ : DirectTranslation T₂ L₃) (π : T₁ ⊳ T₂ let y' : τ.Model (π.Model M) := ⟨⟨y, hy⟩, Model.evalb_translate_iff.mp <| by simpa [Matrix.constant_eq_singleton] using hhy⟩ suffices y' = Structure.func f w' by simpa [y'] using congr_arg Model.val <| congr_arg Model.val this apply Model.func_iff.mpr <| Model.evalb_cons_translate_iff.mp <| by simpa [y', w'] using hf - preserve_eq := complete <| EQ.provOf.{_,0} _ fun M _ _ _ hT ↦ by + preserve_eq := by + apply Theory.Proof.complete_on_eq_models.{_, 0} + intro M _ _ _ hT apply models_iff.mpr - have : π.Model M ⊧ₘ* T₂ := π.model_models_theory hT + have : (π.Model M)↓[L₂] ⊧* T₂ := π.model_models_theory hT suffices ∀ (x y : M), π.trln.Dom x → M ⊧/![x] (π.translate τ.domain) → @@ -477,7 +503,7 @@ section semantics open Semiformula variable (τ : DirectTranslation T₂ L₃) (π : T₁ ⊳ T₂) - {M : Type*} [Nonempty M] [Structure L₁ M] [Structure.Eq L₁ M] [M ⊧ₘ* T₁] + {M : Type*} [Nonempty M] [Structure L₁ M] [Structure.Eq L₁ M] [M↓[L₁] ⊧* T₁] lemma compDirectTranslation_Dom_iff {x : M} : (compDirectTranslation τ π).Dom x ↔ (∃ z : τ.Model (π.Model M), x = z) := by suffices π.trln.Dom x ∧ M ⊧/![x] (π.translate τ.domain) ↔ ∃ z : τ.Model (π.Model M), x = ↑↑z by @@ -490,30 +516,34 @@ lemma compDirectTranslation_Dom_iff {x : M} : (compDirectTranslation τ π).Dom lemma val_compDirectTranslation_Model_equiv {t : Semiterm L₃ ξ n} {ε : ξ → (compDirectTranslation τ π).Model M} {ε' : ξ → τ.Model (π.Model M)} (hε : ∀ x, (ε x : M) = ε' x) {e : Fin n → (compDirectTranslation τ π).Model M} {e' : Fin n → τ.Model (π.Model M)} (he : ∀ x, (e x : M) = e' x) : - (t.valm ((compDirectTranslation τ π).Model M) e ε : M) = t.valm (τ.Model (π.Model M)) e' ε' := by + (t.val (M := (compDirectTranslation τ π).Model M) e ε : M) = + t.val (M := τ.Model (π.Model M)) e' ε' := by match t with | #x => simp [he] | &x => simp [hε] | .func f v => - have ih : ∀ i, ((v i).valm ((compDirectTranslation τ π).Model M) e ε : M) = (v i).valm (τ.Model (π.Model M)) e' ε' := + have ih : ∀ i, ((v i).val (M := (compDirectTranslation τ π).Model M) e ε : M) = + (v i).val (M := τ.Model (π.Model M)) e' ε' := fun i ↦ val_compDirectTranslation_Model_equiv hε he suffices - (↑(Structure.func f fun i ↦ (v i).val (Model.struc τ (π.Model M)) e' ε') : M) = - (Structure.func f fun i ↦ Semiterm.val (Model.struc (compDirectTranslation τ π) M) e ε (v i)) by symm; simpa [Semiterm.val_func] + (↑(Structure.func f fun i ↦ (v i).val (M := τ.Model (π.Model M)) e' ε') : M) = + (Structure.func f fun i ↦ (v i).val (M := (compDirectTranslation τ π).Model M) e ε) by symm; simpa [Semiterm.val_func] apply Model.func_iff'.mpr simp [compDirectTranslation_Dom_iff, Model.evalb_cons_translate_iff, ih] lemma eval_compDirectTranslation_Model_equiv {φ : Semiformula L₃ ξ n} {ε : ξ → (compDirectTranslation τ π).Model M} {ε' : ξ → τ.Model (π.Model M)} (hε : ∀ x, (ε x : M) = ε' x) {e : Fin n → (compDirectTranslation τ π).Model M} {e' : Fin n → τ.Model (π.Model M)} (he : ∀ x, (e x : M) = e' x) : - Semiformula.Evalm ((compDirectTranslation τ π).Model M) e ε φ ↔ Semiformula.Evalm (τ.Model (π.Model M)) e' ε' φ := by + φ.Eval e ε ↔ φ.Eval e' ε' := by match φ with | .rel R v => - have ih : ∀ i, ((v i).valm ((compDirectTranslation τ π).Model M) e ε : M) = (v i).valm (τ.Model (π.Model M)) e' ε' := + have ih : ∀ i, ((v i).val (M := (compDirectTranslation τ π).Model M) e ε : M) = + (v i).val (M := τ.Model (π.Model M)) e' ε' := fun i ↦ val_compDirectTranslation_Model_equiv τ π hε he simp [eval_rel, Model.rel_iff, Model.evalb_translate_iff, ih] | .nrel R v => - have ih : ∀ i, ((v i).valm ((compDirectTranslation τ π).Model M) e ε : M) = (v i).valm (τ.Model (π.Model M)) e' ε' := + have ih : ∀ i, ((v i).val (M := (compDirectTranslation τ π).Model M) e ε : M) = + (v i).val (M := τ.Model (π.Model M)) e' ε' := fun i ↦ val_compDirectTranslation_Model_equiv τ π hε he simp [eval_nrel, Model.rel_iff, Model.evalb_translate_iff, ih] | ⊤ => simp @@ -556,12 +586,14 @@ end semantics protected abbrev comp (τ : T₂ ⊳ T₃) (π : T₁ ⊳ T₂) : T₁ ⊳ T₃ where trln := compDirectTranslation τ.trln π - interpret_theory φ hφ := complete <| EQ.provOf.{_,0} _ fun M _ _ _ hT ↦ by + interpret_theory φ hφ := by + apply Theory.Proof.complete_on_eq_models.{_, 0} + intro M _ _ _ hT apply models_iff.mpr - suffices τ.Model (π.Model M) ⊧ₘ φ by + suffices (τ.Model (π.Model M))↓[L₃] ⊧ φ by apply Model.translate_iff.mpr <| (compDirectTranslation_Model_equiv τ.trln π).models.mpr this - have : τ.Model (π.Model M) ⊧ₘ* T₃ := inferInstance - exact models_theory_iff.mp this hφ + have : (τ.Model (π.Model M))↓[L₃] ⊧* T₃ := inferInstance + exact models_theory_iff.mp this _ hφ end composition @@ -569,9 +601,9 @@ end DirectInterpretation namespace MutualDirectInterpretation -variable {L₁ L₂ L₃ : Language} [L₁.Eq] [L₂.Eq] [L₃.Eq] {T₁ : Theory L₁} {T₂ : Theory L₂} {T₃ : Theory L₃} [𝗘𝗤 ⪯ T₁] [𝗘𝗤 ⪯ T₂] [𝗘𝗤 ⪯ T₃] +variable {L₁ L₂ L₃ : Language} [L₁.Eq] [L₂.Eq] [L₃.Eq] {T₁ : Theory L₁} {T₂ : Theory L₂} {T₃ : Theory L₃} [𝗘𝗤 _ ⪯ T₁] [𝗘𝗤 _ ⪯ T₂] [𝗘𝗤 _ ⪯ T₃] -protected instance refl (T : Theory L₁) [𝗘𝗤 ⪯ T] : T ⋈ T := ⟨DirectInterpretation.refl T, DirectInterpretation.refl T⟩ +protected instance refl (T : Theory L₁) [𝗘𝗤 _ ⪯ T] : T ⋈ T := ⟨DirectInterpretation.refl T, DirectInterpretation.refl T⟩ protected abbrev symm (π : T₁ ⋈ T₂) : T₂ ⋈ T₁ := ⟨π.l, π.r⟩ diff --git a/Foundation/FirstOrder/SetTheory/Basic/Axioms.lean b/Foundation/FirstOrder/SetTheory/Basic/Axioms.lean index f6cd84e53..0dc2779e4 100644 --- a/Foundation/FirstOrder/SetTheory/Basic/Axioms.lean +++ b/Foundation/FirstOrder/SetTheory/Basic/Axioms.lean @@ -68,7 +68,7 @@ end Axiom /-- Zermelo set theory. -/ inductive Zermelo : Theory ℒₛₑₜ /-- Axiom of equality. -/ - | axiom_of_equality : ∀ φ ∈ 𝗘𝗤, Zermelo φ + | axiom_of_equality : ∀ φ ∈ 𝗘𝗤 ℒₛₑₜ, Zermelo φ /-- Axiom of empty set. -/ | axiom_of_empty_set : Zermelo Axiom.empty /-- Axiom of extentionality. -/ @@ -88,14 +88,14 @@ inductive Zermelo : Theory ℒₛₑₜ notation "𝗭" => Zermelo -instance : 𝗘𝗤 ⪯ 𝗭 := Entailment.WeakerThan.ofSubset Zermelo.axiom_of_equality +instance : 𝗘𝗤 _ ⪯ 𝗭 := Entailment.WeakerThan.ofSubset Zermelo.axiom_of_equality /-! ### Zermelo-Fraenkel set theory -/ /-- Zermelo-Fraenkel set theory. -/ inductive ZermeloFraenkel : Theory ℒₛₑₜ /-- Axiom of equality. -/ - | axiom_of_equality : ∀ φ ∈ 𝗘𝗤, ZermeloFraenkel φ + | axiom_of_equality : ∀ φ ∈ 𝗘𝗤 ℒₛₑₜ, ZermeloFraenkel φ /-- Axiom of empty set. -/ | axiom_of_empty_set : ZermeloFraenkel Axiom.empty /-- Axiom of extentionality. -/ @@ -117,7 +117,7 @@ inductive ZermeloFraenkel : Theory ℒₛₑₜ notation "𝗭𝗙" => ZermeloFraenkel -instance : 𝗘𝗤 ⪯ 𝗭𝗙 := Entailment.WeakerThan.ofSubset ZermeloFraenkel.axiom_of_equality +instance : 𝗘𝗤 _ ⪯ 𝗭𝗙 := Entailment.WeakerThan.ofSubset ZermeloFraenkel.axiom_of_equality lemma z_subset_zf : 𝗭 ⊆ 𝗭𝗙 := by rintro φ ⟨h⟩ @@ -141,27 +141,27 @@ def AxiomOfChoice : Theory ℒₛₑₜ := {Axiom.choice} notation "𝗔𝗖" => AxiomOfChoice /-- Zermelo set theory with axiom of choice. -/ -abbrev ZermeloChoice : Theory ℒₛₑₜ := 𝗭 + 𝗔𝗖 +abbrev ZermeloChoice : Theory ℒₛₑₜ := 𝗭 ∪ 𝗔𝗖 notation "𝗭𝗖" => ZermeloChoice instance : 𝗭 ⪯ 𝗭𝗖 := inferInstance -instance : 𝗘𝗤 ⪯ 𝗭𝗖 := - let : 𝗘𝗤 ⪯ 𝗭 := inferInstance +instance : 𝗘𝗤 _ ⪯ 𝗭𝗖 := + let : 𝗘𝗤 _ ⪯ 𝗭 := inferInstance Entailment.WeakerThan.trans this inferInstance /-! ### Zermelo-Fraenkel set theory with axiom of choice -/ /-- Zermelo-Fraenkel set theory with axiom of choice. -/ -abbrev ZermeloFraenkelChoice : Theory ℒₛₑₜ := 𝗭𝗙 + 𝗔𝗖 +abbrev ZermeloFraenkelChoice : Theory ℒₛₑₜ := 𝗭𝗙 ∪ 𝗔𝗖 notation "𝗭𝗙𝗖" => ZermeloFraenkelChoice instance : 𝗭𝗙 ⪯ 𝗭𝗙𝗖 := inferInstance -instance : 𝗘𝗤 ⪯ 𝗭𝗙𝗖 := - let : 𝗘𝗤 ⪯ 𝗭𝗙 := inferInstance +instance : 𝗘𝗤 _ ⪯ 𝗭𝗙𝗖 := + let : 𝗘𝗤 _ ⪯ 𝗭𝗙 := inferInstance Entailment.WeakerThan.trans this inferInstance lemma zc_subset_zfc : 𝗭𝗖 ⊆ 𝗭𝗙𝗖 := Set.union_subset_union_left _ z_subset_zf diff --git a/Foundation/FirstOrder/SetTheory/Basic/Misc.lean b/Foundation/FirstOrder/SetTheory/Basic/Misc.lean index 0736a021c..ec9b5be78 100644 --- a/Foundation/FirstOrder/SetTheory/Basic/Misc.lean +++ b/Foundation/FirstOrder/SetTheory/Basic/Misc.lean @@ -1,6 +1,6 @@ module -public import Foundation.FirstOrder.Completeness.Corollaries +public import Foundation.FirstOrder.Completeness.CounterModel public import Mathlib.SetTheory.Cardinal.Basic @[expose] public section @@ -111,16 +111,16 @@ attribute [instance] Structure.Set.mk namespace SetTheory -private lemma consequence_of_aux (T : SetTheory) [𝗘𝗤 ⪯ T] (φ : Sentence ℒₛₑₜ) +private lemma consequence_of_aux (T : SetTheory) [𝗘𝗤 _ ⪯ T] (φ : Sentence ℒₛₑₜ) (H : ∀ (M : Type w) [SetStructure M] [Structure ℒₛₑₜ M] [Structure.Set M] [Nonempty M] - [M ⊧ₘ* T], - M ⊧ₘ φ) : - T ⊨ φ := consequence_iff_consequence.{_, w}.mp <| consequence_iff_eq.mpr fun M _ _ _ hT => - letI : Structure.Model ℒₛₑₜ M ⊧ₘ* T := Structure.ElementaryEquiv.modelsTheory.mp hT + [M↓[ℒₛₑₜ] ⊧* T], + M↓[ℒₛₑₜ] ⊧ φ) : + T ⊨ φ := Theory.consequence_iff_consequence.{_, w}.mp <| consequence_iff_eq.mpr fun M _ _ _ hT => + letI : (Structure.Model ℒₛₑₜ M)↓[ℒₛₑₜ] ⊧* T := Structure.ElementaryEquiv.modelsTheory.mp hT Structure.ElementaryEquiv.models.mpr (H (Structure.Model ℒₛₑₜ M)) section semantics @@ -152,12 +152,12 @@ lemma standardStructure_unique (s : Structure ℒₛₑₜ M) [hEq : Structure.E /- ### Normalization -/ /-- Normalize model without =-isomorphic. -/ -structure QuotNormalize (M : Type*) [Structure ℒₛₑₜ M] [Nonempty M] [M ⊧ₘ* (𝗘𝗤 : Theory ℒₛₑₜ)] : Type _ where +structure QuotNormalize (M : Type*) [Structure ℒₛₑₜ M] [Nonempty M] [M↓[ℒₛₑₜ] ⊧* (𝗘𝗤 _ : Theory ℒₛₑₜ)] : Type _ where toQuot : Structure.Model ℒₛₑₜ (Structure.Eq.QuotEq ℒₛₑₜ M) namespace QuotNormalize -variable {M : Type*} [s : Structure ℒₛₑₜ M] [Nonempty M] [M ⊧ₘ* (𝗘𝗤 : Theory ℒₛₑₜ)] +variable {M : Type*} [s : Structure ℒₛₑₜ M] [Nonempty M] [M↓[ℒₛₑₜ] ⊧* (𝗘𝗤 _ : Theory ℒₛₑₜ)] def equiv : QuotNormalize M ≃ Structure.Model ℒₛₑₜ (Structure.Eq.QuotEq ℒₛₑₜ M) where toFun x := x.toQuot @@ -211,13 +211,13 @@ end QuotNormalize end semantics -lemma consequence_of_models (T : SetTheory) [𝗘𝗤 ⪯ T] (φ : Sentence ℒₛₑₜ) (H : ∀ (M : Type*) [SetStructure M] [Nonempty M] [M ⊧ₘ* T], M ⊧ₘ φ) : +lemma consequence_of_models (T : SetTheory) [𝗘𝗤 _ ⪯ T] (φ : Sentence ℒₛₑₜ) (H : ∀ (M : Type*) [SetStructure M] [Nonempty M] [M↓[ℒₛₑₜ] ⊧* T], M↓[ℒₛₑₜ] ⊧ φ) : T ⊨ φ := consequence_of_aux T φ fun M _ s _ _ ↦ by rcases standardStructure_unique M s exact H M -lemma provable_of_models (T : SetTheory) [𝗘𝗤 ⪯ T] (φ : Sentence ℒₛₑₜ) (H : ∀ (M : Type*) [SetStructure M] [Nonempty M] [M ⊧ₘ* T], M ⊧ₘ φ) : - T ⊢ φ := complete <| consequence_of_models _ _ H +lemma provable_of_models (T : SetTheory) [𝗘𝗤 _ ⪯ T] (φ : Sentence ℒₛₑₜ) (H : ∀ (M : Type*) [SetStructure M] [Nonempty M] [M↓[ℒₛₑₜ] ⊧* T], M↓[ℒₛₑₜ] ⊧ φ) : + T ⊢ φ := Theory.Proof.complete <| consequence_of_models _ _ H end SetTheory diff --git a/Foundation/FirstOrder/SetTheory/Basic/Model.lean b/Foundation/FirstOrder/SetTheory/Basic/Model.lean index 38663fa0b..901e5b496 100644 --- a/Foundation/FirstOrder/SetTheory/Basic/Model.lean +++ b/Foundation/FirstOrder/SetTheory/Basic/Model.lean @@ -77,11 +77,11 @@ section variable [Nonempty V] -instance [V ⊧ₘ* 𝗭] [V ⊧ₘ* 𝗔𝗖] : V ⊧ₘ* 𝗭𝗖 := inferInstance +instance [V↓[ℒₛₑₜ] ⊧* 𝗭] [V↓[ℒₛₑₜ] ⊧* 𝗔𝗖] : V↓[ℒₛₑₜ] ⊧* 𝗭𝗖 := inferInstance -instance [V ⊧ₘ* 𝗭𝗙] [V ⊧ₘ* 𝗔𝗖] : V ⊧ₘ* 𝗭𝗙𝗖 := inferInstance +instance [V↓[ℒₛₑₜ] ⊧* 𝗭𝗙] [V↓[ℒₛₑₜ] ⊧* 𝗔𝗖] : V↓[ℒₛₑₜ] ⊧* 𝗭𝗙𝗖 := inferInstance -instance : V ⊧ₘ* (𝗘𝗤 : Theory ℒₛₑₜ) := Structure.Eq.models_eqAxiom' ℒₛₑₜ V +instance : V↓[ℒₛₑₜ] ⊧* (𝗘𝗤 _ : Theory ℒₛₑₜ) := Structure.Eq.models_eqAxiom' ℒₛₑₜ V end diff --git a/Foundation/FirstOrder/SetTheory/Function.lean b/Foundation/FirstOrder/SetTheory/Function.lean index 12de78f8e..66a070439 100644 --- a/Foundation/FirstOrder/SetTheory/Function.lean +++ b/Foundation/FirstOrder/SetTheory/Function.lean @@ -9,7 +9,7 @@ public import Foundation.FirstOrder.SetTheory.Z namespace LO.FirstOrder.SetTheory -variable {V : Type*} [SetStructure V] [Nonempty V] [V ⊧ₘ* 𝗭] +variable {V : Type*} [SetStructure V] [Nonempty V] [V↓[ℒₛₑₜ] ⊧* 𝗭] /-! ### Relations -/ diff --git a/Foundation/FirstOrder/SetTheory/LoewenheimSkolem.lean b/Foundation/FirstOrder/SetTheory/LoewenheimSkolem.lean index a3c55845d..1a1cf42ec 100644 --- a/Foundation/FirstOrder/SetTheory/LoewenheimSkolem.lean +++ b/Foundation/FirstOrder/SetTheory/LoewenheimSkolem.lean @@ -39,7 +39,7 @@ lemma closed {v : Fin k → V} (hv : ∀ i, v i ∈ Hull s) @[simp] lemma hull_models_iff {φ : Semisentence ℒₛₑₜ n} : (Hull s) ⊧/b φ ↔ V ⊧/(b ·) φ := by have : - Semiformula.Evalb (Structure.SkolemHull.str (standardStructure V) s) b φ ↔ + φ.Evalb (s := Structure.SkolemHull.str (standardStructure V) s) b ↔ V ⊧/(b ·) φ := Structure.SkolemHull.str_eval (𝓼 := standardStructure V) (φ := φ) (b := b) rw [str_eq] at this diff --git a/Foundation/FirstOrder/SetTheory/Ordinal.lean b/Foundation/FirstOrder/SetTheory/Ordinal.lean index e505be7d9..e580eab2d 100644 --- a/Foundation/FirstOrder/SetTheory/Ordinal.lean +++ b/Foundation/FirstOrder/SetTheory/Ordinal.lean @@ -11,14 +11,14 @@ reference: Ralf Schindler, "Set Theory, Exploring Independence and Truth" [Sch14 namespace LO.FirstOrder.SetTheory -variable {V : Type*} [SetStructure V] [Nonempty V] [V ⊧ₘ* 𝗭] +variable {V : Type*} [SetStructure V] [Nonempty V] [V↓[ℒₛₑₜ] ⊧* 𝗭] /-! ### Transitive set -/ class IsTransitive (x : V) : Prop where transitive : ∀ y ∈ x, y ⊆ x -omit [Nonempty V] [V ⊧ₘ* 𝗭] in +omit [Nonempty V] [V↓[ℒₛₑₜ] ⊧* 𝗭] in lemma isTransitive_def {x : V} : IsTransitive x ↔ ∀ y ∈ x, y ⊆ x := ⟨fun h ↦ h.transitive, fun h ↦ ⟨h⟩⟩ @@ -31,7 +31,7 @@ instance IsTransitive.definable : ℒₛₑₜ-predicate[V] IsTransitive := IsTr namespace IsTransitive -omit [Nonempty V] [V ⊧ₘ* 𝗭] in +omit [Nonempty V] [V↓[ℒₛₑₜ] ⊧* 𝗭] in lemma mem_trans {x y z : V} (H : IsTransitive z) (hxy : x ∈ y) (hyz : y ∈ z) : x ∈ z := H.transitive y hyz x hxy @[simp] protected instance empty : IsTransitive (∅ : V) := ⟨fun x ↦ by simp⟩ @@ -106,7 +106,7 @@ end IsTransitive class IsOrdinal (x : V) : Prop extends IsTransitive x where trichotomy : ∀ y ∈ x, ∀ z ∈ x, y ∈ z ∨ y = z ∨ z ∈ y -omit [Nonempty V] [V ⊧ₘ* 𝗭] in +omit [Nonempty V] [V↓[ℒₛₑₜ] ⊧* 𝗭] in lemma isOrdinal_iff {x : V} : IsOrdinal x ↔ IsTransitive x ∧ ∀ y ∈ x, ∀ z ∈ x, y ∈ z ∨ y = z ∨ z ∈ y := ⟨fun h ↦ ⟨⟨h.transitive⟩, h.trichotomy⟩, fun h ↦ { transitive := h.1.transitive, trichotomy := h.2 }⟩ @@ -326,10 +326,10 @@ instance : Coe (Ordinal V) V := ⟨Ordinal.val⟩ @[coe] def IsOrdinal.toOrdinal (α : V) [IsOrdinal α] : Ordinal V := ⟨α, inferInstance⟩ -omit [Nonempty V] [V ⊧ₘ* 𝗭] in +omit [Nonempty V] [V↓[ℒₛₑₜ] ⊧* 𝗭] in @[simp] lemma IsOrdinal.toOrdinal_val (α : V) [IsOrdinal α] : (IsOrdinal.toOrdinal α).val = α := rfl -omit [Nonempty V] [V ⊧ₘ* 𝗭] in +omit [Nonempty V] [V↓[ℒₛₑₜ] ⊧* 𝗭] in @[simp] lemma Ordinal.val_toOrdinal (α : Ordinal V) : IsOrdinal.toOrdinal α.val = α := rfl namespace Ordinal @@ -340,10 +340,10 @@ instance : LT (Ordinal V) := ⟨fun α β ↦ α.val ∈ β.val⟩ instance : LE (Ordinal V) := ⟨fun α β ↦ α.val ⊆ β.val⟩ -omit [Nonempty V] [V ⊧ₘ* 𝗭] in +omit [Nonempty V] [V↓[ℒₛₑₜ] ⊧* 𝗭] in lemma lt_def : α < β ↔ α.val ∈ β.val := by rfl -omit [Nonempty V] [V ⊧ₘ* 𝗭] in +omit [Nonempty V] [V↓[ℒₛₑₜ] ⊧* 𝗭] in lemma le_def : α ≤ β ↔ α.val ⊆ β.val := by rfl instance : IsOrdinal α.val := α.ordinal diff --git a/Foundation/FirstOrder/SetTheory/Universe.lean b/Foundation/FirstOrder/SetTheory/Universe.lean index 9e8fc615b..d5d473014 100644 --- a/Foundation/FirstOrder/SetTheory/Universe.lean +++ b/Foundation/FirstOrder/SetTheory/Universe.lean @@ -222,12 +222,12 @@ noncomputable def powerset (x : Universe.{u}) : Universe.{u} := refine ⟨equivShrink _ ⟨z, by simpa⟩, ?_⟩ simp [Universe.ext_iff]; tauto -instance models_zf : Universe.{u} ⊧ₘ* 𝗭𝗙 where - models_set φ hφ := by +instance models_zf : Universe.{u}↓[ℒₛₑₜ] ⊧* 𝗭𝗙 := ⟨by + intro φ hφ rcases hφ case axiom_of_equality h => - have : Universe.{u} ⊧ₘ* (𝗘𝗤 : Theory ℒₛₑₜ) := inferInstance - simpa [models_iff] using models_theory_iff.mp this h + have : Universe.{u}↓[ℒₛₑₜ] ⊧* (𝗘𝗤 _ : Theory ℒₛₑₜ) := inferInstance + simpa [models_iff] using models_theory_iff.mp this _ h case axiom_of_empty_set => suffices ∃ x, ∀ y, y ∉ x by simpa [models_iff, Axiom.empty] exact ⟨empty, by simp⟩ @@ -270,7 +270,7 @@ instance models_zf : Universe.{u} ⊧ₘ* 𝗭𝗙 where exact minimal_exists_of_isNonempty hx case axiom_of_separation φ => let P (f : ℕ → Universe.{u}) (x : Universe.{u}) : Prop := - Semiformula.Eval (standardStructure Universe.{u}) ![x] f φ + φ.Eval (s := standardStructure Universe.{u}) ![x] f suffices ∀ (f : ℕ → Universe.{u}) (x : Universe.{u}), ∃ y, ∀ z : Universe.{u}, z ∈ y ↔ z ∈ x ∧ P f z by @@ -280,7 +280,7 @@ instance models_zf : Universe.{u} ⊧ₘ* 𝗭𝗙 where intro z; simp case axiom_of_replacement φ => let R (f : ℕ → Universe.{u}) (x y : Universe.{u}) : Prop := - Semiformula.Eval (standardStructure Universe.{u}) ![x, y] f φ + φ.Eval (s := standardStructure Universe.{u}) ![x, y] f suffices ∀ f : ℕ → Universe.{u}, (∀ x, ∃! y, R f x y) → @@ -291,10 +291,10 @@ instance models_zf : Universe.{u} ⊧ₘ* 𝗭𝗙 where choose F hF using this have (x y : Universe) : R f x y ↔ F x = y := ⟨fun hxy ↦ (h x).unique (hF x) hxy, by rintro rfl; exact hF x⟩ - refine ⟨X.image F, fun _ ↦ by simp [this]⟩ + refine ⟨X.image F, fun _ ↦ by simp [this]⟩⟩ -instance models_ac : Universe.{u} ⊧ₘ* 𝗔𝗖 where - models_set φ hφ := by +instance models_ac : Universe.{u}↓[ℒₛₑₜ] ⊧* 𝗔𝗖 := ⟨by + intro φ hφ rcases hφ suffices ∀ 𝓧 : Universe.{u}, @@ -306,14 +306,14 @@ instance models_ac : Universe.{u} ⊧ₘ* 𝗔𝗖 where refine ⟨𝓧.choice, ?_⟩ intro X hX exact 𝓧.choice_existsUnique - (by intro h; rcases nonempty empty h; simp_all) pairwise_disjoint hX + (by intro h; rcases nonempty empty h; simp_all) pairwise_disjoint hX⟩ -instance models_zfc : Universe.{u} ⊧ₘ* 𝗭𝗙𝗖 := inferInstance +instance models_zfc : Universe.{u}↓[ℒₛₑₜ] ⊧* 𝗭𝗙𝗖 := inferInstance -instance models_z : Universe.{u} ⊧ₘ* 𝗭 := models_of_ss inferInstance z_subset_zf +instance models_z : Universe.{u}↓[ℒₛₑₜ] ⊧* 𝗭 := models_of_ss inferInstance z_subset_zf -instance models_zc : Universe.{u} ⊧ₘ* 𝗭𝗖 := inferInstance +instance models_zc : Universe.{u}↓[ℒₛₑₜ] ⊧* 𝗭𝗖 := inferInstance end Universe diff --git a/Foundation/FirstOrder/SetTheory/Z.lean b/Foundation/FirstOrder/SetTheory/Z.lean index f89dae431..b9fe775cc 100644 --- a/Foundation/FirstOrder/SetTheory/Z.lean +++ b/Foundation/FirstOrder/SetTheory/Z.lean @@ -13,12 +13,12 @@ reference: Ralf Schindler, "Set Theory, Exploring Independence and Truth" [Sch14 namespace LO.FirstOrder.SetTheory -variable {V : Type*} [SetStructure V] [Nonempty V] [V ⊧ₘ* 𝗭] +variable {V : Type*} [SetStructure V] [Nonempty V] [V↓[ℒₛₑₜ] ⊧* 𝗭] /-! ## Axiom of extentionality -/ lemma mem_ext_iff {x y : V} : x = y ↔ ∀ z, z ∈ x ↔ z ∈ y := by - have := by simpa [models_iff, Axiom.extentionality] using Theory.models V Zermelo.axiom_of_extentionality + have := by simpa [models_iff, Axiom.extentionality] using Theory.models V 𝗭 Zermelo.axiom_of_extentionality exact this x y alias ⟨_, mem_ext⟩ := mem_ext_iff @@ -51,7 +51,7 @@ lemma SSubset.of_subset_of_not_mem_of_mem {x y z : V} (ss : x ⊆ y) (hzx : z /-! ## Axiom of empty set -/ -lemma empty_exists : ∃ e : V, IsEmpty e := by simpa [models_iff] using Theory.models V Zermelo.axiom_of_empty_set +lemma empty_exists : ∃ e : V, IsEmpty e := by simpa [models_iff] using Theory.models V 𝗭 Zermelo.axiom_of_empty_set lemma empty_existsUnique : ∃! e : V, IsEmpty e := by rcases empty_exists (V := V) with ⟨e, he⟩ @@ -86,7 +86,7 @@ lemma eq_empty_or_isNonempty (x : V) : x = ∅ ∨ IsNonempty x := by /-! ## Axiom of pairing -/ lemma pairing_exists : ∀ x y : V, ∃ z : V, ∀ w, w ∈ z ↔ w = x ∨ w = y := by - simpa [models_iff, Axiom.pairing] using Theory.models V Zermelo.axiom_of_pairing + simpa [models_iff, Axiom.pairing] using Theory.models V 𝗭 Zermelo.axiom_of_pairing lemma pairing_existsUnique (x y : V) : ∃! z : V, ∀ w, w ∈ z ↔ w = x ∨ w = y := by rcases pairing_exists x y with ⟨p, hp⟩ @@ -132,7 +132,7 @@ instance singleton.definable : ℒₛₑₜ-function₁[V] Singleton.singleton : /-! ## Axiom of union -/ lemma union_exists : ∀ x : V, ∃ y : V, ∀ z, z ∈ y ↔ ∃ w ∈ x, z ∈ w := by - simpa [models_iff, Axiom.union] using Theory.models V Zermelo.axiom_of_union + simpa [models_iff, Axiom.union] using Theory.models V 𝗭 Zermelo.axiom_of_union lemma union_existsUnique (x : V) : ∃! y : V, ∀ z, z ∈ y ↔ ∃ w ∈ x, z ∈ w := by rcases union_exists x with ⟨u, hu⟩ @@ -245,7 +245,7 @@ lemma pair_eq_doubleton (x y : V) : {x, y} = doubleton x y := by ext; simp /-! ## Axiom of power set -/ lemma power_exists : ∀ x : V, ∃ y : V, ∀ z, z ∈ y ↔ z ⊆ x := by - simpa [models_iff, Axiom.power] using Theory.models V Zermelo.axiom_of_power_set + simpa [models_iff, Axiom.power] using Theory.models V 𝗭 Zermelo.axiom_of_power_set lemma power_existsUnique (x : V) : ∃! y : V, ∀ z, z ∈ y ↔ z ⊆ x := by rcases power_exists x with ⟨p, hp⟩ @@ -276,11 +276,11 @@ instance power.definable : ℒₛₑₜ-function₁[V] power := power.defined.to /-! ## Aussonderungsaxiom -/ -lemma separation_exists_eval (x : V) (φ : Semiformula ℒₛₑₜ V 1) : ∃ y : V, ∀ z : V, z ∈ y ↔ z ∈ x ∧ Semiformula.Evalm V ![z] id φ := by +lemma separation_exists_eval (x : V) (φ : Semiformula ℒₛₑₜ V 1) : ∃ y : V, ∀ z : V, z ∈ y ↔ z ∈ x ∧ φ.Eval ![z] id := by have : Inhabited V := inhabited_of_nonempty inferInstance let f := φ.enumarateFVar let ψ := (Rew.rewriteMap φ.idxOfFVar) ▹ φ - have := by simpa [models_iff, Semiformula.eval_univCl, Axiom.separationSchema] using Theory.models V (Zermelo.axiom_of_separation ψ) + have := by simpa [models_iff, Semiformula.eval_univCl, Axiom.separationSchema] using Theory.models V 𝗭 (Zermelo.axiom_of_separation ψ) simpa [ψ, f, Semiformula.eval_rewriteMap, Matrix.constant_eq_singleton] using this f x lemma separation_exists (x : V) (P : V → Prop) (hP : ℒₛₑₜ-predicate P) : ∃ y : V, ∀ z : V, z ∈ y ↔ z ∈ x ∧ P z := by @@ -619,7 +619,7 @@ lemma IsInductive.zero {I : V} (hI : IsInductive I) : ∅ ∈ I := hI.1 lemma IsInductive.succ {I : V} (hI : IsInductive I) {x : V} (hx : x ∈ I) : succ x ∈ I := hI.2 x hx lemma isInductive_exists : ∃ I : V, IsInductive I := by - simpa [models_iff, Axiom.infinity] using Theory.models V Zermelo.axiom_of_infinity + simpa [models_iff, Axiom.infinity] using Theory.models V 𝗭 Zermelo.axiom_of_infinity lemma omega_existsUnique : ∃! ω : V, ∀ x, x ∈ ω ↔ ∀ I : V, IsInductive I → x ∈ I := by rcases isInductive_exists (V := V) with ⟨I, hI⟩ @@ -729,7 +729,7 @@ lemma naturalNumber_induction (P : V → Prop) (hP : ℒₛₑₜ-predicate P) /-! ## Axiom of foundation -/ lemma foundation : ∀ x : V, [IsNonempty x] → ∃ y ∈ x, ∀ z ∈ x, z ∉ y := by - simpa [models_iff, Axiom.foundation] using Theory.models V Zermelo.axiom_of_foundation + simpa [models_iff, Axiom.foundation] using Theory.models V 𝗭 Zermelo.axiom_of_foundation lemma foundation' (x : V) [IsNonempty x] : ∃ y ∈ x, x ∩ y = ∅ := by rcases foundation x with ⟨y, hyx, H⟩ diff --git a/Foundation/FirstOrder/Skolemization/Hull.lean b/Foundation/FirstOrder/Skolemization/Hull.lean index cba3b6dc5..a5bcb32bc 100644 --- a/Foundation/FirstOrder/Skolemization/Hull.lean +++ b/Foundation/FirstOrder/Skolemization/Hull.lean @@ -144,8 +144,8 @@ instance (priority := 50) elementaryEquiv : (SkolemHull L s) ≡ₑ[L] M where models {φ} := by simp [models_iff, Matrix.empty_eq] instance (priority := 50) eq : Structure.Eq L (SkolemHull L s) := ⟨fun x y ↦ by - simp [Operator.val, Matrix.comp_vecCons', Matrix.constant_eq_singleton] - simpa [-Eq.eq, Subtype.ext_iff] using Structure.Eq.eq (L := L) x.val y.val⟩ + rw [Subtype.ext_iff] + simpa [Operator.val, Matrix.fun_eq_vec_two] using Structure.Eq.eq (L := L) (M := M) x.val y.val⟩ section mem @@ -156,8 +156,7 @@ instance (priority := 50) membership : instance (priority := 50) mem [Operator.Mem L] [Membership M M] [Structure.Mem L M] : Structure.Mem L (SkolemHull L s) := ⟨fun x y ↦ by - simp [Operator.val, Matrix.comp_vecCons', Matrix.constant_eq_singleton] - simpa [-Mem.mem, Subtype.ext_iff] using Structure.Mem.mem (L := L) x.val y.val⟩ + simpa [Operator.val, Matrix.fun_eq_vec_two] using Structure.Mem.mem (L := L) (M := M) x.val y.val⟩ end mem From eed8ad30624af3d98e81378431942084f5b94fcb Mon Sep 17 00:00:00 2001 From: palalansouki Date: Fri, 26 Jun 2026 05:39:33 +0900 Subject: [PATCH 54/61] fix --- Foundation.lean | 80 +++++++++---------- .../FirstOrder/Incompleteness/Examples.lean | 16 ++-- .../FirstOrder/Incompleteness/Halting.lean | 2 +- .../FirstOrder/Incompleteness/Second.lean | 8 +- Foundation/FirstOrder/Kripke/WeakForcing.lean | 9 +-- Foundation/ProvabilityLogic/Realization.lean | 16 ++-- Foundation/ProvabilityLogic/S/Soundness.lean | 8 +- .../ProvabilityLogic/SolovaySentences.lean | 30 +++---- 8 files changed, 83 insertions(+), 86 deletions(-) diff --git a/Foundation.lean b/Foundation.lean index de41e3735..82e224aff 100644 --- a/Foundation.lean +++ b/Foundation.lean @@ -81,43 +81,43 @@ public import Foundation.FirstOrder.Completeness.CounterModel public import Foundation.FirstOrder.Hauptsatz public import Foundation.FirstOrder.Incompleteness.Consistency public import Foundation.FirstOrder.Incompleteness.Dense --- public import Foundation.FirstOrder.Incompleteness.Examples +public import Foundation.FirstOrder.Incompleteness.Examples public import Foundation.FirstOrder.Incompleteness.First public import Foundation.FirstOrder.Incompleteness.GödelRosser --- public import Foundation.FirstOrder.Incompleteness.Halting +public import Foundation.FirstOrder.Incompleteness.Halting public import Foundation.FirstOrder.Incompleteness.Jeroslow public import Foundation.FirstOrder.Incompleteness.Löb public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Basic --- public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Height +public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Height public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Refutability public import Foundation.FirstOrder.Incompleteness.RestrictedProvability public import Foundation.FirstOrder.Incompleteness.RosserProvability --- public import Foundation.FirstOrder.Incompleteness.Second +public import Foundation.FirstOrder.Incompleteness.Second public import Foundation.FirstOrder.Incompleteness.StandardProvability public import Foundation.FirstOrder.Incompleteness.Tarski public import Foundation.FirstOrder.Incompleteness.WitnessComparison public import Foundation.FirstOrder.Incompleteness.Yablo --- public import Foundation.FirstOrder.Interpretation +public import Foundation.FirstOrder.Interpretation public import Foundation.FirstOrder.Intuitionistic.Deduction public import Foundation.FirstOrder.Intuitionistic.Formula public import Foundation.FirstOrder.Intuitionistic.Rew public import Foundation.FirstOrder.Kripke.Basic public import Foundation.FirstOrder.Kripke.Intuitionistic --- public import Foundation.FirstOrder.Kripke.WeakForcing +public import Foundation.FirstOrder.Kripke.WeakForcing public import Foundation.FirstOrder.NegationTranslation.GoedelGentzen public import Foundation.FirstOrder.Order.Le public import Foundation.FirstOrder.Polarity --- public import Foundation.FirstOrder.SetTheory.Basic --- public import Foundation.FirstOrder.SetTheory.Basic.Axioms --- public import Foundation.FirstOrder.SetTheory.Basic.Misc --- public import Foundation.FirstOrder.SetTheory.Basic.Model --- public import Foundation.FirstOrder.SetTheory.Function --- public import Foundation.FirstOrder.SetTheory.LoewenheimSkolem --- public import Foundation.FirstOrder.SetTheory.Ordinal --- public import Foundation.FirstOrder.SetTheory.TransitiveModel --- public import Foundation.FirstOrder.SetTheory.Universe --- public import Foundation.FirstOrder.SetTheory.Z --- public import Foundation.FirstOrder.Skolemization.Hull +public import Foundation.FirstOrder.SetTheory.Basic +public import Foundation.FirstOrder.SetTheory.Basic.Axioms +public import Foundation.FirstOrder.SetTheory.Basic.Misc +public import Foundation.FirstOrder.SetTheory.Basic.Model +public import Foundation.FirstOrder.SetTheory.Function +public import Foundation.FirstOrder.SetTheory.LoewenheimSkolem +public import Foundation.FirstOrder.SetTheory.Ordinal +public import Foundation.FirstOrder.SetTheory.TransitiveModel +public import Foundation.FirstOrder.SetTheory.Universe +public import Foundation.FirstOrder.SetTheory.Z +public import Foundation.FirstOrder.Skolemization.Hull public import Foundation.FirstOrder.Ultraproduct public import Foundation.Init public import Foundation.InterpretabilityLogic.Axioms @@ -187,7 +187,7 @@ public import Foundation.InterpretabilityLogic.Veltman.Logic.IL_R public import Foundation.InterpretabilityLogic.Veltman.Logic.IL_R_W public import Foundation.InterpretabilityLogic.Veltman.Logic.IL_W public import Foundation.LinearLogic.FirstOrder.Calculus --- public import Foundation.LinearLogic.FirstOrder.ClassicalEmbedding +public import Foundation.LinearLogic.FirstOrder.ClassicalEmbedding public import Foundation.LinearLogic.FirstOrder.Formula public import Foundation.LinearLogic.FirstOrder.Rew public import Foundation.LinearLogic.LogicSymbol @@ -212,8 +212,8 @@ public import Foundation.Modal.Axioms public import Foundation.Modal.Boxdot.Basic public import Foundation.Modal.Boxdot.GLPoint3_GrzPoint3 public import Foundation.Modal.Boxdot.GL_Grz --- public import Foundation.Modal.Boxdot.GL_S --- public import Foundation.Modal.Boxdot.Grz_S +public import Foundation.Modal.Boxdot.GL_S +public import Foundation.Modal.Boxdot.Grz_S public import Foundation.Modal.Boxdot.Jerabek public import Foundation.Modal.Boxdot.K4_S4 public import Foundation.Modal.Boxdot.Ver_Triv @@ -349,7 +349,7 @@ public import Foundation.Modal.Logic.GLPlusBoxBot.Basic public import Foundation.Modal.Logic.GLPoint3OplusBoxBot.Basic public import Foundation.Modal.Logic.Global public import Foundation.Modal.Logic.S.Basic --- public import Foundation.Modal.Logic.S.Consistent +public import Foundation.Modal.Logic.S.Consistent public import Foundation.Modal.Logic.SumNormal public import Foundation.Modal.Logic.SumQuasiNormal public import Foundation.Modal.LogicSymbol @@ -376,7 +376,7 @@ public import Foundation.Modal.VanBentham.StandardTranslation public import Foundation.Propositional.Boolean.Basic public import Foundation.Propositional.Boolean.Hilbert public import Foundation.Propositional.Boolean.NNFormula --- public import Foundation.Propositional.Boolean.Tait +public import Foundation.Propositional.Boolean.Tait public import Foundation.Propositional.Boolean.ZeroSubst public import Foundation.Propositional.ConsistentTableau public import Foundation.Propositional.Dialectica.Basic @@ -459,26 +459,26 @@ public import Foundation.Propositional.Neighborhood.NB.Basic public import Foundation.Propositional.Neighborhood.NB.Hilbert.Basic public import Foundation.Propositional.Neighborhood.NB.Hilbert.WF public import Foundation.Propositional.Slash --- public import Foundation.Propositional.Tait.Calculus +public import Foundation.Propositional.Tait.Calculus public import Foundation.Propositional.Translation --- public import Foundation.ProvabilityLogic.Arithmetic --- public import Foundation.ProvabilityLogic.Classification.LetterlessTrace --- public import Foundation.ProvabilityLogic.Classification.Result --- public import Foundation.ProvabilityLogic.Classification.Trace --- public import Foundation.ProvabilityLogic.GL.Completeness --- public import Foundation.ProvabilityLogic.GL.Soundness --- public import Foundation.ProvabilityLogic.GL.Uniform --- public import Foundation.ProvabilityLogic.GL.Unprovability --- public import Foundation.ProvabilityLogic.Grz.Completeness --- public import Foundation.ProvabilityLogic.N.Soundness --- public import Foundation.ProvabilityLogic.Realization --- public import Foundation.ProvabilityLogic.S.Completeness --- public import Foundation.ProvabilityLogic.S.Soundness --- public import Foundation.ProvabilityLogic.SolovaySentences +public import Foundation.ProvabilityLogic.Arithmetic +public import Foundation.ProvabilityLogic.Classification.LetterlessTrace +public import Foundation.ProvabilityLogic.Classification.Result +public import Foundation.ProvabilityLogic.Classification.Trace +public import Foundation.ProvabilityLogic.GL.Completeness +public import Foundation.ProvabilityLogic.GL.Soundness +public import Foundation.ProvabilityLogic.GL.Uniform +public import Foundation.ProvabilityLogic.GL.Unprovability +public import Foundation.ProvabilityLogic.Grz.Completeness +public import Foundation.ProvabilityLogic.N.Soundness +public import Foundation.ProvabilityLogic.Realization +public import Foundation.ProvabilityLogic.S.Completeness +public import Foundation.ProvabilityLogic.S.Soundness +public import Foundation.ProvabilityLogic.SolovaySentences public import Foundation.SecondOrder.Derivation --- public import Foundation.SecondOrder.Semantics --- public import Foundation.SecondOrder.Syntax.Formula --- public import Foundation.SecondOrder.Syntax.Rew +public import Foundation.SecondOrder.Semantics +public import Foundation.SecondOrder.Syntax.Formula +public import Foundation.SecondOrder.Syntax.Rew public import Foundation.Semantics.Algebra.Modal.Basic public import Foundation.Semantics.Algebra.Modal.Magari public import Foundation.Semantics.CoherenceSpace.Basic diff --git a/Foundation/FirstOrder/Incompleteness/Examples.lean b/Foundation/FirstOrder/Incompleteness/Examples.lean index b32c20e97..965b97d6a 100644 --- a/Foundation/FirstOrder/Incompleteness/Examples.lean +++ b/Foundation/FirstOrder/Incompleteness/Examples.lean @@ -18,21 +18,21 @@ axiom PA_delta1Definable : 𝗣𝗔.Δ₁ attribute [instance] ISigma1_delta1Definable PA_delta1Definable -instance : 𝗜𝚺₁ ⪱ 𝗜𝚺₁ + 𝗜𝚺₁.Con := inferInstance +instance : 𝗜𝚺₁ ⪱ 𝗜𝚺₁ ∪ 𝗜𝚺₁.Con := inferInstance -instance : 𝗜𝚺₁ + 𝗜𝚺₁.Con ⪱ 𝗧𝗔 := inferInstance +instance : 𝗜𝚺₁ ∪ 𝗜𝚺₁.Con ⪱ 𝗧𝗔 := inferInstance -instance : 𝗜𝚺₁ ⪱ 𝗜𝚺₁ + 𝗜𝚺₁.Incon := inferInstance +instance : 𝗜𝚺₁ ⪱ 𝗜𝚺₁ ∪ 𝗜𝚺₁.Incon := inferInstance -instance : 𝗣𝗔 ⪱ 𝗣𝗔 + 𝗣𝗔.Con := inferInstance +instance : 𝗣𝗔 ⪱ 𝗣𝗔 ∪ 𝗣𝗔.Con := inferInstance -instance : 𝗣𝗔 + 𝗣𝗔.Con ⪱ 𝗧𝗔 := inferInstance +instance : 𝗣𝗔 ∪ 𝗣𝗔.Con ⪱ 𝗧𝗔 := inferInstance -instance : 𝗣𝗔 ⪱ 𝗣𝗔 + 𝗣𝗔.Incon := inferInstance +instance : 𝗣𝗔 ⪱ 𝗣𝗔 ∪ 𝗣𝗔.Incon := inferInstance -instance : 𝗣𝗔 + 𝗣𝗔.Con ⪱ 𝗣𝗔 + 𝗣𝗔.Con + (𝗣𝗔 + 𝗣𝗔.Con).Incon := +instance : 𝗣𝗔 ∪ 𝗣𝗔.Con ⪱ 𝗣𝗔 ∪ 𝗣𝗔.Con ∪ (𝗣𝗔 ∪ 𝗣𝗔.Con).Incon := have : 𝗜𝚺₁ ⪯ 𝗣𝗔 := inferInstance - have : 𝗜𝚺₁ ⪯ 𝗣𝗔 + 𝗣𝗔.Con := Entailment.WeakerThan.trans this inferInstance + have : 𝗜𝚺₁ ⪯ 𝗣𝗔 ∪ 𝗣𝗔.Con := Entailment.WeakerThan.trans this inferInstance inferInstance end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Incompleteness/Halting.lean b/Foundation/FirstOrder/Incompleteness/Halting.lean index 62f72ab9e..e4c759905 100644 --- a/Foundation/FirstOrder/Incompleteness/Halting.lean +++ b/Foundation/FirstOrder/Incompleteness/Halting.lean @@ -23,7 +23,7 @@ lemma incomplete_of_REPred_not_ComputablePred_Nat' {P : ℕ → Prop} (hRE : REP constructor; . assumption; . suffices REPred fun a : ℕ ↦ T ⊬ φ/[a] by simpa [hP] using this; - have : 𝚺₁-Predicate fun b : ℕ ↦ Provable T (Bootstrapping.neg ℒₒᵣ <| Bootstrapping.subst ℒₒᵣ ?[Bootstrapping.Arithmetic.numeral b] ⌜φ⌝) := by clear hP; definability; + have : 𝚺₁-Predicate fun b : ℕ ↦ Bootstrapping.Provable T (Bootstrapping.neg ℒₒᵣ <| Bootstrapping.subst ℒₒᵣ ?[Bootstrapping.Arithmetic.numeral b] ⌜φ⌝) := by clear hP; definability; apply REPred.of_eq (re_iff_sigma1.mpr this); intro a; push Not at h; diff --git a/Foundation/FirstOrder/Incompleteness/Second.lean b/Foundation/FirstOrder/Incompleteness/Second.lean index a835ffb90..7309a182a 100644 --- a/Foundation/FirstOrder/Incompleteness/Second.lean +++ b/Foundation/FirstOrder/Incompleteness/Second.lean @@ -25,14 +25,14 @@ theorem inconsistent_unprovable [ArithmeticTheory.SoundOnHierarchy T 𝚺 1] : T theorem inconsistent_independent [ArithmeticTheory.SoundOnHierarchy T 𝚺 1] : Independent T ↑T.consistent := ProvabilityAbstraction.con_independent (𝔅 := T.standardProvability) -instance [Consistent T] : T ⪱ T + T.Con := +instance [Consistent T] : T ⪱ T ∪ T.Con := StrictlyWeakerThan.of_unprovable_provable (φ := ↑T.consistent) (consistent_unprovable T) - (Entailment.by_axm (by simp [Theory.add_def])) + (Entailment.by_axm (by simp)) -instance [ArithmeticTheory.SoundOnHierarchy T 𝚺 1] : T ⪱ T + T.Incon := +instance [ArithmeticTheory.SoundOnHierarchy T 𝚺 1] : T ⪱ T ∪ T.Incon := StrictlyWeakerThan.of_unprovable_provable (φ := ∼↑T.consistent) (inconsistent_unprovable T) - (Entailment.by_axm (by simp [Theory.add_def])) + (Entailment.by_axm (by simp)) end LO.FirstOrder.Arithmetic diff --git a/Foundation/FirstOrder/Kripke/WeakForcing.lean b/Foundation/FirstOrder/Kripke/WeakForcing.lean index c9e9b8c00..213ed518b 100644 --- a/Foundation/FirstOrder/Kripke/WeakForcing.lean +++ b/Foundation/FirstOrder/Kripke/WeakForcing.lean @@ -285,7 +285,7 @@ instance : WeakForcingRelation.ClassicalKripke ℙ (· ≥ ·) where generic := generic lemma sound : 𝐋𝐊¹ ⊢ φ → ∀ p : ℙ, ∀ fv, (∀ i, p ⊩↓ fv i) → p ⊩ᶜ[![] | fv] φ := fun b p fv Hfv ↦ by - have : 𝗜𝗻𝘁¹ ⊢ φᴺ := Proof.gödel_gentzen b + have : 𝗜𝗻𝘁¹ ⊢ φᴺ := Provable.gödel_gentzen b exact Forces.sound p fv Hfv this lemma sound₀ {σ : Sentence L} : 𝐋𝐊¹ ⊢ (σ : Proposition L) → ℙ ∀⊩ᶜ σ := fun b p ↦ by @@ -328,7 +328,7 @@ lemma sound {σ : Sentence L} : 𝐋𝐊¹ ⊢ (σ : Proposition L) → ℙ ⊧ WeaklyForces₀.sound₀ instance (ℙ : ForcingNotion L) : - Sound (Entailment.pullback (𝐋𝐊¹ : Proof.Symbol L) ((↑·) : Sentence L → Proposition L)) ℙ := + Sound (Entailment.pullback (𝐋𝐊¹ : LK L) ((↑·) : Sentence L → Proposition L)) ℙ := ⟨fun {_} ↦ sound⟩ end ForcingNotion @@ -381,7 +381,7 @@ def add {Γ Δ Ξ Θ : Sequent L} : Γ ⟶⁺ Δ → Ξ ⟶⁺ Θ → Γ ++ Ξ def graft {Ξ Γ : Sequent L} (b : ⊢ᴸᴷ¹ Ξ) : Ξ ⟶⁺ Γ → ⊢ᴸᴷ¹ Γ | or d => .or (d.graft b) | exs d => .exs (d.graft b) - | wk d h => .wk (d.graft b) h + | wk d h => .contraction (d.graft b) h | .id => b end PositiveDerivationFrom @@ -399,9 +399,6 @@ instance : Preorder (ConsistentSequent L) where rintro ⟨bΔ⟩ ⟨bΞ⟩ exact ⟨PositiveDerivationFrom.trans bΞ bΔ⟩ -insta - - end completeness end LO.FirstOrder diff --git a/Foundation/ProvabilityLogic/Realization.lean b/Foundation/ProvabilityLogic/Realization.lean index fdad996a0..ee088861c 100644 --- a/Foundation/ProvabilityLogic/Realization.lean +++ b/Foundation/ProvabilityLogic/Realization.lean @@ -215,26 +215,26 @@ section model variable {M} [Nonempty M] [Structure L M] -@[simp, grind .] lemma models₀_top : M ⊧ₘ f ⊤ := by simp [Realization.interpret]; -@[simp, grind .] lemma models₀_bot : ¬M ⊧ₘ f ⊥ := by simp [Realization.interpret]; +@[simp, grind .] lemma models₀_top : M↓[L] ⊧ f ⊤ := by simp [Realization.interpret]; +@[simp, grind .] lemma models₀_bot : ¬M↓[L] ⊧ f ⊥ := by simp [Realization.interpret]; @[simp, grind ⇒] -lemma iff_models₀_neg : M ⊧ₘ f (∼A) ↔ ¬(M ⊧ₘ (f A)) := by simp [Realization.interpret]; +lemma iff_models₀_neg : M↓[L] ⊧ f (∼A) ↔ ¬(M↓[L] ⊧ (f A)) := by simp [Realization.interpret]; @[simp, grind ⇒] -lemma iff_models₀_imp : M ⊧ₘ f (A 🡒 B) ↔ (M ⊧ₘ (f A) → M ⊧ₘ (f B)) := by simp [Realization.interpret]; +lemma iff_models₀_imp : M↓[L] ⊧ f (A 🡒 B) ↔ (M↓[L] ⊧ (f A) → M↓[L] ⊧ (f B)) := by simp [Realization.interpret]; @[simp, grind ⇒] -lemma iff_models₀_and : M ⊧ₘ f (A ⋏ B) ↔ M ⊧ₘ (f A) ∧ M ⊧ₘ (f B) := by simp [Realization.interpret]; +lemma iff_models₀_and : M↓[L] ⊧ f (A ⋏ B) ↔ M↓[L] ⊧ (f A) ∧ M↓[L] ⊧ (f B) := by simp [Realization.interpret]; @[simp, grind ⇒] -lemma iff_models₀_or : M ⊧ₘ f (A ⋎ B) ↔ M ⊧ₘ (f A) ∨ M ⊧ₘ (f B) := by simp [Realization.interpret]; tauto; +lemma iff_models₀_or : M↓[L] ⊧ f (A ⋎ B) ↔ M↓[L] ⊧ (f A) ∨ M↓[L] ⊧ (f B) := by simp [Realization.interpret]; tauto; @[simp, grind ⇒] -lemma iff_models₀_box : M ⊧ₘ f (□A) ↔ M ⊧ₘ 𝔅 (f A) := by simp [Realization.interpret]; +lemma iff_models₀_box : M↓[L] ⊧ f (□A) ↔ M↓[L] ⊧ 𝔅 (f A) := by simp [Realization.interpret]; @[simp, grind ⇒] -lemma iff_models₀_boxItr {n : ℕ} : M ⊧ₘ f (□^[n] A) ↔ M ⊧ₘ 𝔅^[n] (f A) := by simp; +lemma iff_models₀_boxItr {n : ℕ} : M↓[L] ⊧ f (□^[n] A) ↔ M↓[L] ⊧ 𝔅^[n] (f A) := by simp; end model diff --git a/Foundation/ProvabilityLogic/S/Soundness.lean b/Foundation/ProvabilityLogic/S/Soundness.lean index 3c708c9aa..ce62783d2 100644 --- a/Foundation/ProvabilityLogic/S/Soundness.lean +++ b/Foundation/ProvabilityLogic/S/Soundness.lean @@ -12,19 +12,19 @@ open FirstOrder open FirstOrder.ProvabilityAbstraction variable {T₀ T : FirstOrder.Theory ℒₒᵣ} [T₀ ⪯ T] [Diagonalization T₀] - {𝔅 : Provability T₀ T} [𝔅.HBL] [ℕ ⊧ₘ* T] [𝔅.SoundOn ℕ] + {𝔅 : Provability T₀ T} [𝔅.HBL] [ℕ↓[_] ⊧* T] [𝔅.SoundOn ℕ] {A B : Formula ℕ} -theorem S.arithmetical_soundness (h : Modal.S ⊢ A) (f : Realization 𝔅) : ℕ ⊧ₘ f A := by +theorem S.arithmetical_soundness (h : Modal.S ⊢ A) (f : Realization 𝔅) : ℕ↓[_] ⊧ f A := by induction h using S.rec' with | mem_GL h => exact models_of_provable inferInstance (GL.arithmetical_soundness h); | axiomT => - simp only [Realization.interpret, Models, LO.Semantics.Imp.models_imply]; + simp only [Realization.interpret, LO.Semantics.Imp.models_imply]; intro h; exact models_of_provable inferInstance (𝔅.sound_on h) | mdp ihAB ihA => - simp only [Realization.interpret, Models, LO.Semantics.Imp.models_imply] at ihAB; + simp only [Realization.interpret, LO.Semantics.Imp.models_imply] at ihAB; apply ihAB ihA; end ProvabilityLogic diff --git a/Foundation/ProvabilityLogic/SolovaySentences.lean b/Foundation/ProvabilityLogic/SolovaySentences.lean index 1cb40a91f..b372e01ef 100644 --- a/Foundation/ProvabilityLogic/SolovaySentences.lean +++ b/Foundation/ProvabilityLogic/SolovaySentences.lean @@ -328,7 +328,7 @@ section @[simp] lemma val_solovay {i : F} : V ⊧/![] (T.solovay i) ↔ T.Solovay V i := by simpa [models_iff] using - consequence_iff.mp (sound! (solovay_diag T i)) V inferInstance + consequence_iff.mp (Theory.Proof.sound (solovay_diag T i)) V inferInstance end @@ -361,8 +361,8 @@ private lemma Solovay.exclusive.comparable {i₁ i₂ : F} {ε₁ ε₂ : List F rcases cε₁.tail_exists with ⟨ε₁', rfl⟩ exact List.infix_iff_prefix_suffix.mpr ⟨j :: i₁ :: ε₁', by simp, hj⟩ have hij₁ : i₁ ≺ j := cε₂.rel_of_infix j i₁ hji₁ε₂ - have : ¬T.Provable (⌜∼T.solovay j⌝ : V) := by simpa [Theory.ConsistentWith.quote_iff] using Hi₁ j hij₁ - have : T.Provable (⌜∼T.solovay j⌝ : V) := by + have : ¬Provable T (⌜∼T.solovay j⌝ : V) := by simpa [Theory.ConsistentWith.quote_iff] using Hi₁ j hij₁ + have : Provable T (⌜∼T.solovay j⌝ : V) := by have : ΘChain T V [j, i₁] := by rcases hji₁ε₂ with ⟨η₁, η₂, rfl⟩ have Θε₂ : ΘChain T V (η₁ ++ j :: i₁ :: η₂) := by simpa using Θε₂ @@ -411,10 +411,10 @@ lemma Solovay.exclusive {i₁ i₂ : F} (ne : i₁ ≠ i₂) : T.Solovay V i₁ contradiction /-- Condition 2.-/ -lemma Solovay.consistent {i j : F} (hij : i ≺ j) : T.Solovay V i → ¬T.Provable (⌜∼T.solovay j⌝ : V) := fun h ↦ +lemma Solovay.consistent {i j : F} (hij : i ≺ j) : T.Solovay V i → ¬Provable T (⌜∼T.solovay j⌝ : V) := fun h ↦ (Theory.ConsistentWith.quote_iff T).mp (h.2 j hij) -lemma Solovay.refute (ne : F.root.1 ≠ i) : T.Solovay V i → T.Provable (⌜∼T.solovay i⌝ : V) := by +lemma Solovay.refute (ne : F.root.1 ≠ i) : T.Solovay V i → Provable T (⌜∼T.solovay i⌝ : V) := by intro h rcases show Θ T V i from h.1 with ⟨ε, hε, cε⟩ rcases List.ChainI.prec_exists_of_ne hε (Ne.symm ne) with ⟨ε', i', hii', rfl, hε'⟩ @@ -431,8 +431,8 @@ lemma Θ.disjunction (i : F) : Θ T V i → T.Solovay V i ∨ ∃ j, i ≺ j ∧ · left; exact hS · right have : ∃ j, i ≺ j ∧ ∀ k, i ≺ k → T.ProvabilityComparisonLE (V := V) ⌜∼T.solovay j⌝ ⌜∼T.solovay k⌝ := by - have : ∃ j, i ≺ j ∧ T.Provable (⌜∼T.solovay j⌝ : V) := by - have : Θ T V i → ∃ x, i ≺ x ∧ T.Provable (⌜∼T.solovay x⌝ : V) := by + have : ∃ j, i ≺ j ∧ Provable T (⌜∼T.solovay j⌝ : V) := by + have : Θ T V i → ∃ x, i ≺ x ∧ Provable T (⌜∼T.solovay x⌝ : V) := by simpa [Theory.ConsistentWith.quote_iff, Theory.Solovay] using hS exact this hΘ rcases this with ⟨j', hij', hj'⟩ @@ -459,12 +459,12 @@ lemma disjunctive : ∃ i : F, T.Solovay V i := by /-- Condition 3.-/ lemma Solovay.box_disjunction [𝗜𝚺₁ ⪯ T] {i : F} (ne : F.root.1 ≠ i) : - T.Solovay V i → T.Provable (⌜⩖ j ∈ {j : F | i ≺ j}, T.solovay j⌝ : V) := by + T.Solovay V i → Provable T (⌜⩖ j ∈ {j : F | i ≺ j}, T.solovay j⌝ : V) := by intro hS have TP : T.internalize V ⊢ ⌜θ T i 🡒 T.solovay i ⋎ ⩖ j ∈ {j : F | i ≺ j}, T.solovay j⌝ := internal_provable_of_outer_provable <| by have : 𝗜𝚺₁ ⊢ θ T i 🡒 T.solovay i ⋎ ⩖ j ∈ {j : F | i ≺ j}, T.solovay j := - provable_of_models _ _ fun (V : Type) _ _ ↦ by + complete _ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using Θ.disjunction i exact Entailment.WeakerThan.pbl this have Tθ : T.internalize V ⊢ ⌜θ T i⌝ := @@ -497,7 +497,7 @@ lemma solovay_root_sound [𝗜𝚺₁ ⪯ T] [sound : T.SoundOn (Hierarchy 𝚷 (show Hierarchy 𝚷 1 T.consistentWith.val by simp).strict_mono 𝚺 (show 1 < 2 by simp), (show Hierarchy 𝚺 1 (θ T i) by simp).mono (show 1 ≤ 2 by simp)]) have : T.Solovay ℕ i ↔ ℕ ⊧/![] π := by - simpa [models_iff] using consequence_iff.mp (sound! sπ) ℕ inferInstance + simpa [models_iff] using consequence_iff.mp (Theory.Proof.sound sπ) ℕ inferInstance simpa [this] contradiction have : T.Solovay ℕ F.root.1 ∨ ∃ j, F.root.1 ≺ j ∧ T.Solovay ℕ j := Θ.disjunction (V := ℕ) (T := T) F.root.1 ⟨[F.root], by simp⟩ @@ -509,7 +509,7 @@ lemma solovay_root_sound [𝗜𝚺₁ ⪯ T] [sound : T.SoundOn (Hierarchy 𝚷 lemma solovay_unprovable [𝗜𝚺₁ ⪯ T] [T.SoundOn (Hierarchy 𝚷 2)] {i : F} (h : F.root.1 ≠ i) : T ⊬ ∼T.solovay i := by have : 𝗜𝚺₁ ⪯ T := inferInstance haveI : 𝗥₀ ⪯ T := Entailment.WeakerThan.trans inferInstance this - have : ∼T.Provable ⌜∼T.solovay i⌝ := Solovay.consistent (by grind) solovay_root_sound; + have : ∼Provable T ⌜∼T.solovay i⌝ := Solovay.consistent (by grind) solovay_root_sound; simpa [Theory.ConsistentWith.quote_iff, provable_iff_provable] using this variable (T F) @@ -517,16 +517,16 @@ variable (T F) def _root_.LO.ProvabilityLogic.SolovaySentences.standard [𝗜𝚺₁ ⪯ T] : SolovaySentences T.standardProvability F where σ := T.solovay SC1 i j ne := - provable_of_models _ _ fun (V : Type) _ _ ↦ by + complete _ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using Solovay.exclusive ne SC2 i j h := - provable_of_models _ _ fun (V : Type) _ _ ↦ by + complete _ _ fun (V : Type) _ _ ↦ by simpa [models_iff, standardProvability_def] using Solovay.consistent h SC3 i h := - provable_of_models _ _ fun (V : Type) _ _ ↦ by + complete _ _ fun (V : Type) _ _ ↦ by simpa [models_iff, standardProvability_def] using Solovay.box_disjunction h SC4 := - provable_of_models _ _ fun (V : Type) _ _ ↦ by + complete _ _ fun (V : Type) _ _ ↦ by simpa [models_iff] using disjunctive lemma _root_.LO.ProvabilityLogic.SolovaySentences.standard_σ_def [𝗜𝚺₁ ⪯ T] : From fe3b202399e7c15feb7411de7feef551862d9f61 Mon Sep 17 00:00:00 2001 From: SnO2WMaN Date: Thu, 2 Jul 2026 19:52:01 +0900 Subject: [PATCH 55/61] refactor: Remove ProvabilityLogic The ProvabilityLogic formalization has been moved to SeqPL, so remove it from Foundation along with the Modal lemmas that depended on arithmetical soundness/completeness: - Foundation/ProvabilityLogic/ (whole directory) - Foundation/Modal/Boxdot/GL_S.lean - Foundation/Modal/Boxdot/Grz_S.lean - Foundation/Modal/Logic/S/Consistent.lean Co-Authored-By: Claude Opus 4.8 Claude-Session: https://claude.ai/code/session_01QDE3PcJrxn8nz7V5hJTbjH --- Foundation.lean | 17 - Foundation/Modal/Boxdot/GL_S.lean | 50 - Foundation/Modal/Boxdot/Grz_S.lean | 14 - Foundation/Modal/Logic/S/Consistent.lean | 33 - Foundation/ProvabilityLogic/Arithmetic.lean | 99 -- .../Classification/LetterlessTrace.lean | 1097 ----------------- .../Classification/Result.lean | 288 ----- .../Classification/Trace.lean | 671 ---------- .../ProvabilityLogic/GL/Completeness.lean | 112 -- Foundation/ProvabilityLogic/GL/Soundness.lean | 46 - Foundation/ProvabilityLogic/GL/Uniform.lean | 23 - .../ProvabilityLogic/GL/Unprovability.lean | 159 --- .../ProvabilityLogic/Grz/Completeness.lean | 138 --- Foundation/ProvabilityLogic/N/Soundness.lean | 27 - Foundation/ProvabilityLogic/Realization.lean | 246 ---- .../ProvabilityLogic/S/Completeness.lean | 193 --- Foundation/ProvabilityLogic/S/Soundness.lean | 32 - .../ProvabilityLogic/SolovaySentences.lean | 539 -------- 18 files changed, 3784 deletions(-) delete mode 100644 Foundation/Modal/Boxdot/GL_S.lean delete mode 100644 Foundation/Modal/Boxdot/Grz_S.lean delete mode 100644 Foundation/Modal/Logic/S/Consistent.lean delete mode 100644 Foundation/ProvabilityLogic/Arithmetic.lean delete mode 100644 Foundation/ProvabilityLogic/Classification/LetterlessTrace.lean delete mode 100644 Foundation/ProvabilityLogic/Classification/Result.lean delete mode 100644 Foundation/ProvabilityLogic/Classification/Trace.lean delete mode 100644 Foundation/ProvabilityLogic/GL/Completeness.lean delete mode 100644 Foundation/ProvabilityLogic/GL/Soundness.lean delete mode 100644 Foundation/ProvabilityLogic/GL/Uniform.lean delete mode 100644 Foundation/ProvabilityLogic/GL/Unprovability.lean delete mode 100644 Foundation/ProvabilityLogic/Grz/Completeness.lean delete mode 100644 Foundation/ProvabilityLogic/N/Soundness.lean delete mode 100644 Foundation/ProvabilityLogic/Realization.lean delete mode 100644 Foundation/ProvabilityLogic/S/Completeness.lean delete mode 100644 Foundation/ProvabilityLogic/S/Soundness.lean delete mode 100644 Foundation/ProvabilityLogic/SolovaySentences.lean diff --git a/Foundation.lean b/Foundation.lean index 650a1586a..c46e2f314 100644 --- a/Foundation.lean +++ b/Foundation.lean @@ -213,8 +213,6 @@ public import Foundation.Modal.Axioms public import Foundation.Modal.Boxdot.Basic public import Foundation.Modal.Boxdot.GLPoint3_GrzPoint3 public import Foundation.Modal.Boxdot.GL_Grz -public import Foundation.Modal.Boxdot.GL_S -public import Foundation.Modal.Boxdot.Grz_S public import Foundation.Modal.Boxdot.Jerabek public import Foundation.Modal.Boxdot.K4_S4 public import Foundation.Modal.Boxdot.Ver_Triv @@ -350,7 +348,6 @@ public import Foundation.Modal.Logic.GLPlusBoxBot.Basic public import Foundation.Modal.Logic.GLPoint3OplusBoxBot.Basic public import Foundation.Modal.Logic.Global public import Foundation.Modal.Logic.S.Basic -public import Foundation.Modal.Logic.S.Consistent public import Foundation.Modal.Logic.SumNormal public import Foundation.Modal.Logic.SumQuasiNormal public import Foundation.Modal.LogicSymbol @@ -463,20 +460,6 @@ public import Foundation.Propositional.Neighborhood.NB.Hilbert.WF public import Foundation.Propositional.Slash public import Foundation.Propositional.Tait.Calculus public import Foundation.Propositional.Translation -public import Foundation.ProvabilityLogic.Arithmetic -public import Foundation.ProvabilityLogic.Classification.LetterlessTrace -public import Foundation.ProvabilityLogic.Classification.Result -public import Foundation.ProvabilityLogic.Classification.Trace -public import Foundation.ProvabilityLogic.GL.Completeness -public import Foundation.ProvabilityLogic.GL.Soundness -public import Foundation.ProvabilityLogic.GL.Uniform -public import Foundation.ProvabilityLogic.GL.Unprovability -public import Foundation.ProvabilityLogic.Grz.Completeness -public import Foundation.ProvabilityLogic.N.Soundness -public import Foundation.ProvabilityLogic.Realization -public import Foundation.ProvabilityLogic.S.Completeness -public import Foundation.ProvabilityLogic.S.Soundness -public import Foundation.ProvabilityLogic.SolovaySentences public import Foundation.SecondOrder.Derivation public import Foundation.SecondOrder.Semantics public import Foundation.SecondOrder.Syntax.Formula diff --git a/Foundation/Modal/Boxdot/GL_S.lean b/Foundation/Modal/Boxdot/GL_S.lean deleted file mode 100644 index dbfeef742..000000000 --- a/Foundation/Modal/Boxdot/GL_S.lean +++ /dev/null @@ -1,50 +0,0 @@ -module - -public import Foundation.ProvabilityLogic.S.Completeness - -@[expose] public section - -namespace LO - -namespace Modal.Kripke.Model - -variable {M : Kripke.Model} {x : M.World} - -instance [M.IsTransitive] : (M↾x).IsTransitive := inferInstance - -instance [M.IsTransitive] [M.IsPointRooted] : (M.extendRoot n).IsTransitive := inferInstance - -end Modal.Kripke.Model - - -namespace Modal.Logic - -open Kripke Formula.Kripke - -variable {φ : Formula _} - -lemma iff_provable_rflSubformula_GL_provable_S : Modal.GL ⊢ (φ.rflSubformula.conj 🡒 φ) ↔ Modal.S ⊢ φ := ProvabilityLogic.GL_S_TFAE (T := 𝗜𝚺₁) |>.out 0 1 - -lemma iff_provable_boxdot_GL_provable_boxdot_S : Modal.GL ⊢ φᵇ ↔ Modal.S ⊢ φᵇ := by - constructor; - . apply Entailment.WeakerThan.wk; - infer_instance; - . intro h; - replace h := GL.Kripke.finite_completeness_TFAE.out 0 2 |>.mp $ iff_provable_rflSubformula_GL_provable_S.mpr h; - - apply GL.Kripke.fintype_completeness_TFAE.out 2 0 |>.mp; - intro M _ _ _ _; - - obtain ⟨i, hi⟩ := Kripke.Model.extendRoot.inr_satisfies_forall_axiomT_set (M := M) (Γ := □⁻¹'φᵇ.subformulas); - apply Model.extendRoot.inl_satisfies_boxdot_iff (i := i) |>.mp; - apply h; - apply Satisfies.fconj_def.mpr; - simp only [Formula.rflSubformula, Finset.mem_image, forall_exists_index, and_imp, forall_apply_eq_imp_iff₂]; - rintro ψ hψ; - apply hi; - exact hψ; - -end Modal.Logic - -end LO -end diff --git a/Foundation/Modal/Boxdot/Grz_S.lean b/Foundation/Modal/Boxdot/Grz_S.lean deleted file mode 100644 index f955af336..000000000 --- a/Foundation/Modal/Boxdot/Grz_S.lean +++ /dev/null @@ -1,14 +0,0 @@ -module - -public import Foundation.Modal.Boxdot.GL_Grz -public import Foundation.Modal.Boxdot.GL_S - -@[expose] public section - -namespace LO.Modal.Logic - -lemma iff_provable_Grz_provable_boxdot_S : Modal.S ⊢ φᵇ ↔ Modal.Grz ⊢ φ := by - apply Iff.trans iff_provable_boxdot_GL_provable_boxdot_S.symm iff_provable_boxdot_GL_provable_Grz; - -end LO.Modal.Logic -end diff --git a/Foundation/Modal/Logic/S/Consistent.lean b/Foundation/Modal/Logic/S/Consistent.lean deleted file mode 100644 index aae2a80a2..000000000 --- a/Foundation/Modal/Logic/S/Consistent.lean +++ /dev/null @@ -1,33 +0,0 @@ -module - -public import Foundation.ProvabilityLogic.GL.Completeness -public import Foundation.ProvabilityLogic.S.Soundness - -@[expose] public section - -namespace LO - -namespace Modal.Logic - -open ProvabilityLogic -open Entailment -open Kripke Formula.Kripke - -lemma iff_provable_GL_provable_box_S {A : Modal.Formula _} : Modal.GL ⊢ A ↔ Modal.S ⊢ □A := by - constructor; - . intro h; - apply Logic.sumQuasiNormal.mem₁!; - apply nec! h; - . intro h; - apply GL.arithmetical_completeness (T := 𝗜𝚺₁) (by simp); - intro f; - exact FirstOrder.ProvabilityAbstraction.Provability.SoundOn.sound_on (S.arithmetical_soundness h f) - -theorem S.no_boxbot : Modal.S ⊬ □⊥ := iff_provable_GL_provable_box_S.not.mp $ by simp; - -instance : Entailment.Consistent Modal.S := Entailment.Consistent.of_unprovable S.no_boxbot - -end Modal.Logic - -end LO -end diff --git a/Foundation/ProvabilityLogic/Arithmetic.lean b/Foundation/ProvabilityLogic/Arithmetic.lean deleted file mode 100644 index bb075948e..000000000 --- a/Foundation/ProvabilityLogic/Arithmetic.lean +++ /dev/null @@ -1,99 +0,0 @@ -module - -public import Foundation.ProvabilityLogic.GL.Soundness -/-! -# Provability logic of arithmetic theory --/ - - -@[expose] public section - -namespace LO - -open FirstOrder - -namespace Modal - -namespace Logic - -/-- `L` is provability logic of `T` relative to metatheory `U` -/ -def IsProvabilityLogic (L : Modal.Logic ℕ) (T U : ArithmeticTheory) [T.Δ₁] := ∀ A, L ⊢ A ↔ ∀ f : T.StandardRealization, U ⊢ f A - -variable {T U : ArithmeticTheory} [T.Δ₁] {L : Modal.Logic ℕ} - -/-- `L` is Łukasiewicz if `L` is provability logic. -/ -abbrev inst_Łukasiewiicz_of_isProvabilityLogic (hPL : L.IsProvabilityLogic T U) : Entailment.Łukasiewicz L where - mdp := by - rintro A B ⟨hA⟩ ⟨hB⟩; - constructor; - simp only [←Modal.Logic.iff_provable, hPL A, hPL B, hPL (A 🡒 B)] at hA hB ⊢; - intro f; - replace hA : U ⊢ f A 🡒 f B := hA f; - replace hB : U ⊢ f A := hB f; - cl_prover [hA, hB]; - implyK {_ _} := by - constructor; - apply Modal.Logic.iff_provable.mp; - apply hPL _ |>.mpr; - simp; - implyS {_ _ _} := by - constructor; - apply Modal.Logic.iff_provable.mp; - apply hPL _ |>.mpr; - simp; - elimContra {_ _} := by - constructor; - apply Modal.Logic.iff_provable.mp; - apply hPL _ |>.mpr; - intro f; - dsimp [ProvabilityLogic.Realization.interpret]; - cl_prover; - -abbrev inst_Cl_of_isProvabilityLogic (hPL : L.IsProvabilityLogic T U) : Entailment.Cl L := by - have := inst_Łukasiewiicz_of_isProvabilityLogic hPL; - infer_instance; - -lemma subset_GL_of_isProvabilityLogic [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] [T ⪯ U] (hPL : L.IsProvabilityLogic T U) : Modal.GL ⊆ L := by - intro A hA; - simp only [←Modal.Logic.iff_provable] at ⊢ hA; - apply hPL A |>.mpr; - intro f; - apply Entailment.WeakerThan.pbl (𝓢 := T); - apply ProvabilityLogic.GL.arithmetical_soundness (𝔅 := T.standardProvability) hA; - -lemma provable_GL_of_isProvabilityLogic [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] [T ⪯ U] (hPL : L.IsProvabilityLogic T U) : Modal.GL ⊢ A → L ⊢ A := by - simp only [Modal.Logic.iff_provable]; - apply subset_GL_of_isProvabilityLogic hPL; - -end Logic - -end Modal - - -namespace FirstOrder - -namespace ArithmeticTheory - -variable {T U : ArithmeticTheory} [T.Δ₁] {A : Modal.Formula ℕ} - -/-- Provability Logic of `T` relative to metatheory `U` -/ -def provabilityLogicOn (T U : ArithmeticTheory) [T.Δ₁] : Modal.Logic ℕ := {A | ∀ f : T.StandardRealization, U ⊢ f A} - -@[simp, grind .] -lemma isProvabilityLogic_provabilityLogicOn : (T.provabilityLogicOn U).IsProvabilityLogic T U := by - simp [Modal.Logic.IsProvabilityLogic, provabilityLogicOn]; - grind; - -@[grind =] -lemma provabilityLogicOn.provable_iff : (T.provabilityLogicOn U) ⊢ A ↔ ∀ f : T.StandardRealization, U ⊢ f A := by - simp [Modal.Logic.iff_provable, provabilityLogicOn] - -instance : Entailment.Cl (T.provabilityLogicOn U) := Modal.Logic.inst_Cl_of_isProvabilityLogic isProvabilityLogic_provabilityLogicOn - -end ArithmeticTheory - -end FirstOrder - -end LO - -end diff --git a/Foundation/ProvabilityLogic/Classification/LetterlessTrace.lean b/Foundation/ProvabilityLogic/Classification/LetterlessTrace.lean deleted file mode 100644 index bcbb202b6..000000000 --- a/Foundation/ProvabilityLogic/Classification/LetterlessTrace.lean +++ /dev/null @@ -1,1097 +0,0 @@ -module - -public import Foundation.Modal.Logic.S.Basic -public import Foundation.ProvabilityLogic.GL.Uniform -public import Foundation.Vorspiel.Set.Cofinite - -@[expose] public section - -namespace LO - -open FirstOrder FirstOrder.ProvabilityAbstraction -open ProvabilityLogic - -variable {φ ψ : Modal.Formula ℕ} - {X Y : Modal.FormulaSet ℕ} - {T : ArithmeticTheory} [T.Δ₁] - -namespace Modal - -/-- letterlessSpectrum for letterless formula -/ -def Formula.letterlessSpectrum (φ : Formula ℕ) (φ_closed : φ.Letterless := by grind) : Set ℕ := - match φ with - | ⊥ => ∅ - | φ 🡒 ψ => (φ.letterlessSpectrum)ᶜ ∪ ψ.letterlessSpectrum - | □φ => { n | ∀ i < n, i ∈ φ.letterlessSpectrum } - - -namespace Formula.letterlessSpectrum - --- variable {hφ : φ.Letterless}{hψ : ψ.Letterless} - -@[simp, grind =] lemma def_bot : (⊥ : Formula _).letterlessSpectrum = ∅ := by simp [letterlessSpectrum] -@[simp, grind =] lemma def_top : (⊤ : Formula _).letterlessSpectrum = Set.univ := by simp [letterlessSpectrum] -@[grind =] lemma def_imp {hφψ : Letterless (φ 🡒 ψ)} : (φ 🡒 ψ).letterlessSpectrum hφψ = φ.letterlessSpectrumᶜ ∪ ψ.letterlessSpectrum := by simp [letterlessSpectrum] -@[grind =] lemma def_neg {hφ : Letterless (∼φ)} : (∼φ).letterlessSpectrum hφ = φ.letterlessSpectrumᶜ := by simp [letterlessSpectrum] -@[grind =] lemma def_or {hφψ : Letterless (φ ⋎ ψ)} : (φ ⋎ ψ).letterlessSpectrum hφψ = φ.letterlessSpectrum ∪ ψ.letterlessSpectrum := by simp [letterlessSpectrum]; -@[grind =] lemma def_and {hφψ : Letterless (φ ⋏ ψ)} : (φ ⋏ ψ).letterlessSpectrum hφψ = φ.letterlessSpectrum ∩ ψ.letterlessSpectrum := by simp [letterlessSpectrum]; -@[grind =] lemma def_box {hφ : Letterless (□φ)} : (□φ).letterlessSpectrum hφ = { n | ∀ i < n, i ∈ φ.letterlessSpectrum } := by simp [letterlessSpectrum]; -@[grind =] lemma def_boxItr {n} {hφ : Letterless (□^[(n + 1)]φ)} : (□^[(n + 1)]φ).letterlessSpectrum hφ = { k | ∀ i < k, i ∈ (□^[n]φ).letterlessSpectrum } := by - apply Eq.trans ?_ $ def_box (φ := □^[n]φ); - . grind; - . induction n generalizing φ with - | zero => grind; - | succ n ih => - suffices (□^[n](□□φ)).letterlessSpectrum = (□□^[n](□φ)).letterlessSpectrum by grind; - simpa using @ih (φ := □φ) (by grind); -@[grind =] lemma def_boxdot {hφ : Letterless (⊡φ)} : (⊡φ).letterlessSpectrum hφ = { n | ∀ i ≤ n, i ∈ φ.letterlessSpectrum } := by - ext i; - suffices (i ∈ φ.letterlessSpectrum ∧ ∀ j < i, j ∈ φ.letterlessSpectrum) ↔ ∀ j ≤ i, j ∈ φ.letterlessSpectrum by simpa [letterlessSpectrum]; - constructor; - . rintro ⟨h₁, h₂⟩ j hj; - rcases Nat.le_iff_lt_or_eq.mp hj with (h | rfl); - . apply h₂; - assumption; - . assumption; - . intro h; - constructor; - . apply h; omega; - . intro j hj; - apply h; - omega; - -lemma def_lconj₂ {l : List (Formula ℕ)} (h : (l.conj₂).Letterless) : (l.conj₂).letterlessSpectrum = ⋂ φ ∈ l, φ.letterlessSpectrum := by - induction l using List.induction_with_singleton with - | hcons a l he ih => - suffices (a ⋏ ⋀l).letterlessSpectrum = ⋂ φ, ⋂ (_ : φ ∈ a :: l), φ.letterlessSpectrum by - convert this; - exact List.conj₂_cons_nonempty he; - rw [def_and]; - simp [ih (by grind)]; - | _ => simp; - -lemma def_lconj' {l : List β} {Φ : β → Formula ℕ} (h : (l.conj' Φ).Letterless) : (l.conj' Φ).letterlessSpectrum = ⋂ i ∈ l, (Φ i).letterlessSpectrum := by - induction l using List.induction_with_singleton with - | hcons a l he ih => - suffices (Φ a ⋏ (List.conj' Φ l)).letterlessSpectrum = ⋂ i, ⋂ (_ : i ∈ a :: l), (Φ i).letterlessSpectrum by - convert this; - exact List.conj₂_cons_nonempty (a := Φ a) (as := List.map Φ l) (by simpa); - rw [def_and]; - simp [ih (by grind)]; - | _ => simp; - -lemma def_fconj {s : Finset (Formula _)} (h : (s.conj).Letterless) : (s.conj.letterlessSpectrum) = ⋂ φ ∈ s, φ.letterlessSpectrum := by - unfold Finset.conj; - rw [def_lconj₂]; - . simp; - . simpa; - -lemma def_fconj' {s} {Φ : α → Formula ℕ} (hΦ : ((⩕ i ∈ s, Φ i)).Letterless) : (⩕ i ∈ s, Φ i).letterlessSpectrum = ⋂ i ∈ s, (Φ i).letterlessSpectrum (by apply letterless_fconj'.mp hΦ _; assumption;) := by - unfold Finset.conj'; - rw [def_lconj']; - . simp; - . simpa; - -end Formula.letterlessSpectrum - - -/-- letterlessTrace for letterless formula -/ -@[grind] def Formula.letterlessTrace (φ : Formula ℕ) (φ_closed : φ.Letterless := by grind) := (φ.letterlessSpectrum)ᶜ - -namespace Formula.letterlessTrace - -variable {φ ψ : Formula ℕ} {hφ : φ.Letterless} {hψ : ψ.Letterless} - -@[simp, grind =] lemma def_top : (⊤ : Formula _).letterlessTrace = ∅ := by grind; -@[simp, grind =] lemma def_bot : (⊥ : Formula _).letterlessTrace = Set.univ := by grind; -@[grind =] lemma def_neg : (∼φ).letterlessTrace = φ.letterlessTraceᶜ := by grind; -@[grind =] lemma def_and : (φ ⋏ ψ).letterlessTrace = φ.letterlessTrace ∪ ψ.letterlessTrace := by grind; -@[grind =] lemma def_or : (φ ⋎ ψ).letterlessTrace = φ.letterlessTrace ∩ ψ.letterlessTrace := by grind; - -end Formula.letterlessTrace - - -namespace Formula - -@[grind =] lemma neg_letterlessTrace_letterlessSpectrum {φ : Formula ℕ} {hφ : φ.Letterless} : (∼φ).letterlessTrace = φ.letterlessSpectrum := by grind; -@[grind =] lemma neg_letterlessSpectrum_letterlessTrace {φ : Formula ℕ} {hφ : φ.Letterless} : (∼φ).letterlessSpectrum = φ.letterlessTrace := by grind; - - -lemma letterlessSpectrum_finite_or_cofinite {φ : Formula ℕ} (hφ : φ.Letterless) : φ.letterlessSpectrum.Finite ∨ φ.letterlessSpectrum.Cofinite := by - induction φ with - | hfalsum => simp; - | hatom => grind; - | himp φ ψ ihφ ihψ => - rw [letterlessSpectrum.def_imp]; - . rcases ihφ (by grind) with (ihφ | ihφ) <;> - rcases ihψ (by grind) with (ihψ | ihψ); - case himp.inr.inl => - left; - grind [Set.Finite.union]; - . right; - apply Set.cofinite_union_left; - simpa [Set.Cofinite] - . grind; - . grind; - | hbox φ ihφ => - by_cases h : φ.letterlessSpectrum = Set.univ; - . right; - rw [letterlessSpectrum.def_box, h]; - simp; - . left; - obtain ⟨k, hk₁, hk₂⟩ := exists_minimal_of_wellFoundedLT (λ k => k ∉ φ.letterlessSpectrum) $ Set.ne_univ_iff_exists_notMem _ |>.mp h; - have : {n | ∀ i < n, i ∈ φ.letterlessSpectrum} = { n | n ≤ k} := by - ext i; - suffices (∀ j < i, j ∈ φ.letterlessSpectrum) ↔ i ≤ k by simpa [Set.mem_setOf_eq]; - constructor; - . intro h; - contrapose! hk₁; - exact h k (by omega); - . intro h j hji; - contrapose! hk₂; - use j; - constructor; - . assumption; - . omega; - rw [letterlessSpectrum.def_box, this]; - apply Set.finite_le_nat; - -@[grind .] -lemma letterlessTrace_finite_or_cofinite {φ : Formula ℕ} (hφ : φ.Letterless) : φ.letterlessTrace.Finite ∨ φ.letterlessTrace.Cofinite := by - suffices φ.letterlessSpectrum.Finite ∨ φ.letterlessSpectrum.Cofinite by - simp [Formula.letterlessTrace, Set.iff_cofinite_comp_finite]; - tauto; - apply letterlessSpectrum_finite_or_cofinite hφ; - -@[grind →] -lemma letterlessTrace_cofinite_of_letterlessSpectrum_infinite (hφ : φ.Letterless) : φ.letterlessTrace.Infinite → φ.letterlessTrace.Cofinite := by - have := or_iff_not_imp_left.mp $ letterlessTrace_finite_or_cofinite hφ; - grind [Set.Infinite]; - -@[grind →] -lemma letterlessTrace_finite_of_letterlessSpectrum_cofinite (hφ : φ.Letterless) : φ.letterlessTrace.Coinfinite → φ.letterlessTrace.Finite := by - have := or_iff_not_imp_right.mp $ letterlessTrace_finite_or_cofinite hφ; - simp only [Set.iff_coinfinite_not_cofinite]; - assumption; - -@[simp, grind =] -lemma boxbot_letterlessSpectrum : (□^[n]⊥ : Formula ℕ).letterlessSpectrum = { i | i < n } := by - induction n with - | zero => simp - | succ n ih => - calc - _ = { i | ∀ k < i, k ∈ (□^[n]⊥ : Formula ℕ).letterlessSpectrum } := Formula.letterlessSpectrum.def_boxItr - _ = { i | ∀ k < i, k < n } := by simp [ih]; - _ = { i | i < n + 1 } := by - ext i; - suffices (∀ k < i, k < n) ↔ i < n + 1 by simpa; - constructor; - . contrapose!; - intro h; - use n; - omega; - . omega; - -end Formula - - -/-- Realization which any propositional variable maps to `⊤` -/ -abbrev _root_.LO.FirstOrder.ArithmeticTheory.LetterlessStandardRealization (T : ArithmeticTheory) [T.Δ₁] : T.StandardRealization := ⟨λ _ => ⊤⟩ - - -namespace Formula - -@[grind] def Regular (T : ArithmeticTheory) [T.Δ₁] (φ : Modal.Formula ℕ) := ℕ ⊧ₘ (T.LetterlessStandardRealization φ) - -@[grind] def Singular (T : ArithmeticTheory) [T.Δ₁] (φ : Modal.Formula ℕ) := ¬(φ.Regular T) - -namespace Regular - -@[simp] lemma def_bot : ¬((⊥ : Formula _).Regular T) := by simp [Formula.Regular, Realization.interpret]; -@[simp] lemma def_top : (⊤ : Formula _).Regular T := by simp [Formula.Regular, Realization.interpret]; -lemma def_neg : (∼φ).Regular T ↔ ¬(φ.Regular T) := by simp [Formula.Regular, Realization.interpret]; -lemma def_neg' : (∼φ).Regular T ↔ (φ.Singular T) := Iff.trans def_neg $ by rfl -lemma def_and : (φ ⋏ ψ).Regular T ↔ (φ.Regular T) ∧ (ψ.Regular T) := by simp [Formula.Regular, Realization.interpret]; -lemma def_or : (φ ⋎ ψ).Regular T ↔ (φ.Regular T) ∨ (ψ.Regular T) := by simp [Formula.Regular, Realization.interpret]; tauto; -lemma def_imp : (φ 🡒 ψ).Regular T ↔ ((φ.Regular T) → (ψ.Regular T)) := by simp [Formula.Regular, Realization.interpret]; -lemma def_iff : (φ 🡘 ψ).Regular T ↔ ((φ.Regular T) ↔ (ψ.Regular T)) := by simp [Formula.Regular, Realization.interpret]; tauto; - -attribute [simp, grind .] - def_bot - def_top - def_neg def_neg' - def_and - def_or - def_imp - def_iff - -@[simp, grind =] -lemma def_lconj {l : List (Formula _)} : (l.conj₂).Regular T ↔ ∀ φ ∈ l, (φ.Regular T) := by - induction l using List.induction_with_singleton' with - | hcons _ _ _ ih => simp_all [Regular]; - | _ => simp; - -@[simp, grind =] -lemma def_lconj' {l : List _} {Φ : β → Formula _} : (l.conj' Φ).Regular T ↔ ∀ i ∈ l, ((Φ i).Regular T) := by - induction l using List.induction_with_singleton' with - | hcons _ _ _ ih => simp_all [Regular]; - | _ => simp; - -@[simp, grind =] -lemma def_fconj {s : Finset (Formula _)} : (s.conj).Regular T ↔ ∀ φ ∈ s, (φ.Regular T) := by - simp [Finset.conj]; - -@[simp] -lemma def_fconj' {s : Finset _} {Φ : β → Formula _} : (⩕ i ∈ s, Φ i).Regular T ↔ ∀ i ∈ s, ((Φ i).Regular T) := by - simp [Finset.conj']; - -end Regular - - -namespace Singular - -@[simp] lemma def_bot : (⊥ : Formula _).Singular T := by grind -@[simp] lemma def_top : ¬(⊤ : Formula _).Singular T := by grind -lemma def_neg : (∼φ).Singular T ↔ ¬(φ.Singular T) := by grind; -lemma def_neg' : (∼φ).Singular T ↔ (φ.Regular T) := by grind; -lemma def_and : (φ ⋏ ψ).Singular T ↔ (φ.Singular T) ∨ (ψ.Singular T) := by grind -lemma def_or : (φ ⋎ ψ).Singular T ↔ (φ.Singular T) ∧ (ψ.Singular T) := by grind -lemma def_imp : (φ 🡒 ψ).Singular T ↔ (¬(φ.Singular T) ∧ (ψ.Singular T)) := by grind - -attribute [grind .] - def_bot - def_top - def_neg def_neg' - def_and - def_or - def_imp - -end Singular - -end Formula - - -def FormulaSet.Regular (T : ArithmeticTheory) [T.Δ₁] (X : Modal.FormulaSet ℕ) := ∀ φ ∈ X, φ.Regular T -def FormulaSet.Singular (T : ArithmeticTheory) [T.Δ₁] (X : Modal.FormulaSet ℕ) := ¬X.Regular T - -def FormulaSet.letterlessSpectrum (X : Modal.FormulaSet ℕ) (X_c : X.Letterless := by grind) := ⋂ φ ∈ X, φ.letterlessSpectrum -def FormulaSet.letterlessTrace (X : Modal.FormulaSet ℕ) (_ : X.Letterless := by grind [FormulaSet.Letterless]) := X.letterlessSpectrumᶜ - -namespace FormulaSet - -lemma exists_singular_of_singular (hX_singular : X.Singular T) : ∃ φ ∈ X, φ.Singular T := by - simpa [FormulaSet.Singular, FormulaSet.Regular] using hX_singular; - --- variable (Xll : X.Letterless := by grind) (Yll : Y.Letterless := by grind) - -lemma def_letterlessTrace_union (hX) : X.letterlessTrace hX = ⋃ φ ∈ X, φ.letterlessTrace := by simp [FormulaSet.letterlessTrace, FormulaSet.letterlessSpectrum, Formula.letterlessTrace] - -lemma comp_letterlessTrace_letterlessSpectrum (hX) : (X.letterlessTrace hX)ᶜ = X.letterlessSpectrum := by simp [FormulaSet.letterlessTrace] - -lemma iff_subset_letterlessSpectrum_subset_letterlessTrace (hX hY) : X.letterlessSpectrum hX ⊆ Y.letterlessSpectrum hY ↔ Y.letterlessTrace ⊆ X.letterlessTrace := by simp [FormulaSet.letterlessTrace] - -lemma iff_eq_letterlessSpectrum_eq_letterlessTrace (hX hY) : X.letterlessSpectrum hX = Y.letterlessSpectrum hY ↔ X.letterlessTrace = Y.letterlessTrace := by simp [FormulaSet.letterlessTrace]; - -end FormulaSet - -/-- boxbot instance of axiomT -/ -abbrev TBB (n : ℕ) : Formula ℕ := □^[(n + 1)]⊥ 🡒 □^[n]⊥ - -section - -variable {α α₁ α₂ β β₁ β₂ : Set ℕ} {hβ : β.Cofinite} {hβ₁ : β₁.Cofinite} {hβ₂ : β₂.Cofinite} - -@[simp, grind .] lemma TBB_letterless : (TBB n).Letterless := by grind - -@[simp] -lemma TBB_injective : Function.Injective TBB := by - rintro i j; - wlog hij : i < j; rcases (show i = j ∨ i > j by omega) <;> grind; - suffices (□^[i]⊥ : Formula ℕ) = □^[j]⊥ → i = j by grind [Formula.inj_imp]; - obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_lt hij; - simp [show ((i + k) + 1) = i + (k + 1) by omega, ←Box.boxItr_add (n := i) (m := (k + 1)), InjectiveBox.inj_multibox.eq_iff]; - -@[simp, grind .] -lemma TBB_letterlessSpectrum : (TBB n).letterlessSpectrum = {n}ᶜ := by - ext i; - rw [Formula.letterlessSpectrum.def_imp, Formula.boxbot_letterlessSpectrum, Formula.boxbot_letterlessSpectrum]; - simp; - omega; - -@[simp, grind .] -lemma TBB_letterlessTrace : (TBB n).letterlessTrace = {n} := by simp [Formula.letterlessTrace, TBB_letterlessSpectrum, compl_compl]; - -@[simp, grind .] -lemma TBB_conj'_letterless : (⩕ n ∈ s, TBB n).Letterless := by - apply Formula.letterless_fconj'.mpr; - grind; - -@[simp, grind .] -lemma TBBSet_letterless : FormulaSet.Letterless (TBB '' α) := by simp [FormulaSet.Letterless] - -@[simp] -lemma TBBSet_letterlessTrace : FormulaSet.letterlessTrace (TBB '' α) = α := by - simp [FormulaSet.def_letterlessTrace_union]; - -@[simp, grind .] -lemma TBBMinus_letterless' : Formula.Letterless (∼⩕ n ∈ hβ.toFinset, TBB n) := by - apply Formula.letterless_neg.mpr; - apply Formula.letterless_fconj'.mpr; - grind; - -@[simp, grind .] -lemma TBBMinus_letterless : FormulaSet.Letterless {∼⩕ n ∈ hβ.toFinset, TBB n} := by simp [FormulaSet.Letterless]; - -@[simp, grind .] -lemma TBBMinus_letterlessSpectrum' : (∼⩕ n ∈ hβ.toFinset, TBB n).letterlessSpectrum TBBMinus_letterless' = βᶜ := by - simp only [Formula.letterlessSpectrum.def_neg, compl_inj_iff]; - rw [Formula.letterlessSpectrum.def_fconj' ?_]; - . ext j; - suffices (∀ i ∉ β, j ≠ i) ↔ j ∈ β by simpa [TBB_letterlessSpectrum]; - grind; - . apply Formula.letterless_fconj'.mpr - grind; - -@[simp, grind .] -lemma TBBMinus_letterlessSpectrum : FormulaSet.letterlessSpectrum {(∼⩕ n ∈ hβ.toFinset, TBB n)} (by simp) = βᶜ := by simp [FormulaSet.letterlessSpectrum] - - -section - -variable [ℕ ⊧ₘ* T] - -@[simp high, grind .] -lemma TBB_regular : (TBB n).Regular T := by - apply Formula.Regular.def_imp.mpr; - intro h; - exfalso; - have : ¬ℕ ⊧ₘ T.LetterlessStandardRealization (□^[(n + 1)]⊥) := by - simp only [Box.boxItr_succ, Realization.interpret.def_box, Realization.interpret.def_boxItr, Realization.interpret.def_bot]; - apply not_imp_not.mpr $ Provability.sound_on; - apply iIncon_unprovable_of_sigma1_sound; - apply this; - exact h; - -@[simp, grind .] -lemma TBB_conj'_regular : (⩕ n ∈ s, TBB n).Regular T := by - apply Formula.Regular.def_fconj'.mpr; - grind; - -@[simp high] -lemma TBBSet_regular : FormulaSet.Regular T (TBB '' α) := by - rintro _ ⟨_, _, rfl⟩; - grind; - - -@[simp] -lemma TBBMinus_singular : FormulaSet.Singular T {∼⩕ n ∈ hβ.toFinset, TBB n} := by - simp [FormulaSet.Singular, FormulaSet.Regular, Formula.Regular.def_neg]; - -end - -end - - -namespace Kripke - -open Kripke -open Formula.Kripke - -variable {F : Frame} [F.IsPointRooted] [Fintype F] - -lemma iff_satisfies_mem_rank_letterlessSpectrum - {M : Model} [Fintype M] [M.IsIrreflexive] [M.IsTransitive] [M.IsPointRooted] {w : M} - {φ : Formula ℕ} (φ_closed : φ.Letterless := by grind) - : w ⊧ φ ↔ Frame.rank w ∈ φ.letterlessSpectrum := by - induction φ generalizing w with - | hbox φ ihφ => - calc - w ⊧ □φ ↔ ∀ v, w ≺ v → v ⊧ φ := by rfl; - _ ↔ ∀ v, w ≺ v → (Frame.rank v ∈ φ.letterlessSpectrum) := by - constructor; - . intro h v; rw [←ihφ (by grind)]; apply h; - . intro h v; rw [ihφ (by grind)]; apply h; - _ ↔ ∀ i < (Frame.rank w), i ∈ φ.letterlessSpectrum := by - constructor; - . intro h i hi; - obtain ⟨v, Rwv, rfl⟩ := Frame.exists_of_lt_height hi; - apply h; - assumption; - . intro h v Rwv; - apply h; - apply Frame.rank_lt_of_rel; - assumption; - _ ↔ Frame.rank w ∈ (□φ).letterlessSpectrum := by - rw [Formula.letterlessSpectrum.def_box]; simp; - | _ => grind; - -lemma iff_satisfies_TBB_ne_rank - {M : Model} [Fintype M] [M.IsIrreflexive] [M.IsTransitive] [M.IsPointRooted] {w : M} {n : ℕ} - : w ⊧ TBB n ↔ Frame.rank w ≠ n := by - apply Iff.trans iff_satisfies_mem_rank_letterlessSpectrum; - simp; - -abbrev Frame.finiteLinear (n : ℕ) : Kripke.Frame where - World := Fin (n + 1) - Rel := (· < ·) - -namespace Frame.finiteLinear - -abbrev of (i : Fin (n + 1)) : Frame.finiteLinear n := i - -instance : (Frame.finiteLinear n) |>.IsPointRooted where - default := ⟨of 0, by grind⟩ - uniq {r} := by - by_contra! hC; - have := r.2 0 (by grind); - grind; - -instance : (Frame.finiteLinear n) |>.IsIrreflexive where - irrefl := by simp [Frame.finiteLinear] - -instance : (Frame.finiteLinear n) |>.IsTransitive where - trans := by simp [Frame.finiteLinear]; grind; - -lemma rank_of_eq_sub (i : Fin (n + 1)) : Frame.rank (of i) = n - i := by - induction i using Fin.reverseInduction - case last => - suffices rank (of (Fin.last n)) = 0 by simpa - apply fcwHeight_eq_zero_iff.mpr - intro j - show ¬(Fin.last n) < j - simp [Fin.le_last] - case cast i ih => - suffices rank (of i.castSucc) = rank (of i.succ) + 1 by - rw [this, ih] - simp; omega - apply fcwHeight_eq_succ_fcwHeight - · show i.castSucc < i.succ - exact Fin.castSucc_lt_succ; - · suffices ∀ j : Fin (n + 1), i.castSucc < j → i.succ ≤ j by - simpa [le_iff_lt_or_eq] using this - intro j - exact id - -@[simp] lemma rank_zero : (Frame.finiteLinear n).height = n := by simpa using rank_of_eq_sub _ - -end Frame.finiteLinear - -lemma letterlessSpectrum_TFAE (_ : φ.Letterless) : [ - n ∈ φ.letterlessSpectrum, - ∀ M : Model, [Fintype M] → [M.IsIrreflexive] → [M.IsTransitive] → [M.IsPointRooted] → ∀ w : M.World, Frame.rank w = n → w ⊧ φ, - ∃ M : Model, ∃ _ : Fintype M, ∃ _ : M.IsIrreflexive, ∃ _ : M.IsTransitive, ∃ _ : M.IsPointRooted, ∃ w : M.World, Frame.rank w = n ∧ w ⊧ φ -].TFAE := by - tfae_have 1 → 2 := by - intro h M _ _ _ _ w hw; - apply iff_satisfies_mem_rank_letterlessSpectrum (by grind) |>.mpr; - apply hw ▸ h; - tfae_have 2 → 3 := by - intro h; - let M : Kripke.Model := ⟨Frame.finiteLinear n, λ p i => True⟩; - use ⟨Frame.finiteLinear n, λ p i => True⟩; - refine ⟨inferInstance, inferInstance, inferInstance, inferInstance, ?_⟩; - . use M.root; - constructor; - . exact Frame.finiteLinear.rank_zero; - . apply h; - exact Frame.finiteLinear.rank_zero; - tfae_have 3 → 1 := by - rintro ⟨M, _, _, _, _, w, rfl, hw⟩; - apply iff_satisfies_mem_rank_letterlessSpectrum (by grind) |>.mp hw; - tfae_finish; - -end Kripke - -section - -open Formula -open LO.Entailment Modal.Entailment - -variable {φ ψ : Formula ℕ} (hφ : φ.Letterless) (hψ : ψ.Letterless) - -lemma iff_GL_provable_letterlessSpectrum_Univ : Modal.GL ⊢ φ ↔ φ.letterlessSpectrum = Set.univ := by - rw [Set.eq_univ_iff_forall]; - constructor; - . intro h n; - apply Kripke.letterlessSpectrum_TFAE (φ := φ) (by grind) |>.out 1 0 |>.mp; - intro M _ _ _ _ _ w; - have := GL.Kripke.fintype_completeness_TFAE.out 0 1 |>.mp h; - apply @this M.toFrame; - . intro h; - apply GL.Kripke.fintype_completeness_TFAE.out 1 0 |>.mp; - intro M _ _ _ _ V x; - have := Kripke.letterlessSpectrum_TFAE (φ := φ) (n := Kripke.Frame.rank x) (by grind) |>.out 0 1 |>.mp; - apply this (by grind) _ x rfl; - -lemma iff_GL_provable_C_subset_letterlessSpectrum : Modal.GL ⊢ (φ 🡒 ψ) ↔ φ.letterlessSpectrum hφ ⊆ ψ.letterlessSpectrum hψ := by - apply Iff.trans $ iff_GL_provable_letterlessSpectrum_Univ (show (φ 🡒 ψ).Letterless by grind); - rw [Formula.letterlessSpectrum.def_imp]; - suffices (∀ i, i ∉ φ.letterlessSpectrum ∨ i ∈ ψ.letterlessSpectrum) ↔ φ.letterlessSpectrum ⊆ ψ.letterlessSpectrum by - simpa [Set.eq_univ_iff_forall]; - constructor <;> - . intro h i; - have := @h i; - tauto; - -lemma iff_GL_provable_E_eq_letterlessSpectrum : Modal.GL ⊢ (φ 🡘 ψ) ↔ φ.letterlessSpectrum = ψ.letterlessSpectrum := by - rw [ - Set.Subset.antisymm_iff, - ←iff_GL_provable_C_subset_letterlessSpectrum, - ←iff_GL_provable_C_subset_letterlessSpectrum, - ]; - constructor; - . intro h; constructor <;> cl_prover [h]; - . rintro ⟨h₁, h₂⟩; cl_prover [h₁, h₂]; - -lemma GL_letterlessTrace_TBB_normalization (h : φ.letterlessTrace.Finite) : Modal.GL ⊢ φ 🡘 (⩕ n ∈ h.toFinset, (TBB n)) := by - apply iff_GL_provable_E_eq_letterlessSpectrum _ _ |>.mpr; - . calc - _ = ⋂ i ∈ φ.letterlessTrace, (TBB i).letterlessSpectrum := by - have : φ.letterlessTrace = ⋃ i ∈ φ.letterlessTrace, (TBB i).letterlessTrace := by ext i; simp [TBB_letterlessTrace]; - simpa [Formula.letterlessTrace] using compl_inj_iff.mpr this; - _ = _ := by - ext i; - rw [Formula.letterlessSpectrum.def_fconj' (by simp)]; - simp; - . show φ.Letterless; - assumption; - . show (⩕ n ∈ h.toFinset, TBB n).Letterless; - grind; - -lemma GL_letterlessSpectrum_TBB_normalization (h : φ.letterlessSpectrum.Finite) : Modal.GL ⊢ φ 🡘 ∼(⩕ n ∈ h.toFinset, (TBB n)) := by - have h' : (∼φ).letterlessTrace.Finite := by grind; - have := GL_letterlessTrace_TBB_normalization (show (∼φ).Letterless by grind) h'; - rw [show h.toFinset = h'.toFinset by grind]; - cl_prover [this]; - -lemma GL_proves_letterless_axiomWeakPoint3 (hφ : φ.Letterless) (hψ : ψ.Letterless) : Modal.GL ⊢ (Axioms.WeakPoint3 φ ψ) := by - apply iff_GL_provable_letterlessSpectrum_Univ (by grind) |>.mpr; - apply Set.eq_univ_iff_forall.mpr; - intro n; - rw [ - letterlessSpectrum.def_or, - letterlessSpectrum.def_box, - letterlessSpectrum.def_box, - letterlessSpectrum.def_imp, - letterlessSpectrum.def_imp, - letterlessSpectrum.def_boxdot, - letterlessSpectrum.def_boxdot - ]; - grind; - -/- TODO: -/-- Theorem 2 in [Valentini & Solitro 1983] -/ -lemma iff_provable_GLPoint3_letterless_provable_GL : Modal.GLPoint3 ⊢ φ ↔ (∀ s : ZeroSubstitution _, Modal.GL ⊢ φ⟦s.1⟧) := by - constructor; - . suffices Modal.GLPoint3 ⊢ φ → (∀ s : ZeroSubstitution _, Modal.GL ⊢ φ⟦s.1⟧) by simpa; - intro h s; - induction h using Hilbert.Normal.rec! with - | axm t ht => - rcases ht with (rfl | rfl | rfl); - . simp; - . simp; - . apply GL_proves_letterless_axiomWeakPoint3 <;> - apply Formula.Letterless_zeroSubst; - | mdp h₁ h₂ => exact h₁ ⨀ h₂; - | nec h => apply nec! h; - | _ => simp; - . contrapose!; - suffices Modal.GLPoint3 ⊬ φ → (∃ s : ZeroSubstitution _, Modal.GL ⊬ φ⟦s.1⟧) by simpa; - -- Kripke semantical arguments (?) - intro h; - sorry; --/ - -end - -variable - [ℕ ⊧ₘ* T] - (hφ : φ.Letterless) (hψ : ψ.Letterless) - (X_letterless : X.Letterless) (Y_letterless : Y.Letterless) - -lemma letterless_arithmetical_completeness [𝗜𝚺₁ ⪯ T] (hφ : φ.Letterless) - : Modal.GL ⊢ φ ↔ T ⊢ T.LetterlessStandardRealization φ := by - apply Iff.trans (GL.arithmetical_completeness_sound_iff (T := T) |>.symm); - constructor; - . intro h; - apply h; - . intro h f; - have e : T.LetterlessStandardRealization φ = f φ := Realization.letterless_interpret hφ - exact e ▸ h; - -lemma iff_regular_of_provable_E [𝗜𝚺₁ ⪯ T] (hφ : φ.Letterless) (hψ : ψ.Letterless) (h : Modal.GL ⊢ φ 🡘 ψ) - : φ.Regular T ↔ ψ.Regular T := by - have : T ⊢ T.LetterlessStandardRealization (φ 🡘 ψ) := letterless_arithmetical_completeness (by grind) |>.mp h; - have : ℕ ⊧ₘ T.LetterlessStandardRealization (φ 🡘 ψ) := ArithmeticTheory.SoundOn.sound (F := λ _ => True) this (by simp); - simp [Realization.interpret, Formula.Regular] at this ⊢; - tauto; - -lemma iff_singular_of_provable_E [𝗜𝚺₁ ⪯ T] (hφ : φ.Letterless) (hψ : ψ.Letterless) (h : Modal.GL ⊢ φ 🡘 ψ) - : φ.Singular T ↔ ψ.Singular T := Iff.not $ iff_regular_of_provable_E hφ hψ h - - -variable [𝗜𝚺₁ ⪯ T] - -lemma Formula.iff_regular_letterlessTrace_finite : φ.Regular T ↔ φ.letterlessTrace.Finite := by - constructor; - . contrapose!; - intro h; - have : φ.letterlessSpectrum.Finite := by - have := letterlessTrace_cofinite_of_letterlessSpectrum_infinite (by grind) h; - have : (φ.letterlessTrace)ᶜ.Finite := Set.iff_cofinite_comp_finite.mp this; - simpa [Formula.letterlessTrace] using this; - apply iff_regular_of_provable_E ?_ ?_ (GL_letterlessSpectrum_TBB_normalization (by assumption) this) |>.not.mpr; - . apply Formula.Regular.def_neg.not.mpr; - push Not; - exact TBB_conj'_regular; - . assumption; - . convert @TBBMinus_letterless' φ.letterlessTrace $ by simpa [Formula.letterlessTrace, Set.Cofinite] - simp [Formula.letterlessTrace] - . intro h; - apply iff_regular_of_provable_E (by grind) (by simp) (GL_letterlessTrace_TBB_normalization (by grind) h) |>.mpr; - simp; - -lemma Formula.letterlessSpectrum_finite_of_singular : φ.Singular T → φ.letterlessSpectrum.Finite := by - contrapose!; - suffices ¬(φ.letterlessSpectrum).Finite → Formula.Regular T φ by simpa [Formula.Singular, not_not]; - intro h; - apply iff_regular_letterlessTrace_finite (by grind) |>.mpr; - apply or_iff_not_imp_right.mp $ Formula.letterlessTrace_finite_or_cofinite (by grind); - simpa [Formula.letterlessTrace] using h; - -lemma letterless_arithmetical_completeness' : [ - Modal.GL ⊢ φ, - T ⊢ T.LetterlessStandardRealization φ, - φ.letterlessSpectrum = Set.univ, -].TFAE := by - tfae_have 1 ↔ 2 := letterless_arithmetical_completeness (by grind) - tfae_have 1 ↔ 3 := iff_GL_provable_letterlessSpectrum_Univ (by grind) - tfae_finish; - -lemma FormulaSet.letterlessSpectrum_finite_of_singular (X_singular : X.Singular T) : X.letterlessSpectrum.Finite := by - obtain ⟨φ, hφ₁, hφ₂⟩ := exists_singular_of_singular X_singular; - suffices (X.letterlessSpectrum) ⊆ (φ.letterlessSpectrum) by - apply Set.Finite.subset ?_ this; - exact Formula.letterlessSpectrum_finite_of_singular (by grind) hφ₂; - intro i; - simp_all [FormulaSet.letterlessSpectrum]; - -lemma FormulaSet.regular_of_not_letterlessTrace_cofinite : ¬X.letterlessTrace.Cofinite → X.Regular T := by - contrapose!; - suffices ¬X.Regular T → (X.letterlessSpectrum).Finite by simpa [FormulaSet.letterlessTrace, Set.Cofinite]; - apply letterlessSpectrum_finite_of_singular; - assumption; - -section - -open Classical LO.Entailment in -lemma GL.iff_provable_closed_sumQuasiNormal_subset_letterlessSpectrum (hSR : X.Singular T ∨ φ.Regular T) - : Modal.GL.sumQuasiNormal X ⊢ φ ↔ X.letterlessSpectrum ⊆ φ.letterlessSpectrum := by - calc - _ ↔ ∃ Y, (∀ ψ ∈ Y, ψ ∈ X) ∧ Modal.GL ⊢ Finset.conj Y 🡒 φ := Logic.sumQuasiNormal.iff_provable_finite_provable_letterless X_letterless - _ ↔ ∃ Y : Finset (Formula ℕ), ∃ _ : ∀ ψ ∈ Y, ψ ∈ X, (Finset.conj Y).letterlessSpectrum ⊆ φ.letterlessSpectrum := by - constructor; - . rintro ⟨Y, _, hY₂⟩; - use Y; - constructor; - . apply iff_GL_provable_C_subset_letterlessSpectrum (by grind) (by grind) |>.mp hY₂; - . assumption; - . rintro ⟨Y, hY₁, hY₂⟩; - use Y; - constructor; - . assumption; - . apply iff_GL_provable_C_subset_letterlessSpectrum (by grind) (by grind) |>.mpr hY₂; - _ ↔ ∃ Y : Finset (Formula ℕ), ∃ _ : ∀ ψ ∈ Y, ψ ∈ X, ⋂ ψ ∈ Y, ψ.letterlessSpectrum ⊆ φ.letterlessSpectrum := by - constructor; - . rintro ⟨Y, hY₁, hY₂⟩; - use Y, hY₁; - suffices Y.conj.letterlessSpectrum = ⋂ ψ ∈ Y, ψ.letterlessSpectrum by simpa [this] using hY₂; - rw [Formula.letterlessSpectrum.def_fconj]; - grind; - . rintro ⟨Y, hY₁, hY₂⟩; - use Y; - constructor; - . rw [Formula.letterlessSpectrum.def_fconj]; - . grind; - . grind; - . assumption; - _ ↔ (⋂ ψ ∈ X, ψ.letterlessSpectrum) ⊆ φ.letterlessSpectrum := by - constructor; - . rintro ⟨Y, hY₁, hY₂⟩ i hi; - apply hY₂; - simp_all; - . intro h; - rcases hSR with X_singular | φ_regular; - . wlog X_infinite : X.Infinite - . replace X_infinite := Set.not_infinite.mp X_infinite; - use X_infinite.toFinset; - refine ⟨?_, ?_⟩ - . simp; - . intro i hi; - apply h; - simpa using hi; - - obtain ⟨ψ, hψX, ψ_singular⟩ : ∃ ψ ∈ X, ψ.Singular T := FormulaSet.exists_singular_of_singular X_singular; - - obtain ⟨f, f0, f_monotone, fX, f_inv⟩ := Set.infinitely_finset_approximate (Countable.to_set inferInstance) X_infinite hψX; - have f_conj_letterless : ∀ i, (f i).conj.Letterless := λ i => Formula.letterless_fconj.mpr $ λ ξ hξ => X_letterless _ $ fX _ hξ; - - let sf := λ i => ⋂ ξ, ⋂ (h : ξ ∈ f i), ξ.letterlessSpectrum (X_letterless ξ $ fX _ $ by assumption); - have sf_eq : ∀ i, sf i = Formula.letterlessSpectrum ((f i).conj) (f_conj_letterless _) := by - intro i; - rw [Formula.letterlessSpectrum.def_fconj (f_conj_letterless i)]; - have sf_monotone : ∀ i, sf (i + 1) ⊆ sf i := by - intro i; - rw [sf_eq (i + 1), sf_eq i]; - apply iff_GL_provable_C_subset_letterlessSpectrum (f_conj_letterless _) (f_conj_letterless _) |>.mp; - -- TODO: `Γ ⊇ Δ` → `⊢ Γ.conj → Δ.conj` - apply right_Fconj!_intro; - intro χ hχ; - apply left_Fconj!_intro; - apply f_monotone _ |>.1 hχ; - replace sf_monotone : ∀ i j, i ≤ j → sf j ⊆ sf i := by - intro i j hij; - have : ∀ k, (sf (i + k)) ⊆ sf i := by - intro k; - induction k with - | zero => simp; - | succ k ih => - rw [show i + (k + 1) = (i + k) + 1 by omega]; - exact Set.Subset.trans (sf_monotone (i + k)) ih; - rw [(show j = i + (j - i) by omega)]; - apply this; - - have sf0_eq : sf 0 = ψ.letterlessSpectrum := by simp [sf, f0]; - have sf0_finite : (sf 0).Finite := by rw [sf0_eq]; exact Formula.letterlessSpectrum_finite_of_singular (by grind) ψ_singular; - have sf_finite : ∀ i, (sf i).Finite := by - intro i; - apply Set.Finite.subset sf0_finite; - apply sf_monotone _ _ (by omega); - - have sf_X : ∀ i, sf i ⊇ X.letterlessSpectrum := by - intro i n; - suffices (∀ (ξ : Formula ℕ) (_ : ξ ∈ X), n ∈ ξ.letterlessSpectrum _) → ∀ (ξ : Formula ℕ) (_ : ξ ∈ f i), n ∈ ξ.letterlessSpectrum _ by - simpa [sf, FormulaSet.letterlessSpectrum]; - intro h ξ hξ; - apply h; - apply fX i hξ; - - obtain ⟨k, hk⟩ : ∃ k, sf k = X.letterlessSpectrum := by - by_contra! hC; - have : ∀ i, ∃ n, n ∈ sf i ∧ n ∉ X.letterlessSpectrum := by - intro i; - exact Set.ssubset_iff_exists.mp (Set.ssubset_of_subset_ne (sf_X i) (hC i).symm) |>.2; - - apply Finset.no_ssubset_descending_chain (f := λ i => sf_finite i |>.toFinset); - - intro i; - obtain ⟨n, hn₁, hn₂⟩ := this i; - obtain ⟨ξ, hξ₁, hξ₂⟩ : ∃ ξ, ∃ (_ : ξ ∈ X), n ∉ ξ.letterlessSpectrum _ := by simpa [FormulaSet.letterlessSpectrum] using hn₂; - obtain ⟨j, hj⟩ := f_inv ξ hξ₁; - - have : i < j := by - by_contra hC; - have := Set.Subset.trans (sf_monotone j i (by omega)) $ show sf j ⊆ ξ.letterlessSpectrum by - intro _ hn; - apply hn; - use ξ; - simp_all; - apply hξ₂; - apply this; - apply hn₁; - use j; - constructor; - . assumption; - . suffices (sf j) ⊂ (sf i) by simpa [sf_finite] - exact Set.ssubset_iff_exists.mpr ⟨sf_monotone i j (by omega), by - use n; - constructor; - . assumption; - . suffices ∃ χ, ∃ _ : χ ∈ f j, n ∉ χ.letterlessSpectrum _ by simpa [sf]; - use ξ; - simp_all; - ⟩; - - use (f k) - refine ⟨?_, ?_⟩; - . apply fX; - . apply Set.Subset.trans ?_ h; - rw [←FormulaSet.letterlessSpectrum, ←hk]; - assumption; - . have H : ∀ i ∈ φ.letterlessTrace, ∃ ψ, ∃ _ : ψ ∈ X, i ∈ ψ.letterlessTrace := by - have : φ.letterlessTrace ⊆ ⋃ ψ ∈ X, ψ.letterlessTrace := by - apply Set.compl_subset_compl.mp; - simpa [Formula.letterlessTrace] - simpa [Set.subset_def]; - - let ξ := λ i (hi : i ∈ φ.letterlessTrace) => (H i hi |>.choose); - have ξ_in_X : ∀ {i hi}, (ξ i hi) ∈ X := by - intro i hi; - apply (H i hi |>.choose_spec).1; - have ξ_letterless : ∀ {i hi}, (ξ i hi).Letterless := by - intro i hi; - apply X_letterless _ $ ξ_in_X; - assumption - have H₂ : ⋂ i ∈ φ.letterlessTrace, (ξ i (by assumption)).letterlessSpectrum ⊆ φ.letterlessSpectrum := by - suffices φ.letterlessTrace ⊆ ⋃ i ∈ φ.letterlessTrace, (ξ i (by assumption)).letterlessTrace by - apply Set.compl_subset_compl.mp; - simpa; - intro j hj; - simp only [Set.mem_iUnion, ξ]; - use j, hj; - apply H j hj |>.choose_spec.2; - use @Finset.univ (α := { i // i ∈ φ.letterlessTrace }) ?_ |>.image (λ i => (ξ i.1 i.2)); - . refine ⟨?_, ?_⟩; - . simp only [Finset.mem_image, Finset.mem_univ, true_and, Subtype.exists, forall_exists_index]; - rintro ψ i hi rfl; - apply ξ_in_X; - assumption - . intro i hi; - apply H₂; - simp only [Finset.mem_image, Finset.mem_univ, true_and, Subtype.exists, Set.iInter_exists, Set.mem_iInter] at hi ⊢; - intro j hj; - apply hi (ξ j hj) j hj rfl; - . apply Set.Finite.fintype (s := φ.letterlessTrace); - exact Formula.iff_regular_letterlessTrace_finite (by grind) |>.mp φ_regular; - -lemma GL.iff_subset_closed_sumQuasiNormal_subset_letterlessSpectrum (hSR : X.Singular T ∨ Y.Regular T) - : Modal.GL.sumQuasiNormal Y ⊆ Modal.GL.sumQuasiNormal X ↔ X.letterlessSpectrum ⊆ Y.letterlessSpectrum := by - calc - _ ↔ ∀ ψ ∈ Y, Modal.GL.sumQuasiNormal X ⊢ ψ := Logic.sumQuasiNormal.iff_subset - _ ↔ ∀ ψ, (h : ψ ∈ Y) → X.letterlessSpectrum ⊆ ψ.letterlessSpectrum := by - constructor; - . intro h ψ _; - apply GL.iff_provable_closed_sumQuasiNormal_subset_letterlessSpectrum (T := T) (by grind) (by grind) (by tauto) |>.mp; - exact h ψ (by simpa); - . intro h ψ _; - apply GL.iff_provable_closed_sumQuasiNormal_subset_letterlessSpectrum (T := T) (by grind) (by grind) (by tauto) |>.mpr; - apply h; - simpa; - _ ↔ X.letterlessSpectrum ⊆ (⋂ ψ ∈ Y, ψ.letterlessSpectrum) := by simp; - -lemma GL.iff_subset_closed_sumQuasiNormal_subset_letterlessTrace (hSR : X.Singular T ∨ Y.Regular T) - : Modal.GL.sumQuasiNormal Y ⊆ Modal.GL.sumQuasiNormal X ↔ Y.letterlessTrace ⊆ X.letterlessTrace := by - apply Iff.trans (iff_subset_closed_sumQuasiNormal_subset_letterlessSpectrum X_letterless Y_letterless hSR); - apply FormulaSet.iff_subset_letterlessSpectrum_subset_letterlessTrace; - -lemma GL.iff_eq_closed_sumQuasiNormal_eq_letterlessSpectrum (hXY : (X.Regular T ∧ Y.Regular T) ∨ (X.Singular T ∧ Y.Singular T)) - : Modal.GL.sumQuasiNormal X = Modal.GL.sumQuasiNormal Y ↔ X.letterlessSpectrum = Y.letterlessSpectrum := by - simp only [Set.Subset.antisymm_iff]; - rw [ - iff_subset_closed_sumQuasiNormal_subset_letterlessSpectrum X_letterless Y_letterless (by tauto), - iff_subset_closed_sumQuasiNormal_subset_letterlessSpectrum Y_letterless X_letterless (by tauto) - ]; - tauto; - - - -protected abbrev GLα (α : Set ℕ) : Logic ℕ := Modal.GL.sumQuasiNormal (TBB '' α) - -protected abbrev GLαω : Logic ℕ := Modal.GLα Set.univ - -protected abbrev GLβMinus (β : Set ℕ) (hβ : β.Cofinite := by grind) : Logic ℕ := Modal.GL.sumQuasiNormal {∼(⩕ n ∈ hβ.toFinset, (TBB n))} - - -lemma GL.iff_eq_closed_sumQuasiNormal_eq_letterlessTrace (hXY : (X.Regular T ∧ Y.Regular T) ∨ (X.Singular T ∧ Y.Singular T)) - : Modal.GL.sumQuasiNormal X = Modal.GL.sumQuasiNormal Y ↔ X.letterlessTrace = Y.letterlessTrace := by - apply Iff.trans (iff_eq_closed_sumQuasiNormal_eq_letterlessSpectrum X_letterless Y_letterless hXY); - apply FormulaSet.iff_eq_letterlessSpectrum_eq_letterlessTrace; - -lemma GL.eq_closed_regular_sumQuasiNormal_GLα (X_regular : X.Regular T) - : Modal.GL.sumQuasiNormal X = Modal.GLα (X.letterlessTrace) := by - apply GL.iff_eq_closed_sumQuasiNormal_eq_letterlessTrace (T := T) ?_ ?_ ?_ |>.mpr; - . simp; - . assumption; - . simp [FormulaSet.Letterless]; - . left; - constructor; - . assumption; - . simp; - - -@[grind! <=] -lemma FormulaSet.comp_letterlessTrace_finite_of_singular (X_singular : X.Singular T) : (X.letterlessTrace).Cofinite := by - have := FormulaSet.letterlessSpectrum_finite_of_singular X_letterless X_singular; - have := FormulaSet.comp_letterlessTrace_letterlessSpectrum (hX := X_letterless); - grind; - -set_option backward.isDefEq.respectTransparency false in -lemma GL.eq_closed_singular_sumQuasiNormal_GLβMinus (X_singular : X.Singular T) : Modal.GL.sumQuasiNormal X = Modal.GLβMinus (X.letterlessTrace) := by - apply GL.iff_eq_closed_sumQuasiNormal_eq_letterlessSpectrum (T := T) ?_ ?_ ?_ |>.mpr; - . simp [TBBMinus_letterlessSpectrum, FormulaSet.letterlessTrace]; - . assumption; - . grind; - . right; - constructor; - . assumption; - . simp; - -/-- - Quasi-normal extension of `Modal.GL` by closed formula set `X` is - either `Modal.GLα (X.letterlessTrace)` (`X` is regular) or `Modal.GLβMinus (X.letterlessTrace)` (`X` is singular) --/ -theorem GL.eq_closed_sumQuasiNormal_GLα_or_GLβMinus : - (∃ _ : X.Regular T, Modal.GL.sumQuasiNormal X = Modal.GLα (X.letterlessTrace)) ∨ - (∃ _ : X.Singular T, Modal.GL.sumQuasiNormal X = Modal.GLβMinus (X.letterlessTrace)) := by - by_cases h : X.Regular T; - . left; - constructor; - . apply GL.eq_closed_regular_sumQuasiNormal_GLα X_letterless h; - . assumption; - . right; - constructor; - . apply eq_closed_singular_sumQuasiNormal_GLβMinus (T := T) X_letterless h; - . assumption - -lemma iff_GLα_subset : Modal.GLα α₁ ⊆ Modal.GLα α₂ ↔ α₁ ⊆ α₂ := by - calc - _ ↔ FormulaSet.letterlessTrace (α₁.image TBB) ⊆ FormulaSet.letterlessTrace (α₂.image TBB) := by - apply GL.iff_subset_closed_sumQuasiNormal_subset_letterlessTrace (T := 𝗣𝗔) (by grind) (by grind); - simp; - _ ↔ α₁ ⊆ α₂ := by simp; - -lemma iff_GLβMinus_subset (hβ₁ : β₁.Cofinite) (hβ₂ : β₂.Cofinite) : Modal.GLβMinus β₁ ⊆ Modal.GLβMinus β₂ ↔ β₁ ⊆ β₂ := by - calc - _ ↔ FormulaSet.letterlessSpectrum ({∼(⩕ n ∈ hβ₂.toFinset, (TBB n))}) ⊆ FormulaSet.letterlessSpectrum ({∼(⩕ n ∈ hβ₁.toFinset, (TBB n))}) := by - apply GL.iff_subset_closed_sumQuasiNormal_subset_letterlessSpectrum (T := 𝗣𝗔) (by grind) (by grind); - simp; - _ ↔ β₂ᶜ ⊆ β₁ᶜ := by rw [TBBMinus_letterlessSpectrum, TBBMinus_letterlessSpectrum]; - _ ↔ β₁ ⊆ β₂ := by simp; - -lemma GLα_subset_GLβMinus (hβ : β.Cofinite) : Modal.GLα β ⊆ Modal.GLβMinus β := by - apply GL.iff_subset_closed_sumQuasiNormal_subset_letterlessSpectrum (T := 𝗣𝗔) ?_ ?_ ?_ |>.mpr; - . simp [FormulaSet.letterlessSpectrum]; - . grind; - . grind; - . simp; - -end - -end Modal - - -namespace FirstOrder.Theory - -open LO.Entailment - -variable - {L : Language} [L.DecidableEq] - {T U : Theory L} [DecidablePred (· ∈ T)] [DecidablePred (· ∈ U)] - {φ : Sentence L} - -lemma compact_add_right (h : (T + U) ⊢ φ) : ∃ (s : { s : Finset (Sentence L) // ↑s ⊆ U }), T ⊢ s.1.conj 🡒 φ := by - obtain ⟨⟨s, hsTU⟩, hs⟩ := Theory.compact' h; - let sT := { ψ ∈ s | ψ ∈ T }; - let sU := { ψ ∈ s | ψ ∈ U }; - - use ⟨sU, λ _ => by simp [sU]⟩; - - have : (∅ : Theory _) ⊢ sT.conj 🡒 sU.conj 🡒 φ := CK!_iff_CC!.mp $ C!_trans CKFconjFconjUnion! $ by - have : sT ∪ sU = s:= by - ext ψ; - constructor; - . grind; - . intro hψ; rcases hsTU hψ with (hψT | hψU) <;> grind; - rwa [this]; - apply Entailment.mdp! $ Axiomatized.weakening! (λ _ => by simp) this; - apply Entailment.FConj!_iff_forall_provable.mpr; - intro ψ hψ; - apply Axiomatized.provable_axm; - grind; - -lemma compact_add_left (h : (T + U) ⊢ φ) : ∃ (s : { s : Finset (Sentence L) // ↑s ⊆ T }), U ⊢ s.1.conj 🡒 φ := by - rw [show (T + U = U + T) by simp [add_def, Set.union_comm]] at h - simpa using compact_add_right h; - -end FirstOrder.Theory - - - -namespace ProvabilityLogic - -open LO.Entailment -open FirstOrder.ArithmeticTheory -open Classical - -lemma _root_.finite_preimage_choice (s : Finset α) (X : Set β) (f : β → α) (hs : ∀ a ∈ s, ∃ b ∈ X, f b = a) : - ∃ t : Finset β, ↑t ⊆ X ∧ ∀ a ∈ s, ∃ b ∈ t, f b = a := by - classical - choose g hga hgb using hs; - use Finset.univ.image (λ (a : { b // b ∈ s}) => g a.1 (by simp)); - constructor; - . intro b hb; - grind; - . intro h b; - simp only [Finset.univ_eq_attach, Finset.mem_image, Finset.mem_attach, true_and, Subtype.exists, ↓existsAndEq]; - grind; - -theorem letterless_provabilityLogic - {T : ArithmeticTheory} [𝗜𝚺₁ ⪯ T] [T.Δ₁] [ℕ ⊧ₘ* T] - (X : Modal.FormulaSet ℕ) (X_letterless : X.Letterless) : - (Modal.GL.sumQuasiNormal X).IsProvabilityLogic T (T + (T.LetterlessStandardRealization '' X)) := by - intro A; - rw [ - (show T.LetterlessStandardRealization '' X = (GL.uniformStandardRealization T) '' X by ext φ; grind [Realization.letterless_interpret]), - Modal.Logic.sumQuasiNormal.iff_provable_finite_provable_letterless X_letterless - ]; - - constructor; - . rintro ⟨Γ, hΓ₁, hΓ₂⟩ f; - have H : T ⊢ (f Γ.conj) 🡒 (f A) := GL.arithmetical_soundness hΓ₂; - rw [ - show f Γ.conj = (GL.uniformStandardRealization T) Γ.conj from - Realization.letterless_interpret $ Modal.Formula.letterless_fconj.mpr λ B hB ↦ X_letterless B $ hΓ₁ hB - ] at H; - apply Entailment.mdp! $ WeakerThan.pbl H; - apply Realization.interpret.iff_provable_fconj.mpr; - intro B hB; - apply Axiomatized.provable_axm; - right; - use B; - tauto; - . intro h; - obtain ⟨Γ, hΓX, H⟩ : - ∃ Γ : Finset (Modal.Formula ℕ), ↑Γ ⊆ X ∧ T ⊢ (Γ.image (GL.uniformStandardRealization T)).conj 🡒 (GL.uniformStandardRealization T) A := by - obtain ⟨⟨s, hs₁⟩, hs₂⟩ := Theory.compact_add_right $ h (GL.uniformStandardRealization T); - obtain ⟨t, ht₁, ht₂⟩ := finite_preimage_choice s X (GL.uniformStandardRealization T) hs₁; - use t; - constructor; - . assumption; - . apply Entailment.C!_trans ?_ hs₂; - apply Entailment.CFConj_FConj!_of_subset; - intro φ hφ; - obtain ⟨B, hB, rfl⟩ := ht₂ _ hφ; - grind; - use Γ; - constructor; - . assumption; - . apply GL.uniformStandardRealization_spec (T := T) |>.mp; - apply C!_trans ?_ H; - exact C_of_E_mp! $ Realization.interpret.iff_provable_fconj_inside (f := GL.uniformStandardRealization T); - -end ProvabilityLogic - -@[simp, grind .] -lemma Modal.GLα.isProvabilityLogic {T : ArithmeticTheory} [𝗜𝚺₁ ⪯ T] [T.Δ₁] [ℕ ⊧ₘ* T] {α : Set ℕ} - : (Modal.GLα α).IsProvabilityLogic T (T + ((T.LetterlessStandardRealization ∘ Modal.TBB) '' α)) := by - suffices (T.LetterlessStandardRealization ∘ Modal.TBB) '' α = T.LetterlessStandardRealization '' (Modal.TBB '' α) by - rw [this]; - apply letterless_provabilityLogic; - simp; - ext i; - simp; - -@[simp, grind .] -lemma Modal.GLαω.isProvabilityLogic {T : ArithmeticTheory} [𝗜𝚺₁ ⪯ T] [T.Δ₁] [ℕ ⊧ₘ* T] - : Modal.GLαω.IsProvabilityLogic T (T + ((T.LetterlessStandardRealization ∘ Modal.TBB) '' Set.univ)) := by - apply Modal.GLα.isProvabilityLogic; - -/- --- TODO: probably not use. -lemma Modal.GLβMinus.isProvabilityLogic {T : ArithmeticTheory} [𝗜𝚺₁ ⪯ T] [T.Δ₁] [ℕ ⊧ₘ* T] {β : Set ℕ} (hβ : β.Cofinite) - : (Modal.GLβMinus β).IsProvabilityLogic T (T + { ∼⩕ n ∈ hβ.toFinset, T.LetterlessStandardRealization $ Modal.TBB n }) := by sorry; --/ - -end LO - -end diff --git a/Foundation/ProvabilityLogic/Classification/Result.lean b/Foundation/ProvabilityLogic/Classification/Result.lean deleted file mode 100644 index e77293a37..000000000 --- a/Foundation/ProvabilityLogic/Classification/Result.lean +++ /dev/null @@ -1,288 +0,0 @@ -module - -public import Foundation.ProvabilityLogic.Classification.Trace - -@[expose] public section - -namespace LO - -open FirstOrder -open ArithmeticTheory - -namespace Modal - -namespace Logic - -variable {T U : ArithmeticTheory} [T.Δ₁] {L : Modal.Logic ℕ} - -section - -/-- α-type provability logic extension -/ -def αPL (L : Modal.Logic ℕ) (X : Set ℕ) := L.sumQuasiNormal (X.image Modal.TBB) - -variable {X : Set ℕ} - -@[simp, grind =] -lemma eq_GLαω_GLαPL : Modal.GLαω = Modal.GL.αPL Set.univ := by - simp [Modal.GLαω, Modal.GLα, αPL]; - -instance : Logic.Substitution (X.image Modal.TBB) := by - constructor; - simp only [iff_provable, Set.mem_image, forall_exists_index, and_imp]; - rintro A s a h rfl; - use a; - grind; - -variable (hPL : L.IsProvabilityLogic T U) (hCf : L.trace.Cofinite) - -lemma αPL_isProvabilityLogic [L.Substitution] (hPL : L.IsProvabilityLogic T U) : - (L.αPL X).IsProvabilityLogic T (U + (X.image (T.LetterlessStandardRealization $ Modal.TBB ·))) := by - intro A; - constructor; - . intro hA f; - induction hA using Modal.Logic.sumQuasiNormal.rec_letterless_expansion (L₁ := L) (X := X.image Modal.TBB) (by grind) with - | mem₁ hA => apply Entailment.WeakerThan.pbl $ hPL _ |>.mp hA f; - | mem₂ hA => - obtain ⟨n, hn, rfl⟩ := by simpa using hA; - sorry; - | mdp ih₁ ih₂ => exact ih₁ ⨀ ih₂; - . intro h; - sorry; - -lemma αPL_subset_S (hS : L ⊆ Modal.S) : L.αPL X ⊆ Modal.S := by - intro A; - suffices (L.αPL X) ⊢ A → Modal.S ⊢ A by grind; - intro hA; - induction hA using Modal.Logic.sumQuasiNormal.rec! with - | mem₁ hA => grind; - | mem₂ hA => - obtain ⟨_, _, rfl⟩ := by simpa using hA; - simp only [S.provable_TBB] - | mdp ih₁ ih₂ => exact ih₁ ⨀ ih₂; - | subst ih => apply Logic.subst; assumption; - -end - -end Logic - - -end Modal - - -namespace ProvabilityLogic - -open LO.Entailment Entailment.FiniteContext -open FirstOrder FirstOrder.ProvabilityAbstraction -open Arithmetic -open ArithmeticTheory -open LO.Modal -open Modal.Logic -open Modal.Kripke -open Formula.Kripke - -variable {T U : ArithmeticTheory} [Theory.Δ₁ T] [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] [T ⪯ U] -variable {L : Modal.Logic ℕ} - -/-- - Corollary 50 (half) in [A.B05] --/ -theorem subset_GLαω_of_omega_trace (L) (hPL : L.IsProvabilityLogic T U) (hT : L.trace = Set.univ) : Modal.GLαω ⊆ L := by - have := Modal.Logic.inst_Cl_of_isProvabilityLogic hPL; - intro A; - suffices Modal.GLαω ⊢ A → L ⊢ A by grind only [Logic.iff_unprovable]; - intro hA; - induction hA using Modal.Logic.sumQuasiNormal.rec_letterless_expansion (L₁ := Modal.GL) (X := TBB '' Set.univ) (by grind) with - | mem₁ hA => - apply Logic.provable_GL_of_isProvabilityLogic hPL hA; - | mem₂ hA => - obtain ⟨n, hn, rfl⟩ := by simpa using hA; - apply provable_TBB_of_mem_trace hPL; - simp [hT, Set.mem_univ] - | mdp ihAB ihA => - exact ihAB ⨀ ihA; - -section no_logic_between_GLαβ_D - -/-- - - Corollary 52(2) in [A.B05] --/ -theorem subset_D_of_subset_GLαβ_of_omega_trace - (L : Modal.Logic ℕ) (hPL : L.IsProvabilityLogic T U) (hT : L.trace = Set.univ) - : Modal.GLαω ⊂ L → Modal.D ⊆ L := by - have := Modal.Logic.inst_Cl_of_isProvabilityLogic hPL; - have : L.Substitution := by sorry; - - intro h; - obtain ⟨A, hAL, hAGL⟩ := Set.exists_of_ssubset h; - trans Modal.GLαω.sumQuasiNormal {A}; - . sorry; -- Hard part - . apply Modal.Logic.sumQuasiNormal.covered <;> grind; - -/-- - - Corollary 55 in [A.B05] --/ -lemma no_logic_between_GLαω_D - (L : Modal.Logic ℕ) (hPL : L.IsProvabilityLogic T U) (hT : L.trace = Set.univ) - : ¬((Modal.GLαω ⊂ L) ∧ (L ⊂ Modal.D)) := by - grind [subset_D_of_subset_GLαβ_of_omega_trace L hPL hT]; - -end no_logic_between_GLαβ_D - - -section no_logic_between_D_S - -/-- - - Assertion 1 in [Bek90] --/ -theorem eq_S_of_not_subset_D_of_omega_trace (L : Modal.Logic ℕ) (hPL : L.IsProvabilityLogic T U) (hT : L.trace = Set.univ) - : Modal.D ⊂ L → Modal.S ⊆ L := by - have := Modal.Logic.inst_Cl_of_isProvabilityLogic hPL; - have : L.Substitution := by sorry; - - intro h; - obtain ⟨A, hAL, hAGL⟩ := Set.exists_of_ssubset h; - trans Modal.D.sumQuasiNormal {A}; - . apply Modal.Logic.sumQuasiNormal.covered; - . intro B hB; - apply Logic.sumQuasiNormal.mem₁; - rw [Logic.iff_provable]; - apply Logic.sumQuasiNormal.mem₁; - rwa [Logic.iff_provable]; - . simp [←Logic.iff_provable]; -- Hard part - sorry - . apply Modal.Logic.sumQuasiNormal.covered <;> grind; - -/-- - - Corollary 58 in [A.B05] --/ -lemma no_logic_between_D_S (L : Modal.Logic ℕ) (hPL : L.IsProvabilityLogic T U) (hT : L.trace = Set.univ) - : ¬(Modal.D ⊂ L ∧ L ⊂ Modal.S) := by - grind [eq_S_of_not_subset_D_of_omega_trace L hPL hT]; - -end no_logic_between_D_S - -/-- - If `L.trace` is omega then `L` is one of `GLαω`, `D`, and `S`. - - Assertion 3 in [Bek90] --/ -lemma classification_S_sublogics_of_omega_trace - (L : Modal.Logic ℕ) (hPL : L.IsProvabilityLogic T U) (hT : L.trace = Set.univ) (L_subset_S : L ⊆ Modal.S) - : L = Modal.GLαω ∨ L = Modal.D ∨ L = Modal.S - := by - wlog GLαω_ssubset_L : Modal.GLαω ⊂ L; . grind [subset_GLαω_of_omega_trace]; - - have : Modal.D ⊆ L := by sorry; -- Hard part: Assertion 2 in [Bek90] using `GLαω_ssubset_L` - rcases Set.eq_or_ssubset_of_subset this with rfl | D_ssubset_L; - case inl => grind; - - right; right; - apply Set.Subset.antisymm; - . assumption; - . apply eq_S_of_not_subset_D_of_omega_trace L hPL hT D_ssubset_L; - -/-- - Let `L` be provability logic `L.trace` is cofinite. - Then `L = (L.αPL L.traceᶜ) ∩ (GLβMinus L.trace)`. --/ -theorem eq_inter_αPL_GLβMinus_of_isProvabilityLogic_of_cofinite_trace - (L : Modal.Logic ℕ) [L.Substitution] (hPL : L.IsProvabilityLogic T U) (hCf : L.trace.Cofinite) - : L = (L.αPL L.traceᶜ) ∩ (Modal.GLβMinus L.trace) := by - have := Modal.Logic.inst_Cl_of_isProvabilityLogic hPL; - - apply Set.Subset.antisymm; - . intro A hA; - constructor; - . exact Logic.sumQuasiNormal.mem₁ $ Logic.iff_provable.mpr hA; - . exact subset_GLβMinus_of_trace_cofinite hCf hA; - . rintro A ⟨h₁, h₂⟩; - simp only [Logic.αPL, ←Logic.iff_provable] at h₁ h₂ ⊢; - obtain ⟨Γ, hΓ, h₁⟩ := sumQuasiNormal.iff_provable_finite_provable_letterless TBBSet_letterless |>.mp h₁; - obtain ⟨Δ, hΔ, h₂⟩ := sumQuasiNormal.iff_provable_finite_provable_letterless TBBMinus_letterless |>.mp h₂; - apply of_C!_of_C!_of_A! (φ := (⩕ n ∈ hCf.toFinset, TBB n)) ?_ ?_ lem!; - . show L ⊢ (⩕ n ∈ hCf.toFinset, TBB n) 🡒 A; - apply Entailment.C!_trans ?_ h₁; - apply right_Fconj!_intro; - intro B hB; - obtain ⟨n, hn, rfl⟩ := hΓ hB; - apply left_Fconj'!_intro; - simpa using hn; - . show L ⊢ (∼⩕ n ∈ hCf.toFinset, TBB n) 🡒 A; - rw [(show (∼⩕ n ∈ hCf.toFinset, TBB n) = Finset.conj {∼⩕ n ∈ hCf.toFinset, TBB n} by simp)]; - apply Entailment.C!_trans (CFConj_FConj!_of_subset ?_) $ Modal.Logic.provable_GL_of_isProvabilityLogic hPL h₂; - intro δ hδ; - grind [hΔ hδ]; - -lemma eq_GLαω_inter_GLβMinus_GLα (hβ : L.trace.Cofinite) : Modal.GLα L.trace = Modal.GLαω ∩ (Modal.GLβMinus L.trace) := by - let L₁ := (Modal.GLα L.trace).αPL (Modal.GLα L.trace).traceᶜ; - let L₂ := Modal.GLβMinus (Modal.GLα L.trace).trace (by simpa); - trans (L₁ ∩ L₂); - . apply eq_inter_αPL_GLβMinus_of_isProvabilityLogic_of_cofinite_trace (L := Modal.GLα L.trace) (Modal.GLα.isProvabilityLogic (T := 𝗜𝚺₁)) ?_; - . simpa only [GLα.eq_trace]; - . have : L₁ = Modal.GLαω := by - subst L₁; - rw [ - GLα.eq_trace, - Logic.αPL, - Logic.sumQuasiNormal.sum_sum_eq_sum_union, - Modal.GLαω, - Modal.GLα, - ]; - simp [-Set.compl_iUnion, Set.image_univ]; - have : L₂ = Modal.GLβMinus L.trace := by grind [GLα.eq_trace (α := L.trace)]; - grind only; - -lemma aPL_compl_trace_isProvabilityLogic [L.Substitution] (hPL : L.IsProvabilityLogic T U) - : (L.αPL L.traceᶜ).IsProvabilityLogic T (U + (L.traceᶜ.image (T.LetterlessStandardRealization $ Modal.TBB ·))) := by - apply Modal.Logic.αPL_isProvabilityLogic hPL; - -lemma aPL_compl_trace_subset_S (hS : L ⊆ Modal.S) : L.αPL L.traceᶜ ⊆ Modal.S := by - apply Modal.Logic.αPL_subset_S hS; - -lemma aPL_compl_trace_omega_trace (hS : L ⊆ Modal.S) - : (L.αPL L.traceᶜ).trace = Set.univ := by - simp [Set.eq_univ_iff_forall, Modal.Logic.αPL]; - intro n; - use (TBB n); - constructor; - . sorry; - . sorry; - -lemma classification_S_sublogics_of_cofinite_trace - [L.Substitution] (hPL : L.IsProvabilityLogic T U) (hCf : L.trace.Cofinite) (hS : L ⊆ Modal.S) - : L = Modal.GLα L.trace ∨ L = Modal.D ∩ (Modal.GLβMinus L.trace) ∨ L = Modal.S ∩ (Modal.GLβMinus L.trace) - := by - have : 𝗜𝚺₁ ⪯ U + (L.traceᶜ.image (T.LetterlessStandardRealization $ Modal.TBB ·)) := by trans U <;> infer_instance; - have : T ⪯ U + (L.traceᶜ.image (T.LetterlessStandardRealization $ Modal.TBB ·)) := by trans U <;> infer_instance; - rcases classification_S_sublogics_of_omega_trace (L := (L.αPL L.traceᶜ)) - (aPL_compl_trace_isProvabilityLogic hPL) (aPL_compl_trace_omega_trace hS) (aPL_compl_trace_subset_S hS) - with _ | _ | _; - case inl => grind [eq_inter_αPL_GLβMinus_of_isProvabilityLogic_of_cofinite_trace, eq_GLαω_inter_GLβMinus_GLα hCf]; - all_goals. grind [eq_inter_αPL_GLβMinus_of_isProvabilityLogic_of_cofinite_trace]; - -open Classical in -/-- - The classification theorem of provability logics. - - Assertion 6 in [Bek90] - - Theorem 40 in [A.B05] --/ -theorem classification_provability_logics - (L : Modal.Logic ℕ) [L.Substitution] (hPL : L.IsProvabilityLogic T U) : - if h_coinfinite : L.trace.Coinfinite then - L = Modal.GLα L.trace - else - haveI h_cofinite : L.trace.Cofinite := Set.iff_cofinite_not_coinfinite.mpr h_coinfinite; - if ¬(L ⊆ Modal.S) then - L = Modal.GLβMinus L.trace - else - L = Modal.GLα L.trace ∨ - L = Modal.D ∩ Modal.GLβMinus L.trace ∨ - L = Modal.S ∩ Modal.GLβMinus L.trace - := by - split_ifs with h_coinfinite h_S; - . exact eq_provablityLogic_GLα_of_coinfinite_trace hPL h_coinfinite; - . exact classification_S_sublogics_of_cofinite_trace hPL (Set.iff_cofinite_not_coinfinite.mpr h_coinfinite) h_S; - . exact eq_provabilityLogic_GLβMinus_of_not_subset_S hPL h_S; - -end ProvabilityLogic - -end LO diff --git a/Foundation/ProvabilityLogic/Classification/Trace.lean b/Foundation/ProvabilityLogic/Classification/Trace.lean deleted file mode 100644 index ea5e580eb..000000000 --- a/Foundation/ProvabilityLogic/Classification/Trace.lean +++ /dev/null @@ -1,671 +0,0 @@ -module - -public import Foundation.ProvabilityLogic.Classification.LetterlessTrace -public import Foundation.Modal.Boxdot.GL_S -public import Foundation.Modal.Logic.D.Basic - -@[expose] public section - - - - -namespace LO - -namespace Modal - -variable {φ ψ : Formula ℕ} - -open Kripke -open Formula.Kripke - - -namespace Formula - -def trace (φ : Formula ℕ) : Set ℕ := { n | - ∃ M : Kripke.Model, ∃ _ : Fintype M, ∃ _ : M.IsTransitive, ∃ _ : M.IsConverseWellFounded, ∃ _ : M.IsRooted, - (M.height = n ∧ M.root.1 ⊭ φ) -} - -lemma iff_mem_trace {n : ℕ} : - n ∈ φ.trace ↔ - ∃ M : Kripke.Model, ∃ _ : Fintype M, ∃ _ : M.IsTransitive, ∃ _ : M.IsConverseWellFounded, ∃ _ : M.IsRooted, M.height = n ∧ M.root.1 ⊭ φ := by - simp [Formula.trace]; - -lemma satisfies_of_not_mem_trace : - n ∉ φ.trace ↔ - ∀ M : Kripke.Model, [Fintype M] → [M.IsTransitive] → [M.IsConverseWellFounded] → [M.IsRooted] → M.height = n → M.root.1 ⊧ φ := by - simp [Formula.trace]; - -@[grind =] -lemma eq_trace_trace_of_letterless {φ : Formula ℕ} (φ_letterless : φ.Letterless) : φ.trace = φ.letterlessTrace := by - ext n; - apply Iff.trans ?_ (Kripke.letterlessSpectrum_TFAE φ_letterless (n := n) |>.out 1 0 |>.not); - rw [iff_mem_trace]; - push Not; - constructor; - . rintro ⟨M, _, _, _, _, _⟩; - refine ⟨M, inferInstance, inferInstance, inferInstance, inferInstance, M.root, by tauto, by tauto⟩; - . contrapose! - rintro h M _ _ _ _ x rfl; - apply Model.pointGenerate.modal_equivalent x ⟨x, by tauto⟩ |>.mp; - apply h; - apply Frame.pointGenerate.eq_original_height; - -open Formula.Kripke - -@[simp, grind =] lemma trace_bot : (⊥ : Formula ℕ).trace = Set.univ := by grind; -@[simp, grind =] lemma trace_top : (⊤ : Formula ℕ).trace = ∅ := by grind; - -lemma trace_and : (φ ⋏ ψ).trace = φ.trace ∪ ψ.trace := by - ext n; - calc - _ ↔ ∃ M : Kripke.Model, ∃ _ : Fintype M, ∃ _ : M.IsTransitive, ∃ _ : M.IsConverseWellFounded, ∃ _ : M.IsRooted, M.height = n ∧ (M.root.1 ⊭ φ ∨ M.root.1 ⊭ ψ) := by - simp [Semantics.NotModels, trace, -not_and, not_and_or] - _ ↔ - (∃ M : Kripke.Model, ∃ _ : Fintype M, ∃ _ : M.IsTransitive, ∃ _ : M.IsConverseWellFounded, ∃ _ : M.IsRooted, M.height = n ∧ M.root.1 ⊭ φ) ∨ - (∃ M : Kripke.Model, ∃ _ : Fintype M, ∃ _ : M.IsTransitive, ∃ _ : M.IsConverseWellFounded, ∃ _ : M.IsRooted, M.height = n ∧ M.root.1 ⊭ ψ) := by - constructor; - . rintro ⟨M, _, _, _, _, rfl, h⟩; - cases h with - | inl h => left; tauto - | inr h => right; tauto - . rintro (⟨M, _, _, _, _, rfl, hr⟩ | ⟨M, _, _, _, _, rfl, hr⟩) <;> - refine ⟨M, inferInstance, inferInstance, inferInstance, inferInstance, rfl, by grind⟩; - _ ↔ _ := by simp [Formula.trace]; - -lemma trace_lconj₂ {s : List (Formula ℕ)} : (s.conj₂).trace = ⋃ φ ∈ s, φ.trace := by - induction s using List.induction_with_singleton with - | hcons φ s hs ih => simp [List.conj₂_cons_nonempty hs, Formula.trace_and, ih]; - | _ => simp [List.conj₂]; - -lemma trace_fconj {s : Finset (Formula ℕ)} : s.conj.trace = ⋃ φ ∈ s, φ.trace := by simp [Finset.conj, Formula.trace_lconj₂]; - -lemma subset_trace_of_provable_imp_GL (h : Modal.GL ⊢ φ 🡒 ψ) : ψ.trace ⊆ φ.trace := by - intro n hn; - obtain ⟨M, _, _, _, _, rfl, hr⟩ := iff_mem_trace.mp hn; - apply iff_mem_trace.mpr; - refine ⟨M, inferInstance, inferInstance, inferInstance, inferInstance, rfl, ?_⟩; - contrapose! hr; - have := GL.Kripke.fintype_completeness_TFAE.out 0 2 |>.mp h; - exact this M hr; - -end Formula - - -namespace FormulaSet - -abbrev trace (X : FormulaSet ℕ) : Set ℕ := ⋃ φ ∈ X, φ.trace - -@[simp] lemma trace_empty : (∅ : FormulaSet ℕ).trace = ∅ := by simp [FormulaSet.trace]; - -lemma eq_FormulaSet_trace_finset_conj {X : Finset (Formula ℕ)} : X.conj.trace = FormulaSet.trace X := by simp [FormulaSet.trace, Formula.trace_fconj]; - -lemma subset_trace_of_subset {X Y : FormulaSet ℕ} (h : X ⊆ Y) : X.trace ⊆ Y.trace := by - simp only [trace, Set.iUnion_subset_iff]; - intro φ hφ i hi; - simp only [Set.mem_iUnion, exists_prop]; - use φ; - constructor; - . apply h; assumption; - . assumption; - -end FormulaSet - - -abbrev Logic.trace (L : Logic ℕ) : Set ℕ := FormulaSet.trace L - -lemma GL.eq_trace_ext {X : FormulaSet ℕ} (hX : ∀ ξ ∈ X, ∀ s : Substitution _, ξ⟦s⟧ ∈ X) : (Modal.GL.sumQuasiNormal X).trace = X.trace := by - ext n; - constructor; - . suffices (∃ φ, Modal.GL.sumQuasiNormal X ⊢ φ ∧ n ∈ φ.trace) → (n ∈ X.trace) by simpa [Logic.trace, Logic.iff_provable]; - rintro ⟨φ, hφ₁, hφ₂⟩; - obtain ⟨Y, hY₁, hY₂⟩ := Logic.sumQuasiNormal.iff_provable_finite_provable hX |>.mp hφ₁; - apply FormulaSet.subset_trace_of_subset hY₁; - apply FormulaSet.eq_FormulaSet_trace_finset_conj ▸ Formula.subset_trace_of_provable_imp_GL hY₂; - assumption; - . suffices (∃ φ ∈ X, n ∈ φ.trace) → (∃ φ, Modal.GL.sumQuasiNormal X ⊢ φ ∧ n ∈ φ.trace) by simpa [Logic.trace, Logic.iff_provable]; - rintro ⟨φ, hφ₁, hφ₂⟩; - use φ; - constructor; - . apply Logic.sumQuasiNormal.mem₂!; - simpa [Logic.iff_provable]; - . assumption; - -lemma GL.unprovable_of_exists_trace (φ_letterless : φ.Letterless) : (∃ n, n ∈ φ.letterlessTrace) → Modal.GL ⊬ φ := by - contrapose!; - intro h; - have := Modal.iff_GL_provable_letterlessSpectrum_Univ φ_letterless |>.mp (by simpa using h); - simp_all [Formula.letterlessTrace]; - -@[simp] -lemma TBBMinus_trace (hβ : β.Cofinite) : (∼⩕ n ∈ hβ.toFinset, TBB n).letterlessTrace = β := by - simp [Formula.letterlessTrace, TBBMinus_letterlessSpectrum'] - -@[simp] -lemma GL.eq_trace_emptyset : Modal.GL.trace = ∅ := by - rw [←Logic.sumQuasiNormal.with_empty (L₁ := Modal.GL)] - simpa using GL.eq_trace_ext (X := ∅) (by simp); - -@[simp] -lemma GLα.eq_trace {α : Set ℕ} : (Modal.GLα α).trace = α := by - apply Eq.trans $ GL.eq_trace_ext $ by grind; - simp [FormulaSet.trace, Formula.eq_trace_trace_of_letterless]; - -@[simp] -lemma GLβMinus.eq_trace {β : Set ℕ} (hβ : β.Cofinite := by grind) : (Modal.GLβMinus β).trace = β := by - apply Eq.trans $ GL.eq_trace_ext $ by grind; - simp [FormulaSet.trace, Formula.eq_trace_trace_of_letterless]; - -@[simp, grind .] lemma S.provable_TBB {n : ℕ} : Modal.S ⊢ TBB n := by simp [TBB] - -@[simp] -lemma subset_GLα_S : Modal.GLα α ⊆ Modal.S := by - intro φ; - suffices Modal.GLα α ⊢ φ → Modal.S ⊢ φ by grind; - intro hφ; - induction hφ using Modal.Logic.sumQuasiNormal.rec! with - | mem₁ hφ => exact Entailment.WeakerThan.pbl hφ; - | mem₂ hφ => obtain ⟨_, _, rfl⟩ := hφ; simp; - | mdp ihφψ ihφ => exact ihφψ ⨀ ihφ; - | subst ihφ => exact Logic.subst _ ihφ; - -instance : Modal.GLα α ⪯ Modal.S := Logic.weakerThan_of_subset subset_GLα_S - -@[simp] -lemma S.eq_trace : Modal.S.trace = Set.univ := by - suffices ∀ (x : ℕ), ∃ i ∈ Modal.S, x ∈ i.trace by simpa [Set.eq_univ_iff_forall] - intro n; - use (TBB n); - constructor; - . apply Logic.iff_provable.mp; grind; - . simp [Formula.eq_trace_trace_of_letterless]; - -variable {L : Logic ℕ} {φ : Formula ℕ} - - -lemma subset_of_provable (h : L ⊢ φ) : φ.trace ⊆ L.trace := by - intro n h; - suffices ∃ i ∈ L, n ∈ i.trace by simpa [Logic.trace, FormulaSet.trace]; - use φ; - grind; - - -namespace Kripke - -/-- - `... ≺ x ≺ a ≺ y ≺ ...` - - ↓ - - `... ≺ x ≺ (n - 1) ≺ ... ≺ 0 ≺ a ≺ y ≺ ...` --/ -abbrev Model.boneLengthening (M : Kripke.Model) (a : M) (n : ℕ) : Kripke.Model where - World := M.World ⊕ Fin n - Rel w v := - match w, v with - | .inl x, .inl y => x ≺ y - | .inl x, .inr _ => x ≺ a - | .inr _, .inl y => y = a ∨ a ≺ y - | .inr i, .inr j => i > j - Val p x := - match x with - | .inl w => M.Val p w - | .inr _ => M.Val p a - -namespace Model.boneLengthening - -variable {M : Kripke.Model} {a : M} [M.IsIrreflexive] {k : ℕ} {φ : Formula ℕ} - -@[coe] abbrev callus (i : Fin k) : M.boneLengthening a k := Sum.inr i -instance : Coe (Fin k) (M.boneLengthening a k) := ⟨callus⟩ - -@[coe] abbrev embed (x : M) : M.boneLengthening a k := Sum.inl x -instance : Coe (M.World) ((M.boneLengthening a k).World) := ⟨embed⟩ - -instance [Fintype M] : Fintype (M.boneLengthening a k) := by apply instFintypeSum - -instance [M.IsTransitive] : (M.boneLengthening a k).IsTransitive where - trans := by - rintro (x | i) (y | j) (z | l) Rxy Ryz <;> simp_all only; - . apply Frame.trans Rxy Ryz; - . apply Frame.trans Rxy Ryz; - . rcases Ryz with rfl | Ray; - . assumption; - . exact Frame.trans Rxy Ray; - . rcases Rxy with rfl | Ray; - . tauto; - . right; - exact Frame.trans Ray Ryz; - . exfalso; - rcases Rxy with rfl | Ray; - . apply M.irrefl _ Ryz; - . apply M.irrefl _ $ Frame.trans Ryz Ray; - . omega; - -instance [M.IsIrreflexive] : (M.boneLengthening a k).IsIrreflexive where - irrefl := by - rintro (x | i); - . apply M.irrefl x; - . simp; - -instance instRooted [M.IsTransitive] [M.IsRooted] (ha : a ≠ M.root) : (M.boneLengthening a k).IsRooted where - default := ⟨Sum.inl M.root.1, by rintro (x | i) <;> grind⟩; - -instance isTree [M.IsAsymmetric] (hra : r ≠ a) : (M.boneLengthening a k).IsAsymmetric where - asymm := by - rintro (x | i) (y | j) Rxy; - . apply M.asymm Rxy; - . apply not_or.mpr; - constructor; - . contrapose! Rxy; - simp_all - . exact M.asymm Rxy; - . rcases Rxy with rfl | Ray; - . apply Frame.irrefl; - . apply M.asymm Ray; - . simp_all - omega; - -@[simp] -axiom eq_height [Fintype M] [M.IsIrreflexive] [M.IsTransitive] [M.IsRooted] (hra : a ≠ M.root) : - have : (M.boneLengthening a k).IsRooted := instRooted hra; - (M.boneLengthening a k).height = M.height + k - /- - := by - intro _; - apply height_eq_iff_relItr.mpr; - constructor; - . obtain ⟨t, Rrt⟩ := Kripke.exists_rank_terminal (F := M.boneLengthening a k |>.toFrame) r; - use t; - induction k with - | zero => - sorry; - | succ k ih => - suffices (r : M.boneLengthening a (k + 1)) ≺^[(M.rank + k) + 1] t by - rwa [(show M.rank + (k + 1) = (M.rank + k) + 1 by omega)]; - dsimp [Frame.RelItr', Rel.Iterate] - sorry; - . intro t Rrt x; - sorry; - -/ - -axiom equivalence {x : M} (hx : x = a ∨ a ≺ x) : ∀ φ, x ⊧ φ ↔ (Satisfies _ (x : M.boneLengthening a k) φ) -- := by sorry - -lemma mainlemma_aux - (hrfl : a ⊧ φ.rflSubformula.conj) - {ψ} (hψ : ψ ∈ φ.subformulas) : - (∀ i : Fin k, (Satisfies _ (i : M.boneLengthening a k) ψ ↔ Satisfies _ (a : M.boneLengthening a k) ψ)) ∧ - (∀ x : M, (x ⊧ ψ ↔ Satisfies _ (x : M.boneLengthening a k) ψ)) := by - induction ψ with - | hatom => simp [Semantics.Models, Satisfies, Model.boneLengthening]; - | hfalsum => simp [Satisfies]; - | himp ψ ξ ihψ ihξ => simp [Satisfies, ihψ (by grind), ihξ (by grind)]; - | hbox ψ ihφ => - have ⟨ihφ₁, ihφ₂⟩ := ihφ (by grind); - constructor; - . intro i; - constructor; - . rintro h j Raj; - apply h; - rcases j with (j | j); - . right; exact Raj; - . simp [Frame.Rel', Model.boneLengthening] at Raj; - . intro h; - have : Satisfies _ (a : M.boneLengthening a k) ψ := Satisfies.fconj_def.mp (equivalence (by tauto) _ |>.mp hrfl) (□ψ 🡒 ψ) ?_ h; - . rintro (y | j) Ri; - . rcases Ri with rfl | Ray; - . assumption; - . apply h; - exact Ray; - . apply ihφ₁ j |>.mpr this; - . simp only [Finset.mem_image, Finset.LO.preboxItr, Function.iterate_one, Finset.mem_preimage] - use ψ; - . intro y; - constructor; - . rintro h (z | j) Ryz; - . apply ihφ₂ _ |>.mp; - apply h; - exact Ryz; - . apply ihφ₁ j |>.mpr; - apply ihφ₂ _ |>.mp; - apply h; - apply Ryz; - . intro h z Ryz; - apply ihφ₂ z |>.mpr; - apply h; - exact Ryz; - -lemma mainlemma₁ - (hrfl : a ⊧ φ.rflSubformula.conj) {ψ} (hψ : ψ ∈ φ.subformulas) (i : Fin k) - : (Satisfies _ (i : M.boneLengthening a k) ψ) ↔ Satisfies _ (a : M.boneLengthening a k) ψ := (mainlemma_aux hrfl (by grind)).1 i - -lemma mainlemma₂ - (hrfl : a ⊧ φ.rflSubformula.conj) {ψ} (hψ : ψ ∈ φ.subformulas) (x : M) - : (x ⊧ ψ) ↔ Satisfies _ (x : M.boneLengthening a k) ψ := (mainlemma_aux hrfl (by grind)).2 x - -end Model.boneLengthening - -end Kripke - -axiom GL.formalized_validates_axiomT_set_in_irrefl_trans_chain : Modal.GL ⊢ ∼□^[(φ.rflSubformula.card + 1)]⊥ 🡒 ◇φ.rflSubformula.conj - -@[grind .] -lemma Formula.trace.finite_or_cofinite : φ.trace.Finite ∨ φ.trace.Cofinite := by - suffices φ.trace.Infinite → φ.trace.Cofinite by tauto; - intro tr_infinite; - - obtain ⟨m, hm₁, hm₂⟩ : ∃ m, m ∈ φ.trace ∧ φ.rflSubformula.card < m := Set.infinite_iff_exists_gt.mp tr_infinite _; - obtain ⟨M, _, _, _, _, rfl, hr⟩ := iff_mem_trace.mp hm₁; - - have H₁ : M.root.1 ⊧ ∼□^[(φ.rflSubformula.card + 1)]⊥ := height_lt_iff_satisfies_boxbot (i := M.root.1) (n := φ.rflSubformula.card + 1) |>.not.mp $ by - rw [←Frame.height]; - omega; - - have := GL.Kripke.fintype_completeness_TFAE (φ := ∼□^[(φ.rflSubformula.card + 1)]⊥ 🡒 ◇φ.rflSubformula.conj) |>.out 0 2 |>.mp GL.formalized_validates_axiomT_set_in_irrefl_trans_chain; - have H₂ : M.root.1 ⊧ ∼□^[(φ.rflSubformula.card + 1)]⊥ 🡒 ◇φ.rflSubformula.conj := this M; - obtain ⟨a, Rrx, hx⟩ := Satisfies.dia_def.mp $ H₂ H₁; - replace Rrx : M.root.1 ≠ a := by rintro rfl; apply M.irrefl _ Rrx; - - have : {k | k ≥ M.height} ⊆ φ.trace := by - intro k hmk; - obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le hmk; - apply iff_mem_trace.mpr; - refine ⟨M.boneLengthening a k, inferInstance, inferInstance, inferInstance, ?_, ?_, ?_⟩; - . exact Model.boneLengthening.instRooted (by grind); - . exact Model.boneLengthening.eq_height (by grind); - . exact Model.boneLengthening.mainlemma₂ hx (show φ ∈ φ.subformulas by grind) (k := k) M.root |>.not.mp hr; - apply Set.Cofinite.subset this; - apply Set.Finite.subset (s := Finset.range M.height); - . apply Finset.finite_toSet; - . intro i; - simp; - -@[grind →] -lemma Formula.trace.finite_of_coinfinite (h_ci : φ.trace.Coinfinite) : φ.trace.Finite := by - apply or_iff_not_imp_right.mp $ Formula.trace.finite_or_cofinite; - simpa; - -/-- - `L` is contained in `GLα L.trace` when `L.trace` is coinfinite --/ -lemma subset_GLα_of_trace_coinfinite (hL : L.trace.Coinfinite) : L ⊆ Modal.GLα L.trace := by - intro φ hφ; - apply Modal.Logic.iff_provable.mp; - - have : φ.trace ⊆ L.trace := subset_of_provable (by grind); - have : φ.trace.Finite := by - have : φ.trace.Coinfinite := Set.Coinfinite.subset this hL - grind - let Tφ := this.toFinset; - - apply Logic.sumQuasiNormal.iff_provable_finite_provable_letterless ?_ |>.mpr ⟨(Tφ.image TBB), ?_, ?_⟩; - . grind; - . simpa [Tφ] - . apply GL.Kripke.fintype_completeness_TFAE.out 2 0 |>.mp; - intro M _ _ _ _ hr; - have : Fintype M.World := Fintype.ofFinite _; - apply Formula.satisfies_of_not_mem_trace (n := M.height) |>.mp; - . replace hr : ∀ n ∈ φ.trace, M.height ≠ n := by - intro n h; - apply iff_satisfies_TBB_ne_rank.mp; - apply Satisfies.fconj_def.mp hr _; - suffices ∃ m ∈ φ.trace, (□^[m]⊥ : Formula ℕ) = □^[n]⊥ by - simp only [Finset.mem_image, Set.Finite.mem_toFinset, Tφ]; - use n; - use n; - by_contra hC; - apply hr _ hC rfl; - . rfl; - -/-- - `L` is contained in `GLβMinus L.trace` when `L.trace` is cofinite --/ -lemma subset_GLβMinus_of_trace_cofinite (hL : L.trace.Cofinite) : L ⊆ Modal.GLβMinus L.trace := by - intro φ hφ; - apply Modal.Logic.iff_provable.mp; - - have : φ.trace ⊆ L.trace := subset_of_provable (by grind); - - let Tφ := hL.toFinset; - - apply Logic.sumQuasiNormal.iff_provable_finite_provable_letterless ?_ |>.mpr ⟨{∼⩕ n ∈ Tφ, TBB n}, ?_, ?_⟩; - . grind; - . simp_all [Set.compl_iUnion, Tφ]; - . apply GL.Kripke.fintype_completeness_TFAE.out 2 0 |>.mp; - intro M _ _ _ _ hr; - have : Fintype M.World := Fintype.ofFinite _; - apply Formula.satisfies_of_not_mem_trace (n := M.height) |>.mp; - . replace hr : ∀ (n : ℕ), ∀ x ∈ L, n ∈ x.trace → ¬M.height = n := by - rintro n ξ hξ₁ hξ₂ rfl; - obtain ⟨m, hm₁, hm₂⟩ : ∃ m, m ∈ Tφ ∧ M.root.1 ⊭ TBB m := Satisfies.not_fconj'_def.mp $ Satisfies.not_def.mp $ by - simpa only [Finset.conj_singleton] using hr; - replace hm₁ : ∀ i ∈ L, m ∉ i.trace := by simpa [Tφ] using hm₁; - replace hm₂ : M.height = m := by simpa using iff_satisfies_TBB_ne_rank.not.mp hm₂; - apply hm₁ ξ; - . assumption; - . grind; - by_contra hC; - apply hr M.height φ hφ hC rfl; - . rfl; - -@[simp] -lemma eq_GLβMinusOmega : Modal.GLβMinus Set.univ = Set.univ := by - apply Set.eq_univ_iff_forall.mpr; - intro φ; - apply Logic.iff_provable.mp; - apply Logic.sumQuasiNormal.iff_provable_finite_provable_letterless (by grind;) |>.mpr; - use {∼⊤}; - constructor; - . simp; - . suffices Modal.GL ⊢ ∼⊤ 🡒 φ by simpa; - cl_prover; - -end Modal - -namespace ProvabilityLogic - -open LO.Entailment Entailment.FiniteContext -open FirstOrder FirstOrder.ProvabilityAbstraction -open Arithmetic -open ArithmeticTheory (provabilityLogicOn) -open LO.Modal -open Modal.Kripke -open Formula.Kripke - -variable {T U : ArithmeticTheory} [T.Δ₁] -variable {A : Formula ℕ} - -lemma provable_TBB_of_mem_trace - [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] - {L : Logic _} (hPL : L.IsProvabilityLogic T U) - {n : ℕ} (h : n ∈ L.trace) : L ⊢ Modal.TBB n := by - obtain ⟨A, hA₁, ⟨M, _, _, _, _, rfl, h₂⟩⟩ := by simpa using h; - replace hA₁ : ∀ f : T.StandardRealization, U ⊢ f A := hPL A |>.mp $ by grind; - - let M₀ := M.extendRoot 1; - - let S := SolovaySentences.standard T M₀.toFrame; - have : M₀ ⊧ A 🡒 (Modal.TBB M.height) := by - rintro x hA; - rcases Nat.lt_trichotomy (Frame.rank x) M.height with h | h | h; - . intro _; - exact height_lt_iff_satisfies_boxbot.mp h; - . exfalso; - apply h₂; - apply Kripke.Model.extendRoot.modal_equivalence_original_world.mp; - rwa [Kripke.Frame.extendRoot.iff_eq_height_eq_original_root.mp h] at hA; - . apply iff_satisfies_mem_rank_letterlessSpectrum (by grind) |>.mpr; - simp; - omega; - have : ∀ i : M₀.World, 𝗜𝚺₁ ⊢ S i 🡒 S.realization (A 🡒 (Modal.TBB M.height)) := by - rintro (a | i); - . apply C!_trans $ C!_trans (S.SC2 (Sum.inl a) M.root (by grind)) - $ contra! - $ T.standardProvability.mono' - $ CN!_of_CN!_right - $ S.mainlemma_neg (by simp) - $ height_lt_iff_satisfies_boxbot.not.mp - $ by - show ¬(Frame.rank (Frame.extendRoot.embed M.root.1)) < M.height; - simp [Frame.extendRoot.eq_original_height_root]; - simp only [Realization.interpret.def_imp, Box.boxItr_succ, Realization.interpret.def_box]; - cl_prover; - . apply S.mainlemma (by simp); - apply this; - have : 𝗜𝚺₁ ⊢ (⩖ j, S j) 🡒 S.realization (A 🡒 (Modal.TBB M.height)) := left_Udisj!_intro _ this - have : 𝗜𝚺₁ ⊢ S.realization (A 🡒 (Modal.TBB M.height)) := by cl_prover [this, S.SC4]; - have : U ⊢ S.realization (Modal.TBB M.height) := by - have : U ⊢ S.realization A 🡒 S.realization (Modal.TBB M.height) := WeakerThan.pbl this; - cl_prover [this, hA₁ S.realization]; - apply hPL _ |>.mpr; - grind only [ - Realization.interpret.def_imp, - Realization.interpret.def_boxItr, - Realization.interpret.def_box, - Realization.interpret.def_bot - ]; - - -/-- - `L` equals `GLα L.trace` when `L.trace` is coinfinite. - - Corollary 48 in [A.B05] --/ -theorem eq_provablityLogic_GLα_of_coinfinite_trace - [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] [T ⪯ U] -- TODO: `[T ⪯ U]` might not be necessary - {L : Logic _} (hPL : L.IsProvabilityLogic T U) (hCi : L.trace.Coinfinite) - : L = Modal.GLα L.trace := by - haveI := Logic.inst_Cl_of_isProvabilityLogic hPL; - apply Set.Subset.antisymm; - . apply subset_GLα_of_trace_coinfinite hCi; - . intro A; - suffices Modal.GLα L.trace ⊢ A → L ⊢ A by grind; - intro hA; - induction hA using - Modal.Logic.sumQuasiNormal.rec!_omitSubst_strong (L₁ := Modal.GL) (L₂ := L.trace.image TBB) - inferInstance $ Logic.substitution_of_letterless $ Modal.TBBSet_letterless - with - | mem₁ hA => - apply hPL _ |>.mpr; - intro f; - exact WeakerThan.pbl $ GL.arithmetical_soundness hA; - | mem₂ hA => - obtain ⟨n, ⟨N, ⟨A, hA₁, hA₂⟩, hN₂⟩, rfl⟩ := hA; - apply provable_TBB_of_mem_trace hPL; - simp_all only [Set.mem_iUnion, exists_prop]; - use A; - | mdp ihAB ihA => - exact ihAB ⨀ ihA; - -lemma cofinite_of_not_subset_S - [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] [T ⪯ U] - {L : Logic _} (hPL : L.IsProvabilityLogic T U) (hS : ¬L ⊆ Modal.S) - : L.trace.Cofinite := by - contrapose! hS; - rw [eq_provablityLogic_GLα_of_coinfinite_trace hPL hS]; - simp; - -lemma provable_TBBMinus_of_mem_trace - [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] [T ⪯ U] - {L : Logic _} (hPL : L.IsProvabilityLogic T U) (hS : ¬L ⊆ Modal.S) - : L ⊢ ∼⩕ i ∈ (cofinite_of_not_subset_S hPL hS).toFinset, TBB i := by - haveI := Logic.inst_Cl_of_isProvabilityLogic hPL; - - obtain ⟨A, hA₁, hA₂⟩ := Set.not_subset.mp hS; - replace hA₁ : L ⊢ A := Logic.iff_provable.mpr hA₁; - replace hA₂ : Modal.GL ⊬ A.rflSubformula.conj 🡒 A := Modal.Logic.iff_provable_rflSubformula_GL_provable_S.not.mpr $ Logic.iff_provable.not.mpr hA₂; - obtain ⟨M₁, _, _, _, _, hM⟩ := Modal.GL.Kripke.iff_unprovable_exists_fintype_rooted_model.mp hA₂; - - let M₀ := Model.extendRoot M₁ 1; - - let R := Set.Finite.inter_of_left (s := (Finset.range M₁.height)) (t := L.trace) (Finset.finite_toSet _) |>.toFinset; - let B := A ⋏ ⩕ i ∈ R, TBB i; - have hB : L ⊢ B := by - suffices L ⊢ A ∧ ∀ i ∈ R, L ⊢ TBB i by - have ⟨h₁, h₂⟩ := this; - replace h₂ : L ⊢ ⩕ i ∈ R, TBB i := Entailment.FConj'_iff_forall_provable.mpr h₂; - cl_prover [h₁, h₂]; - constructor; - . assumption; - . rintro i hi; - apply provable_TBB_of_mem_trace hPL; - simp_all [R, Logic.trace]; - - letI S := SolovaySentences.standard T M₀.toFrame; - letI Tr := cofinite_of_not_subset_S hPL hS |>.toFinset; - - apply hPL _ |>.mpr; - intro g; - apply Realization.iff_provable_letterless_interpret ?_ |>.mp; - . show U ⊢ S.realization (∼⩕ n ∈ Tr, TBB n); - apply Entailment.mdp! (φ := S.realization B) ?_ $ hPL _ |>.mp hB S.realization; - . apply WeakerThan.pbl (𝓢 := 𝗜𝚺₁); - show 𝗜𝚺₁ ⊢ (S.realization B 🡒 S.realization (∼⩕ n ∈ Tr, TBB n)); - apply ?_ ⨀ S.SC4; - apply left_Udisj!_intro _; - intro i; - rcases Frame.extendRoot.eq_root_or_eq_original i with (rfl | ⟨i, rfl⟩); - . have H₁ : 𝗜𝚺₁ ⊢ S M₀.root 🡒 ∼S.realization A := SolovaySentences.rfl_mainlemma_neg hM A (by grind) $ Satisfies.not_imp_def.mp hM |>.2; - have H₂ : 𝗜𝚺₁ ⊢ S.realization B 🡘 S.realization A ⋏ S.realization (⩕ n ∈ R, TBB n) := Realization.interpret.iff_provable_and_inside; - cl_prover [H₁, H₂]; - . suffices 𝗜𝚺₁ ⊢ S i 🡒 S.realization (B 🡒 (∼⩕ n ∈ Tr, TBB n)) by simpa; - apply SolovaySentences.mainlemma (S := S) (T := T) (i := i); - . simp; - . intro h; - apply Satisfies.not_def.mpr; - apply Satisfies.not_fconj'_def.mpr; - use Frame.rank (i : M₀); - constructor; - . by_contra hC; - apply iff_satisfies_TBB_ne_rank (M := M₀) (w := ↑i) (n := Frame.rank (i : M₀)) |>.mp; - . have := Satisfies.fconj'_def.mp $ Satisfies.and_def.mp h |>.2; - apply this _ ?_; - simp only [R, Finset.coe_range, Set.Finite.mem_toFinset, Set.mem_inter_iff, Set.mem_Iio, Set.mem_iUnion, exists_prop]; - constructor; - . suffices Frame.rank i < M₁.height by calc - _ = Frame.rank (i : M₁) := Frame.extendRoot.eq_original_height - _ < _ := this; - apply Frame.rank_lt_whole_height; - wlog ei : i = M₁.root; . grind; - subst ei; - exfalso; - apply Satisfies.not_imp_def.mp hM |>.2; - apply Model.extendRoot.modal_equivalence_original_world.mp; - exact Satisfies.and_def.mp h |>.1; - . simpa [Tr] using hC; - . rfl; - . apply iff_satisfies_TBB_ne_rank.not.mpr; - simp; - . apply TBBMinus_letterless'; - -/-- - `L` equals `GLβMinus L.trace` when `L` is not a subset of `S`. - - Lemma 49 in [A.B05] --/ -theorem eq_provabilityLogic_GLβMinus_of_not_subset_S - [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] [T ⪯ U] - {L : Logic _} (hPL : L.IsProvabilityLogic T U) (hS : ¬L ⊆ Modal.S) - : L = Modal.GLβMinus L.trace (cofinite_of_not_subset_S hPL hS) := by - haveI := Logic.inst_Cl_of_isProvabilityLogic hPL; - - apply Set.Subset.antisymm; - . apply subset_GLβMinus_of_trace_cofinite; - apply cofinite_of_not_subset_S hPL hS; - . intro A; - rw [←Logic.iff_provable, ←Logic.iff_provable] - intro hA; - induction hA using - Modal.Logic.sumQuasiNormal.rec!_omitSubst_strong (L₁ := Modal.GL) (L₂ := {∼(⩕ n ∈ (cofinite_of_not_subset_S hPL hS).toFinset, (TBB n))}) - inferInstance (Logic.substitution_of_letterless TBBMinus_letterless) with - | mem₁ hA => - apply hPL _ |>.mpr; - intro f; - exact WeakerThan.pbl $ GL.arithmetical_soundness hA; - | mem₂ hA => - replace hA := Logic.iff_provable.mp hA; - subst hA; - exact provable_TBBMinus_of_mem_trace hPL hS; - | mdp ihAB ihA => exact ihAB ⨀ ihA; - -end ProvabilityLogic - -end LO diff --git a/Foundation/ProvabilityLogic/GL/Completeness.lean b/Foundation/ProvabilityLogic/GL/Completeness.lean deleted file mode 100644 index dc18c2317..000000000 --- a/Foundation/ProvabilityLogic/GL/Completeness.lean +++ /dev/null @@ -1,112 +0,0 @@ -module - -public import Foundation.ProvabilityLogic.SolovaySentences -public import Foundation.ProvabilityLogic.Arithmetic - -@[expose] public section -/-! -# Solovay's arithmetical completeness of $\mathsf{GL}$ and $\mathsf{GL} + \square^n \bot$ --/ - -namespace LO.ProvabilityLogic - -open LO.Entailment Entailment.FiniteContext -open FirstOrder -open Modal -open Modal.Kripke -open ArithmeticTheory (provabilityLogicOn) -open Modal.Formula.Kripke - -variable {T : ArithmeticTheory} [T.Δ₁] [𝗜𝚺₁ ⪯ T] {A : Modal.Formula _} - -theorem unprovable_realization_exists - (M₁ : Model) [Fintype M₁] [M₁.IsConverseWellFounded] [M₁.IsTransitive] [M₁.IsRooted] - (hA : M₁.root.1 ⊭ A) (h : M₁.height < T.height) - : ∃ f : T.StandardRealization, T ⊬ f A := by - let M₀ := M₁.extendRoot 1 - let r₀ : M₀.Root := M₀.root; - have hdnA : Satisfies M₀ M₀.root.1 (◇(∼A)) := by - suffices ∃ i, r₀.1 ≺ i ∧ ¬Satisfies _ i A by simpa [Formula.Kripke.Satisfies] - refine ⟨.inr M₁.root.1, ?_, ?_⟩ - · grind; - · exact Model.extendRoot.inr_satisfies_iff |>.not.mpr hA - let S : SolovaySentences T.standardProvability M₀.toFrame := - SolovaySentences.standard T M₀.toFrame - use S.realization - intro hC - have : T.height ≤ M₁.height := by - apply Order.le_of_lt_add_one - calc - T.standardProvability.height < M₀.height := S.theory_height (T.standardProvability.syntactical_sound ℕ) hdnA hC - _ = M₁.height + 1 := by simp [M₀]; - exact not_lt_of_ge this h - -/-- Arithmetical completeness of $\mathsf{GL}$-/ -theorem GL.arithmetical_completeness - (height : T.height = ⊤) : - (∀ f : T.StandardRealization, T ⊢ f A) → Modal.GL ⊢ A := by - suffices ¬Modal.GL ⊢ A → ∃ f : T.StandardRealization, T ⊬ f A by - contrapose!; - assumption; - intro hA - obtain ⟨M₁, _, _, _, _, hA₁⟩ := GL.Kripke.iff_unprovable_exists_fintype_rooted_model.mp hA; - exact unprovable_realization_exists M₁ hA₁ <| by simp [height] - -theorem GLPlusBoxBot.arithmetical_completeness_aux - {n : ℕ} (height : n ≤ T.height) - : (∀ f : T.StandardRealization, T ⊢ f A) → Modal.GL ⊢ □^[n] ⊥ 🡒 A := by - suffices ¬Modal.GL ⊢ □^[n]⊥ 🡒 A → ∃ f : T.StandardRealization, T ⊬ f A by - contrapose!; - assumption; - intro hA - obtain ⟨M₁, _, _, _, _, hA₁⟩ := GL.Kripke.iff_unprovable_exists_fintype_rooted_model.mp hA; - have hA₁ : M₁.root.1 ⊧ □^[n]⊥ ∧ M₁.root.1 ⊭ A := by simpa [Formula.Kripke.Satisfies] using hA₁ - have M₁_height : M₁.height < n := height_lt_iff_satisfies_boxbot.mpr hA₁.1 - exact unprovable_realization_exists M₁ hA₁.2 <| lt_of_lt_of_le (by simp [M₁_height]) height - -theorem GL.arithmetical_completeness_iff - (height : T.height = ⊤) - : (∀ f : T.StandardRealization, T ⊢ f A) ↔ Modal.GL ⊢ A := - ⟨GL.arithmetical_completeness height, GL.arithmetical_soundness⟩ - -theorem GL.arithmetical_completeness_sound_iff [T.SoundOnHierarchy 𝚺 1] {A} : - (∀ f : T.StandardRealization, T ⊢ f A) ↔ Modal.GL ⊢ A := - GL.arithmetical_completeness_iff (Arithmetic.height_eq_top_of_sigma1_sound T) - -/-- Provability logic of $\Sigma_1$-sound theory contains $\mathsf{I}\Sigma_1$ is $\mathsf{GL}$-/ -theorem provabilityLogic_eq_GL_of_sigma1_sound [T.SoundOnHierarchy 𝚺 1] - : (T.provabilityLogicOn T) ≊ Modal.GL := by - apply Logic.iff_equal_provable_equiv.mp - ext A; - simpa [Logic.iff_provable] using GL.arithmetical_completeness_sound_iff - -open Classical - -/-- Arithmetical completeness of $\mathsf{GL} + \square^n \bot$-/ -theorem GLPlusBoxBot.arithmetical_completeness - {n : ℕ∞} (hn : n ≤ T.height) - -- [T.standardProvability.SoundOnClass ((T.standardProvability^[·] ⊥) '' Set.univ)] - (h : ∀ f : T.StandardRealization, T ⊢ f A) - : Modal.GLPlusBoxBot n ⊢ A := by - match n with - | .none => - have : T.height = ⊤ := eq_top_iff.mpr hn - simpa using GL.arithmetical_completeness this h - | .some n => - apply iff_provable_GLPlusBoxBot_provable_GL.mpr - exact GLPlusBoxBot.arithmetical_completeness_aux (n := n) (by simpa using hn) h - -theorem GLPlusBoxBot.arithmetical_completeness_iff - : (∀ f : T.StandardRealization, T ⊢ f A) ↔ Modal.GLPlusBoxBot T.height ⊢ A := - ⟨GLPlusBoxBot.arithmetical_completeness (T := T) (by simp), GLPlusBoxBot.arithmetical_soundness⟩ - -/-- Provability logic of theory contains $\mathsf{I}\Sigma_1$ is $\mathsf{GL} + \square^{\text{height of } T} \bot$-/ -theorem provabilityLogic_eq_GLPlusBoxBot - : (T.provabilityLogicOn T) ≊ Modal.GLPlusBoxBot T.height := by - apply Logic.iff_equal_provable_equiv.mp - ext A - simpa [Logic.iff_provable] using GLPlusBoxBot.arithmetical_completeness_iff - -instance : (𝗣𝗔.provabilityLogicOn 𝗣𝗔) ≊ Modal.GL := provabilityLogic_eq_GL_of_sigma1_sound - -end LO.ProvabilityLogic diff --git a/Foundation/ProvabilityLogic/GL/Soundness.lean b/Foundation/ProvabilityLogic/GL/Soundness.lean deleted file mode 100644 index ba9883d0a..000000000 --- a/Foundation/ProvabilityLogic/GL/Soundness.lean +++ /dev/null @@ -1,46 +0,0 @@ -module - -public import Foundation.ProvabilityLogic.Realization -public import Foundation.Modal.Logic.GLPlusBoxBot.Basic -public import Foundation.FirstOrder.Incompleteness.ProvabilityAbstraction.Height - -@[expose] public section -namespace LO.ProvabilityLogic - -open Entailment -open Modal -open Modal.Hilbert -open FirstOrder -open FirstOrder.ProvabilityAbstraction - -variable {L : FirstOrder.Language} [L.ReferenceableBy L] - [L.DecidableEq] - {T U : FirstOrder.Theory L} [Diagonalization T] [T ⪯ U] - {𝔅 : Provability T U} [𝔅.HBL] - -lemma GL.arithmetical_soundness (h : Modal.GL ⊢ A) {f : Realization 𝔅} : U ⊢ f A := by - induction h using Hilbert.Normal.rec! with - | axm _ hp => - rcases hp with (⟨_, rfl⟩ | ⟨_, rfl⟩) - . exact WeakerThan.pbl $ 𝔅.D2; - . exact WeakerThan.pbl $ formalized_löb_theorem; - | nec ihp => exact WeakerThan.pbl $ 𝔅.D1 ihp; - | mdp ihpq ihp => exact ihpq ⨀ ihp; - | _ => dsimp [Realization.interpret]; cl_prover; - -open Classical - -theorem GLPlusBoxBot.arithmetical_soundness - (hA : Modal.GLPlusBoxBot 𝔅.height ⊢ A) - (f : Realization 𝔅) : U ⊢ f A := by - cases h : 𝔅.height - case _ => - exact GL.arithmetical_soundness (by simpa [h] using hA) - case _ n => - have : Modal.GLPlusBoxBot n ⊢ A := by simpa [h] using hA - have : Modal.GL ⊢ □^[n]⊥ 🡒 A := iff_provable_GLPlusBoxBot_provable_GL.mp this - have : U ⊢ f (□^[n]⊥ 🡒 A) := GL.arithmetical_soundness this; - have : U ⊢ 𝔅^[n] ⊥ 🡒 f A := by simpa using (Realization.interpret.def_boxItr (f := f) n (A := ⊥)) ▸ this; - exact this ⨀ (𝔅.height_le_iff_boxBot.mp (by simp [h])) - -end LO.ProvabilityLogic diff --git a/Foundation/ProvabilityLogic/GL/Uniform.lean b/Foundation/ProvabilityLogic/GL/Uniform.lean deleted file mode 100644 index a11f717fb..000000000 --- a/Foundation/ProvabilityLogic/GL/Uniform.lean +++ /dev/null @@ -1,23 +0,0 @@ -module - -public import Foundation.ProvabilityLogic.GL.Completeness - -@[expose] public section -namespace LO.ProvabilityLogic.GL - -open LO.Entailment Entailment.FiniteContext -open FirstOrder Arithmetic -open Modal -open Modal.Kripke - -variable {T : ArithmeticTheory} [T.Δ₁] [𝗜𝚺₁ ⪯ T] [T.SoundOnHierarchy 𝚺 1] - --- TODO: prove this! -axiom uniform_arithmetical_completeness [T.SoundOnHierarchy 𝚺 1] : ∃ f : T.StandardRealization, ∀ A, T ⊢ f A ↔ Modal.GL ⊢ A - -protected noncomputable def uniformStandardRealization (T : ArithmeticTheory) [T.Δ₁] [𝗜𝚺₁ ⪯ T] [T.SoundOnHierarchy 𝚺 1] : T.StandardRealization := GL.uniform_arithmetical_completeness.choose - -@[grind =] -lemma uniformStandardRealization_spec : T ⊢ (GL.uniformStandardRealization T) A ↔ Modal.GL ⊢ A := GL.uniform_arithmetical_completeness.choose_spec A - -end LO.ProvabilityLogic.GL diff --git a/Foundation/ProvabilityLogic/GL/Unprovability.lean b/Foundation/ProvabilityLogic/GL/Unprovability.lean deleted file mode 100644 index 3d311771b..000000000 --- a/Foundation/ProvabilityLogic/GL/Unprovability.lean +++ /dev/null @@ -1,159 +0,0 @@ -module - -public import Foundation.Modal.Logic.GL.Independency -public import Foundation.ProvabilityLogic.GL.Completeness - -@[expose] public section -namespace LO.FirstOrder - -open LO.Entailment - -namespace ProvabilityAbstraction - -variable {L : Language} [L.ReferenceableBy L] [DecidableEq (Sentence L)] - {T₀ T : Theory L} [T₀ ⪯ T] - {𝔅 : Provability T₀ T} - {σ π : Sentence L} - -def Provability.indep (𝔅 : Provability T₀ T) (σ : Sentence L) : Sentence L := ∼(𝔅 σ) ⋏ ∼(𝔅 (∼σ)) - -lemma indep_distribute [𝔅.HBL2] (h : T ⊢ σ 🡘 π) : T ⊢ 𝔅.indep σ 🡒 𝔅.indep π := by - apply CKK!_of_C!_of_C!; - . apply contra!; - apply WeakerThan.pbl (𝓢 := T₀); - apply 𝔅.mono; - cl_prover [h]; - . apply contra!; - apply WeakerThan.pbl (𝓢 := T₀); - apply 𝔅.mono; - cl_prover [h]; - -lemma indep_iff_distribute_inside [𝔅.HBL2] (h : T ⊢ σ 🡘 π) : - T ⊢ 𝔅.indep σ 🡘 𝔅.indep π := by - apply K!_intro - . exact indep_distribute $ h; - . apply indep_distribute; - cl_prover [h]; - -lemma indep_iff_distribute [𝔅.HBL2] (h : T ⊢ σ 🡘 π) : - T ⊢ 𝔅.indep σ ↔ T ⊢ 𝔅.indep π := by - constructor; - . intro H; exact K!_left (indep_iff_distribute_inside h) ⨀ H; - . intro H; exact K!_right (indep_iff_distribute_inside h) ⨀ H; - -end ProvabilityAbstraction - - -namespace Arithmetic - -open Modal ProvabilityLogic -open ProvabilityAbstraction - -variable {T : ArithmeticTheory} [T.Δ₁] - {σ π : Sentence L} - {f : T.StandardRealization} - {A B : Modal.Formula _} - -example [𝗜𝚺₁ ⪯ T] (height : T.height = ⊤) : T ⊬ T.standardProvability.con := by - have h := ProvabilityLogic.GL.arithmetical_completeness_iff height (T := T) |>.not.mpr $ GL.unprovable_notbox (φ := ⊥); - push Not at h; - obtain ⟨f, h⟩ := h; - exact Realization.interpret.iff_provable_neg (f := f) |>.not.mp h; - -lemma iff_modalConsis_bewConsis_inside : T ⊢ f (∼□⊥) 🡘 T.standardProvability.con := by - apply K!_intro; - . refine C!_trans (K!_left Realization.interpret.iff_provable_neg_inside) ?_; - apply contra!; - simp [Realization.interpret]; - . refine C!_trans ?_ (K!_right Realization.interpret.iff_provable_neg_inside) - apply contra!; - simp [Realization.interpret]; - -variable [𝗜𝚺₁ ⪯ T] - -lemma iff_modalIndep_bewIndep_inside : - T ⊢ f (Modal.independency A) 🡘 T.standardProvability.indep (f A) := by - apply K!_intro; - . refine C!_trans (K!_left $ Realization.interpret.iff_provable_and_inside) ?_; - apply CKK!_of_C!_of_C!; - . apply K!_left $ Realization.interpret.iff_provable_neg_inside (L := ℒₒᵣ); - . apply C!_trans (K!_left $ Realization.interpret.iff_provable_neg_inside (L := ℒₒᵣ) (A := □(∼A))) ?_; - apply contra!; - apply WeakerThan.pbl (𝓢 := 𝗜𝚺₁); - apply T.standardProvability.mono; - apply K!_right $ Realization.interpret.iff_provable_neg_inside (L := ℒₒᵣ) ; - . refine C!_trans ?_ (K!_right $ Realization.interpret.iff_provable_and_inside); - apply CKK!_of_C!_of_C!; - . exact C!_trans (K!_right $ Realization.interpret.iff_provable_neg_inside (A := □A)) C!_id; - . apply C!_trans ?_ (K!_right $ Realization.interpret.iff_provable_neg_inside (L := ℒₒᵣ) (A := □(∼A))); - apply contra!; - apply WeakerThan.pbl (𝓢 := 𝗜𝚺₁); - apply T.standardProvability.mono; - apply K!_left $ Realization.interpret.iff_provable_neg_inside (L := ℒₒᵣ); - -lemma iff_modalIndep_bewIndep : - T ⊢ f (Modal.independency A) ↔ T ⊢ T.standardProvability.indep (f A) := by - constructor; - . intro h; exact (K!_left iff_modalIndep_bewIndep_inside) ⨀ h; - . intro h; exact (K!_right iff_modalIndep_bewIndep_inside) ⨀ h; - -lemma iff_not_modalIndep_not_bewIndep_inside : - T ⊢ ∼f (Modal.independency A) 🡘 ∼T.standardProvability.indep (f A) := - ENN!_of_E! iff_modalIndep_bewIndep_inside - -lemma iff_not_modalIndep_not_bewIndep : - T ⊢ ∼f (Modal.independency A) ↔ T ⊢ ∼T.standardProvability.indep (f A) := by - constructor; - . intro h; exact (K!_left iff_not_modalIndep_not_bewIndep_inside) ⨀ h; - . intro h; exact (K!_right iff_not_modalIndep_not_bewIndep_inside) ⨀ h; - -lemma unprovable_independency_of_consistency (height : T.height = ⊤) : - T ⊬ T.standardProvability.indep (T.standardProvability.con) := by - let g : T.StandardRealization := ⟨λ _ => ⊥⟩ - suffices T ⊬ g (Modal.independency (∼□⊥)) by - have H₁ := iff_modalIndep_bewIndep (f := g) (T := T) (A := ∼□⊥); - have H₂ := indep_iff_distribute (𝔅 := T.standardProvability) (T := T) - (σ := g (∼□⊥)) - (π := T.standardProvability.con) - iff_modalConsis_bewConsis_inside; - exact Iff.trans H₁ H₂ |>.not.mp this; - have h := GL.arithmetical_completeness_iff height |>.not.mpr $ GL.unprovable_independency (φ := ∼□⊥); - push Not at h; - obtain ⟨f, h⟩ := h; - congr; - -lemma unrefutable_independency_of_consistency (height : T.height = ⊤): - T ⊬ ∼T.standardProvability.indep (T.standardProvability.con) := by - let g : T.StandardRealization := ⟨λ _ => ⊥⟩ - suffices T ⊬ ∼g (Modal.independency (∼□⊥)) by - have H₁ := iff_not_modalIndep_not_bewIndep (f := g) (T := T) (A := ∼□⊥); - have H₂ : T ⊢ - ∼T.standardProvability.indep (g (∼□⊥)) 🡘 - ∼T.standardProvability.indep T.standardProvability.con - := ENN!_of_E! $ indep_iff_distribute_inside (T := T) - (σ := g (∼□⊥)) - (π := T.standardProvability.con) - iff_modalConsis_bewConsis_inside; - replace H₂ : - T ⊢ ∼T.standardProvability.indep (g (∼□⊥)) ↔ - T ⊢ ∼T.standardProvability.indep T.standardProvability.con - := by - constructor; - . intro H; exact K!_left H₂ ⨀ H; - . intro H; exact K!_right H₂ ⨀ H; - apply Iff.trans H₁ H₂ |>.not.mp this; - have h := GL.arithmetical_completeness_iff height |>.not.mpr $ GL.unprovable_not_independency_of_consistency; - push Not at h; - obtain ⟨f, h⟩ := h; - replace h := Realization.interpret.iff_provable_neg (L := ℒₒᵣ) |>.not.mp h; - congr; - -theorem undecidable_independency_of_consistency (height : T.height = ⊤) : - Independent T (T.standardProvability.indep T.standardProvability.con) := by - constructor; - . exact unprovable_independency_of_consistency height; - . exact unrefutable_independency_of_consistency height; - -end Arithmetic - -end LO.FirstOrder diff --git a/Foundation/ProvabilityLogic/Grz/Completeness.lean b/Foundation/ProvabilityLogic/Grz/Completeness.lean deleted file mode 100644 index 6caf922c3..000000000 --- a/Foundation/ProvabilityLogic/Grz/Completeness.lean +++ /dev/null @@ -1,138 +0,0 @@ -module - -public import Foundation.Modal.Boxdot.Grz_S - -@[expose] public section -namespace LO - -open FirstOrder -open Modal -open Modal.Hilbert -open FirstOrder FirstOrder.ProvabilityAbstraction -open Entailment FiniteContext -open Provability - -namespace Entailment - - -variable {F : Type*} [LogicalConnective F] [DecidableEq F] - {S : Type*} [Entailment S F] - {𝓢 : S} [Entailment.Cl 𝓢] - {φ ψ χ ξ : F} - -lemma CCCCOOK! : 𝓢 ⊢ ((φ 🡒 (ψ 🡒 ⊥)) 🡒 ⊥) 🡒 (φ ⋏ ψ) := by cl_prover - -lemma CKCCCOO! : 𝓢 ⊢ (φ ⋏ ψ) 🡒 ((φ 🡒 ψ 🡒 ⊥) 🡒 ⊥) := by cl_prover; - -end Entailment - - - -namespace ProvabilityLogic - - -variable {L : Language} [L.ReferenceableBy L] [L.DecidableEq] - {T₀ T : Theory L} [T₀ ⪯ T] {A : Modal.Formula ℕ} - -namespace Realization - -variable {𝔅 : Provability T₀ T} {f : Realization 𝔅} {A B : Modal.Formula _} - -def strongInterpret (f : Realization 𝔅) : Formula ℕ → Sentence L - | .atom a => f a - | ⊥ => ⊥ - | φ 🡒 ψ => (f.strongInterpret φ) 🡒 (f.strongInterpret ψ) - | □φ => (f.strongInterpret φ) ⋏ 𝔅 (f.strongInterpret φ) - -lemma iff_interpret_boxdot_strongInterpret_inside [𝔅.HBL2] : T ⊢ f (Aᵇ) 🡘 f.strongInterpret A := by - induction A with - | hatom φ => simp [Realization.interpret, strongInterpret, Formula.boxdotTranslate]; - | hfalsum => simp [strongInterpret, Formula.boxdotTranslate]; - | himp A B ihA ihB => exact ECC!_of_E!_of_E! ihA ihB; - | hbox A ih => - apply E!_trans Realization.interpret.iff_provable_boxdot_inside; - apply K!_intro; - . apply CKK!_of_C!_of_C!; - . cl_prover [ih]; - . apply WeakerThan.pbl (𝓢 := T₀); - apply 𝔅.mono; - cl_prover [ih]; - . apply CKK!_of_C!_of_C!; - . cl_prover [ih]; - . apply WeakerThan.pbl (𝓢 := T₀); - apply 𝔅.mono; - cl_prover [ih]; - -lemma iff_interpret_boxdot_strongInterpret [𝔅.HBL2] : - T ⊢ f (Aᵇ) ↔ T ⊢ f.strongInterpret A := by - constructor; - . intro h; exact (K!_left iff_interpret_boxdot_strongInterpret_inside) ⨀ h; - . intro h; exact (K!_right iff_interpret_boxdot_strongInterpret_inside) ⨀ h; - -lemma iff_models_interpret_boxdot_strongInterpret - {M} [Nonempty M] [Structure L M] [M ⊧ₘ* T] [𝔅.HBL2] [𝔅.SoundOn M] : - M ⊧ₘ f (Aᵇ) ↔ M ⊧ₘ f.strongInterpret A := by - induction A with - | hatom φ => simp [Realization.interpret, strongInterpret, Formula.boxdotTranslate]; - | hfalsum => simp [strongInterpret, Formula.boxdotTranslate]; - | himp A B ihA ihB => - simp only [Formula.boxdotTranslate, interpret, Models, Semantics.Imp.models_imply, strongInterpret]; - constructor; - . intro hAB hA; - apply ihB.mp; - apply hAB; - apply ihA.mpr; - exact hA; - . intro hAB hA; - apply ihB.mpr; - apply hAB; - apply ihA.mp; - exact hA; - | hbox A ih => - suffices (M ⊧ₘ f (Aᵇ)) ∧ (M ⊧ₘ 𝔅 (f (Aᵇ))) ↔ M ⊧ₘ f.strongInterpret A ∧ M ⊧ₘ 𝔅 (f.strongInterpret A) by - simpa [Formula.boxdotTranslate, interpret, strongInterpret] using this; - constructor; - . rintro ⟨h₁, h₂⟩; - constructor; - . exact ih.mp h₁; - . apply models_of_provable (T := T) inferInstance; - apply WeakerThan.pbl (𝓢 := T₀); - apply 𝔅.D1; - exact iff_interpret_boxdot_strongInterpret.mp $ 𝔅.sound_on h₂; - . rintro ⟨h₁, h₂⟩; - constructor; - . apply ih.mpr h₁; - . apply models_of_provable (T := T) inferInstance; - apply WeakerThan.pbl (𝓢 := T₀); - apply 𝔅.D1; - exact iff_interpret_boxdot_strongInterpret.mpr $ 𝔅.sound_on h₂; - -end Realization - -theorem Grz.arithmetical_completeness_iff - {T : ArithmeticTheory} [T.Δ₁] [𝗜𝚺₁ ⪯ T] (height : T.height = ⊤) - : (∀ f : T.StandardRealization, T ⊢ f.strongInterpret A) ↔ Modal.Grz ⊢ A := by - constructor; - . intro h; - suffices Modal.GL ⊢ Aᵇ by apply iff_provable_boxdot_GL_provable_Grz.mp this; - apply GL.arithmetical_completeness_iff height |>.mp; - intro f; - apply Realization.iff_interpret_boxdot_strongInterpret (L := ℒₒᵣ).mpr; - apply h; - . intro h f; - replace h := iff_provable_boxdot_GL_provable_Grz.mpr h; - have : (∀ f : T.StandardRealization, T ⊢ f (Aᵇ)) := GL.arithmetical_completeness_iff height |>.mpr h; - exact Realization.iff_interpret_boxdot_strongInterpret (L := ℒₒᵣ) |>.mp $ this f; - -theorem Grz.arithmetical_completeness_model_iff - {T : ArithmeticTheory} [T.Δ₁] [𝗜𝚺₁ ⪯ T] [ℕ ⊧ₘ* T] : - (∀ f : T.StandardRealization, ℕ ⊧ₘ f.strongInterpret A) ↔ Modal.Grz ⊢ A := by - apply Iff.trans ?_ Modal.Logic.iff_provable_Grz_provable_boxdot_S; - apply Iff.trans ?_ (S.arithmetical_completeness_iff (T := T)).symm; - have : 𝗥₀ ⪯ 𝗜𝚺₁ := inferInstance - have : 𝗥₀ ⪯ T := WeakerThan.trans this inferInstance - constructor; - . intro h f; exact Realization.iff_models_interpret_boxdot_strongInterpret (L := ℒₒᵣ) |>.mpr $ h f; - . intro h f; exact Realization.iff_models_interpret_boxdot_strongInterpret (L := ℒₒᵣ) |>.mp $ h f; - -end LO.ProvabilityLogic diff --git a/Foundation/ProvabilityLogic/N/Soundness.lean b/Foundation/ProvabilityLogic/N/Soundness.lean deleted file mode 100644 index 0a5d64e04..000000000 --- a/Foundation/ProvabilityLogic/N/Soundness.lean +++ /dev/null @@ -1,27 +0,0 @@ -module - -public import Foundation.ProvabilityLogic.Realization -public import Foundation.Modal.PLoN.Logic.N - -@[expose] public section -namespace LO.ProvabilityLogic - -open Entailment -open Modal -open Modal.Hilbert -open FirstOrder -open FirstOrder.ProvabilityAbstraction - -variable {L : FirstOrder.Language} [L.ReferenceableBy L] - [L.DecidableEq] - {T U : FirstOrder.Theory L} [T ⪯ U] - {𝔅 : Provability T U} - -lemma N.arithmetical_soundness (h : Modal.N ⊢ A) {f : Realization 𝔅} : U ⊢ f A := by - induction h using Hilbert.Normal.rec! with - | axm _ hp => simp at hp; - | nec ihp => exact WeakerThan.pbl $ 𝔅.D1 ihp; - | mdp ihpq ihp => exact ihpq ⨀ ihp; - | _ => simp only [Realization.interpret]; cl_prover; - -end LO.ProvabilityLogic diff --git a/Foundation/ProvabilityLogic/Realization.lean b/Foundation/ProvabilityLogic/Realization.lean deleted file mode 100644 index fdad996a0..000000000 --- a/Foundation/ProvabilityLogic/Realization.lean +++ /dev/null @@ -1,246 +0,0 @@ -module - -public import Foundation.FirstOrder.Incompleteness.StandardProvability -public import Foundation.Modal.Hilbert.Normal.Basic - -@[expose] public section -namespace LO - -open Entailment FiniteContext -open FirstOrder ProvabilityAbstraction -open Modal Modal.Hilbert - -variable {L : Language} [L.ReferenceableBy L] {T₀ T U : Theory L} - -namespace ProvabilityLogic - -/-- Mapping modal prop vars to first-order sentence -/ -structure Realization (𝔅 : Provability T₀ T) where - val : ℕ → FirstOrder.Sentence L - -abbrev _root_.LO.FirstOrder.ArithmeticTheory.StandardRealization (T : ArithmeticTheory) [T.Δ₁] := Realization T.standardProvability - -namespace Realization - -variable {𝔅 : Provability T₀ T} {f f₁ f₂ : Realization 𝔅} {A : Formula ℕ} - -/-- Mapping modal formulae to first-order sentence -/ -@[coe] def interpret {𝔅 : Provability T₀ T} (f : Realization 𝔅) : Formula ℕ → FirstOrder.Sentence L - | .atom a => f.val a - | □φ => 𝔅 (f.interpret φ) - | ⊥ => ⊥ - | φ 🡒 ψ => (f.interpret φ) 🡒 (f.interpret ψ) - -instance : CoeFun (Realization 𝔅) (fun _ ↦ Formula ℕ → FirstOrder.Sentence L) := ⟨interpret⟩ - -@[grind ⇒] -lemma letterless_interpret (A_letterless : A.Letterless) : f₁ A = f₂ A := by - induction A with - | hatom a => grind; - | hfalsum => simp_all [Realization.interpret]; - | himp A B ihA ihB => - replace ihA := ihA $ by grind; - replace ihB := ihB $ by grind; - simp_all [Realization.interpret]; - | hbox A ihA => - replace ihA := ihA $ by grind; - simp_all [Realization.interpret]; - -@[grind ⇒] -lemma iff_provable_letterless_interpret (A_letterless : A.Letterless) : U ⊢ f₁ A ↔ U ⊢ f₂ A := by - suffices f₁ A = f₂ A by rw [this]; - exact letterless_interpret A_letterless; - -namespace interpret - -variable {𝔅 : Provability T₀ T} {f : Realization 𝔅} {A B : Modal.Formula _} - -section - -@[simp, grind =] lemma def_atom : f (.atom a) = f.val a := rfl - -@[simp, grind =] lemma def_imp : f (A 🡒 B) = (f A) 🡒 (f B) := rfl - -@[simp, grind =] lemma def_bot : f ⊥ = ⊥ := rfl - -@[simp, grind =] lemma def_box : f (□A) = 𝔅 (f A) := rfl - -@[simp, grind =] -lemma def_boxItr (n : ℕ) : f (□^[n] A) = 𝔅^[n] (f A) := by - induction n <;> simp [-Function.iterate_succ, Function.iterate_succ', *] - -end - - -section provability - - -variable [DecidableEq (Sentence L)] - -omit [DecidableEq (Sentence L)] in -@[simp, grind ⇒] -lemma iff_provable_atom : U ⊢ f (.atom a) ↔ U ⊢ f.val a := by simp; - -@[grind .] -lemma iff_provable_imp_inside : U ⊢ f (A 🡒 B) 🡘 (f A) 🡒 (f B) := by simp only [def_imp]; cl_prover; - -@[grind =] -lemma iff_provable_imp : U ⊢ f (A 🡒 B) ↔ U ⊢ (f A) 🡒 (f B) := by - have := iff_provable_imp_inside (U := U) (f := f) (A := A) (B := B); - constructor <;> . intro h; cl_prover [h, this]; - - -omit [DecidableEq (Sentence L)] in -@[simp, grind =] -lemma iff_provable_bot : U ⊢ f ⊥ ↔ U ⊢ ⊥ := by simp [Realization.interpret]; - - -omit [DecidableEq (Sentence L)] in -@[grind .] -lemma iff_provable_box_inside : U ⊢ f (□A) 🡘 𝔅 (f A) := by simp; - -@[grind =] -lemma iff_provable_box : U ⊢ f (□A) ↔ U ⊢ 𝔅 (f A) := by - have := iff_provable_box_inside (U := U) (f := f) (A := A); - constructor <;> . intro h; cl_prover [h, this]; - -omit [DecidableEq (Sentence L)] in -@[grind .] -lemma iff_provable_boxItr_inside {n : ℕ} : U ⊢ f (□^[n] A) 🡘 𝔅^[n] (f A) := by simp; - -@[simp, grind =] -lemma iff_provable_boxItr {n : ℕ} : U ⊢ f (□^[n] A) ↔ U ⊢ 𝔅^[n] (f A) := by - have := iff_provable_boxItr_inside (U := U) (f := f) (A := A) (n := n); - constructor <;> . intro h; cl_prover [h, this]; - -@[grind .] -lemma iff_provable_neg_inside : U ⊢ f (∼A) 🡘 ∼(f A) := by - dsimp [Realization.interpret]; - cl_prover; - -@[grind =] -lemma iff_provable_neg : U ⊢ f (∼A) ↔ U ⊢ ∼(f A) := by - have := iff_provable_neg_inside (U := U) (f := f) (A := A); - constructor <;> . intro h; cl_prover [h, this]; - -@[grind .] -lemma iff_provable_or_inside : U ⊢ f (A ⋎ B) 🡘 (f A) ⋎ (f B) := by - dsimp [Realization.interpret]; - cl_prover; - -@[grind =] -lemma iff_provable_or : U ⊢ f (A ⋎ B) ↔ U ⊢ (f A) ⋎ (f B) := by - have := iff_provable_or_inside (U := U) (f := f) (A := A) (B := B); - constructor <;> . intro h; cl_prover [h, this]; - - -@[grind .] -lemma iff_provable_and_inside : U ⊢ f (A ⋏ B) 🡘 (f A) ⋏ (f B) := by - dsimp [Realization.interpret]; - cl_prover; - -@[grind =] -lemma iff_provable_and' : U ⊢ f (A ⋏ B) ↔ U ⊢ (f A) ⋏ (f B) := by - dsimp [Realization.interpret]; - constructor <;> . intro h; cl_prover [h]; - -@[grind =] -lemma iff_provable_and : U ⊢ f (A ⋏ B) ↔ U ⊢ (f A) ∧ U ⊢ (f B) := by - constructor; - . intro h; - have := iff_provable_and'.mp h; - constructor <;> cl_prover [this]; - . rintro ⟨hA, hB⟩; - apply iff_provable_and'.mpr; - cl_prover [hA, hB]; - -lemma iff_provable_lconj_inside {Γ : List _} : U ⊢ f (⋀Γ) 🡘 ⋀(Γ.map f) := by - induction Γ using List.induction_with_singleton with - | hcons A Γ h ih => - simp only [ - List.conj₂_cons_nonempty h, List.map_cons, - List.conj₂_cons_nonempty (List.map_eq_nil_iff.not.mpr h) - ]; - apply E!_trans $ iff_provable_and_inside; - cl_prover [ih]; - | hnil => simp only [List.conj₂_nil, interpret, List.map_nil]; cl_prover; - | hsingle => simp; - -lemma iff_provable_fconj_inside : T ⊢ f Γ.conj 🡘 (Finset.image f Γ).conj := by - apply E!_trans $ iff_provable_lconj_inside; - apply E!_intro; - . apply Entailment.CConj₂Conj₂!_of_subset; simp; - . apply Entailment.CConj₂Conj₂!_of_subset; simp; - -@[simp, grind =] -lemma iff_provable_lconj₂ {l : List (Formula _)} : U ⊢ f (l.conj₂) ↔ ∀ A ∈ l, U ⊢ f A := by - induction l using List.induction_with_singleton with - | hcons a l h ih => - rw [List.conj₂_cons_nonempty h (a := a), iff_provable_and]; - constructor; - . grind; - . intro h; - constructor; - . apply h; simp; - . apply ih.mpr; grind; - | _ => simp [Realization.interpret]; - -@[simp, grind =] -lemma iff_provable_lconj' {l : List (Formula ℕ)} : U ⊢ f (l.conj' ι) ↔ (∀ A ∈ l, U ⊢ f (ι A)) := by - simp [List.conj'] - -@[simp, grind =] -lemma iff_provable_fconj {s : Finset (Formula ℕ)} : U ⊢ f (s.conj) ↔ ∀ A ∈ s, U ⊢ f A := by - simp [Finset.conj] - -@[simp, grind =] -lemma iff_provable_fconj' {s : Finset (Formula ℕ)} : U ⊢ f (s.conj' ι) ↔ (∀ A ∈ s, U ⊢ f (ι A)) := by - simp [Finset.conj'] - -@[grind .] -lemma iff_provable_boxdot_inside : U ⊢ f (⊡A) 🡘 (f A) ⋏ 𝔅 (f A) := by - apply E!_trans iff_provable_and_inside; - cl_prover; - -@[grind =] -lemma iff_provable_boxdot : U ⊢ f (⊡A) ↔ U ⊢ (f A) ⋏ 𝔅 (f A) := by - constructor; - . intro h; exact (C_of_E_mp! iff_provable_boxdot_inside) ⨀ h; - . intro h; exact (C_of_E_mpr! iff_provable_boxdot_inside) ⨀ h; - -end provability - - -section model - -variable {M} [Nonempty M] [Structure L M] - -@[simp, grind .] lemma models₀_top : M ⊧ₘ f ⊤ := by simp [Realization.interpret]; -@[simp, grind .] lemma models₀_bot : ¬M ⊧ₘ f ⊥ := by simp [Realization.interpret]; - -@[simp, grind ⇒] -lemma iff_models₀_neg : M ⊧ₘ f (∼A) ↔ ¬(M ⊧ₘ (f A)) := by simp [Realization.interpret]; - -@[simp, grind ⇒] -lemma iff_models₀_imp : M ⊧ₘ f (A 🡒 B) ↔ (M ⊧ₘ (f A) → M ⊧ₘ (f B)) := by simp [Realization.interpret]; - -@[simp, grind ⇒] -lemma iff_models₀_and : M ⊧ₘ f (A ⋏ B) ↔ M ⊧ₘ (f A) ∧ M ⊧ₘ (f B) := by simp [Realization.interpret]; - -@[simp, grind ⇒] -lemma iff_models₀_or : M ⊧ₘ f (A ⋎ B) ↔ M ⊧ₘ (f A) ∨ M ⊧ₘ (f B) := by simp [Realization.interpret]; tauto; - -@[simp, grind ⇒] -lemma iff_models₀_box : M ⊧ₘ f (□A) ↔ M ⊧ₘ 𝔅 (f A) := by simp [Realization.interpret]; - -@[simp, grind ⇒] -lemma iff_models₀_boxItr {n : ℕ} : M ⊧ₘ f (□^[n] A) ↔ M ⊧ₘ 𝔅^[n] (f A) := by simp; - -end model - - -end interpret - -end Realization - -end LO.ProvabilityLogic diff --git a/Foundation/ProvabilityLogic/S/Completeness.lean b/Foundation/ProvabilityLogic/S/Completeness.lean deleted file mode 100644 index 406137836..000000000 --- a/Foundation/ProvabilityLogic/S/Completeness.lean +++ /dev/null @@ -1,193 +0,0 @@ -module - -public import Foundation.ProvabilityLogic.GL.Completeness -public import Foundation.ProvabilityLogic.S.Soundness -public import Foundation.FirstOrder.Incompleteness.Tarski - -@[expose] public section -noncomputable abbrev LO.Modal.Formula.rflSubformula [DecidableEq α] (φ : Formula α) : FormulaFinset α := - ((□⁻¹'φ.subformulas).image (λ ψ => □ψ 🡒 ψ)) - -namespace LO.ProvabilityLogic - -open Entailment -open Modal -open FirstOrder FirstOrder.ProvabilityAbstraction -open ArithmeticTheory (provabilityLogicOn) - -variable {T₀ T : ArithmeticTheory} [T₀ ⪯ T] [Diagonalization T₀] - {𝔅 : Provability T₀ T} [𝔅.HBL] [ℕ ⊧ₘ* T] [𝔅.SoundOn ℕ] - {A B : Formula ℕ} - -open Entailment FiniteContext -open Modal -open Modal.Kripke -open Modal.Formula.Kripke -open Arithmetic - -variable [T.Δ₁] [𝗜𝚺₁ ⪯ T] - -namespace SolovaySentences - -section - -omit [ℕ ⊧ₘ* T] - -variable {M₁ : Kripke.Model} [Fintype M₁.World] [M₁.IsIrreflexive] [M₁.IsTransitive] [M₁.IsRooted] {A : Formula _} - -lemma refl_mainlemma_aux (hA : ¬M₁.root.1 ⊧ (A.rflSubformula.conj 🡒 A)) : - let M₀ := M₁.extendRoot 1; - let S := SolovaySentences.standard T M₀.toFrame - ∀ B ∈ A.subformulas, - (M₁.root.1 ⊧ B → 𝗜𝚺₁ ⊢ (S M₀.root) 🡒 (S.realization B)) ∧ - (M₁.root.1 ⊭ B → 𝗜𝚺₁ ⊢ (S M₀.root) 🡒 ∼(S.realization B)) := by - intro M₀ S B B_sub; - - replace hA := Formula.Kripke.Satisfies.imp_def.not.mp hA; - push Not at hA; - obtain ⟨hA₁, hA₂⟩ := hA; - replace hA₁ : ∀ φ ∈ A.rflSubformula, M₁.root.1 ⊧ φ := by - intro φ hφ; - apply Model.extendRoot.inr_satisfies_iff.mp - $ (Satisfies.fconj_def.mp - $ Model.extendRoot.inr_satisfies_iff (n := 1) |>.mpr hA₁) φ hφ; - - induction B with - | hfalsum => simp [Realization.interpret]; - | himp B C ihB ihC => - replace ihB := ihB (by grind); - replace ihC := ihC (by grind); - dsimp [Realization.interpret]; - constructor; - . intro h; - rcases Satisfies.imp_def₂.mp h with (hA | hB); - . exact C!_trans (ihB.2 hA) CNC!; - . exact C!_trans (ihC.1 hB) implyK!; - . intro h; - have := Satisfies.imp_def.not.mp h; - push Not at this; - obtain ⟨hA, hB⟩ := this; - have h₁ := ihB.1 hA; - have h₂ := ihC.2 hB; - cl_prover [h₁, h₂]; - | hatom => - constructor; - . intro h; - apply right_Fdisj'!_intro; - simpa; - . intro h; - apply CN!_of_CN!_right; - apply left_Fdisj'!_intro; - intro i hi; - apply S.SC1; - by_contra hC; subst hC; - apply h; - simpa using hi; - | hbox B ihB => - simp only [Realization.interpret]; - constructor; - . intro h; - apply C!_of_conseq!; - apply T.standardProvability.D1; - apply Entailment.WeakerThan.pbl (𝓢 := 𝗜𝚺₁); - have : 𝗜𝚺₁ ⊢ ((⩖ j, S j)) 🡒 S.realization B := by - apply left_Fdisj'!_intro; - have hrfl : M₁.root.1 ⊧ □B 🡒 B := by - apply hA₁; - simp [Formula.rflSubformula, Finset.LO.preboxItr]; - grind; - rintro (i | i) _; - . suffices 𝗜𝚺₁ ⊢ S (M₀.root) 🡒 S.realization B by - simpa [M₀, Frame.root, default] using this; - apply ihB (by grind) |>.1; - exact hrfl h; - . by_cases e : i = M₁.root.1; - . rw [e]; - apply S.mainlemma (i := M₁.root.1) (by simp); - exact Model.extendRoot.inr_satisfies_iff (n := 1) |>.mpr $ hrfl h; - . apply S.mainlemma (i := i) (by simp); - apply Model.extendRoot.inr_satisfies_iff (n := 1) |>.mpr; - apply h; - grind; - have b : 𝗜𝚺₁ ⊢ ⩖ j, S j := provable_of_models _ _ fun (V : Type) _ _ ↦ by - simpa [models_iff, S, SolovaySentences.standard_σ_def] using FirstOrder.Arithmetic.Bootstrapping.SolovaySentences.disjunctive - exact this ⨀ b - . intro h; - have := Satisfies.box_def.not.mp h; - push Not at this; - obtain ⟨i, Rij, hA⟩ := this; - have : 𝗜𝚺₁ ⊢ S (Sum.inr i) 🡒 ∼S.realization B := S.mainlemma_neg (A := B) (i := i) (by simp) - <| Model.extendRoot.inr_satisfies_iff (n := 1) |>.not.mpr hA; - have : 𝗜𝚺₁ ⊢ ∼T.standardProvability (∼S (Sum.inr i)) 🡒 ∼T.standardProvability (S.realization B) := - contra! - $ T.standardProvability.mono' - $ CN!_of_CN!_right $ this; - refine C!_trans ?_ this; - apply S.SC2; - grind; - -lemma rfl_mainlemma (hA : ¬M₁.root.1 ⊧ (A.rflSubformula.conj 🡒 A)) : - letI M₀ := M₁.extendRoot 1 - letI S := SolovaySentences.standard T M₀.toFrame - ∀ B ∈ A.subformulas, M₁.root.1 ⊧ B → 𝗜𝚺₁ ⊢ (S M₀.root) 🡒 (S.realization B) := fun B B_sub => (refl_mainlemma_aux hA B B_sub).1 - -lemma rfl_mainlemma_neg (hA : ¬M₁.root.1 ⊧ (A.rflSubformula.conj 🡒 A)) : - letI M₀ := M₁.extendRoot 1 - letI S := SolovaySentences.standard T M₀.toFrame - ∀ B ∈ A.subformulas, ¬(M₁.root.1 ⊧ B) → 𝗜𝚺₁ ⊢ (S M₀.root) 🡒 ∼(S.realization B) := λ B B_sub => (refl_mainlemma_aux hA B B_sub).2 - -end - -end SolovaySentences - - -lemma GL_S_TFAE : - [ - Modal.GL ⊢ (A.rflSubformula.conj 🡒 A), - Modal.S ⊢ A, - ∀ f : T.StandardRealization, ℕ ⊧ₘ (f A) - ].TFAE := by - tfae_have 1 → 2 := by - intro h; - have h : Modal.S ⊢ Finset.conj A.rflSubformula 🡒 A := WeakerThan.pbl h; - apply h ⨀ ?_; - apply FConj!_iff_forall_provable.mpr; - simp - tfae_have 2 → 3 := by - intro h f; - have : 𝗥₀ ⪯ 𝗜𝚺₁ := inferInstance - have : 𝗥₀ ⪯ T := WeakerThan.trans this inferInstance - apply S.arithmetical_soundness; - exact h; - tfae_have 3 → 1 := by - have : ℕ ⊧ₘ* 𝗜𝚺₁ := models_of_subtheory (U := 𝗜𝚺₁) (T := T) (M := ℕ) inferInstance; - - contrapose; - push Not; - intro hA; - obtain ⟨M₁, _, _, _, _, hA⟩ := GL.Kripke.iff_unprovable_exists_fintype_rooted_model.mp hA; - - let M₀ := Model.extendRoot M₁ 1; - have : Fintype M₀.World := Fintype.ofFinite _ - let S := SolovaySentences.standard T M₀.toFrame - use S.realization; - - have := Formula.Kripke.Satisfies.not_imp_def.mp hA |>.2; - have : ℕ ⊧ₘ S M₀.root 🡒 ∼S.realization A := models_of_provable inferInstance $ by - show 𝗜𝚺₁ ⊢ S M₀.root 🡒 ∼S.realization A; - convert SolovaySentences.rfl_mainlemma_neg (T := T) hA A (by grind) $ Formula.Kripke.Satisfies.not_imp_def.mp hA |>.2; - simp only [Models, LO.Semantics.Not.models_not, LO.Semantics.Imp.models_imply] at this; - exact this <| by - simpa [models_iff, S, SolovaySentences.standard_σ_def] using FirstOrder.Arithmetic.Bootstrapping.SolovaySentences.solovay_root_sound - tfae_finish; - -theorem S.arithmetical_completeness_iff : Modal.S ⊢ A ↔ ∀ f : T.StandardRealization, ℕ ⊧ₘ f A := GL_S_TFAE.out 1 2 - -theorem provabilityLogic_PA_TA_eq_S : (T.provabilityLogicOn 𝗧𝗔) ≊ Modal.S := by - apply Logic.iff_equal_provable_equiv.mp - ext A; - simpa [Logic.iff_provable, provabilityLogicOn, TA.provable_iff] using S.arithmetical_completeness_iff.symm - -instance : (𝗣𝗔.provabilityLogicOn 𝗧𝗔) ≊ Modal.S := provabilityLogic_PA_TA_eq_S - -end LO.ProvabilityLogic diff --git a/Foundation/ProvabilityLogic/S/Soundness.lean b/Foundation/ProvabilityLogic/S/Soundness.lean deleted file mode 100644 index 3c708c9aa..000000000 --- a/Foundation/ProvabilityLogic/S/Soundness.lean +++ /dev/null @@ -1,32 +0,0 @@ -module - -public import Foundation.Modal.Logic.S.Basic -public import Foundation.ProvabilityLogic.GL.Soundness - -@[expose] public section -namespace LO.ProvabilityLogic - -open Entailment -open Modal -open FirstOrder -open FirstOrder.ProvabilityAbstraction - -variable {T₀ T : FirstOrder.Theory ℒₒᵣ} [T₀ ⪯ T] [Diagonalization T₀] - {𝔅 : Provability T₀ T} [𝔅.HBL] [ℕ ⊧ₘ* T] [𝔅.SoundOn ℕ] - {A B : Formula ℕ} - -theorem S.arithmetical_soundness (h : Modal.S ⊢ A) (f : Realization 𝔅) : ℕ ⊧ₘ f A := by - induction h using S.rec' with - | mem_GL h => - exact models_of_provable inferInstance (GL.arithmetical_soundness h); - | axiomT => - simp only [Realization.interpret, Models, LO.Semantics.Imp.models_imply]; - intro h; - exact models_of_provable inferInstance (𝔅.sound_on h) - | mdp ihAB ihA => - simp only [Realization.interpret, Models, LO.Semantics.Imp.models_imply] at ihAB; - apply ihAB ihA; - -end ProvabilityLogic - -end LO diff --git a/Foundation/ProvabilityLogic/SolovaySentences.lean b/Foundation/ProvabilityLogic/SolovaySentences.lean deleted file mode 100644 index 25a1c8734..000000000 --- a/Foundation/ProvabilityLogic/SolovaySentences.lean +++ /dev/null @@ -1,539 +0,0 @@ -module - -public import Foundation.Modal.Kripke.Rank -public import Foundation.ProvabilityLogic.GL.Soundness -public import Foundation.Vorspiel.List.ChainI - -/-! -# Basic propaties of Solovay sentences and its construction --/ - -@[expose] public section - -open Classical - -noncomputable section - -namespace LO.ProvabilityLogic - -open Entailment Entailment.FiniteContext -open FirstOrder -open FirstOrder.ProvabilityAbstraction -open Modal -open Modal.Kripke -open Modal.Formula.Kripke - -variable {L : Language} [L.DecidableEq] [L.ReferenceableBy L] - {T₀ T : Theory L} [T₀ ⪯ T] (𝔅 : Provability T₀ T) [𝔅.Mono] - {A B : Modal.Formula _} - -structure SolovaySentences (F : Kripke.Frame) [F.IsRooted] [Fintype F] where - σ : F → Sentence L - protected SC1 : ∀ i j, i ≠ j → T₀ ⊢ σ i 🡒 ∼σ j - protected SC2 : ∀ i j, i ≺ j → T₀ ⊢ σ i 🡒 𝔅.dia (σ j) - protected SC3 : ∀ i : F.World, F.root ≠ i → T₀ ⊢ σ i 🡒 𝔅 (⩖ j ∈ { j : F | i ≺ j }, σ j) - protected SC4 : T₀ ⊢ ⩖ j, σ j - -attribute [coe] SolovaySentences.σ - -variable {𝔅} - -namespace SolovaySentences - -instance {F : Kripke.Frame} [F.IsRooted] [Fintype F] : CoeFun (SolovaySentences 𝔅 F) (λ _ => F → Sentence L) := ⟨λ σ => σ.σ⟩ - -variable {M : Model} [M.IsRooted] [Fintype M] [M.IsIrreflexive] [M.IsTransitive] - (S : SolovaySentences 𝔅 M.toFrame) - -noncomputable def realization : Realization 𝔅 := ⟨fun a ↦ ⩖ i ∈ { i : M | i ⊧ (.atom a) }, S i⟩ - -private lemma mainlemma_aux {i : M} (hri : M.root ≠ i) : - (i ⊧ A → T₀ ⊢ S i 🡒 S.realization A) ∧ - (i ⊭ A → T₀ ⊢ S i 🡒 ∼S.realization A) := by - induction A generalizing i with - | hfalsum => simp [Realization.interpret, Semantics.Models, Satisfies]; - | hatom a => - constructor; - . intro h; - apply right_Fdisj'!_intro; - simpa using h; - . intro h; - apply CN!_of_CN!_right; - apply left_Fdisj'!_intro; - intro i hi; - apply S.SC1; - by_contra hC; subst hC; - apply h; - simpa using hi; - | himp A B ihA ihB => - simp only [Realization.interpret, Semantics.Imp.models_imply, Semantics.NotModels, Classical.not_imp, and_imp]; - constructor; - . intro h; - rcases Satisfies.imp_def₂.mp h with (hA | hB); - . exact C!_trans ((ihA hri).2 hA) CNC!; - . exact C!_trans ((ihB hri).1 hB) implyK!; - . intro hA hB; - exact not_imply_prem''! ((ihA hri).1 hA) ((ihB hri).2 hB); - | hbox A ihA => - simp only [Realization.interpret]; - constructor; - . intro h; - apply C!_trans $ S.SC3 i $ (by grind); - apply 𝔅.mono'; - apply left_Fdisj'!_intro; - rintro j Rij; - replace Rij : i ≺ j := by simpa using Rij - exact (ihA (by grind)).1 (h j Rij) - . intro h; - have := Satisfies.box_def.not.mp h; - push Not at this; - obtain ⟨j, Rij, hA⟩ := this; - have := CN!_of_CN!_right $ (ihA (by grind)).2 hA - have : T₀ ⊢ ∼𝔅 (∼S.σ j) 🡒 ∼𝔅 (S.realization A) := - contra! $ 𝔅.mono' $ CN!_of_CN!_right $ (ihA (by grind)).2 hA; - exact C!_trans (S.SC2 i j Rij) this; - -theorem mainlemma (S : SolovaySentences 𝔅 M.toFrame) {i : M} (hri : M.root ≠ i) : - i ⊧ A → T₀ ⊢ S i 🡒 S.realization A := (mainlemma_aux S hri).1 - -theorem mainlemma_neg (S : SolovaySentences 𝔅 M.toFrame) {i : M} (hri : M.root ≠ i) : - i ⊭ A → T₀ ⊢ S i 🡒 ∼S.realization A := (mainlemma_aux S hri).2 - -lemma root_of_iterated_inconsistency : T₀ ⊢ ∼𝔅^[M.height] ⊥ 🡒 S M.root := by - suffices T₀ ⊢ (⩖ j, S j) 🡒 ∼S M.root 🡒 𝔅^[M.height] ⊥ by cl_prover [this, S.SC4] - apply Entailment.left_Udisj!_intro - intro i - by_cases hir : i = M.root - · rcases hir - cl_prover - · have : T₀ ⊢ S.σ i 🡒 (↑𝔅)^[M.height] ⊥ := by - simpa using - S.mainlemma (by grind) (A := □^[M.height] ⊥) - <| height_lt_iff_satisfies_boxbot.mp - <| Frame.rank_lt_whole_height (by grind) - cl_prover [this]; - -lemma theory_height (hSound : ∀ {σ}, T₀ ⊢ 𝔅 σ → T ⊢ σ) (h : M.root.1 ⊧ ◇(∼A)) (b : T ⊢ S.realization A) : 𝔅.height < M.height := by - apply 𝔅.height_lt_pos_of_boxBot hSound (n := M.height) (by simpa using height_pos_of_dia h) - have : ∃ i : M, M.root ≺ i ∧ i ⊭ A := Formula.Kripke.Satisfies.dia_def.mp h - rcases this with ⟨i, hi, hiA⟩ - have b₀ : T₀ ⊢ 𝔅 (S.realization A) := 𝔅.D1 b - have b₁ : T₀ ⊢ ∼(↑𝔅)^[M.height] ⊥ 🡒 S M.root := S.root_of_iterated_inconsistency - have b₂ : T₀ ⊢ S M.root 🡒 𝔅.dia (S i) := S.SC2 M.root i (by grind) - have b₃ : T₀ ⊢ 𝔅.dia (S i) 🡒 ∼𝔅 (S.realization A) := by - simpa [Provability.dia] using 𝔅.dia_mono <| WeakerThan.pbl <| S.mainlemma_neg (by grind) hiA - cl_prover [b₀, b₁, b₂, b₃] - -end SolovaySentences - -end LO.ProvabilityLogic - -namespace LO.FirstOrder.Arithmetic.Bootstrapping - -namespace SolovaySentences - -open Modal ProvabilityLogic Kripke - -variable {T : ArithmeticTheory} [T.Δ₁] - -section frame - -variable {F : Kripke.Frame} [Fintype F] [F.IsIrreflexive] [F.IsTransitive] [F.IsRooted] - -section model - -variable (T) {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] - -def NegativeSuccessor (φ ψ : V) : Prop := T.ProvabilityComparisonLE (neg ℒₒᵣ φ) (neg ℒₒᵣ ψ) - -lemma NegativeSuccessor.quote_iff_provabilityComparisonLE {φ ψ : Sentence ℒₒᵣ} : - NegativeSuccessor (V := V) T ⌜φ⌝ ⌜ψ⌝ ↔ T.ProvabilityComparisonLE (V := V) ⌜∼φ⌝ ⌜∼ψ⌝ := by - simp [NegativeSuccessor, Sentence.quote_def, Semiformula.quote_def] - -section - -def negativeSuccessor : 𝚺₁.Semisentence 2 := .mkSigma - “φ ψ. ∃ nφ, ∃ nψ, !(negGraph ℒₒᵣ) nφ φ ∧ !(negGraph ℒₒᵣ) nψ ψ ∧ !T.provabilityComparisonLE nφ nψ” - -instance negativeSuccessor_defined : 𝚺₁-Relation[V] NegativeSuccessor T via (negativeSuccessor T) := .mk fun v ↦ by - simp [negativeSuccessor, NegativeSuccessor] - -instance negativeSuccessor_definable : 𝚺₁-Relation (NegativeSuccessor T : V → V → Prop) := (negativeSuccessor_defined T).to_definable - -/-- instance for definability tactic-/ -instance negativeSuccessor_definable' : 𝚺-[0 + 1]-Relation (NegativeSuccessor T : V → V → Prop) := (negativeSuccessor_defined T).to_definable - -end - -end model - -section stx - -variable (T) - -abbrev WChain (i j : F) := {l : List F // l.ChainI (· ≻ ·) j i} - -instance (i j : F) [F.IsIrreflexive] [F.IsTransitive] : Finite (WChain j i) := - List.ChainI.finite_of_irreflexive_of_transitive - (by exact Std.Irrefl.irrefl (r := (· ≺ ·))) - (by intro x y z hxy hyz - exact IsTrans.trans (r := (· ≺ ·)) z y x hyz hxy) - i j - -def twoPointAux (t : F → FirstOrder.Semiterm ℒₒᵣ Empty N) (i j : F) : Semisentence ℒₒᵣ N := - ⩕ k ∈ { k : F | i ≺ k }, (negativeSuccessor T)/[t j, t k] - -def θChainAux (t : F → FirstOrder.Semiterm ℒₒᵣ Empty N) : List F → Semisentence ℒₒᵣ N - | [] => ⊥ - | [_] => ⊤ - | j :: i :: ε => θChainAux t (i :: ε) ⋏ twoPointAux T t i j - -omit [F.IsIrreflexive] [F.IsTransitive] [F.IsRooted] in -lemma rew_twoPointAux (w : Fin N → FirstOrder.Semiterm ℒₒᵣ Empty N') (t : F → FirstOrder.Semiterm ℒₒᵣ Empty N) : - Rew.subst w ▹ twoPointAux T t i j = twoPointAux T (fun i ↦ Rew.subst w (t i)) i j := by - simp [twoPointAux, Finset.map_conj', Function.comp_def, ←TransitiveRewriting.comp_app, - Rew.subst_comp_subst, Matrix.comp_vecCons', Matrix.constant_eq_singleton] - -omit [F.IsIrreflexive] [F.IsTransitive] [F.IsRooted] in -lemma rew_θChainAux (w : Fin N → FirstOrder.Semiterm ℒₒᵣ Empty N') (t : F → FirstOrder.Semiterm ℒₒᵣ Empty N) (ε : List F) : - Rew.subst w ▹ θChainAux T t ε = θChainAux T (fun i ↦ Rew.subst w (t i)) ε := by - match ε with - | [] => simp [θChainAux] - | [_] => simp [θChainAux] - | j :: i :: ε => simp [θChainAux, rew_θChainAux w _ (i :: ε), rew_twoPointAux] - -def θAux [F.IsIrreflexive] [F.IsTransitive] [F.IsRooted] (t : F → FirstOrder.Semiterm ℒₒᵣ Empty N) (i : F) : Semisentence ℒₒᵣ N := - haveI := Fintype.ofFinite (WChain F.root i); - ⩖ ε : WChain F.root i, θChainAux T t ε - -lemma rew_θAux (w : Fin N → FirstOrder.Semiterm ℒₒᵣ Empty N') (t : F → FirstOrder.Semiterm ℒₒᵣ Empty N) (i : F) : - Rew.subst w ▹ θAux T t i = θAux T (fun i ↦ Rew.subst w (t i)) i := by - simp [Finset.map_udisj, θAux, rew_θChainAux] - -def _root_.LO.FirstOrder.Theory.solovay [F.IsIrreflexive] [F.IsTransitive] (i : F) : Sentence ℒₒᵣ := exclusiveMultifixedpoint - (fun j ↦ - let jj := (Fintype.equivFin F).symm j - θAux T (fun i ↦ #(Fintype.equivFin F i)) jj ⋏ ⩕ k ∈ { k : F | jj ≺ k }, T.consistentWith/[#(Fintype.equivFin F k)]) - (Fintype.equivFin F i) - -def twoPoint (i j : F) : Sentence ℒₒᵣ := twoPointAux T (fun i ↦ ⌜T.solovay i⌝) i j - -def θChain (ε : List F) : Sentence ℒₒᵣ := θChainAux T (fun i ↦ ⌜T.solovay i⌝) ε - -def θ (i : F) : Sentence ℒₒᵣ := θAux T (fun i ↦ ⌜T.solovay i⌝) i - -lemma solovay_diag (i : F) : - 𝗜𝚺₁ ⊢ T.solovay i 🡘 θ T i ⋏ ⩕ j ∈ { j : F | i ≺ j }, T.consistentWith/[⌜T.solovay j⌝] := by - have : 𝗜𝚺₁ ⊢ T.solovay i 🡘 - (Rew.subst fun j ↦ ⌜T.solovay ((Fintype.equivFin F).symm j)⌝) ▹ - (θAux T (fun i ↦ #(Fintype.equivFin F i)) i ⋏ ⩕ k ∈ { k : F | i ≺ k }, T.consistentWith/[#(Fintype.equivFin F k)]) := by - simpa [Theory.solovay, Matrix.comp_vecCons', Matrix.constant_eq_singleton] using - exclusiveMultidiagonal (T := 𝗜𝚺₁) (i := Fintype.equivFin F i) - (fun j ↦ - let jj := (Fintype.equivFin F).symm j - θAux T (fun i ↦ #(Fintype.equivFin F i)) jj ⋏ ⩕ k ∈ { k : F | jj ≺ k }, T.consistentWith/[#(Fintype.equivFin F k)]) - simpa [θ, Finset.map_conj', Function.comp_def, rew_θAux, ←TransitiveRewriting.comp_app, - Rew.subst_comp_subst, Matrix.comp_vecCons', Matrix.constant_eq_singleton] using this - -@[simp] lemma solovay_exclusive {i j : F} : T.solovay i = T.solovay j ↔ i = j := by simp [Theory.solovay] - -omit [F.IsIrreflexive] [F.IsTransitive] [F.IsRooted] in -private lemma θChainAux_sigma1 (ε : List F) : Hierarchy 𝚺 1 (θChainAux T t ε) := by - match ε with - | [] => simp [θChainAux] - | [_] => simp [θChainAux] - | _ :: i :: ε => - simp [θChainAux, twoPointAux, θChainAux_sigma1 (i :: ε)] - -@[simp] lemma θ_sigma1 (i : F) : Hierarchy 𝚺 1 (θ T i) := by - simp [θ, θAux, θChainAux_sigma1] - -end stx - -section model - -variable (T) - -variable {V : Type*} [ORingStructure V] [V ⊧ₘ* 𝗜𝚺₁] - -open Modal ProvabilityLogic Kripke - -@[simp] lemma val_twoPoint (i j : F) : - V ⊧/![] (twoPoint T i j) ↔ ∀ k, i ≺ k → NegativeSuccessor (V := V) T ⌜T.solovay j⌝ ⌜T.solovay k⌝ := by - simp [twoPoint, twoPointAux] - -variable (V) - -inductive ΘChain : List F → Prop where - | singleton (i : F) : ΘChain [i] - | cons {i j : F} : - (∀ k, i ≺ k → NegativeSuccessor (V := V) T ⌜T.solovay j⌝ ⌜T.solovay k⌝) → ΘChain (i :: ε) → ΘChain (j :: i :: ε) - -def Θ (i : F) : Prop := ∃ ε : List F, ε.ChainI (· ≻ ·) i F.root ∧ ΘChain T V ε - -def _root_.LO.FirstOrder.Theory.Solovay (i : F) := Θ T V i ∧ ∀ j, i ≺ j → T.ConsistentWith (⌜T.solovay j⌝ : V) - -variable {T V} - -attribute [simp] ΘChain.singleton - -@[simp] lemma ΘChain.not_nil : ¬ΘChain T V ([] : List F) := by rintro ⟨⟩ - -lemma ΘChain.doubleton_iff {i j : F} : - ΘChain T V [j, i] ↔ (∀ k, i ≺ k → NegativeSuccessor (V := V) T ⌜T.solovay j⌝ ⌜T.solovay k⌝) := by - constructor - · rintro ⟨⟩; simp_all - · rintro h; exact .cons h (by simp) - -lemma ΘChain.cons_cons_iff {i j : F} {ε} : - ΘChain T V (j :: i :: ε) ↔ - ΘChain T V (i :: ε) ∧ (∀ k, i ≺ k → NegativeSuccessor (V := V) T ⌜T.solovay j⌝ ⌜T.solovay k⌝) := by - constructor - · rintro ⟨⟩; simp_all - · rintro ⟨ih, h⟩; exact .cons h ih - -lemma ΘChain.cons_cons_iff' {i j : F} {ε} : - ΘChain T V (j :: i :: ε) ↔ ΘChain T V [j, i] ∧ ΘChain T V (i :: ε) := by - constructor - · rintro ⟨⟩; simpa [ΘChain.doubleton_iff, *] - · rintro ⟨ih, h⟩; exact h.cons (by rcases ih; assumption) - -lemma ΘChain.cons_of {m i j : F} {ε} - (hc : List.ChainI (· ≻ ·) i m ε) - (hΘ : ΘChain T V ε) - (H : (∀ k, i ≺ k → NegativeSuccessor (V := V) T ⌜T.solovay j⌝ ⌜T.solovay k⌝)) - (hij : i ≺ j) : - ΘChain T V (j :: ε) := by - rcases hc - case singleton => exact .cons H hΘ - case cons => exact .cons H hΘ - -section - -@[simp] lemma val_θChain (ε : List F) : V ⊧/![] (θChain T ε) ↔ ΘChain T V ε := by - unfold θChain θChainAux - match ε with - | [] => simp - | [i] => simp - | j :: i :: ε => - suffices - V ⊧/![] (θChain T (i :: ε)) ∧ V ⊧/![] (twoPoint T i j) ↔ - ΘChain T V (j :: i :: ε) by simpa [-val_twoPoint] using this - simp [ΘChain.cons_cons_iff, val_θChain (i :: ε)] - -@[simp] lemma val_θ {i : F} : V ⊧/![] (θ T i) ↔ Θ T V i := by - suffices (∃ ε, List.ChainI (· ≻ ·) i F.root ε ∧ V ⊧/![] (θChain T ε)) ↔ Θ T V i by - simpa [-val_θChain, θ, θAux] - simp [Θ] - -@[simp] lemma val_solovay {i : F} : V ⊧/![] (T.solovay i) ↔ T.Solovay V i := by - simpa [models_iff] using - consequence_iff.mp (sound! (solovay_diag T i)) V inferInstance - -end - -lemma ΘChain.append_iff {ε₁ ε₂ : List F} : ΘChain T V (ε₁ ++ i :: ε₂) ↔ ΘChain T V (ε₁ ++ [i]) ∧ ΘChain T V (i :: ε₂) := by - match ε₁ with - | [] => simp - | [x] => simp [ΘChain.cons_cons_iff' (ε := ε₂)] - | x :: y :: ε₁ => - have : ΘChain T V (y :: (ε₁ ++ i :: ε₂)) ↔ ΘChain T V (y :: (ε₁ ++ [i])) ∧ ΘChain T V (i :: ε₂) := - append_iff (ε₁ := y :: ε₁) (ε₂ := ε₂) (i := i) - simp [cons_cons_iff' (ε := ε₁ ++ i :: ε₂), cons_cons_iff' (ε := ε₁ ++ [i]), and_assoc, this] - -private lemma Solovay.exclusive.comparable {i₁ i₂ : F} {ε₁ ε₂ : List F} - (ne : i₁ ≠ i₂) - (h : ε₁ <:+ ε₂) - (Hi₁ : ∀ j, i₁ ≺ j → T.ConsistentWith (⌜T.solovay j⌝ : V)) - (cε₁ : List.ChainI (· ≻ ·) i₁ r ε₁) - (cε₂ : List.ChainI (· ≻ ·) i₂ r ε₂) - (Θε₂ : ΘChain T V ε₂) : False := by - have : ∃ a, a :: ε₁ <:+ ε₂ := by - rcases List.IsSuffix.eq_or_cons_suffix h with (e | h) - · have : ε₁ ≠ ε₂ := by - rintro rfl - have : i₁ = i₂ := (List.ChainI.eq_of cε₁ cε₂).1 - contradiction - contradiction - · exact h - rcases this with ⟨j, hj⟩ - have hji₁ε₂ : [j, i₁] <:+: ε₂ := by - rcases cε₁.tail_exists with ⟨ε₁', rfl⟩ - exact List.infix_iff_prefix_suffix.mpr ⟨j :: i₁ :: ε₁', by simp, hj⟩ - have hij₁ : i₁ ≺ j := cε₂.rel_of_infix j i₁ hji₁ε₂ - have : ¬T.Provable (⌜∼T.solovay j⌝ : V) := by simpa [Theory.ConsistentWith.quote_iff] using Hi₁ j hij₁ - have : T.Provable (⌜∼T.solovay j⌝ : V) := by - have : ΘChain T V [j, i₁] := by - rcases hji₁ε₂ with ⟨η₁, η₂, rfl⟩ - have Θε₂ : ΘChain T V (η₁ ++ j :: i₁ :: η₂) := by simpa using Θε₂ - exact ΘChain.cons_cons_iff'.mp (ΘChain.append_iff.mp Θε₂).2 |>.1 - have : ∀ k, i₁ ≺ k → T.ProvabilityComparisonLE (V := V) ⌜∼T.solovay j⌝ ⌜∼T.solovay k⌝ := by - simpa [NegativeSuccessor.quote_iff_provabilityComparisonLE] using ΘChain.cons_cons_iff.mp this - exact (ProvabilityComparison.iff_le_refl_provable (L := ℒₒᵣ)).mp (this j hij₁) - contradiction - -/-- Condition 1.-/ -lemma Solovay.exclusive {i₁ i₂ : F} (ne : i₁ ≠ i₂) : T.Solovay V i₁ → ¬T.Solovay V i₂ := by - intro S₁ S₂ - rcases S₁ with ⟨⟨ε₁, cε₁, Θε₁⟩, Hi₁⟩ - rcases S₂ with ⟨⟨ε₂, cε₂, Θε₂⟩, Hi₂⟩ - by_cases hε₁₂ : ε₁ <:+ ε₂ - · exact Solovay.exclusive.comparable ne hε₁₂ Hi₁ cε₁ cε₂ Θε₂ - by_cases hε₂₁ : ε₂ <:+ ε₁ - · exact Solovay.exclusive.comparable (Ne.symm ne) hε₂₁ Hi₂ cε₂ cε₁ Θε₁ - have : ∃ ε k j₁ j₂, j₁ ≠ j₂ ∧ j₁ :: k :: ε <:+ ε₁ ∧ j₂ :: k :: ε <:+ ε₂ := by - rcases List.suffix_trichotomy hε₁₂ hε₂₁ with ⟨ε', j₁, j₂, nej, h₁, h₂⟩ - match ε' with - | [] => - rcases show j₁ = F.root from List.single_suffix_uniq h₁ cε₁.prefix_suffix.2 - rcases show j₂ = F.root from List.single_suffix_uniq h₂ cε₂.prefix_suffix.2 - contradiction - | k :: ε => - exact ⟨ε, k, j₁, j₂, nej, h₁, h₂⟩ - rcases this with ⟨ε, k, j₁, j₂, nej, hj₁, hj₂⟩ - have C₁ : ΘChain T V [j₁, k] := by - rcases hj₁ with ⟨_, rfl⟩ - have : ΘChain T V ([j₁] ++ k :: ε) := (ΘChain.append_iff.mp Θε₁).2 - simpa using (ΘChain.append_iff.mp this).1 - have C₂ : ΘChain T V [j₂, k] := by - rcases hj₂ with ⟨_, rfl⟩ - have : ΘChain T V ([j₂] ++ k :: ε) := (ΘChain.append_iff.mp Θε₂).2 - simpa using (ΘChain.append_iff.mp this).1 - have P₁ : T.ProvabilityComparisonLE (V := V) ⌜∼T.solovay j₁⌝ ⌜∼T.solovay j₂⌝ := by - simpa [NegativeSuccessor.quote_iff_provabilityComparisonLE] using - ΘChain.doubleton_iff.mp C₁ j₂ - (cε₂.rel_of_infix _ _ <| List.infix_iff_prefix_suffix.mpr ⟨j₂ :: k :: ε, by simp, hj₂⟩) - have P₂ : T.ProvabilityComparisonLE (V := V) ⌜∼T.solovay j₂⌝ ⌜∼T.solovay j₁⌝ := by - simpa [NegativeSuccessor.quote_iff_provabilityComparisonLE] using - ΘChain.doubleton_iff.mp C₂ j₁ - (cε₁.rel_of_infix _ _ <| List.infix_iff_prefix_suffix.mpr ⟨j₁ :: k :: ε, by simp, hj₁⟩) - have : j₁ = j₂ := by simpa using ProvabilityComparison.le_antisymm (V := V) P₁ P₂ - contradiction - -/-- Condition 2.-/ -lemma Solovay.consistent {i j : F} (hij : i ≺ j) : T.Solovay V i → ¬T.Provable (⌜∼T.solovay j⌝ : V) := fun h ↦ - (Theory.ConsistentWith.quote_iff T).mp (h.2 j hij) - -lemma Solovay.refute (ne : F.root.1 ≠ i) : T.Solovay V i → T.Provable (⌜∼T.solovay i⌝ : V) := by - intro h - rcases show Θ T V i from h.1 with ⟨ε, hε, cε⟩ - rcases List.ChainI.prec_exists_of_ne hε (Ne.symm ne) with ⟨ε', i', hii', rfl, hε'⟩ - have : ∀ k, i' ≺ k → NegativeSuccessor T ⌜T.solovay i⌝ ⌜T.solovay k⌝ := (ΘChain.cons_cons_iff.mp cε).2 - have : T.ProvabilityComparisonLE (V := V) ⌜∼T.solovay i⌝ ⌜∼T.solovay i⌝ := by - simpa [NegativeSuccessor.quote_iff_provabilityComparisonLE] using this i hii' - exact (ProvabilityComparison.iff_le_refl_provable (T := T)).mp this - -lemma Θ.disjunction (i : F) : Θ T V i → T.Solovay V i ∨ ∃ j, i ≺ j ∧ T.Solovay V j := by - have : IsConverseWellFounded F (· ≺ ·) := inferInstance - apply WellFounded.induction this.cwf i - intro i ih hΘ - by_cases hS : T.Solovay V i - · left; exact hS - · right - have : ∃ j, i ≺ j ∧ ∀ k, i ≺ k → T.ProvabilityComparisonLE (V := V) ⌜∼T.solovay j⌝ ⌜∼T.solovay k⌝ := by - have : ∃ j, i ≺ j ∧ T.Provable (⌜∼T.solovay j⌝ : V) := by - have : Θ T V i → ∃ x, i ≺ x ∧ T.Provable (⌜∼T.solovay x⌝ : V) := by - simpa [Theory.ConsistentWith.quote_iff, Theory.Solovay] using hS - exact this hΘ - rcases this with ⟨j', hij', hj'⟩ - have := ProvabilityComparison.find_minimal_proof_fintype (T := T) (ι := {j : F // i ≺ j}) (i := ⟨j', hij'⟩) - (fun k ↦ ⌜∼T.solovay k.val⌝) (by simpa) - simpa using this - rcases this with ⟨j, hij, hj⟩ - have : Θ T V j := by - rcases hΘ with ⟨ε, hε, cε⟩ - exact ⟨ - j :: ε, - hε.cons hij, - cε.cons_of hε (by simpa [NegativeSuccessor.quote_iff_provabilityComparisonLE]) hij⟩ - have : T.Solovay V j ∨ ∃ k, j ≺ k ∧ T.Solovay V k := ih j hij this - rcases this with (hSj | ⟨k, hjk, hSk⟩) - · exact ⟨j, hij, hSj⟩ - · exact ⟨k, Trans.trans hij hjk, hSk⟩ - -/-- Condition 4.-/ -lemma disjunctive : ∃ i : F, T.Solovay V i := by - rcases Θ.disjunction (V := V) (T := T) F.root.1 ⟨[F.root], by simp⟩ with (H | ⟨i, _, H⟩); - . use F.root; - . use i; - -/-- Condition 3.-/ -lemma Solovay.box_disjunction [𝗜𝚺₁ ⪯ T] {i : F} (ne : F.root.1 ≠ i) : - T.Solovay V i → T.Provable (⌜⩖ j ∈ {j : F | i ≺ j}, T.solovay j⌝ : V) := by - intro hS - have TP : T.internalize V ⊢ ⌜θ T i 🡒 T.solovay i ⋎ ⩖ j ∈ {j : F | i ≺ j}, T.solovay j⌝ := - internal_provable_of_outer_provable <| by - have : 𝗜𝚺₁ ⊢ θ T i 🡒 T.solovay i ⋎ ⩖ j ∈ {j : F | i ≺ j}, T.solovay j := - provable_of_models _ _ fun (V : Type) _ _ ↦ by - simpa [models_iff] using Θ.disjunction i - exact Entailment.WeakerThan.pbl this - have Tθ : T.internalize V ⊢ ⌜θ T i⌝ := - Bootstrapping.Arithmetic.sigma_one_provable_of_models T (show Hierarchy 𝚺 1 (θ T i) by simp) (by simpa [models_iff] using hS.1) - have hP : T.internalize V ⊢ ⌜T.solovay i⌝ ⋎ ⌜⩖ j ∈ {j : F | i ≺ j}, T.solovay j⌝ := (by simpa using TP) ⨀ Tθ - have : T.internalize V ⊢ ∼⌜T.solovay i⌝ := by simpa using (tprovable_tquote_iff_provable_quote (T := T)).mpr (Solovay.refute ne hS) - have : T.internalize V ⊢ ⌜⩖ j ∈ {j : F | i ≺ j}, T.solovay j⌝ := Entailment.of_a!_of_n! hP this - exact (tprovable_tquote_iff_provable_quote (T := T)).mp this - -end model - -lemma solovay_root_sound [𝗜𝚺₁ ⪯ T] [sound : T.SoundOn (Hierarchy 𝚷 2)] : T.Solovay ℕ F.root.1 := by - have : 𝗜𝚺₁ ⪯ T := inferInstance - haveI : 𝗥₀ ⪯ T := Entailment.WeakerThan.trans inferInstance this - have NS : ∀ i, F.root.1 ≠ i → ¬T.Solovay ℕ i := by - intro i hi H - have Bi : T ⊢ ∼T.solovay i := (provable_iff_provable (T := T)).mp (Solovay.refute hi H) - have : ¬T.Solovay ℕ i := by - set π := θ T i ⋏ ⩕ j ∈ { j : F | i ≺ j }, T.consistentWith/[⌜T.solovay j⌝] - have sπ : 𝗜𝚺₁ ⊢ T.solovay i 🡘 π := solovay_diag T i - have : T ⊢ ∼π := by - have : T ⊢ T.solovay i 🡘 π := Entailment.WeakerThan.wk (inferInstanceAs (𝗜𝚺₁ ⪯ T)) sπ - exact Entailment.K!_left (Entailment.ENN!_of_E! this) ⨀ Bi - have : ¬ℕ ⊧/![] π := by - simpa [models_iff] using - sound.sound - (σ := ∼π) - this - (by simp [π, - (show Hierarchy 𝚷 1 T.consistentWith.val by simp).strict_mono 𝚺 (show 1 < 2 by simp), - (show Hierarchy 𝚺 1 (θ T i) by simp).mono (show 1 ≤ 2 by simp)]) - have : T.Solovay ℕ i ↔ ℕ ⊧/![] π := by - simpa [models_iff] using consequence_iff.mp (sound! sπ) ℕ inferInstance - simpa [this] - contradiction - have : T.Solovay ℕ F.root.1 ∨ ∃ j, F.root.1 ≺ j ∧ T.Solovay ℕ j := Θ.disjunction (V := ℕ) (T := T) F.root.1 ⟨[F.root], by simp⟩ - rcases this with (H | ⟨i, hri, Hi⟩) - · assumption - · have : ¬T.Solovay ℕ i := NS i (by rintro rfl; exact Std.Irrefl.irrefl F.root.1 hri) - contradiction - -lemma solovay_unprovable [𝗜𝚺₁ ⪯ T] [T.SoundOn (Hierarchy 𝚷 2)] {i : F} (h : F.root.1 ≠ i) : T ⊬ ∼T.solovay i := by - have : 𝗜𝚺₁ ⪯ T := inferInstance - haveI : 𝗥₀ ⪯ T := Entailment.WeakerThan.trans inferInstance this - have : ∼T.Provable ⌜∼T.solovay i⌝ := Solovay.consistent (by grind) solovay_root_sound; - simpa [Theory.ConsistentWith.quote_iff, provable_iff_provable] using this - -variable (T F) - -def _root_.LO.ProvabilityLogic.SolovaySentences.standard [𝗜𝚺₁ ⪯ T] : SolovaySentences T.standardProvability F where - σ := T.solovay - SC1 i j ne := - provable_of_models _ _ fun (V : Type) _ _ ↦ by - simpa [models_iff] using Solovay.exclusive ne - SC2 i j h := - provable_of_models _ _ fun (V : Type) _ _ ↦ by - simpa [models_iff, standardProvability_def] using Solovay.consistent h - SC3 i h := - provable_of_models _ _ fun (V : Type) _ _ ↦ by - simpa [models_iff, standardProvability_def] using Solovay.box_disjunction h - SC4 := - provable_of_models _ _ fun (V : Type) _ _ ↦ by - simpa [models_iff] using disjunctive - -lemma _root_.LO.ProvabilityLogic.SolovaySentences.standard_σ_def [𝗜𝚺₁ ⪯ T] : - (SolovaySentences.standard T F).σ = T.solovay := rfl - -end frame - -end SolovaySentences - -end LO.FirstOrder.Arithmetic.Bootstrapping From d81b1482fadc113e80c916c0020bd6eb4871eb6f Mon Sep 17 00:00:00 2001 From: SnO2WMaN Date: Thu, 2 Jul 2026 20:02:09 +0900 Subject: [PATCH 56/61] chore: remove ProvabilityLogic/Classification (moved out in separate work) Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01S1wqPfbHabyo2rsKAtJm9g --- Foundation.lean | 3 - .../Classification/LetterlessTrace.lean | 1097 ----------------- .../Classification/Result.lean | 288 ----- .../Classification/Trace.lean | 671 ---------- 4 files changed, 2059 deletions(-) delete mode 100644 Foundation/ProvabilityLogic/Classification/LetterlessTrace.lean delete mode 100644 Foundation/ProvabilityLogic/Classification/Result.lean delete mode 100644 Foundation/ProvabilityLogic/Classification/Trace.lean diff --git a/Foundation.lean b/Foundation.lean index 82e224aff..2ec306e05 100644 --- a/Foundation.lean +++ b/Foundation.lean @@ -462,9 +462,6 @@ public import Foundation.Propositional.Slash public import Foundation.Propositional.Tait.Calculus public import Foundation.Propositional.Translation public import Foundation.ProvabilityLogic.Arithmetic -public import Foundation.ProvabilityLogic.Classification.LetterlessTrace -public import Foundation.ProvabilityLogic.Classification.Result -public import Foundation.ProvabilityLogic.Classification.Trace public import Foundation.ProvabilityLogic.GL.Completeness public import Foundation.ProvabilityLogic.GL.Soundness public import Foundation.ProvabilityLogic.GL.Uniform diff --git a/Foundation/ProvabilityLogic/Classification/LetterlessTrace.lean b/Foundation/ProvabilityLogic/Classification/LetterlessTrace.lean deleted file mode 100644 index eee74cce5..000000000 --- a/Foundation/ProvabilityLogic/Classification/LetterlessTrace.lean +++ /dev/null @@ -1,1097 +0,0 @@ -module - -public import Foundation.Modal.Logic.S.Basic -public import Foundation.ProvabilityLogic.GL.Uniform -public import Foundation.Vorspiel.Set.Cofinite - -@[expose] public section - -namespace LO - -open FirstOrder FirstOrder.ProvabilityAbstraction -open ProvabilityLogic - -variable {φ ψ : Modal.Formula ℕ} - {X Y : Modal.FormulaSet ℕ} - {T : ArithmeticTheory} [T.Δ₁] - -namespace Modal - -/-- letterlessSpectrum for letterless formula -/ -def Formula.letterlessSpectrum (φ : Formula ℕ) (φ_closed : φ.Letterless := by grind) : Set ℕ := - match φ with - | ⊥ => ∅ - | φ 🡒 ψ => (φ.letterlessSpectrum)ᶜ ∪ ψ.letterlessSpectrum - | □φ => { n | ∀ i < n, i ∈ φ.letterlessSpectrum } - - -namespace Formula.letterlessSpectrum - --- variable {hφ : φ.Letterless}{hψ : ψ.Letterless} - -@[simp, grind =] lemma def_bot : (⊥ : Formula _).letterlessSpectrum = ∅ := by simp [letterlessSpectrum] -@[simp, grind =] lemma def_top : (⊤ : Formula _).letterlessSpectrum = Set.univ := by simp [letterlessSpectrum] -@[grind =] lemma def_imp {hφψ : Letterless (φ 🡒 ψ)} : (φ 🡒 ψ).letterlessSpectrum hφψ = φ.letterlessSpectrumᶜ ∪ ψ.letterlessSpectrum := by simp [letterlessSpectrum] -@[grind =] lemma def_neg {hφ : Letterless (∼φ)} : (∼φ).letterlessSpectrum hφ = φ.letterlessSpectrumᶜ := by simp [letterlessSpectrum] -@[grind =] lemma def_or {hφψ : Letterless (φ ⋎ ψ)} : (φ ⋎ ψ).letterlessSpectrum hφψ = φ.letterlessSpectrum ∪ ψ.letterlessSpectrum := by simp [letterlessSpectrum]; -@[grind =] lemma def_and {hφψ : Letterless (φ ⋏ ψ)} : (φ ⋏ ψ).letterlessSpectrum hφψ = φ.letterlessSpectrum ∩ ψ.letterlessSpectrum := by simp [letterlessSpectrum]; -@[grind =] lemma def_box {hφ : Letterless (□φ)} : (□φ).letterlessSpectrum hφ = { n | ∀ i < n, i ∈ φ.letterlessSpectrum } := by simp [letterlessSpectrum]; -@[grind =] lemma def_boxItr {n} {hφ : Letterless (□^[(n + 1)]φ)} : (□^[(n + 1)]φ).letterlessSpectrum hφ = { k | ∀ i < k, i ∈ (□^[n]φ).letterlessSpectrum } := by - apply Eq.trans ?_ $ def_box (φ := □^[n]φ); - . grind; - . induction n generalizing φ with - | zero => grind; - | succ n ih => - suffices (□^[n](□□φ)).letterlessSpectrum = (□□^[n](□φ)).letterlessSpectrum by grind; - simpa using @ih (φ := □φ) (by grind); -@[grind =] lemma def_boxdot {hφ : Letterless (⊡φ)} : (⊡φ).letterlessSpectrum hφ = { n | ∀ i ≤ n, i ∈ φ.letterlessSpectrum } := by - ext i; - suffices (i ∈ φ.letterlessSpectrum ∧ ∀ j < i, j ∈ φ.letterlessSpectrum) ↔ ∀ j ≤ i, j ∈ φ.letterlessSpectrum by simpa [letterlessSpectrum]; - constructor; - . rintro ⟨h₁, h₂⟩ j hj; - rcases Nat.le_iff_lt_or_eq.mp hj with (h | rfl); - . apply h₂; - assumption; - . assumption; - . intro h; - constructor; - . apply h; omega; - . intro j hj; - apply h; - omega; - -lemma def_lconj₂ {l : List (Formula ℕ)} (h : (l.conj₂).Letterless) : (l.conj₂).letterlessSpectrum = ⋂ φ ∈ l, φ.letterlessSpectrum := by - induction l using List.induction_with_singleton with - | hcons a l he ih => - suffices (a ⋏ ⋀l).letterlessSpectrum = ⋂ φ, ⋂ (_ : φ ∈ a :: l), φ.letterlessSpectrum by - convert this; - exact List.conj₂_cons_nonempty he; - rw [def_and]; - simp [ih (by grind)]; - | _ => simp; - -lemma def_lconj' {l : List β} {Φ : β → Formula ℕ} (h : (l.conj' Φ).Letterless) : (l.conj' Φ).letterlessSpectrum = ⋂ i ∈ l, (Φ i).letterlessSpectrum := by - induction l using List.induction_with_singleton with - | hcons a l he ih => - suffices (Φ a ⋏ (List.conj' Φ l)).letterlessSpectrum = ⋂ i, ⋂ (_ : i ∈ a :: l), (Φ i).letterlessSpectrum by - convert this; - exact List.conj₂_cons_nonempty (a := Φ a) (as := List.map Φ l) (by simpa); - rw [def_and]; - simp [ih (by grind)]; - | _ => simp; - -lemma def_fconj {s : Finset (Formula _)} (h : (s.conj).Letterless) : (s.conj.letterlessSpectrum) = ⋂ φ ∈ s, φ.letterlessSpectrum := by - unfold Finset.conj; - rw [def_lconj₂]; - . simp; - . simpa; - -lemma def_fconj' {s} {Φ : α → Formula ℕ} (hΦ : ((⩕ i ∈ s, Φ i)).Letterless) : (⩕ i ∈ s, Φ i).letterlessSpectrum = ⋂ i ∈ s, (Φ i).letterlessSpectrum (by apply letterless_fconj'.mp hΦ _; assumption;) := by - unfold Finset.conj'; - rw [def_lconj']; - . simp; - . simpa; - -end Formula.letterlessSpectrum - - -/-- letterlessTrace for letterless formula -/ -@[grind] def Formula.letterlessTrace (φ : Formula ℕ) (φ_closed : φ.Letterless := by grind) := (φ.letterlessSpectrum)ᶜ - -namespace Formula.letterlessTrace - -variable {φ ψ : Formula ℕ} {hφ : φ.Letterless} {hψ : ψ.Letterless} - -@[simp, grind =] lemma def_top : (⊤ : Formula _).letterlessTrace = ∅ := by grind; -@[simp, grind =] lemma def_bot : (⊥ : Formula _).letterlessTrace = Set.univ := by grind; -@[grind =] lemma def_neg : (∼φ).letterlessTrace = φ.letterlessTraceᶜ := by grind; -@[grind =] lemma def_and : (φ ⋏ ψ).letterlessTrace = φ.letterlessTrace ∪ ψ.letterlessTrace := by grind; -@[grind =] lemma def_or : (φ ⋎ ψ).letterlessTrace = φ.letterlessTrace ∩ ψ.letterlessTrace := by grind; - -end Formula.letterlessTrace - - -namespace Formula - -@[grind =] lemma neg_letterlessTrace_letterlessSpectrum {φ : Formula ℕ} {hφ : φ.Letterless} : (∼φ).letterlessTrace = φ.letterlessSpectrum := by grind; -@[grind =] lemma neg_letterlessSpectrum_letterlessTrace {φ : Formula ℕ} {hφ : φ.Letterless} : (∼φ).letterlessSpectrum = φ.letterlessTrace := by grind; - - -lemma letterlessSpectrum_finite_or_cofinite {φ : Formula ℕ} (hφ : φ.Letterless) : φ.letterlessSpectrum.Finite ∨ φ.letterlessSpectrum.Cofinite := by - induction φ with - | hfalsum => simp; - | hatom => grind; - | himp φ ψ ihφ ihψ => - rw [letterlessSpectrum.def_imp]; - . rcases ihφ (by grind) with (ihφ | ihφ) <;> - rcases ihψ (by grind) with (ihψ | ihψ); - case himp.inr.inl => - left; - grind [Set.Finite.union]; - . right; - apply Set.cofinite_union_left; - simpa [Set.Cofinite] - . grind; - . grind; - | hbox φ ihφ => - by_cases h : φ.letterlessSpectrum = Set.univ; - . right; - rw [letterlessSpectrum.def_box, h]; - simp; - . left; - obtain ⟨k, hk₁, hk₂⟩ := exists_minimal_of_wellFoundedLT (λ k => k ∉ φ.letterlessSpectrum) $ Set.ne_univ_iff_exists_notMem _ |>.mp h; - have : {n | ∀ i < n, i ∈ φ.letterlessSpectrum} = { n | n ≤ k} := by - ext i; - suffices (∀ j < i, j ∈ φ.letterlessSpectrum) ↔ i ≤ k by simpa [Set.mem_setOf_eq]; - constructor; - . intro h; - contrapose! hk₁; - exact h k (by omega); - . intro h j hji; - contrapose! hk₂; - use j; - constructor; - . assumption; - . omega; - rw [letterlessSpectrum.def_box, this]; - apply Set.finite_le_nat; - -@[grind .] -lemma letterlessTrace_finite_or_cofinite {φ : Formula ℕ} (hφ : φ.Letterless) : φ.letterlessTrace.Finite ∨ φ.letterlessTrace.Cofinite := by - suffices φ.letterlessSpectrum.Finite ∨ φ.letterlessSpectrum.Cofinite by - simp [Formula.letterlessTrace, Set.iff_cofinite_comp_finite]; - tauto; - apply letterlessSpectrum_finite_or_cofinite hφ; - -@[grind →] -lemma letterlessTrace_cofinite_of_letterlessSpectrum_infinite (hφ : φ.Letterless) : φ.letterlessTrace.Infinite → φ.letterlessTrace.Cofinite := by - have := or_iff_not_imp_left.mp $ letterlessTrace_finite_or_cofinite hφ; - grind [Set.Infinite]; - -@[grind →] -lemma letterlessTrace_finite_of_letterlessSpectrum_cofinite (hφ : φ.Letterless) : φ.letterlessTrace.Coinfinite → φ.letterlessTrace.Finite := by - have := or_iff_not_imp_right.mp $ letterlessTrace_finite_or_cofinite hφ; - simp only [Set.iff_coinfinite_not_cofinite]; - assumption; - -@[simp, grind =] -lemma boxbot_letterlessSpectrum : (□^[n]⊥ : Formula ℕ).letterlessSpectrum = { i | i < n } := by - induction n with - | zero => simp - | succ n ih => - calc - _ = { i | ∀ k < i, k ∈ (□^[n]⊥ : Formula ℕ).letterlessSpectrum } := Formula.letterlessSpectrum.def_boxItr - _ = { i | ∀ k < i, k < n } := by simp [ih]; - _ = { i | i < n + 1 } := by - ext i; - suffices (∀ k < i, k < n) ↔ i < n + 1 by simpa; - constructor; - . contrapose!; - intro h; - use n; - omega; - . omega; - -end Formula - - -/-- Realization which any propositional variable maps to `⊤` -/ -abbrev _root_.LO.FirstOrder.ArithmeticTheory.LetterlessStandardRealization (T : ArithmeticTheory) [T.Δ₁] : T.StandardRealization := ⟨λ _ => ⊤⟩ - - -namespace Formula - -@[grind] def Regular (T : ArithmeticTheory) [T.Δ₁] (φ : Modal.Formula ℕ) := ℕ ⊧ₘ (T.LetterlessStandardRealization φ) - -@[grind] def Singular (T : ArithmeticTheory) [T.Δ₁] (φ : Modal.Formula ℕ) := ¬(φ.Regular T) - -namespace Regular - -@[simp] lemma def_bot : ¬((⊥ : Formula _).Regular T) := by simp [Formula.Regular, Realization.interpret]; -@[simp] lemma def_top : (⊤ : Formula _).Regular T := by simp [Formula.Regular, Realization.interpret]; -lemma def_neg : (∼φ).Regular T ↔ ¬(φ.Regular T) := by simp [Formula.Regular, Realization.interpret]; -lemma def_neg' : (∼φ).Regular T ↔ (φ.Singular T) := Iff.trans def_neg $ by rfl -lemma def_and : (φ ⋏ ψ).Regular T ↔ (φ.Regular T) ∧ (ψ.Regular T) := by simp [Formula.Regular, Realization.interpret]; -lemma def_or : (φ ⋎ ψ).Regular T ↔ (φ.Regular T) ∨ (ψ.Regular T) := by simp [Formula.Regular, Realization.interpret]; tauto; -lemma def_imp : (φ 🡒 ψ).Regular T ↔ ((φ.Regular T) → (ψ.Regular T)) := by simp [Formula.Regular, Realization.interpret]; -lemma def_iff : (φ 🡘 ψ).Regular T ↔ ((φ.Regular T) ↔ (ψ.Regular T)) := by simp [Formula.Regular, Realization.interpret]; tauto; - -attribute [simp, grind .] - def_bot - def_top - def_neg def_neg' - def_and - def_or - def_imp - def_iff - -@[simp, grind =] -lemma def_lconj {l : List (Formula _)} : (l.conj₂).Regular T ↔ ∀ φ ∈ l, (φ.Regular T) := by - induction l using List.induction_with_singleton' with - | hcons _ _ _ ih => simp_all [Regular]; - | _ => simp; - -@[simp, grind =] -lemma def_lconj' {l : List _} {Φ : β → Formula _} : (l.conj' Φ).Regular T ↔ ∀ i ∈ l, ((Φ i).Regular T) := by - induction l using List.induction_with_singleton' with - | hcons _ _ _ ih => simp_all [Regular]; - | _ => simp; - -@[simp, grind =] -lemma def_fconj {s : Finset (Formula _)} : (s.conj).Regular T ↔ ∀ φ ∈ s, (φ.Regular T) := by - simp [Finset.conj]; - -@[simp] -lemma def_fconj' {s : Finset _} {Φ : β → Formula _} : (⩕ i ∈ s, Φ i).Regular T ↔ ∀ i ∈ s, ((Φ i).Regular T) := by - simp [Finset.conj']; - -end Regular - - -namespace Singular - -@[simp] lemma def_bot : (⊥ : Formula _).Singular T := by grind -@[simp] lemma def_top : ¬(⊤ : Formula _).Singular T := by grind -lemma def_neg : (∼φ).Singular T ↔ ¬(φ.Singular T) := by grind; -lemma def_neg' : (∼φ).Singular T ↔ (φ.Regular T) := by grind; -lemma def_and : (φ ⋏ ψ).Singular T ↔ (φ.Singular T) ∨ (ψ.Singular T) := by grind -lemma def_or : (φ ⋎ ψ).Singular T ↔ (φ.Singular T) ∧ (ψ.Singular T) := by grind -lemma def_imp : (φ 🡒 ψ).Singular T ↔ (¬(φ.Singular T) ∧ (ψ.Singular T)) := by grind - -attribute [grind .] - def_bot - def_top - def_neg def_neg' - def_and - def_or - def_imp - -end Singular - -end Formula - - -def FormulaSet.Regular (T : ArithmeticTheory) [T.Δ₁] (X : Modal.FormulaSet ℕ) := ∀ φ ∈ X, φ.Regular T -def FormulaSet.Singular (T : ArithmeticTheory) [T.Δ₁] (X : Modal.FormulaSet ℕ) := ¬X.Regular T - -def FormulaSet.letterlessSpectrum (X : Modal.FormulaSet ℕ) (X_c : X.Letterless := by grind) := ⋂ φ ∈ X, φ.letterlessSpectrum -def FormulaSet.letterlessTrace (X : Modal.FormulaSet ℕ) (_ : X.Letterless := by grind [FormulaSet.Letterless]) := X.letterlessSpectrumᶜ - -namespace FormulaSet - -lemma exists_singular_of_singular (hX_singular : X.Singular T) : ∃ φ ∈ X, φ.Singular T := by - simpa [FormulaSet.Singular, FormulaSet.Regular] using hX_singular; - --- variable (Xll : X.Letterless := by grind) (Yll : Y.Letterless := by grind) - -lemma def_letterlessTrace_union (hX) : X.letterlessTrace hX = ⋃ φ ∈ X, φ.letterlessTrace := by simp [FormulaSet.letterlessTrace, FormulaSet.letterlessSpectrum, Formula.letterlessTrace] - -lemma comp_letterlessTrace_letterlessSpectrum (hX) : (X.letterlessTrace hX)ᶜ = X.letterlessSpectrum := by simp [FormulaSet.letterlessTrace] - -lemma iff_subset_letterlessSpectrum_subset_letterlessTrace (hX hY) : X.letterlessSpectrum hX ⊆ Y.letterlessSpectrum hY ↔ Y.letterlessTrace ⊆ X.letterlessTrace := by simp [FormulaSet.letterlessTrace] - -lemma iff_eq_letterlessSpectrum_eq_letterlessTrace (hX hY) : X.letterlessSpectrum hX = Y.letterlessSpectrum hY ↔ X.letterlessTrace = Y.letterlessTrace := by simp [FormulaSet.letterlessTrace]; - -end FormulaSet - -/-- boxbot instance of axiomT -/ -abbrev TBB (n : ℕ) : Formula ℕ := □^[(n + 1)]⊥ 🡒 □^[n]⊥ - -section - -variable {α α₁ α₂ β β₁ β₂ : Set ℕ} {hβ : β.Cofinite} {hβ₁ : β₁.Cofinite} {hβ₂ : β₂.Cofinite} - -@[simp, grind .] lemma TBB_letterless : (TBB n).Letterless := by grind - -@[simp] -lemma TBB_injective : Function.Injective TBB := by - rintro i j; - wlog hij : i < j; rcases (show i = j ∨ i > j by omega) <;> grind; - suffices (□^[i]⊥ : Formula ℕ) = □^[j]⊥ → i = j by grind [Formula.inj_imp]; - obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_lt hij; - simp [show ((i + k) + 1) = i + (k + 1) by omega, ←Box.boxItr_add (n := i) (m := (k + 1)), InjectiveBox.inj_multibox.eq_iff]; - -@[simp, grind .] -lemma TBB_letterlessSpectrum : (TBB n).letterlessSpectrum = {n}ᶜ := by - ext i; - rw [Formula.letterlessSpectrum.def_imp, Formula.boxbot_letterlessSpectrum, Formula.boxbot_letterlessSpectrum]; - simp; - omega; - -@[simp, grind .] -lemma TBB_letterlessTrace : (TBB n).letterlessTrace = {n} := by simp [Formula.letterlessTrace, TBB_letterlessSpectrum, compl_compl]; - -@[simp, grind .] -lemma TBB_conj'_letterless : (⩕ n ∈ s, TBB n).Letterless := by - apply Formula.letterless_fconj'.mpr; - grind; - -@[simp, grind .] -lemma TBBSet_letterless : FormulaSet.Letterless (TBB '' α) := by simp [FormulaSet.Letterless] - -@[simp] -lemma TBBSet_letterlessTrace : FormulaSet.letterlessTrace (TBB '' α) = α := by - simp [FormulaSet.def_letterlessTrace_union]; - -@[simp, grind .] -lemma TBBMinus_letterless' : Formula.Letterless (∼⩕ n ∈ hβ.toFinset, TBB n) := by - apply Formula.letterless_neg.mpr; - apply Formula.letterless_fconj'.mpr; - grind; - -@[simp, grind .] -lemma TBBMinus_letterless : FormulaSet.Letterless {∼⩕ n ∈ hβ.toFinset, TBB n} := by simp [FormulaSet.Letterless]; - -@[simp, grind .] -lemma TBBMinus_letterlessSpectrum' : (∼⩕ n ∈ hβ.toFinset, TBB n).letterlessSpectrum TBBMinus_letterless' = βᶜ := by - simp only [Formula.letterlessSpectrum.def_neg, compl_inj_iff]; - rw [Formula.letterlessSpectrum.def_fconj' ?_]; - . ext j; - suffices (∀ i ∉ β, j ≠ i) ↔ j ∈ β by simpa [TBB_letterlessSpectrum]; - grind; - . apply Formula.letterless_fconj'.mpr - grind; - -@[simp, grind .] -lemma TBBMinus_letterlessSpectrum : FormulaSet.letterlessSpectrum {(∼⩕ n ∈ hβ.toFinset, TBB n)} (by simp) = βᶜ := by simp [FormulaSet.letterlessSpectrum] - - -section - -variable [ℕ ⊧ₘ* T] - -@[simp high, grind .] -lemma TBB_regular : (TBB n).Regular T := by - apply Formula.Regular.def_imp.mpr; - intro h; - exfalso; - have : ¬ℕ ⊧ₘ T.LetterlessStandardRealization (□^[(n + 1)]⊥) := by - simp only [Box.boxItr_succ, Realization.interpret.def_box, Realization.interpret.def_boxItr, Realization.interpret.def_bot]; - apply not_imp_not.mpr $ Provability.sound_on; - apply iIncon_unprovable_of_sigma1_sound; - apply this; - exact h; - -@[simp, grind .] -lemma TBB_conj'_regular : (⩕ n ∈ s, TBB n).Regular T := by - apply Formula.Regular.def_fconj'.mpr; - grind; - -@[simp high] -lemma TBBSet_regular : FormulaSet.Regular T (TBB '' α) := by - rintro _ ⟨_, _, rfl⟩; - grind; - - -@[simp] -lemma TBBMinus_singular : FormulaSet.Singular T {∼⩕ n ∈ hβ.toFinset, TBB n} := by - simp [FormulaSet.Singular, FormulaSet.Regular, Formula.Regular.def_neg]; - -end - -end - - -namespace Kripke - -open Kripke -open Formula.Kripke - -variable {F : Frame} [F.IsPointRooted] [Fintype F] - -lemma iff_satisfies_mem_rank_letterlessSpectrum - {M : Model} [Fintype M] [M.IsIrreflexive] [M.IsTransitive] [M.IsPointRooted] {w : M} - {φ : Formula ℕ} (φ_closed : φ.Letterless := by grind) - : w ⊧ φ ↔ Frame.rank w ∈ φ.letterlessSpectrum := by - induction φ generalizing w with - | hbox φ ihφ => - calc - w ⊧ □φ ↔ ∀ v, w ≺ v → v ⊧ φ := by rfl; - _ ↔ ∀ v, w ≺ v → (Frame.rank v ∈ φ.letterlessSpectrum) := by - constructor; - . intro h v; rw [←ihφ (by grind)]; apply h; - . intro h v; rw [ihφ (by grind)]; apply h; - _ ↔ ∀ i < (Frame.rank w), i ∈ φ.letterlessSpectrum := by - constructor; - . intro h i hi; - obtain ⟨v, Rwv, rfl⟩ := Frame.exists_of_lt_height hi; - apply h; - assumption; - . intro h v Rwv; - apply h; - apply Frame.rank_lt_of_rel; - assumption; - _ ↔ Frame.rank w ∈ (□φ).letterlessSpectrum := by - rw [Formula.letterlessSpectrum.def_box]; simp; - | _ => grind; - -lemma iff_satisfies_TBB_ne_rank - {M : Model} [Fintype M] [M.IsIrreflexive] [M.IsTransitive] [M.IsPointRooted] {w : M} {n : ℕ} - : w ⊧ TBB n ↔ Frame.rank w ≠ n := by - apply Iff.trans iff_satisfies_mem_rank_letterlessSpectrum; - simp; - -abbrev Frame.finiteLinear (n : ℕ) : Kripke.Frame where - World := Fin (n + 1) - Rel := (· < ·) - -namespace Frame.finiteLinear - -abbrev of (i : Fin (n + 1)) : Frame.finiteLinear n := i - -instance : (Frame.finiteLinear n) |>.IsPointRooted where - default := ⟨of 0, by grind⟩ - uniq {r} := by - by_contra! hC; - have := r.2 0 (by grind); - grind; - -instance : (Frame.finiteLinear n) |>.IsIrreflexive where - irrefl := by simp [Frame.finiteLinear] - -instance : (Frame.finiteLinear n) |>.IsTransitive where - trans := by simp [Frame.finiteLinear]; grind; - -lemma rank_of_eq_sub (i : Fin (n + 1)) : Frame.rank (of i) = n - i := by - induction i using Fin.reverseInduction - case last => - suffices rank (of (Fin.last n)) = 0 by simpa - apply fcwHeight_eq_zero_iff.mpr - intro j - show ¬(Fin.last n) < j - simp [Fin.le_last] - case cast i ih => - suffices rank (of i.castSucc) = rank (of i.succ) + 1 by - rw [this, ih] - simp; omega - apply fcwHeight_eq_succ_fcwHeight - · show i.castSucc < i.succ - exact Fin.castSucc_lt_succ; - · suffices ∀ j : Fin (n + 1), i.castSucc < j → i.succ ≤ j by - simpa [le_iff_lt_or_eq] using this - intro j - exact id - -@[simp] lemma rank_zero : (Frame.finiteLinear n).height = n := by simpa using rank_of_eq_sub _ - -end Frame.finiteLinear - -lemma letterlessSpectrum_TFAE (_ : φ.Letterless) : [ - n ∈ φ.letterlessSpectrum, - ∀ M : Model, [Fintype M] → [M.IsIrreflexive] → [M.IsTransitive] → [M.IsPointRooted] → ∀ w : M.World, Frame.rank w = n → w ⊧ φ, - ∃ M : Model, ∃ _ : Fintype M, ∃ _ : M.IsIrreflexive, ∃ _ : M.IsTransitive, ∃ _ : M.IsPointRooted, ∃ w : M.World, Frame.rank w = n ∧ w ⊧ φ -].TFAE := by - tfae_have 1 → 2 := by - intro h M _ _ _ _ w hw; - apply iff_satisfies_mem_rank_letterlessSpectrum (by grind) |>.mpr; - apply hw ▸ h; - tfae_have 2 → 3 := by - intro h; - let M : Kripke.Model := ⟨Frame.finiteLinear n, λ p i => True⟩; - use ⟨Frame.finiteLinear n, λ p i => True⟩; - refine ⟨inferInstance, inferInstance, inferInstance, inferInstance, ?_⟩; - . use M.root; - constructor; - . exact Frame.finiteLinear.rank_zero; - . apply h; - exact Frame.finiteLinear.rank_zero; - tfae_have 3 → 1 := by - rintro ⟨M, _, _, _, _, w, rfl, hw⟩; - apply iff_satisfies_mem_rank_letterlessSpectrum (by grind) |>.mp hw; - tfae_finish; - -end Kripke - -section - -open Formula -open LO.Entailment Modal.Entailment - -variable {φ ψ : Formula ℕ} (hφ : φ.Letterless) (hψ : ψ.Letterless) - -lemma iff_GL_provable_letterlessSpectrum_Univ : Modal.GL ⊢ φ ↔ φ.letterlessSpectrum = Set.univ := by - rw [Set.eq_univ_iff_forall]; - constructor; - . intro h n; - apply Kripke.letterlessSpectrum_TFAE (φ := φ) (by grind) |>.out 1 0 |>.mp; - intro M _ _ _ _ _ w; - have := GL.Kripke.fintype_completeness_TFAE.out 0 1 |>.mp h; - apply @this M.toFrame; - . intro h; - apply GL.Kripke.fintype_completeness_TFAE.out 1 0 |>.mp; - intro M _ _ _ _ V x; - have := Kripke.letterlessSpectrum_TFAE (φ := φ) (n := Kripke.Frame.rank x) (by grind) |>.out 0 1 |>.mp; - apply this (by grind) _ x rfl; - -lemma iff_GL_provable_C_subset_letterlessSpectrum : Modal.GL ⊢ (φ 🡒 ψ) ↔ φ.letterlessSpectrum hφ ⊆ ψ.letterlessSpectrum hψ := by - apply Iff.trans $ iff_GL_provable_letterlessSpectrum_Univ (show (φ 🡒 ψ).Letterless by grind); - rw [Formula.letterlessSpectrum.def_imp]; - suffices (∀ i, i ∉ φ.letterlessSpectrum ∨ i ∈ ψ.letterlessSpectrum) ↔ φ.letterlessSpectrum ⊆ ψ.letterlessSpectrum by - simpa [Set.eq_univ_iff_forall]; - constructor <;> - . intro h i; - have := @h i; - tauto; - -lemma iff_GL_provable_E_eq_letterlessSpectrum : Modal.GL ⊢ (φ 🡘 ψ) ↔ φ.letterlessSpectrum = ψ.letterlessSpectrum := by - rw [ - Set.Subset.antisymm_iff, - ←iff_GL_provable_C_subset_letterlessSpectrum, - ←iff_GL_provable_C_subset_letterlessSpectrum, - ]; - constructor; - . intro h; constructor <;> cl_prover [h]; - . rintro ⟨h₁, h₂⟩; cl_prover [h₁, h₂]; - -lemma GL_letterlessTrace_TBB_normalization (h : φ.letterlessTrace.Finite) : Modal.GL ⊢ φ 🡘 (⩕ n ∈ h.toFinset, (TBB n)) := by - apply iff_GL_provable_E_eq_letterlessSpectrum _ _ |>.mpr; - . calc - _ = ⋂ i ∈ φ.letterlessTrace, (TBB i).letterlessSpectrum := by - have : φ.letterlessTrace = ⋃ i ∈ φ.letterlessTrace, (TBB i).letterlessTrace := by ext i; simp [TBB_letterlessTrace]; - simpa [Formula.letterlessTrace] using compl_inj_iff.mpr this; - _ = _ := by - ext i; - rw [Formula.letterlessSpectrum.def_fconj' (by simp)]; - simp; - . show φ.Letterless; - assumption; - . show (⩕ n ∈ h.toFinset, TBB n).Letterless; - grind; - -lemma GL_letterlessSpectrum_TBB_normalization (h : φ.letterlessSpectrum.Finite) : Modal.GL ⊢ φ 🡘 ∼(⩕ n ∈ h.toFinset, (TBB n)) := by - have h' : (∼φ).letterlessTrace.Finite := by grind; - have := GL_letterlessTrace_TBB_normalization (show (∼φ).Letterless by grind) h'; - rw [show h.toFinset = h'.toFinset by grind]; - cl_prover [this]; - -lemma GL_proves_letterless_axiomWeakPoint3 (hφ : φ.Letterless) (hψ : ψ.Letterless) : Modal.GL ⊢ (Axioms.WeakPoint3 φ ψ) := by - apply iff_GL_provable_letterlessSpectrum_Univ (by grind) |>.mpr; - apply Set.eq_univ_iff_forall.mpr; - intro n; - rw [ - letterlessSpectrum.def_or, - letterlessSpectrum.def_box, - letterlessSpectrum.def_box, - letterlessSpectrum.def_imp, - letterlessSpectrum.def_imp, - letterlessSpectrum.def_boxdot, - letterlessSpectrum.def_boxdot - ]; - grind; - -/- TODO: -/-- Theorem 2 in [Valentini & Solitro 1983] -/ -lemma iff_provable_GLPoint3_letterless_provable_GL : Modal.GLPoint3 ⊢ φ ↔ (∀ s : ZeroSubstitution _, Modal.GL ⊢ φ⟦s.1⟧) := by - constructor; - . suffices Modal.GLPoint3 ⊢ φ → (∀ s : ZeroSubstitution _, Modal.GL ⊢ φ⟦s.1⟧) by simpa; - intro h s; - induction h using Hilbert.Normal.rec! with - | axm t ht => - rcases ht with (rfl | rfl | rfl); - . simp; - . simp; - . apply GL_proves_letterless_axiomWeakPoint3 <;> - apply Formula.Letterless_zeroSubst; - | mdp h₁ h₂ => exact h₁ ⨀ h₂; - | nec h => apply nec! h; - | _ => simp; - . contrapose!; - suffices Modal.GLPoint3 ⊬ φ → (∃ s : ZeroSubstitution _, Modal.GL ⊬ φ⟦s.1⟧) by simpa; - -- Kripke semantical arguments (?) - intro h; - sorry; --/ - -end - -variable - [ℕ ⊧ₘ* T] - (hφ : φ.Letterless) (hψ : ψ.Letterless) - (X_letterless : X.Letterless) (Y_letterless : Y.Letterless) - -lemma letterless_arithmetical_completeness [𝗜𝚺₁ ⪯ T] (hφ : φ.Letterless) - : Modal.GL ⊢ φ ↔ T ⊢ T.LetterlessStandardRealization φ := by - apply Iff.trans (GL.arithmetical_completeness_sound_iff (T := T) |>.symm); - constructor; - . intro h; - apply h; - . intro h f; - have e : T.LetterlessStandardRealization φ = f φ := Realization.letterless_interpret hφ - exact e ▸ h; - -lemma iff_regular_of_provable_E [𝗜𝚺₁ ⪯ T] (hφ : φ.Letterless) (hψ : ψ.Letterless) (h : Modal.GL ⊢ φ 🡘 ψ) - : φ.Regular T ↔ ψ.Regular T := by - have : T ⊢ T.LetterlessStandardRealization (φ 🡘 ψ) := letterless_arithmetical_completeness (by grind) |>.mp h; - have : ℕ ⊧ₘ T.LetterlessStandardRealization (φ 🡘 ψ) := ArithmeticTheory.SoundOn.sound (F := λ _ => True) this (by simp); - simp [Realization.interpret, Formula.Regular] at this ⊢; - tauto; - -lemma iff_singular_of_provable_E [𝗜𝚺₁ ⪯ T] (hφ : φ.Letterless) (hψ : ψ.Letterless) (h : Modal.GL ⊢ φ 🡘 ψ) - : φ.Singular T ↔ ψ.Singular T := Iff.not $ iff_regular_of_provable_E hφ hψ h - - -variable [𝗜𝚺₁ ⪯ T] - -lemma Formula.iff_regular_letterlessTrace_finite : φ.Regular T ↔ φ.letterlessTrace.Finite := by - constructor; - . contrapose!; - intro h; - have : φ.letterlessSpectrum.Finite := by - have := letterlessTrace_cofinite_of_letterlessSpectrum_infinite (by grind) h; - have : (φ.letterlessTrace)ᶜ.Finite := Set.iff_cofinite_comp_finite.mp this; - simpa [Formula.letterlessTrace] using this; - apply iff_regular_of_provable_E ?_ ?_ (GL_letterlessSpectrum_TBB_normalization (by assumption) this) |>.not.mpr; - . apply Formula.Regular.def_neg.not.mpr; - push Not; - exact TBB_conj'_regular; - . assumption; - . convert @TBBMinus_letterless' φ.letterlessTrace $ by simpa [Formula.letterlessTrace, Set.Cofinite] - simp [Formula.letterlessTrace] - . intro h; - apply iff_regular_of_provable_E (by grind) (by simp) (GL_letterlessTrace_TBB_normalization (by grind) h) |>.mpr; - simp; - -lemma Formula.letterlessSpectrum_finite_of_singular : φ.Singular T → φ.letterlessSpectrum.Finite := by - contrapose!; - suffices ¬(φ.letterlessSpectrum).Finite → Formula.Regular T φ by simpa [Formula.Singular, not_not]; - intro h; - apply iff_regular_letterlessTrace_finite (by grind) |>.mpr; - apply or_iff_not_imp_right.mp $ Formula.letterlessTrace_finite_or_cofinite (by grind); - simpa [Formula.letterlessTrace] using h; - -lemma letterless_arithmetical_completeness' : [ - Modal.GL ⊢ φ, - T ⊢ T.LetterlessStandardRealization φ, - φ.letterlessSpectrum = Set.univ, -].TFAE := by - tfae_have 1 ↔ 2 := letterless_arithmetical_completeness (by grind) - tfae_have 1 ↔ 3 := iff_GL_provable_letterlessSpectrum_Univ (by grind) - tfae_finish; - -lemma FormulaSet.letterlessSpectrum_finite_of_singular (X_singular : X.Singular T) : X.letterlessSpectrum.Finite := by - obtain ⟨φ, hφ₁, hφ₂⟩ := exists_singular_of_singular X_singular; - suffices (X.letterlessSpectrum) ⊆ (φ.letterlessSpectrum) by - apply Set.Finite.subset ?_ this; - exact Formula.letterlessSpectrum_finite_of_singular (by grind) hφ₂; - intro i; - simp_all [FormulaSet.letterlessSpectrum]; - -lemma FormulaSet.regular_of_not_letterlessTrace_cofinite : ¬X.letterlessTrace.Cofinite → X.Regular T := by - contrapose!; - suffices ¬X.Regular T → (X.letterlessSpectrum).Finite by simpa [FormulaSet.letterlessTrace, Set.Cofinite]; - apply letterlessSpectrum_finite_of_singular; - assumption; - -section - -open Classical LO.Entailment in -lemma GL.iff_provable_closed_sumQuasiNormal_subset_letterlessSpectrum (hSR : X.Singular T ∨ φ.Regular T) - : Modal.GL.sumQuasiNormal X ⊢ φ ↔ X.letterlessSpectrum ⊆ φ.letterlessSpectrum := by - calc - _ ↔ ∃ Y, (∀ ψ ∈ Y, ψ ∈ X) ∧ Modal.GL ⊢ Finset.conj Y 🡒 φ := Logic.sumQuasiNormal.iff_provable_finite_provable_letterless X_letterless - _ ↔ ∃ Y : Finset (Formula ℕ), ∃ _ : ∀ ψ ∈ Y, ψ ∈ X, (Finset.conj Y).letterlessSpectrum ⊆ φ.letterlessSpectrum := by - constructor; - . rintro ⟨Y, _, hY₂⟩; - use Y; - constructor; - . apply iff_GL_provable_C_subset_letterlessSpectrum (by grind) (by grind) |>.mp hY₂; - . assumption; - . rintro ⟨Y, hY₁, hY₂⟩; - use Y; - constructor; - . assumption; - . apply iff_GL_provable_C_subset_letterlessSpectrum (by grind) (by grind) |>.mpr hY₂; - _ ↔ ∃ Y : Finset (Formula ℕ), ∃ _ : ∀ ψ ∈ Y, ψ ∈ X, ⋂ ψ ∈ Y, ψ.letterlessSpectrum ⊆ φ.letterlessSpectrum := by - constructor; - . rintro ⟨Y, hY₁, hY₂⟩; - use Y, hY₁; - suffices Y.conj.letterlessSpectrum = ⋂ ψ ∈ Y, ψ.letterlessSpectrum by simpa [this] using hY₂; - rw [Formula.letterlessSpectrum.def_fconj]; - grind; - . rintro ⟨Y, hY₁, hY₂⟩; - use Y; - constructor; - . rw [Formula.letterlessSpectrum.def_fconj]; - . grind; - . grind; - . assumption; - _ ↔ (⋂ ψ ∈ X, ψ.letterlessSpectrum) ⊆ φ.letterlessSpectrum := by - constructor; - . rintro ⟨Y, hY₁, hY₂⟩ i hi; - apply hY₂; - simp_all; - . intro h; - rcases hSR with X_singular | φ_regular; - . wlog X_infinite : X.Infinite - . replace X_infinite := Set.not_infinite.mp X_infinite; - use X_infinite.toFinset; - refine ⟨?_, ?_⟩ - . simp; - . intro i hi; - apply h; - simpa using hi; - - obtain ⟨ψ, hψX, ψ_singular⟩ : ∃ ψ ∈ X, ψ.Singular T := FormulaSet.exists_singular_of_singular X_singular; - - obtain ⟨f, f0, f_monotone, fX, f_inv⟩ := Set.infinitely_finset_approximate (Countable.to_set inferInstance) X_infinite hψX; - have f_conj_letterless : ∀ i, (f i).conj.Letterless := λ i => Formula.letterless_fconj.mpr $ λ ξ hξ => X_letterless _ $ fX _ hξ; - - let sf := λ i => ⋂ ξ, ⋂ (h : ξ ∈ f i), ξ.letterlessSpectrum (X_letterless ξ $ fX _ $ by assumption); - have sf_eq : ∀ i, sf i = Formula.letterlessSpectrum ((f i).conj) (f_conj_letterless _) := by - intro i; - rw [Formula.letterlessSpectrum.def_fconj (f_conj_letterless i)]; - have sf_monotone : ∀ i, sf (i + 1) ⊆ sf i := by - intro i; - rw [sf_eq (i + 1), sf_eq i]; - apply iff_GL_provable_C_subset_letterlessSpectrum (f_conj_letterless _) (f_conj_letterless _) |>.mp; - -- TODO: `Γ ⊇ Δ` → `⊢ Γ.conj → Δ.conj` - apply right_Fconj!_intro; - intro χ hχ; - apply left_Fconj!_intro; - apply f_monotone _ |>.1 hχ; - replace sf_monotone : ∀ i j, i ≤ j → sf j ⊆ sf i := by - intro i j hij; - have : ∀ k, (sf (i + k)) ⊆ sf i := by - intro k; - induction k with - | zero => simp; - | succ k ih => - rw [show i + (k + 1) = (i + k) + 1 by omega]; - exact Set.Subset.trans (sf_monotone (i + k)) ih; - rw [(show j = i + (j - i) by omega)]; - apply this; - - have sf0_eq : sf 0 = ψ.letterlessSpectrum := by simp [sf, f0]; - have sf0_finite : (sf 0).Finite := by rw [sf0_eq]; exact Formula.letterlessSpectrum_finite_of_singular (by grind) ψ_singular; - have sf_finite : ∀ i, (sf i).Finite := by - intro i; - apply Set.Finite.subset sf0_finite; - apply sf_monotone _ _ (by omega); - - have sf_X : ∀ i, sf i ⊇ X.letterlessSpectrum := by - intro i n; - suffices (∀ (ξ : Formula ℕ) (_ : ξ ∈ X), n ∈ ξ.letterlessSpectrum _) → ∀ (ξ : Formula ℕ) (_ : ξ ∈ f i), n ∈ ξ.letterlessSpectrum _ by - simpa [sf, FormulaSet.letterlessSpectrum]; - intro h ξ hξ; - apply h; - apply fX i hξ; - - obtain ⟨k, hk⟩ : ∃ k, sf k = X.letterlessSpectrum := by - by_contra! hC; - have : ∀ i, ∃ n, n ∈ sf i ∧ n ∉ X.letterlessSpectrum := by - intro i; - exact Set.ssubset_iff_exists.mp (Set.ssubset_of_subset_ne (sf_X i) (hC i).symm) |>.2; - - apply Finset.no_ssubset_descending_chain (f := λ i => sf_finite i |>.toFinset); - - intro i; - obtain ⟨n, hn₁, hn₂⟩ := this i; - obtain ⟨ξ, hξ₁, hξ₂⟩ : ∃ ξ, ∃ (_ : ξ ∈ X), n ∉ ξ.letterlessSpectrum _ := by simpa [FormulaSet.letterlessSpectrum] using hn₂; - obtain ⟨j, hj⟩ := f_inv ξ hξ₁; - - have : i < j := by - by_contra hC; - have := Set.Subset.trans (sf_monotone j i (by omega)) $ show sf j ⊆ ξ.letterlessSpectrum by - intro _ hn; - apply hn; - use ξ; - simp_all; - apply hξ₂; - apply this; - apply hn₁; - use j; - constructor; - . assumption; - . suffices (sf j) ⊂ (sf i) by simpa [sf_finite] - exact Set.ssubset_iff_exists.mpr ⟨sf_monotone i j (by omega), by - use n; - constructor; - . assumption; - . suffices ∃ χ, ∃ _ : χ ∈ f j, n ∉ χ.letterlessSpectrum _ by simpa [sf]; - use ξ; - simp_all; - ⟩; - - use (f k) - refine ⟨?_, ?_⟩; - . apply fX; - . apply Set.Subset.trans ?_ h; - rw [←FormulaSet.letterlessSpectrum, ←hk]; - assumption; - . have H : ∀ i ∈ φ.letterlessTrace, ∃ ψ, ∃ _ : ψ ∈ X, i ∈ ψ.letterlessTrace := by - have : φ.letterlessTrace ⊆ ⋃ ψ ∈ X, ψ.letterlessTrace := by - apply Set.compl_subset_compl.mp; - simpa [Formula.letterlessTrace] - simpa [Set.subset_def]; - - let ξ := λ i (hi : i ∈ φ.letterlessTrace) => (H i hi |>.choose); - have ξ_in_X : ∀ {i hi}, (ξ i hi) ∈ X := by - intro i hi; - apply (H i hi |>.choose_spec).1; - have ξ_letterless : ∀ {i hi}, (ξ i hi).Letterless := by - intro i hi; - apply X_letterless _ $ ξ_in_X; - assumption - have H₂ : ⋂ i ∈ φ.letterlessTrace, (ξ i (by assumption)).letterlessSpectrum ⊆ φ.letterlessSpectrum := by - suffices φ.letterlessTrace ⊆ ⋃ i ∈ φ.letterlessTrace, (ξ i (by assumption)).letterlessTrace by - apply Set.compl_subset_compl.mp; - simpa; - intro j hj; - simp only [Set.mem_iUnion, ξ]; - use j, hj; - apply H j hj |>.choose_spec.2; - use @Finset.univ (α := { i // i ∈ φ.letterlessTrace }) ?_ |>.image (λ i => (ξ i.1 i.2)); - . refine ⟨?_, ?_⟩; - . simp only [Finset.mem_image, Finset.mem_univ, true_and, Subtype.exists, forall_exists_index]; - rintro ψ i hi rfl; - apply ξ_in_X; - assumption - . intro i hi; - apply H₂; - simp only [Finset.mem_image, Finset.mem_univ, true_and, Subtype.exists, Set.iInter_exists, Set.mem_iInter] at hi ⊢; - intro j hj; - apply hi (ξ j hj) j hj rfl; - . apply Set.Finite.fintype (s := φ.letterlessTrace); - exact Formula.iff_regular_letterlessTrace_finite (by grind) |>.mp φ_regular; - -lemma GL.iff_subset_closed_sumQuasiNormal_subset_letterlessSpectrum (hSR : X.Singular T ∨ Y.Regular T) - : Modal.GL.sumQuasiNormal Y ⊆ Modal.GL.sumQuasiNormal X ↔ X.letterlessSpectrum ⊆ Y.letterlessSpectrum := by - calc - _ ↔ ∀ ψ ∈ Y, Modal.GL.sumQuasiNormal X ⊢ ψ := Logic.sumQuasiNormal.iff_subset - _ ↔ ∀ ψ, (h : ψ ∈ Y) → X.letterlessSpectrum ⊆ ψ.letterlessSpectrum := by - constructor; - . intro h ψ _; - apply GL.iff_provable_closed_sumQuasiNormal_subset_letterlessSpectrum (T := T) (by grind) (by grind) (by tauto) |>.mp; - exact h ψ (by simpa); - . intro h ψ _; - apply GL.iff_provable_closed_sumQuasiNormal_subset_letterlessSpectrum (T := T) (by grind) (by grind) (by tauto) |>.mpr; - apply h; - simpa; - _ ↔ X.letterlessSpectrum ⊆ (⋂ ψ ∈ Y, ψ.letterlessSpectrum) := by simp; - -lemma GL.iff_subset_closed_sumQuasiNormal_subset_letterlessTrace (hSR : X.Singular T ∨ Y.Regular T) - : Modal.GL.sumQuasiNormal Y ⊆ Modal.GL.sumQuasiNormal X ↔ Y.letterlessTrace ⊆ X.letterlessTrace := by - apply Iff.trans (iff_subset_closed_sumQuasiNormal_subset_letterlessSpectrum X_letterless Y_letterless hSR); - apply FormulaSet.iff_subset_letterlessSpectrum_subset_letterlessTrace; - -lemma GL.iff_eq_closed_sumQuasiNormal_eq_letterlessSpectrum (hXY : (X.Regular T ∧ Y.Regular T) ∨ (X.Singular T ∧ Y.Singular T)) - : Modal.GL.sumQuasiNormal X = Modal.GL.sumQuasiNormal Y ↔ X.letterlessSpectrum = Y.letterlessSpectrum := by - simp only [Set.Subset.antisymm_iff]; - rw [ - iff_subset_closed_sumQuasiNormal_subset_letterlessSpectrum X_letterless Y_letterless (by tauto), - iff_subset_closed_sumQuasiNormal_subset_letterlessSpectrum Y_letterless X_letterless (by tauto) - ]; - tauto; - - - -protected abbrev GLα (α : Set ℕ) : Logic ℕ := Modal.GL.sumQuasiNormal (TBB '' α) - -protected abbrev GLαω : Logic ℕ := Modal.GLα Set.univ - -protected abbrev GLβMinus (β : Set ℕ) (hβ : β.Cofinite := by grind) : Logic ℕ := Modal.GL.sumQuasiNormal {∼(⩕ n ∈ hβ.toFinset, (TBB n))} - - -lemma GL.iff_eq_closed_sumQuasiNormal_eq_letterlessTrace (hXY : (X.Regular T ∧ Y.Regular T) ∨ (X.Singular T ∧ Y.Singular T)) - : Modal.GL.sumQuasiNormal X = Modal.GL.sumQuasiNormal Y ↔ X.letterlessTrace = Y.letterlessTrace := by - apply Iff.trans (iff_eq_closed_sumQuasiNormal_eq_letterlessSpectrum X_letterless Y_letterless hXY); - apply FormulaSet.iff_eq_letterlessSpectrum_eq_letterlessTrace; - -lemma GL.eq_closed_regular_sumQuasiNormal_GLα (X_regular : X.Regular T) - : Modal.GL.sumQuasiNormal X = Modal.GLα (X.letterlessTrace) := by - apply GL.iff_eq_closed_sumQuasiNormal_eq_letterlessTrace (T := T) ?_ ?_ ?_ |>.mpr; - . simp; - . assumption; - . simp [FormulaSet.Letterless]; - . left; - constructor; - . assumption; - . simp; - - -@[grind! <=] -lemma FormulaSet.comp_letterlessTrace_finite_of_singular (X_singular : X.Singular T) : (X.letterlessTrace).Cofinite := by - have := FormulaSet.letterlessSpectrum_finite_of_singular X_letterless X_singular; - have := FormulaSet.comp_letterlessTrace_letterlessSpectrum (hX := X_letterless); - grind; - -set_option backward.isDefEq.respectTransparency false in -lemma GL.eq_closed_singular_sumQuasiNormal_GLβMinus (X_singular : X.Singular T) : Modal.GL.sumQuasiNormal X = Modal.GLβMinus (X.letterlessTrace) := by - apply GL.iff_eq_closed_sumQuasiNormal_eq_letterlessSpectrum (T := T) ?_ ?_ ?_ |>.mpr; - . simp [TBBMinus_letterlessSpectrum, FormulaSet.letterlessTrace]; - . assumption; - . grind; - . right; - constructor; - . assumption; - . simp; - -/-- - Quasi-normal extension of `Modal.GL` by closed formula set `X` is - either `Modal.GLα (X.letterlessTrace)` (`X` is regular) or `Modal.GLβMinus (X.letterlessTrace)` (`X` is singular) --/ -theorem GL.eq_closed_sumQuasiNormal_GLα_or_GLβMinus : - (∃ _ : X.Regular T, Modal.GL.sumQuasiNormal X = Modal.GLα (X.letterlessTrace)) ∨ - (∃ _ : X.Singular T, Modal.GL.sumQuasiNormal X = Modal.GLβMinus (X.letterlessTrace)) := by - by_cases h : X.Regular T; - . left; - constructor; - . apply GL.eq_closed_regular_sumQuasiNormal_GLα X_letterless h; - . assumption; - . right; - constructor; - . apply eq_closed_singular_sumQuasiNormal_GLβMinus (T := T) X_letterless h; - . assumption - -lemma iff_GLα_subset : Modal.GLα α₁ ⊆ Modal.GLα α₂ ↔ α₁ ⊆ α₂ := by - calc - _ ↔ FormulaSet.letterlessTrace (α₁.image TBB) ⊆ FormulaSet.letterlessTrace (α₂.image TBB) := by - apply GL.iff_subset_closed_sumQuasiNormal_subset_letterlessTrace (T := 𝗣𝗔) (by grind) (by grind); - simp; - _ ↔ α₁ ⊆ α₂ := by simp; - -lemma iff_GLβMinus_subset (hβ₁ : β₁.Cofinite) (hβ₂ : β₂.Cofinite) : Modal.GLβMinus β₁ ⊆ Modal.GLβMinus β₂ ↔ β₁ ⊆ β₂ := by - calc - _ ↔ FormulaSet.letterlessSpectrum ({∼(⩕ n ∈ hβ₂.toFinset, (TBB n))}) ⊆ FormulaSet.letterlessSpectrum ({∼(⩕ n ∈ hβ₁.toFinset, (TBB n))}) := by - apply GL.iff_subset_closed_sumQuasiNormal_subset_letterlessSpectrum (T := 𝗣𝗔) (by grind) (by grind); - simp; - _ ↔ β₂ᶜ ⊆ β₁ᶜ := by rw [TBBMinus_letterlessSpectrum, TBBMinus_letterlessSpectrum]; - _ ↔ β₁ ⊆ β₂ := by simp; - -lemma GLα_subset_GLβMinus (hβ : β.Cofinite) : Modal.GLα β ⊆ Modal.GLβMinus β := by - apply GL.iff_subset_closed_sumQuasiNormal_subset_letterlessSpectrum (T := 𝗣𝗔) ?_ ?_ ?_ |>.mpr; - . simp [FormulaSet.letterlessSpectrum]; - . grind; - . grind; - . simp; - -end - -end Modal - - -namespace FirstOrder.Theory - -open LO.Entailment - -variable - {L : Language} [L.DecidableEq] - {T U : Theory L} [DecidablePred (· ∈ T)] [DecidablePred (· ∈ U)] - {φ : Sentence L} - -lemma compact_add_right (h : (T + U) ⊢ φ) : ∃ (s : { s : Finset (Sentence L) // ↑s ⊆ U }), T ⊢ s.1.conj 🡒 φ := by - obtain ⟨⟨s, hsTU⟩, hs⟩ := Theory.compact' h; - let sT := { ψ ∈ s | ψ ∈ T }; - let sU := { ψ ∈ s | ψ ∈ U }; - - use ⟨sU, λ _ => by simp [sU]⟩; - - have : (∅ : Theory _) ⊢ sT.conj 🡒 sU.conj 🡒 φ := CK!_iff_CC!.mp $ C!_trans CKFconjFconjUnion! $ by - have : sT ∪ sU = s:= by - ext ψ; - constructor; - . grind; - . intro hψ; rcases hsTU hψ with (hψT | hψU) <;> grind; - rwa [this]; - apply Entailment.mdp! $ Axiomatized.weakening! (λ _ => by simp) this; - apply Entailment.FConj!_iff_forall_provable.mpr; - intro ψ hψ; - apply Axiomatized.provable_refl; - grind; - -lemma compact_add_left (h : (T + U) ⊢ φ) : ∃ (s : { s : Finset (Sentence L) // ↑s ⊆ T }), U ⊢ s.1.conj 🡒 φ := by - rw [show (T + U = U + T) by simp [add_def, Set.union_comm]] at h - simpa using compact_add_right h; - -end FirstOrder.Theory - - - -namespace ProvabilityLogic - -open LO.Entailment -open FirstOrder.ArithmeticTheory -open Classical - -lemma _root_.finite_preimage_choice (s : Finset α) (X : Set β) (f : β → α) (hs : ∀ a ∈ s, ∃ b ∈ X, f b = a) : - ∃ t : Finset β, ↑t ⊆ X ∧ ∀ a ∈ s, ∃ b ∈ t, f b = a := by - classical - choose g hga hgb using hs; - use Finset.univ.image (λ (a : { b // b ∈ s}) => g a.1 (by simp)); - constructor; - . intro b hb; - grind; - . intro h b; - simp only [Finset.univ_eq_attach, Finset.mem_image, Finset.mem_attach, true_and, Subtype.exists, ↓existsAndEq]; - grind; - -theorem letterless_provabilityLogic - {T : ArithmeticTheory} [𝗜𝚺₁ ⪯ T] [T.Δ₁] [ℕ ⊧ₘ* T] - (X : Modal.FormulaSet ℕ) (X_letterless : X.Letterless) : - (Modal.GL.sumQuasiNormal X).IsProvabilityLogic T (T + (T.LetterlessStandardRealization '' X)) := by - intro A; - rw [ - (show T.LetterlessStandardRealization '' X = (GL.uniformStandardRealization T) '' X by ext φ; grind [Realization.letterless_interpret]), - Modal.Logic.sumQuasiNormal.iff_provable_finite_provable_letterless X_letterless - ]; - - constructor; - . rintro ⟨Γ, hΓ₁, hΓ₂⟩ f; - have H : T ⊢ (f Γ.conj) 🡒 (f A) := GL.arithmetical_soundness hΓ₂; - rw [ - show f Γ.conj = (GL.uniformStandardRealization T) Γ.conj from - Realization.letterless_interpret $ Modal.Formula.letterless_fconj.mpr λ B hB ↦ X_letterless B $ hΓ₁ hB - ] at H; - apply Entailment.mdp! $ WeakerThan.pbl H; - apply Realization.interpret.iff_provable_fconj.mpr; - intro B hB; - apply Axiomatized.provable_refl; - right; - use B; - tauto; - . intro h; - obtain ⟨Γ, hΓX, H⟩ : - ∃ Γ : Finset (Modal.Formula ℕ), ↑Γ ⊆ X ∧ T ⊢ (Γ.image (GL.uniformStandardRealization T)).conj 🡒 (GL.uniformStandardRealization T) A := by - obtain ⟨⟨s, hs₁⟩, hs₂⟩ := Theory.compact_add_right $ h (GL.uniformStandardRealization T); - obtain ⟨t, ht₁, ht₂⟩ := finite_preimage_choice s X (GL.uniformStandardRealization T) hs₁; - use t; - constructor; - . assumption; - . apply Entailment.C!_trans ?_ hs₂; - apply Entailment.CFConj_FConj!_of_subset; - intro φ hφ; - obtain ⟨B, hB, rfl⟩ := ht₂ _ hφ; - grind; - use Γ; - constructor; - . assumption; - . apply GL.uniformStandardRealization_spec (T := T) |>.mp; - apply C!_trans ?_ H; - exact C_of_E_mp! $ Realization.interpret.iff_provable_fconj_inside (f := GL.uniformStandardRealization T); - -end ProvabilityLogic - -@[simp, grind .] -lemma Modal.GLα.isProvabilityLogic {T : ArithmeticTheory} [𝗜𝚺₁ ⪯ T] [T.Δ₁] [ℕ ⊧ₘ* T] {α : Set ℕ} - : (Modal.GLα α).IsProvabilityLogic T (T + ((T.LetterlessStandardRealization ∘ Modal.TBB) '' α)) := by - suffices (T.LetterlessStandardRealization ∘ Modal.TBB) '' α = T.LetterlessStandardRealization '' (Modal.TBB '' α) by - rw [this]; - apply letterless_provabilityLogic; - simp; - ext i; - simp; - -@[simp, grind .] -lemma Modal.GLαω.isProvabilityLogic {T : ArithmeticTheory} [𝗜𝚺₁ ⪯ T] [T.Δ₁] [ℕ ⊧ₘ* T] - : Modal.GLαω.IsProvabilityLogic T (T + ((T.LetterlessStandardRealization ∘ Modal.TBB) '' Set.univ)) := by - apply Modal.GLα.isProvabilityLogic; - -/- --- TODO: probably not use. -lemma Modal.GLβMinus.isProvabilityLogic {T : ArithmeticTheory} [𝗜𝚺₁ ⪯ T] [T.Δ₁] [ℕ ⊧ₘ* T] {β : Set ℕ} (hβ : β.Cofinite) - : (Modal.GLβMinus β).IsProvabilityLogic T (T + { ∼⩕ n ∈ hβ.toFinset, T.LetterlessStandardRealization $ Modal.TBB n }) := by sorry; --/ - -end LO - -end diff --git a/Foundation/ProvabilityLogic/Classification/Result.lean b/Foundation/ProvabilityLogic/Classification/Result.lean deleted file mode 100644 index e77293a37..000000000 --- a/Foundation/ProvabilityLogic/Classification/Result.lean +++ /dev/null @@ -1,288 +0,0 @@ -module - -public import Foundation.ProvabilityLogic.Classification.Trace - -@[expose] public section - -namespace LO - -open FirstOrder -open ArithmeticTheory - -namespace Modal - -namespace Logic - -variable {T U : ArithmeticTheory} [T.Δ₁] {L : Modal.Logic ℕ} - -section - -/-- α-type provability logic extension -/ -def αPL (L : Modal.Logic ℕ) (X : Set ℕ) := L.sumQuasiNormal (X.image Modal.TBB) - -variable {X : Set ℕ} - -@[simp, grind =] -lemma eq_GLαω_GLαPL : Modal.GLαω = Modal.GL.αPL Set.univ := by - simp [Modal.GLαω, Modal.GLα, αPL]; - -instance : Logic.Substitution (X.image Modal.TBB) := by - constructor; - simp only [iff_provable, Set.mem_image, forall_exists_index, and_imp]; - rintro A s a h rfl; - use a; - grind; - -variable (hPL : L.IsProvabilityLogic T U) (hCf : L.trace.Cofinite) - -lemma αPL_isProvabilityLogic [L.Substitution] (hPL : L.IsProvabilityLogic T U) : - (L.αPL X).IsProvabilityLogic T (U + (X.image (T.LetterlessStandardRealization $ Modal.TBB ·))) := by - intro A; - constructor; - . intro hA f; - induction hA using Modal.Logic.sumQuasiNormal.rec_letterless_expansion (L₁ := L) (X := X.image Modal.TBB) (by grind) with - | mem₁ hA => apply Entailment.WeakerThan.pbl $ hPL _ |>.mp hA f; - | mem₂ hA => - obtain ⟨n, hn, rfl⟩ := by simpa using hA; - sorry; - | mdp ih₁ ih₂ => exact ih₁ ⨀ ih₂; - . intro h; - sorry; - -lemma αPL_subset_S (hS : L ⊆ Modal.S) : L.αPL X ⊆ Modal.S := by - intro A; - suffices (L.αPL X) ⊢ A → Modal.S ⊢ A by grind; - intro hA; - induction hA using Modal.Logic.sumQuasiNormal.rec! with - | mem₁ hA => grind; - | mem₂ hA => - obtain ⟨_, _, rfl⟩ := by simpa using hA; - simp only [S.provable_TBB] - | mdp ih₁ ih₂ => exact ih₁ ⨀ ih₂; - | subst ih => apply Logic.subst; assumption; - -end - -end Logic - - -end Modal - - -namespace ProvabilityLogic - -open LO.Entailment Entailment.FiniteContext -open FirstOrder FirstOrder.ProvabilityAbstraction -open Arithmetic -open ArithmeticTheory -open LO.Modal -open Modal.Logic -open Modal.Kripke -open Formula.Kripke - -variable {T U : ArithmeticTheory} [Theory.Δ₁ T] [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] [T ⪯ U] -variable {L : Modal.Logic ℕ} - -/-- - Corollary 50 (half) in [A.B05] --/ -theorem subset_GLαω_of_omega_trace (L) (hPL : L.IsProvabilityLogic T U) (hT : L.trace = Set.univ) : Modal.GLαω ⊆ L := by - have := Modal.Logic.inst_Cl_of_isProvabilityLogic hPL; - intro A; - suffices Modal.GLαω ⊢ A → L ⊢ A by grind only [Logic.iff_unprovable]; - intro hA; - induction hA using Modal.Logic.sumQuasiNormal.rec_letterless_expansion (L₁ := Modal.GL) (X := TBB '' Set.univ) (by grind) with - | mem₁ hA => - apply Logic.provable_GL_of_isProvabilityLogic hPL hA; - | mem₂ hA => - obtain ⟨n, hn, rfl⟩ := by simpa using hA; - apply provable_TBB_of_mem_trace hPL; - simp [hT, Set.mem_univ] - | mdp ihAB ihA => - exact ihAB ⨀ ihA; - -section no_logic_between_GLαβ_D - -/-- - - Corollary 52(2) in [A.B05] --/ -theorem subset_D_of_subset_GLαβ_of_omega_trace - (L : Modal.Logic ℕ) (hPL : L.IsProvabilityLogic T U) (hT : L.trace = Set.univ) - : Modal.GLαω ⊂ L → Modal.D ⊆ L := by - have := Modal.Logic.inst_Cl_of_isProvabilityLogic hPL; - have : L.Substitution := by sorry; - - intro h; - obtain ⟨A, hAL, hAGL⟩ := Set.exists_of_ssubset h; - trans Modal.GLαω.sumQuasiNormal {A}; - . sorry; -- Hard part - . apply Modal.Logic.sumQuasiNormal.covered <;> grind; - -/-- - - Corollary 55 in [A.B05] --/ -lemma no_logic_between_GLαω_D - (L : Modal.Logic ℕ) (hPL : L.IsProvabilityLogic T U) (hT : L.trace = Set.univ) - : ¬((Modal.GLαω ⊂ L) ∧ (L ⊂ Modal.D)) := by - grind [subset_D_of_subset_GLαβ_of_omega_trace L hPL hT]; - -end no_logic_between_GLαβ_D - - -section no_logic_between_D_S - -/-- - - Assertion 1 in [Bek90] --/ -theorem eq_S_of_not_subset_D_of_omega_trace (L : Modal.Logic ℕ) (hPL : L.IsProvabilityLogic T U) (hT : L.trace = Set.univ) - : Modal.D ⊂ L → Modal.S ⊆ L := by - have := Modal.Logic.inst_Cl_of_isProvabilityLogic hPL; - have : L.Substitution := by sorry; - - intro h; - obtain ⟨A, hAL, hAGL⟩ := Set.exists_of_ssubset h; - trans Modal.D.sumQuasiNormal {A}; - . apply Modal.Logic.sumQuasiNormal.covered; - . intro B hB; - apply Logic.sumQuasiNormal.mem₁; - rw [Logic.iff_provable]; - apply Logic.sumQuasiNormal.mem₁; - rwa [Logic.iff_provable]; - . simp [←Logic.iff_provable]; -- Hard part - sorry - . apply Modal.Logic.sumQuasiNormal.covered <;> grind; - -/-- - - Corollary 58 in [A.B05] --/ -lemma no_logic_between_D_S (L : Modal.Logic ℕ) (hPL : L.IsProvabilityLogic T U) (hT : L.trace = Set.univ) - : ¬(Modal.D ⊂ L ∧ L ⊂ Modal.S) := by - grind [eq_S_of_not_subset_D_of_omega_trace L hPL hT]; - -end no_logic_between_D_S - -/-- - If `L.trace` is omega then `L` is one of `GLαω`, `D`, and `S`. - - Assertion 3 in [Bek90] --/ -lemma classification_S_sublogics_of_omega_trace - (L : Modal.Logic ℕ) (hPL : L.IsProvabilityLogic T U) (hT : L.trace = Set.univ) (L_subset_S : L ⊆ Modal.S) - : L = Modal.GLαω ∨ L = Modal.D ∨ L = Modal.S - := by - wlog GLαω_ssubset_L : Modal.GLαω ⊂ L; . grind [subset_GLαω_of_omega_trace]; - - have : Modal.D ⊆ L := by sorry; -- Hard part: Assertion 2 in [Bek90] using `GLαω_ssubset_L` - rcases Set.eq_or_ssubset_of_subset this with rfl | D_ssubset_L; - case inl => grind; - - right; right; - apply Set.Subset.antisymm; - . assumption; - . apply eq_S_of_not_subset_D_of_omega_trace L hPL hT D_ssubset_L; - -/-- - Let `L` be provability logic `L.trace` is cofinite. - Then `L = (L.αPL L.traceᶜ) ∩ (GLβMinus L.trace)`. --/ -theorem eq_inter_αPL_GLβMinus_of_isProvabilityLogic_of_cofinite_trace - (L : Modal.Logic ℕ) [L.Substitution] (hPL : L.IsProvabilityLogic T U) (hCf : L.trace.Cofinite) - : L = (L.αPL L.traceᶜ) ∩ (Modal.GLβMinus L.trace) := by - have := Modal.Logic.inst_Cl_of_isProvabilityLogic hPL; - - apply Set.Subset.antisymm; - . intro A hA; - constructor; - . exact Logic.sumQuasiNormal.mem₁ $ Logic.iff_provable.mpr hA; - . exact subset_GLβMinus_of_trace_cofinite hCf hA; - . rintro A ⟨h₁, h₂⟩; - simp only [Logic.αPL, ←Logic.iff_provable] at h₁ h₂ ⊢; - obtain ⟨Γ, hΓ, h₁⟩ := sumQuasiNormal.iff_provable_finite_provable_letterless TBBSet_letterless |>.mp h₁; - obtain ⟨Δ, hΔ, h₂⟩ := sumQuasiNormal.iff_provable_finite_provable_letterless TBBMinus_letterless |>.mp h₂; - apply of_C!_of_C!_of_A! (φ := (⩕ n ∈ hCf.toFinset, TBB n)) ?_ ?_ lem!; - . show L ⊢ (⩕ n ∈ hCf.toFinset, TBB n) 🡒 A; - apply Entailment.C!_trans ?_ h₁; - apply right_Fconj!_intro; - intro B hB; - obtain ⟨n, hn, rfl⟩ := hΓ hB; - apply left_Fconj'!_intro; - simpa using hn; - . show L ⊢ (∼⩕ n ∈ hCf.toFinset, TBB n) 🡒 A; - rw [(show (∼⩕ n ∈ hCf.toFinset, TBB n) = Finset.conj {∼⩕ n ∈ hCf.toFinset, TBB n} by simp)]; - apply Entailment.C!_trans (CFConj_FConj!_of_subset ?_) $ Modal.Logic.provable_GL_of_isProvabilityLogic hPL h₂; - intro δ hδ; - grind [hΔ hδ]; - -lemma eq_GLαω_inter_GLβMinus_GLα (hβ : L.trace.Cofinite) : Modal.GLα L.trace = Modal.GLαω ∩ (Modal.GLβMinus L.trace) := by - let L₁ := (Modal.GLα L.trace).αPL (Modal.GLα L.trace).traceᶜ; - let L₂ := Modal.GLβMinus (Modal.GLα L.trace).trace (by simpa); - trans (L₁ ∩ L₂); - . apply eq_inter_αPL_GLβMinus_of_isProvabilityLogic_of_cofinite_trace (L := Modal.GLα L.trace) (Modal.GLα.isProvabilityLogic (T := 𝗜𝚺₁)) ?_; - . simpa only [GLα.eq_trace]; - . have : L₁ = Modal.GLαω := by - subst L₁; - rw [ - GLα.eq_trace, - Logic.αPL, - Logic.sumQuasiNormal.sum_sum_eq_sum_union, - Modal.GLαω, - Modal.GLα, - ]; - simp [-Set.compl_iUnion, Set.image_univ]; - have : L₂ = Modal.GLβMinus L.trace := by grind [GLα.eq_trace (α := L.trace)]; - grind only; - -lemma aPL_compl_trace_isProvabilityLogic [L.Substitution] (hPL : L.IsProvabilityLogic T U) - : (L.αPL L.traceᶜ).IsProvabilityLogic T (U + (L.traceᶜ.image (T.LetterlessStandardRealization $ Modal.TBB ·))) := by - apply Modal.Logic.αPL_isProvabilityLogic hPL; - -lemma aPL_compl_trace_subset_S (hS : L ⊆ Modal.S) : L.αPL L.traceᶜ ⊆ Modal.S := by - apply Modal.Logic.αPL_subset_S hS; - -lemma aPL_compl_trace_omega_trace (hS : L ⊆ Modal.S) - : (L.αPL L.traceᶜ).trace = Set.univ := by - simp [Set.eq_univ_iff_forall, Modal.Logic.αPL]; - intro n; - use (TBB n); - constructor; - . sorry; - . sorry; - -lemma classification_S_sublogics_of_cofinite_trace - [L.Substitution] (hPL : L.IsProvabilityLogic T U) (hCf : L.trace.Cofinite) (hS : L ⊆ Modal.S) - : L = Modal.GLα L.trace ∨ L = Modal.D ∩ (Modal.GLβMinus L.trace) ∨ L = Modal.S ∩ (Modal.GLβMinus L.trace) - := by - have : 𝗜𝚺₁ ⪯ U + (L.traceᶜ.image (T.LetterlessStandardRealization $ Modal.TBB ·)) := by trans U <;> infer_instance; - have : T ⪯ U + (L.traceᶜ.image (T.LetterlessStandardRealization $ Modal.TBB ·)) := by trans U <;> infer_instance; - rcases classification_S_sublogics_of_omega_trace (L := (L.αPL L.traceᶜ)) - (aPL_compl_trace_isProvabilityLogic hPL) (aPL_compl_trace_omega_trace hS) (aPL_compl_trace_subset_S hS) - with _ | _ | _; - case inl => grind [eq_inter_αPL_GLβMinus_of_isProvabilityLogic_of_cofinite_trace, eq_GLαω_inter_GLβMinus_GLα hCf]; - all_goals. grind [eq_inter_αPL_GLβMinus_of_isProvabilityLogic_of_cofinite_trace]; - -open Classical in -/-- - The classification theorem of provability logics. - - Assertion 6 in [Bek90] - - Theorem 40 in [A.B05] --/ -theorem classification_provability_logics - (L : Modal.Logic ℕ) [L.Substitution] (hPL : L.IsProvabilityLogic T U) : - if h_coinfinite : L.trace.Coinfinite then - L = Modal.GLα L.trace - else - haveI h_cofinite : L.trace.Cofinite := Set.iff_cofinite_not_coinfinite.mpr h_coinfinite; - if ¬(L ⊆ Modal.S) then - L = Modal.GLβMinus L.trace - else - L = Modal.GLα L.trace ∨ - L = Modal.D ∩ Modal.GLβMinus L.trace ∨ - L = Modal.S ∩ Modal.GLβMinus L.trace - := by - split_ifs with h_coinfinite h_S; - . exact eq_provablityLogic_GLα_of_coinfinite_trace hPL h_coinfinite; - . exact classification_S_sublogics_of_cofinite_trace hPL (Set.iff_cofinite_not_coinfinite.mpr h_coinfinite) h_S; - . exact eq_provabilityLogic_GLβMinus_of_not_subset_S hPL h_S; - -end ProvabilityLogic - -end LO diff --git a/Foundation/ProvabilityLogic/Classification/Trace.lean b/Foundation/ProvabilityLogic/Classification/Trace.lean deleted file mode 100644 index ea5e580eb..000000000 --- a/Foundation/ProvabilityLogic/Classification/Trace.lean +++ /dev/null @@ -1,671 +0,0 @@ -module - -public import Foundation.ProvabilityLogic.Classification.LetterlessTrace -public import Foundation.Modal.Boxdot.GL_S -public import Foundation.Modal.Logic.D.Basic - -@[expose] public section - - - - -namespace LO - -namespace Modal - -variable {φ ψ : Formula ℕ} - -open Kripke -open Formula.Kripke - - -namespace Formula - -def trace (φ : Formula ℕ) : Set ℕ := { n | - ∃ M : Kripke.Model, ∃ _ : Fintype M, ∃ _ : M.IsTransitive, ∃ _ : M.IsConverseWellFounded, ∃ _ : M.IsRooted, - (M.height = n ∧ M.root.1 ⊭ φ) -} - -lemma iff_mem_trace {n : ℕ} : - n ∈ φ.trace ↔ - ∃ M : Kripke.Model, ∃ _ : Fintype M, ∃ _ : M.IsTransitive, ∃ _ : M.IsConverseWellFounded, ∃ _ : M.IsRooted, M.height = n ∧ M.root.1 ⊭ φ := by - simp [Formula.trace]; - -lemma satisfies_of_not_mem_trace : - n ∉ φ.trace ↔ - ∀ M : Kripke.Model, [Fintype M] → [M.IsTransitive] → [M.IsConverseWellFounded] → [M.IsRooted] → M.height = n → M.root.1 ⊧ φ := by - simp [Formula.trace]; - -@[grind =] -lemma eq_trace_trace_of_letterless {φ : Formula ℕ} (φ_letterless : φ.Letterless) : φ.trace = φ.letterlessTrace := by - ext n; - apply Iff.trans ?_ (Kripke.letterlessSpectrum_TFAE φ_letterless (n := n) |>.out 1 0 |>.not); - rw [iff_mem_trace]; - push Not; - constructor; - . rintro ⟨M, _, _, _, _, _⟩; - refine ⟨M, inferInstance, inferInstance, inferInstance, inferInstance, M.root, by tauto, by tauto⟩; - . contrapose! - rintro h M _ _ _ _ x rfl; - apply Model.pointGenerate.modal_equivalent x ⟨x, by tauto⟩ |>.mp; - apply h; - apply Frame.pointGenerate.eq_original_height; - -open Formula.Kripke - -@[simp, grind =] lemma trace_bot : (⊥ : Formula ℕ).trace = Set.univ := by grind; -@[simp, grind =] lemma trace_top : (⊤ : Formula ℕ).trace = ∅ := by grind; - -lemma trace_and : (φ ⋏ ψ).trace = φ.trace ∪ ψ.trace := by - ext n; - calc - _ ↔ ∃ M : Kripke.Model, ∃ _ : Fintype M, ∃ _ : M.IsTransitive, ∃ _ : M.IsConverseWellFounded, ∃ _ : M.IsRooted, M.height = n ∧ (M.root.1 ⊭ φ ∨ M.root.1 ⊭ ψ) := by - simp [Semantics.NotModels, trace, -not_and, not_and_or] - _ ↔ - (∃ M : Kripke.Model, ∃ _ : Fintype M, ∃ _ : M.IsTransitive, ∃ _ : M.IsConverseWellFounded, ∃ _ : M.IsRooted, M.height = n ∧ M.root.1 ⊭ φ) ∨ - (∃ M : Kripke.Model, ∃ _ : Fintype M, ∃ _ : M.IsTransitive, ∃ _ : M.IsConverseWellFounded, ∃ _ : M.IsRooted, M.height = n ∧ M.root.1 ⊭ ψ) := by - constructor; - . rintro ⟨M, _, _, _, _, rfl, h⟩; - cases h with - | inl h => left; tauto - | inr h => right; tauto - . rintro (⟨M, _, _, _, _, rfl, hr⟩ | ⟨M, _, _, _, _, rfl, hr⟩) <;> - refine ⟨M, inferInstance, inferInstance, inferInstance, inferInstance, rfl, by grind⟩; - _ ↔ _ := by simp [Formula.trace]; - -lemma trace_lconj₂ {s : List (Formula ℕ)} : (s.conj₂).trace = ⋃ φ ∈ s, φ.trace := by - induction s using List.induction_with_singleton with - | hcons φ s hs ih => simp [List.conj₂_cons_nonempty hs, Formula.trace_and, ih]; - | _ => simp [List.conj₂]; - -lemma trace_fconj {s : Finset (Formula ℕ)} : s.conj.trace = ⋃ φ ∈ s, φ.trace := by simp [Finset.conj, Formula.trace_lconj₂]; - -lemma subset_trace_of_provable_imp_GL (h : Modal.GL ⊢ φ 🡒 ψ) : ψ.trace ⊆ φ.trace := by - intro n hn; - obtain ⟨M, _, _, _, _, rfl, hr⟩ := iff_mem_trace.mp hn; - apply iff_mem_trace.mpr; - refine ⟨M, inferInstance, inferInstance, inferInstance, inferInstance, rfl, ?_⟩; - contrapose! hr; - have := GL.Kripke.fintype_completeness_TFAE.out 0 2 |>.mp h; - exact this M hr; - -end Formula - - -namespace FormulaSet - -abbrev trace (X : FormulaSet ℕ) : Set ℕ := ⋃ φ ∈ X, φ.trace - -@[simp] lemma trace_empty : (∅ : FormulaSet ℕ).trace = ∅ := by simp [FormulaSet.trace]; - -lemma eq_FormulaSet_trace_finset_conj {X : Finset (Formula ℕ)} : X.conj.trace = FormulaSet.trace X := by simp [FormulaSet.trace, Formula.trace_fconj]; - -lemma subset_trace_of_subset {X Y : FormulaSet ℕ} (h : X ⊆ Y) : X.trace ⊆ Y.trace := by - simp only [trace, Set.iUnion_subset_iff]; - intro φ hφ i hi; - simp only [Set.mem_iUnion, exists_prop]; - use φ; - constructor; - . apply h; assumption; - . assumption; - -end FormulaSet - - -abbrev Logic.trace (L : Logic ℕ) : Set ℕ := FormulaSet.trace L - -lemma GL.eq_trace_ext {X : FormulaSet ℕ} (hX : ∀ ξ ∈ X, ∀ s : Substitution _, ξ⟦s⟧ ∈ X) : (Modal.GL.sumQuasiNormal X).trace = X.trace := by - ext n; - constructor; - . suffices (∃ φ, Modal.GL.sumQuasiNormal X ⊢ φ ∧ n ∈ φ.trace) → (n ∈ X.trace) by simpa [Logic.trace, Logic.iff_provable]; - rintro ⟨φ, hφ₁, hφ₂⟩; - obtain ⟨Y, hY₁, hY₂⟩ := Logic.sumQuasiNormal.iff_provable_finite_provable hX |>.mp hφ₁; - apply FormulaSet.subset_trace_of_subset hY₁; - apply FormulaSet.eq_FormulaSet_trace_finset_conj ▸ Formula.subset_trace_of_provable_imp_GL hY₂; - assumption; - . suffices (∃ φ ∈ X, n ∈ φ.trace) → (∃ φ, Modal.GL.sumQuasiNormal X ⊢ φ ∧ n ∈ φ.trace) by simpa [Logic.trace, Logic.iff_provable]; - rintro ⟨φ, hφ₁, hφ₂⟩; - use φ; - constructor; - . apply Logic.sumQuasiNormal.mem₂!; - simpa [Logic.iff_provable]; - . assumption; - -lemma GL.unprovable_of_exists_trace (φ_letterless : φ.Letterless) : (∃ n, n ∈ φ.letterlessTrace) → Modal.GL ⊬ φ := by - contrapose!; - intro h; - have := Modal.iff_GL_provable_letterlessSpectrum_Univ φ_letterless |>.mp (by simpa using h); - simp_all [Formula.letterlessTrace]; - -@[simp] -lemma TBBMinus_trace (hβ : β.Cofinite) : (∼⩕ n ∈ hβ.toFinset, TBB n).letterlessTrace = β := by - simp [Formula.letterlessTrace, TBBMinus_letterlessSpectrum'] - -@[simp] -lemma GL.eq_trace_emptyset : Modal.GL.trace = ∅ := by - rw [←Logic.sumQuasiNormal.with_empty (L₁ := Modal.GL)] - simpa using GL.eq_trace_ext (X := ∅) (by simp); - -@[simp] -lemma GLα.eq_trace {α : Set ℕ} : (Modal.GLα α).trace = α := by - apply Eq.trans $ GL.eq_trace_ext $ by grind; - simp [FormulaSet.trace, Formula.eq_trace_trace_of_letterless]; - -@[simp] -lemma GLβMinus.eq_trace {β : Set ℕ} (hβ : β.Cofinite := by grind) : (Modal.GLβMinus β).trace = β := by - apply Eq.trans $ GL.eq_trace_ext $ by grind; - simp [FormulaSet.trace, Formula.eq_trace_trace_of_letterless]; - -@[simp, grind .] lemma S.provable_TBB {n : ℕ} : Modal.S ⊢ TBB n := by simp [TBB] - -@[simp] -lemma subset_GLα_S : Modal.GLα α ⊆ Modal.S := by - intro φ; - suffices Modal.GLα α ⊢ φ → Modal.S ⊢ φ by grind; - intro hφ; - induction hφ using Modal.Logic.sumQuasiNormal.rec! with - | mem₁ hφ => exact Entailment.WeakerThan.pbl hφ; - | mem₂ hφ => obtain ⟨_, _, rfl⟩ := hφ; simp; - | mdp ihφψ ihφ => exact ihφψ ⨀ ihφ; - | subst ihφ => exact Logic.subst _ ihφ; - -instance : Modal.GLα α ⪯ Modal.S := Logic.weakerThan_of_subset subset_GLα_S - -@[simp] -lemma S.eq_trace : Modal.S.trace = Set.univ := by - suffices ∀ (x : ℕ), ∃ i ∈ Modal.S, x ∈ i.trace by simpa [Set.eq_univ_iff_forall] - intro n; - use (TBB n); - constructor; - . apply Logic.iff_provable.mp; grind; - . simp [Formula.eq_trace_trace_of_letterless]; - -variable {L : Logic ℕ} {φ : Formula ℕ} - - -lemma subset_of_provable (h : L ⊢ φ) : φ.trace ⊆ L.trace := by - intro n h; - suffices ∃ i ∈ L, n ∈ i.trace by simpa [Logic.trace, FormulaSet.trace]; - use φ; - grind; - - -namespace Kripke - -/-- - `... ≺ x ≺ a ≺ y ≺ ...` - - ↓ - - `... ≺ x ≺ (n - 1) ≺ ... ≺ 0 ≺ a ≺ y ≺ ...` --/ -abbrev Model.boneLengthening (M : Kripke.Model) (a : M) (n : ℕ) : Kripke.Model where - World := M.World ⊕ Fin n - Rel w v := - match w, v with - | .inl x, .inl y => x ≺ y - | .inl x, .inr _ => x ≺ a - | .inr _, .inl y => y = a ∨ a ≺ y - | .inr i, .inr j => i > j - Val p x := - match x with - | .inl w => M.Val p w - | .inr _ => M.Val p a - -namespace Model.boneLengthening - -variable {M : Kripke.Model} {a : M} [M.IsIrreflexive] {k : ℕ} {φ : Formula ℕ} - -@[coe] abbrev callus (i : Fin k) : M.boneLengthening a k := Sum.inr i -instance : Coe (Fin k) (M.boneLengthening a k) := ⟨callus⟩ - -@[coe] abbrev embed (x : M) : M.boneLengthening a k := Sum.inl x -instance : Coe (M.World) ((M.boneLengthening a k).World) := ⟨embed⟩ - -instance [Fintype M] : Fintype (M.boneLengthening a k) := by apply instFintypeSum - -instance [M.IsTransitive] : (M.boneLengthening a k).IsTransitive where - trans := by - rintro (x | i) (y | j) (z | l) Rxy Ryz <;> simp_all only; - . apply Frame.trans Rxy Ryz; - . apply Frame.trans Rxy Ryz; - . rcases Ryz with rfl | Ray; - . assumption; - . exact Frame.trans Rxy Ray; - . rcases Rxy with rfl | Ray; - . tauto; - . right; - exact Frame.trans Ray Ryz; - . exfalso; - rcases Rxy with rfl | Ray; - . apply M.irrefl _ Ryz; - . apply M.irrefl _ $ Frame.trans Ryz Ray; - . omega; - -instance [M.IsIrreflexive] : (M.boneLengthening a k).IsIrreflexive where - irrefl := by - rintro (x | i); - . apply M.irrefl x; - . simp; - -instance instRooted [M.IsTransitive] [M.IsRooted] (ha : a ≠ M.root) : (M.boneLengthening a k).IsRooted where - default := ⟨Sum.inl M.root.1, by rintro (x | i) <;> grind⟩; - -instance isTree [M.IsAsymmetric] (hra : r ≠ a) : (M.boneLengthening a k).IsAsymmetric where - asymm := by - rintro (x | i) (y | j) Rxy; - . apply M.asymm Rxy; - . apply not_or.mpr; - constructor; - . contrapose! Rxy; - simp_all - . exact M.asymm Rxy; - . rcases Rxy with rfl | Ray; - . apply Frame.irrefl; - . apply M.asymm Ray; - . simp_all - omega; - -@[simp] -axiom eq_height [Fintype M] [M.IsIrreflexive] [M.IsTransitive] [M.IsRooted] (hra : a ≠ M.root) : - have : (M.boneLengthening a k).IsRooted := instRooted hra; - (M.boneLengthening a k).height = M.height + k - /- - := by - intro _; - apply height_eq_iff_relItr.mpr; - constructor; - . obtain ⟨t, Rrt⟩ := Kripke.exists_rank_terminal (F := M.boneLengthening a k |>.toFrame) r; - use t; - induction k with - | zero => - sorry; - | succ k ih => - suffices (r : M.boneLengthening a (k + 1)) ≺^[(M.rank + k) + 1] t by - rwa [(show M.rank + (k + 1) = (M.rank + k) + 1 by omega)]; - dsimp [Frame.RelItr', Rel.Iterate] - sorry; - . intro t Rrt x; - sorry; - -/ - -axiom equivalence {x : M} (hx : x = a ∨ a ≺ x) : ∀ φ, x ⊧ φ ↔ (Satisfies _ (x : M.boneLengthening a k) φ) -- := by sorry - -lemma mainlemma_aux - (hrfl : a ⊧ φ.rflSubformula.conj) - {ψ} (hψ : ψ ∈ φ.subformulas) : - (∀ i : Fin k, (Satisfies _ (i : M.boneLengthening a k) ψ ↔ Satisfies _ (a : M.boneLengthening a k) ψ)) ∧ - (∀ x : M, (x ⊧ ψ ↔ Satisfies _ (x : M.boneLengthening a k) ψ)) := by - induction ψ with - | hatom => simp [Semantics.Models, Satisfies, Model.boneLengthening]; - | hfalsum => simp [Satisfies]; - | himp ψ ξ ihψ ihξ => simp [Satisfies, ihψ (by grind), ihξ (by grind)]; - | hbox ψ ihφ => - have ⟨ihφ₁, ihφ₂⟩ := ihφ (by grind); - constructor; - . intro i; - constructor; - . rintro h j Raj; - apply h; - rcases j with (j | j); - . right; exact Raj; - . simp [Frame.Rel', Model.boneLengthening] at Raj; - . intro h; - have : Satisfies _ (a : M.boneLengthening a k) ψ := Satisfies.fconj_def.mp (equivalence (by tauto) _ |>.mp hrfl) (□ψ 🡒 ψ) ?_ h; - . rintro (y | j) Ri; - . rcases Ri with rfl | Ray; - . assumption; - . apply h; - exact Ray; - . apply ihφ₁ j |>.mpr this; - . simp only [Finset.mem_image, Finset.LO.preboxItr, Function.iterate_one, Finset.mem_preimage] - use ψ; - . intro y; - constructor; - . rintro h (z | j) Ryz; - . apply ihφ₂ _ |>.mp; - apply h; - exact Ryz; - . apply ihφ₁ j |>.mpr; - apply ihφ₂ _ |>.mp; - apply h; - apply Ryz; - . intro h z Ryz; - apply ihφ₂ z |>.mpr; - apply h; - exact Ryz; - -lemma mainlemma₁ - (hrfl : a ⊧ φ.rflSubformula.conj) {ψ} (hψ : ψ ∈ φ.subformulas) (i : Fin k) - : (Satisfies _ (i : M.boneLengthening a k) ψ) ↔ Satisfies _ (a : M.boneLengthening a k) ψ := (mainlemma_aux hrfl (by grind)).1 i - -lemma mainlemma₂ - (hrfl : a ⊧ φ.rflSubformula.conj) {ψ} (hψ : ψ ∈ φ.subformulas) (x : M) - : (x ⊧ ψ) ↔ Satisfies _ (x : M.boneLengthening a k) ψ := (mainlemma_aux hrfl (by grind)).2 x - -end Model.boneLengthening - -end Kripke - -axiom GL.formalized_validates_axiomT_set_in_irrefl_trans_chain : Modal.GL ⊢ ∼□^[(φ.rflSubformula.card + 1)]⊥ 🡒 ◇φ.rflSubformula.conj - -@[grind .] -lemma Formula.trace.finite_or_cofinite : φ.trace.Finite ∨ φ.trace.Cofinite := by - suffices φ.trace.Infinite → φ.trace.Cofinite by tauto; - intro tr_infinite; - - obtain ⟨m, hm₁, hm₂⟩ : ∃ m, m ∈ φ.trace ∧ φ.rflSubformula.card < m := Set.infinite_iff_exists_gt.mp tr_infinite _; - obtain ⟨M, _, _, _, _, rfl, hr⟩ := iff_mem_trace.mp hm₁; - - have H₁ : M.root.1 ⊧ ∼□^[(φ.rflSubformula.card + 1)]⊥ := height_lt_iff_satisfies_boxbot (i := M.root.1) (n := φ.rflSubformula.card + 1) |>.not.mp $ by - rw [←Frame.height]; - omega; - - have := GL.Kripke.fintype_completeness_TFAE (φ := ∼□^[(φ.rflSubformula.card + 1)]⊥ 🡒 ◇φ.rflSubformula.conj) |>.out 0 2 |>.mp GL.formalized_validates_axiomT_set_in_irrefl_trans_chain; - have H₂ : M.root.1 ⊧ ∼□^[(φ.rflSubformula.card + 1)]⊥ 🡒 ◇φ.rflSubformula.conj := this M; - obtain ⟨a, Rrx, hx⟩ := Satisfies.dia_def.mp $ H₂ H₁; - replace Rrx : M.root.1 ≠ a := by rintro rfl; apply M.irrefl _ Rrx; - - have : {k | k ≥ M.height} ⊆ φ.trace := by - intro k hmk; - obtain ⟨k, rfl⟩ := Nat.exists_eq_add_of_le hmk; - apply iff_mem_trace.mpr; - refine ⟨M.boneLengthening a k, inferInstance, inferInstance, inferInstance, ?_, ?_, ?_⟩; - . exact Model.boneLengthening.instRooted (by grind); - . exact Model.boneLengthening.eq_height (by grind); - . exact Model.boneLengthening.mainlemma₂ hx (show φ ∈ φ.subformulas by grind) (k := k) M.root |>.not.mp hr; - apply Set.Cofinite.subset this; - apply Set.Finite.subset (s := Finset.range M.height); - . apply Finset.finite_toSet; - . intro i; - simp; - -@[grind →] -lemma Formula.trace.finite_of_coinfinite (h_ci : φ.trace.Coinfinite) : φ.trace.Finite := by - apply or_iff_not_imp_right.mp $ Formula.trace.finite_or_cofinite; - simpa; - -/-- - `L` is contained in `GLα L.trace` when `L.trace` is coinfinite --/ -lemma subset_GLα_of_trace_coinfinite (hL : L.trace.Coinfinite) : L ⊆ Modal.GLα L.trace := by - intro φ hφ; - apply Modal.Logic.iff_provable.mp; - - have : φ.trace ⊆ L.trace := subset_of_provable (by grind); - have : φ.trace.Finite := by - have : φ.trace.Coinfinite := Set.Coinfinite.subset this hL - grind - let Tφ := this.toFinset; - - apply Logic.sumQuasiNormal.iff_provable_finite_provable_letterless ?_ |>.mpr ⟨(Tφ.image TBB), ?_, ?_⟩; - . grind; - . simpa [Tφ] - . apply GL.Kripke.fintype_completeness_TFAE.out 2 0 |>.mp; - intro M _ _ _ _ hr; - have : Fintype M.World := Fintype.ofFinite _; - apply Formula.satisfies_of_not_mem_trace (n := M.height) |>.mp; - . replace hr : ∀ n ∈ φ.trace, M.height ≠ n := by - intro n h; - apply iff_satisfies_TBB_ne_rank.mp; - apply Satisfies.fconj_def.mp hr _; - suffices ∃ m ∈ φ.trace, (□^[m]⊥ : Formula ℕ) = □^[n]⊥ by - simp only [Finset.mem_image, Set.Finite.mem_toFinset, Tφ]; - use n; - use n; - by_contra hC; - apply hr _ hC rfl; - . rfl; - -/-- - `L` is contained in `GLβMinus L.trace` when `L.trace` is cofinite --/ -lemma subset_GLβMinus_of_trace_cofinite (hL : L.trace.Cofinite) : L ⊆ Modal.GLβMinus L.trace := by - intro φ hφ; - apply Modal.Logic.iff_provable.mp; - - have : φ.trace ⊆ L.trace := subset_of_provable (by grind); - - let Tφ := hL.toFinset; - - apply Logic.sumQuasiNormal.iff_provable_finite_provable_letterless ?_ |>.mpr ⟨{∼⩕ n ∈ Tφ, TBB n}, ?_, ?_⟩; - . grind; - . simp_all [Set.compl_iUnion, Tφ]; - . apply GL.Kripke.fintype_completeness_TFAE.out 2 0 |>.mp; - intro M _ _ _ _ hr; - have : Fintype M.World := Fintype.ofFinite _; - apply Formula.satisfies_of_not_mem_trace (n := M.height) |>.mp; - . replace hr : ∀ (n : ℕ), ∀ x ∈ L, n ∈ x.trace → ¬M.height = n := by - rintro n ξ hξ₁ hξ₂ rfl; - obtain ⟨m, hm₁, hm₂⟩ : ∃ m, m ∈ Tφ ∧ M.root.1 ⊭ TBB m := Satisfies.not_fconj'_def.mp $ Satisfies.not_def.mp $ by - simpa only [Finset.conj_singleton] using hr; - replace hm₁ : ∀ i ∈ L, m ∉ i.trace := by simpa [Tφ] using hm₁; - replace hm₂ : M.height = m := by simpa using iff_satisfies_TBB_ne_rank.not.mp hm₂; - apply hm₁ ξ; - . assumption; - . grind; - by_contra hC; - apply hr M.height φ hφ hC rfl; - . rfl; - -@[simp] -lemma eq_GLβMinusOmega : Modal.GLβMinus Set.univ = Set.univ := by - apply Set.eq_univ_iff_forall.mpr; - intro φ; - apply Logic.iff_provable.mp; - apply Logic.sumQuasiNormal.iff_provable_finite_provable_letterless (by grind;) |>.mpr; - use {∼⊤}; - constructor; - . simp; - . suffices Modal.GL ⊢ ∼⊤ 🡒 φ by simpa; - cl_prover; - -end Modal - -namespace ProvabilityLogic - -open LO.Entailment Entailment.FiniteContext -open FirstOrder FirstOrder.ProvabilityAbstraction -open Arithmetic -open ArithmeticTheory (provabilityLogicOn) -open LO.Modal -open Modal.Kripke -open Formula.Kripke - -variable {T U : ArithmeticTheory} [T.Δ₁] -variable {A : Formula ℕ} - -lemma provable_TBB_of_mem_trace - [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] - {L : Logic _} (hPL : L.IsProvabilityLogic T U) - {n : ℕ} (h : n ∈ L.trace) : L ⊢ Modal.TBB n := by - obtain ⟨A, hA₁, ⟨M, _, _, _, _, rfl, h₂⟩⟩ := by simpa using h; - replace hA₁ : ∀ f : T.StandardRealization, U ⊢ f A := hPL A |>.mp $ by grind; - - let M₀ := M.extendRoot 1; - - let S := SolovaySentences.standard T M₀.toFrame; - have : M₀ ⊧ A 🡒 (Modal.TBB M.height) := by - rintro x hA; - rcases Nat.lt_trichotomy (Frame.rank x) M.height with h | h | h; - . intro _; - exact height_lt_iff_satisfies_boxbot.mp h; - . exfalso; - apply h₂; - apply Kripke.Model.extendRoot.modal_equivalence_original_world.mp; - rwa [Kripke.Frame.extendRoot.iff_eq_height_eq_original_root.mp h] at hA; - . apply iff_satisfies_mem_rank_letterlessSpectrum (by grind) |>.mpr; - simp; - omega; - have : ∀ i : M₀.World, 𝗜𝚺₁ ⊢ S i 🡒 S.realization (A 🡒 (Modal.TBB M.height)) := by - rintro (a | i); - . apply C!_trans $ C!_trans (S.SC2 (Sum.inl a) M.root (by grind)) - $ contra! - $ T.standardProvability.mono' - $ CN!_of_CN!_right - $ S.mainlemma_neg (by simp) - $ height_lt_iff_satisfies_boxbot.not.mp - $ by - show ¬(Frame.rank (Frame.extendRoot.embed M.root.1)) < M.height; - simp [Frame.extendRoot.eq_original_height_root]; - simp only [Realization.interpret.def_imp, Box.boxItr_succ, Realization.interpret.def_box]; - cl_prover; - . apply S.mainlemma (by simp); - apply this; - have : 𝗜𝚺₁ ⊢ (⩖ j, S j) 🡒 S.realization (A 🡒 (Modal.TBB M.height)) := left_Udisj!_intro _ this - have : 𝗜𝚺₁ ⊢ S.realization (A 🡒 (Modal.TBB M.height)) := by cl_prover [this, S.SC4]; - have : U ⊢ S.realization (Modal.TBB M.height) := by - have : U ⊢ S.realization A 🡒 S.realization (Modal.TBB M.height) := WeakerThan.pbl this; - cl_prover [this, hA₁ S.realization]; - apply hPL _ |>.mpr; - grind only [ - Realization.interpret.def_imp, - Realization.interpret.def_boxItr, - Realization.interpret.def_box, - Realization.interpret.def_bot - ]; - - -/-- - `L` equals `GLα L.trace` when `L.trace` is coinfinite. - - Corollary 48 in [A.B05] --/ -theorem eq_provablityLogic_GLα_of_coinfinite_trace - [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] [T ⪯ U] -- TODO: `[T ⪯ U]` might not be necessary - {L : Logic _} (hPL : L.IsProvabilityLogic T U) (hCi : L.trace.Coinfinite) - : L = Modal.GLα L.trace := by - haveI := Logic.inst_Cl_of_isProvabilityLogic hPL; - apply Set.Subset.antisymm; - . apply subset_GLα_of_trace_coinfinite hCi; - . intro A; - suffices Modal.GLα L.trace ⊢ A → L ⊢ A by grind; - intro hA; - induction hA using - Modal.Logic.sumQuasiNormal.rec!_omitSubst_strong (L₁ := Modal.GL) (L₂ := L.trace.image TBB) - inferInstance $ Logic.substitution_of_letterless $ Modal.TBBSet_letterless - with - | mem₁ hA => - apply hPL _ |>.mpr; - intro f; - exact WeakerThan.pbl $ GL.arithmetical_soundness hA; - | mem₂ hA => - obtain ⟨n, ⟨N, ⟨A, hA₁, hA₂⟩, hN₂⟩, rfl⟩ := hA; - apply provable_TBB_of_mem_trace hPL; - simp_all only [Set.mem_iUnion, exists_prop]; - use A; - | mdp ihAB ihA => - exact ihAB ⨀ ihA; - -lemma cofinite_of_not_subset_S - [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] [T ⪯ U] - {L : Logic _} (hPL : L.IsProvabilityLogic T U) (hS : ¬L ⊆ Modal.S) - : L.trace.Cofinite := by - contrapose! hS; - rw [eq_provablityLogic_GLα_of_coinfinite_trace hPL hS]; - simp; - -lemma provable_TBBMinus_of_mem_trace - [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] [T ⪯ U] - {L : Logic _} (hPL : L.IsProvabilityLogic T U) (hS : ¬L ⊆ Modal.S) - : L ⊢ ∼⩕ i ∈ (cofinite_of_not_subset_S hPL hS).toFinset, TBB i := by - haveI := Logic.inst_Cl_of_isProvabilityLogic hPL; - - obtain ⟨A, hA₁, hA₂⟩ := Set.not_subset.mp hS; - replace hA₁ : L ⊢ A := Logic.iff_provable.mpr hA₁; - replace hA₂ : Modal.GL ⊬ A.rflSubformula.conj 🡒 A := Modal.Logic.iff_provable_rflSubformula_GL_provable_S.not.mpr $ Logic.iff_provable.not.mpr hA₂; - obtain ⟨M₁, _, _, _, _, hM⟩ := Modal.GL.Kripke.iff_unprovable_exists_fintype_rooted_model.mp hA₂; - - let M₀ := Model.extendRoot M₁ 1; - - let R := Set.Finite.inter_of_left (s := (Finset.range M₁.height)) (t := L.trace) (Finset.finite_toSet _) |>.toFinset; - let B := A ⋏ ⩕ i ∈ R, TBB i; - have hB : L ⊢ B := by - suffices L ⊢ A ∧ ∀ i ∈ R, L ⊢ TBB i by - have ⟨h₁, h₂⟩ := this; - replace h₂ : L ⊢ ⩕ i ∈ R, TBB i := Entailment.FConj'_iff_forall_provable.mpr h₂; - cl_prover [h₁, h₂]; - constructor; - . assumption; - . rintro i hi; - apply provable_TBB_of_mem_trace hPL; - simp_all [R, Logic.trace]; - - letI S := SolovaySentences.standard T M₀.toFrame; - letI Tr := cofinite_of_not_subset_S hPL hS |>.toFinset; - - apply hPL _ |>.mpr; - intro g; - apply Realization.iff_provable_letterless_interpret ?_ |>.mp; - . show U ⊢ S.realization (∼⩕ n ∈ Tr, TBB n); - apply Entailment.mdp! (φ := S.realization B) ?_ $ hPL _ |>.mp hB S.realization; - . apply WeakerThan.pbl (𝓢 := 𝗜𝚺₁); - show 𝗜𝚺₁ ⊢ (S.realization B 🡒 S.realization (∼⩕ n ∈ Tr, TBB n)); - apply ?_ ⨀ S.SC4; - apply left_Udisj!_intro _; - intro i; - rcases Frame.extendRoot.eq_root_or_eq_original i with (rfl | ⟨i, rfl⟩); - . have H₁ : 𝗜𝚺₁ ⊢ S M₀.root 🡒 ∼S.realization A := SolovaySentences.rfl_mainlemma_neg hM A (by grind) $ Satisfies.not_imp_def.mp hM |>.2; - have H₂ : 𝗜𝚺₁ ⊢ S.realization B 🡘 S.realization A ⋏ S.realization (⩕ n ∈ R, TBB n) := Realization.interpret.iff_provable_and_inside; - cl_prover [H₁, H₂]; - . suffices 𝗜𝚺₁ ⊢ S i 🡒 S.realization (B 🡒 (∼⩕ n ∈ Tr, TBB n)) by simpa; - apply SolovaySentences.mainlemma (S := S) (T := T) (i := i); - . simp; - . intro h; - apply Satisfies.not_def.mpr; - apply Satisfies.not_fconj'_def.mpr; - use Frame.rank (i : M₀); - constructor; - . by_contra hC; - apply iff_satisfies_TBB_ne_rank (M := M₀) (w := ↑i) (n := Frame.rank (i : M₀)) |>.mp; - . have := Satisfies.fconj'_def.mp $ Satisfies.and_def.mp h |>.2; - apply this _ ?_; - simp only [R, Finset.coe_range, Set.Finite.mem_toFinset, Set.mem_inter_iff, Set.mem_Iio, Set.mem_iUnion, exists_prop]; - constructor; - . suffices Frame.rank i < M₁.height by calc - _ = Frame.rank (i : M₁) := Frame.extendRoot.eq_original_height - _ < _ := this; - apply Frame.rank_lt_whole_height; - wlog ei : i = M₁.root; . grind; - subst ei; - exfalso; - apply Satisfies.not_imp_def.mp hM |>.2; - apply Model.extendRoot.modal_equivalence_original_world.mp; - exact Satisfies.and_def.mp h |>.1; - . simpa [Tr] using hC; - . rfl; - . apply iff_satisfies_TBB_ne_rank.not.mpr; - simp; - . apply TBBMinus_letterless'; - -/-- - `L` equals `GLβMinus L.trace` when `L` is not a subset of `S`. - - Lemma 49 in [A.B05] --/ -theorem eq_provabilityLogic_GLβMinus_of_not_subset_S - [𝗜𝚺₁ ⪯ T] [𝗜𝚺₁ ⪯ U] [T ⪯ U] - {L : Logic _} (hPL : L.IsProvabilityLogic T U) (hS : ¬L ⊆ Modal.S) - : L = Modal.GLβMinus L.trace (cofinite_of_not_subset_S hPL hS) := by - haveI := Logic.inst_Cl_of_isProvabilityLogic hPL; - - apply Set.Subset.antisymm; - . apply subset_GLβMinus_of_trace_cofinite; - apply cofinite_of_not_subset_S hPL hS; - . intro A; - rw [←Logic.iff_provable, ←Logic.iff_provable] - intro hA; - induction hA using - Modal.Logic.sumQuasiNormal.rec!_omitSubst_strong (L₁ := Modal.GL) (L₂ := {∼(⩕ n ∈ (cofinite_of_not_subset_S hPL hS).toFinset, (TBB n))}) - inferInstance (Logic.substitution_of_letterless TBBMinus_letterless) with - | mem₁ hA => - apply hPL _ |>.mpr; - intro f; - exact WeakerThan.pbl $ GL.arithmetical_soundness hA; - | mem₂ hA => - replace hA := Logic.iff_provable.mp hA; - subst hA; - exact provable_TBBMinus_of_mem_trace hPL hS; - | mdp ihAB ihA => exact ihAB ⨀ ihA; - -end ProvabilityLogic - -end LO From efef74da8d8d373c116d1475eebddfb7338e6e13 Mon Sep 17 00:00:00 2001 From: SnO2WMaN Date: Thu, 2 Jul 2026 20:02:26 +0900 Subject: [PATCH 57/61] fix(Propositional/Tait): rename OneSidedLK instance field wk to contraction Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01S1wqPfbHabyo2rsKAtJm9g --- Foundation/Propositional/Tait/Calculus.lean | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Foundation/Propositional/Tait/Calculus.lean b/Foundation/Propositional/Tait/Calculus.lean index 2657035c9..cdaa759c2 100644 --- a/Foundation/Propositional/Tait/Calculus.lean +++ b/Foundation/Propositional/Tait/Calculus.lean @@ -60,7 +60,7 @@ instance : OneSidedLK (Derivation (α := α)) where verum := verum and d₁ d₂ := d₁.and d₂ or d := d.or - wk d ss := d.wk ss + contraction d ss := d.wk ss identity φ := eta φ instance : OneSidedLK.Cut (Derivation (α := α)) where From d89bfb0cb64043d141d3593853d78fb9aae54e04 Mon Sep 17 00:00:00 2001 From: SnO2WMaN Date: Thu, 2 Jul 2026 20:02:26 +0900 Subject: [PATCH 58/61] fix(SecondOrder): adapt to instance-implicit Semiterm.val and annotate term types Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01S1wqPfbHabyo2rsKAtJm9g --- Foundation/SecondOrder/Semantics.lean | 32 +++++++++++++-------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Foundation/SecondOrder/Semantics.lean b/Foundation/SecondOrder/Semantics.lean index e04df0154..d9a45fafe 100644 --- a/Foundation/SecondOrder/Semantics.lean +++ b/Foundation/SecondOrder/Semantics.lean @@ -36,12 +36,12 @@ variable {M : Type w} [𝓈 : Structure L M] def EvalAux (𝕊 : Set (Set M)) (F : Ξ → Set M) (f : ξ → M) (E : Fin N → Set M) (e : Fin n → M) : Semiformula L Ξ ξ N n → Prop - | rel R v => 𝓈.rel R (Semiterm.val 𝓈 e f ∘ v) - | nrel R v => ¬𝓈.rel R (Semiterm.val 𝓈 e f ∘ v) - | t ∈& X => t.val 𝓈 e f ∈ F X - | t ∉& X => t.val 𝓈 e f ∉ F X - | t ∈# X => t.val 𝓈 e f ∈ E X - | t ∉# X => t.val 𝓈 e f ∉ E X + | rel R v => 𝓈.rel R (Semiterm.val e f ∘ v) + | nrel R v => ¬𝓈.rel R (Semiterm.val e f ∘ v) + | t ∈& X => t.val e f ∈ F X + | t ∉& X => t.val e f ∉ F X + | t ∈# X => t.val e f ∈ E X + | t ∉# X => t.val e f ∉ E X | ⊤ => True | ⊥ => False | φ ⋏ ψ => φ.EvalAux 𝕊 F f E e ∧ ψ.EvalAux 𝕊 F f E e @@ -67,22 +67,22 @@ def Eval (𝕊 : Set (Set M)) (F : Ξ → Set M) (f : ξ → M) (E : Fin N → S map_imply' := by simp [EvalAux_neg, EvalAux, imp_iff_not_or] @[simp] lemma eval_rel {k} {R : L.Rel k} {v} : - (rel R v).Eval 𝕊 F f E e ↔ 𝓈.rel R (Semiterm.val 𝓈 e f ∘ v) := by rfl + (rel R v).Eval 𝕊 F f E e ↔ 𝓈.rel R (Semiterm.val e f ∘ v) := by rfl @[simp] lemma eval_nrel {k} {R : L.Rel k} {v} : - (nrel R v).Eval 𝕊 F f E e ↔ ¬𝓈.rel R (Semiterm.val 𝓈 e f ∘ v) := by rfl + (nrel R v).Eval 𝕊 F f E e ↔ ¬𝓈.rel R (Semiterm.val e f ∘ v) := by rfl -@[simp] lemma eval_fvar {X : Ξ} {t} : - (t ∈& X).Eval 𝕊 F f E e ↔ t.val 𝓈 e f ∈ F X := by rfl +@[simp] lemma eval_fvar {X : Ξ} {t : Semiterm L ξ n} : + (t ∈& X).Eval 𝕊 F f E e ↔ t.val e f ∈ F X := by rfl -@[simp] lemma eval_nfvar {X : Ξ} {t} : - (t ∉& X).Eval 𝕊 F f E e ↔ t.val 𝓈 e f ∉ F X := by rfl +@[simp] lemma eval_nfvar {X : Ξ} {t : Semiterm L ξ n} : + (t ∉& X).Eval 𝕊 F f E e ↔ t.val e f ∉ F X := by rfl -@[simp] lemma eval_bvar {X : Fin N} {t} : - (t ∈# X).Eval 𝕊 F f E e ↔ t.val 𝓈 e f ∈ E X := by rfl +@[simp] lemma eval_bvar {X : Fin N} {t : Semiterm L ξ n} : + (t ∈# X).Eval 𝕊 F f E e ↔ t.val e f ∈ E X := by rfl -@[simp] lemma eval_nbvar {X : Fin N} {t} : - (t ∉# X).Eval 𝕊 F f E e ↔ t.val 𝓈 e f ∉ E X := by rfl +@[simp] lemma eval_nbvar {X : Fin N} {t : Semiterm L ξ n} : + (t ∉# X).Eval 𝕊 F f E e ↔ t.val e f ∉ E X := by rfl @[simp] lemma eval_fal₀ {φ : Semiformula L Ξ ξ N (n + 1)} : (∀⁰ φ).Eval 𝕊 F f E e ↔ ∀ x, φ.Eval 𝕊 F f E (x :> e) := by rfl From 7918a5de47d143fed8cd6e18132bb869308f2bc4 Mon Sep 17 00:00:00 2001 From: SnO2WMaN Date: Thu, 2 Jul 2026 20:02:27 +0900 Subject: [PATCH 59/61] =?UTF-8?q?fix:=20replace=20removed=20=E2=8A=A7?= =?UTF-8?q?=E2=82=98/=E2=8A=A7=E2=82=98*=20notation=20with=20M=E2=86=93[L]?= =?UTF-8?q?=20=E2=8A=A7/=E2=8A=A7*=20form?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01S1wqPfbHabyo2rsKAtJm9g --- .../FirstOrder/Arithmetic/R0/Representation.lean | 2 +- .../ProvabilityLogic/Grz/Completeness.lean | 10 +++++----- Foundation/ProvabilityLogic/S/Completeness.lean | 16 ++++++++-------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Foundation/FirstOrder/Arithmetic/R0/Representation.lean b/Foundation/FirstOrder/Arithmetic/R0/Representation.lean index c2a8e46cd..a39fb3b7c 100644 --- a/Foundation/FirstOrder/Arithmetic/R0/Representation.lean +++ b/Foundation/FirstOrder/Arithmetic/R0/Representation.lean @@ -117,7 +117,7 @@ section model open LO.Arithmetic -variable {M : Type*} [ORingStructure M] [M ⊧ₘ* 𝗥₀] +variable {M : Type*} [ORingStructure M] [M↓[ℒₒᵣ] ⊧* 𝗥₀] private lemma codeAux_uniq {k} {c : Code k} {v : Fin k → M} {z z' : M} : Semiformula.Evalfm M (z :> v) (codeAux c) → Semiformula.Evalfm M (z' :> v) (codeAux c) → z = z' := by diff --git a/Foundation/ProvabilityLogic/Grz/Completeness.lean b/Foundation/ProvabilityLogic/Grz/Completeness.lean index 6caf922c3..1deb19a71 100644 --- a/Foundation/ProvabilityLogic/Grz/Completeness.lean +++ b/Foundation/ProvabilityLogic/Grz/Completeness.lean @@ -70,8 +70,8 @@ lemma iff_interpret_boxdot_strongInterpret [𝔅.HBL2] : . intro h; exact (K!_right iff_interpret_boxdot_strongInterpret_inside) ⨀ h; lemma iff_models_interpret_boxdot_strongInterpret - {M} [Nonempty M] [Structure L M] [M ⊧ₘ* T] [𝔅.HBL2] [𝔅.SoundOn M] : - M ⊧ₘ f (Aᵇ) ↔ M ⊧ₘ f.strongInterpret A := by + {M} [Nonempty M] [Structure L M] [M↓[L] ⊧* T] [𝔅.HBL2] [𝔅.SoundOn M] : + M↓[L] ⊧ f (Aᵇ) ↔ M↓[L] ⊧ f.strongInterpret A := by induction A with | hatom φ => simp [Realization.interpret, strongInterpret, Formula.boxdotTranslate]; | hfalsum => simp [strongInterpret, Formula.boxdotTranslate]; @@ -89,7 +89,7 @@ lemma iff_models_interpret_boxdot_strongInterpret apply ihA.mp; exact hA; | hbox A ih => - suffices (M ⊧ₘ f (Aᵇ)) ∧ (M ⊧ₘ 𝔅 (f (Aᵇ))) ↔ M ⊧ₘ f.strongInterpret A ∧ M ⊧ₘ 𝔅 (f.strongInterpret A) by + suffices (M↓[L] ⊧ f (Aᵇ)) ∧ (M↓[L] ⊧ 𝔅 (f (Aᵇ))) ↔ M↓[L] ⊧ f.strongInterpret A ∧ M↓[L] ⊧ 𝔅 (f.strongInterpret A) by simpa [Formula.boxdotTranslate, interpret, strongInterpret] using this; constructor; . rintro ⟨h₁, h₂⟩; @@ -125,8 +125,8 @@ theorem Grz.arithmetical_completeness_iff exact Realization.iff_interpret_boxdot_strongInterpret (L := ℒₒᵣ) |>.mp $ this f; theorem Grz.arithmetical_completeness_model_iff - {T : ArithmeticTheory} [T.Δ₁] [𝗜𝚺₁ ⪯ T] [ℕ ⊧ₘ* T] : - (∀ f : T.StandardRealization, ℕ ⊧ₘ f.strongInterpret A) ↔ Modal.Grz ⊢ A := by + {T : ArithmeticTheory} [T.Δ₁] [𝗜𝚺₁ ⪯ T] [ℕ↓[ℒₒᵣ] ⊧* T] : + (∀ f : T.StandardRealization, ℕ↓[ℒₒᵣ] ⊧ f.strongInterpret A) ↔ Modal.Grz ⊢ A := by apply Iff.trans ?_ Modal.Logic.iff_provable_Grz_provable_boxdot_S; apply Iff.trans ?_ (S.arithmetical_completeness_iff (T := T)).symm; have : 𝗥₀ ⪯ 𝗜𝚺₁ := inferInstance diff --git a/Foundation/ProvabilityLogic/S/Completeness.lean b/Foundation/ProvabilityLogic/S/Completeness.lean index 406137836..34930f596 100644 --- a/Foundation/ProvabilityLogic/S/Completeness.lean +++ b/Foundation/ProvabilityLogic/S/Completeness.lean @@ -16,7 +16,7 @@ open FirstOrder FirstOrder.ProvabilityAbstraction open ArithmeticTheory (provabilityLogicOn) variable {T₀ T : ArithmeticTheory} [T₀ ⪯ T] [Diagonalization T₀] - {𝔅 : Provability T₀ T} [𝔅.HBL] [ℕ ⊧ₘ* T] [𝔅.SoundOn ℕ] + {𝔅 : Provability T₀ T} [𝔅.HBL] [ℕ↓[ℒₒᵣ] ⊧* T] [𝔅.SoundOn ℕ] {A B : Formula ℕ} open Entailment FiniteContext @@ -31,7 +31,7 @@ namespace SolovaySentences section -omit [ℕ ⊧ₘ* T] +omit [ℕ↓[ℒₒᵣ] ⊧* T] variable {M₁ : Kripke.Model} [Fintype M₁.World] [M₁.IsIrreflexive] [M₁.IsTransitive] [M₁.IsRooted] {A : Formula _} @@ -109,7 +109,7 @@ lemma refl_mainlemma_aux (hA : ¬M₁.root.1 ⊧ (A.rflSubformula.conj 🡒 A)) apply Model.extendRoot.inr_satisfies_iff (n := 1) |>.mpr; apply h; grind; - have b : 𝗜𝚺₁ ⊢ ⩖ j, S j := provable_of_models _ _ fun (V : Type) _ _ ↦ by + have b : 𝗜𝚺₁ ⊢ ⩖ j, S j := Arithmetic.complete _ _ fun (V : Type) _ _ ↦ by simpa [models_iff, S, SolovaySentences.standard_σ_def] using FirstOrder.Arithmetic.Bootstrapping.SolovaySentences.disjunctive exact this ⨀ b . intro h; @@ -145,7 +145,7 @@ lemma GL_S_TFAE : [ Modal.GL ⊢ (A.rflSubformula.conj 🡒 A), Modal.S ⊢ A, - ∀ f : T.StandardRealization, ℕ ⊧ₘ (f A) + ∀ f : T.StandardRealization, ℕ↓[ℒₒᵣ] ⊧ (f A) ].TFAE := by tfae_have 1 → 2 := by intro h; @@ -160,7 +160,7 @@ lemma GL_S_TFAE : apply S.arithmetical_soundness; exact h; tfae_have 3 → 1 := by - have : ℕ ⊧ₘ* 𝗜𝚺₁ := models_of_subtheory (U := 𝗜𝚺₁) (T := T) (M := ℕ) inferInstance; + have : ℕ↓[ℒₒᵣ] ⊧* 𝗜𝚺₁ := models_of_subtheory (T := 𝗜𝚺₁) (U := T) (M := ℕ) inferInstance; contrapose; push Not; @@ -173,15 +173,15 @@ lemma GL_S_TFAE : use S.realization; have := Formula.Kripke.Satisfies.not_imp_def.mp hA |>.2; - have : ℕ ⊧ₘ S M₀.root 🡒 ∼S.realization A := models_of_provable inferInstance $ by + have : ℕ↓[ℒₒᵣ] ⊧ S M₀.root 🡒 ∼S.realization A := models_of_provable inferInstance $ by show 𝗜𝚺₁ ⊢ S M₀.root 🡒 ∼S.realization A; convert SolovaySentences.rfl_mainlemma_neg (T := T) hA A (by grind) $ Formula.Kripke.Satisfies.not_imp_def.mp hA |>.2; - simp only [Models, LO.Semantics.Not.models_not, LO.Semantics.Imp.models_imply] at this; + simp only [LO.Semantics.Not.models_not, LO.Semantics.Imp.models_imply] at this; exact this <| by simpa [models_iff, S, SolovaySentences.standard_σ_def] using FirstOrder.Arithmetic.Bootstrapping.SolovaySentences.solovay_root_sound tfae_finish; -theorem S.arithmetical_completeness_iff : Modal.S ⊢ A ↔ ∀ f : T.StandardRealization, ℕ ⊧ₘ f A := GL_S_TFAE.out 1 2 +theorem S.arithmetical_completeness_iff : Modal.S ⊢ A ↔ ∀ f : T.StandardRealization, ℕ↓[ℒₒᵣ] ⊧ f A := GL_S_TFAE.out 1 2 theorem provabilityLogic_PA_TA_eq_S : (T.provabilityLogicOn 𝗧𝗔) ≊ Modal.S := by apply Logic.iff_equal_provable_equiv.mp From fc25d37513af95152d92129166082c8bd78bfa60 Mon Sep 17 00:00:00 2001 From: SnO2WMaN Date: Thu, 2 Jul 2026 20:02:27 +0900 Subject: [PATCH 60/61] fix(LinearLogic): adapt ClassicalEmbedding to redesigned LK calculus MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use ⊢ᴸᴷ¹/close/contra/contraction/identity, context-splitting cut, and (∅ : Theory L) with empty_provable_iff_eprovable in place of 𝐋𝐊/𝐋𝐊₀/Proof.cast. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01S1wqPfbHabyo2rsKAtJm9g --- .../FirstOrder/ClassicalEmbedding.lean | 79 ++++++++++--------- 1 file changed, 40 insertions(+), 39 deletions(-) diff --git a/Foundation/LinearLogic/FirstOrder/ClassicalEmbedding.lean b/Foundation/LinearLogic/FirstOrder/ClassicalEmbedding.lean index 53dd2220a..872f3a0cc 100644 --- a/Foundation/LinearLogic/FirstOrder/ClassicalEmbedding.lean +++ b/Foundation/LinearLogic/FirstOrder/ClassicalEmbedding.lean @@ -66,7 +66,8 @@ def forget : Semiformula L ξ n → FirstOrder.Semiformula L ξ n @[simp] lemma forget_rew (ω : Rew L ξ₁ n₁ ξ₂ n₂) (φ : Semiformula L ξ₁ n₁) : (ω ▹ φ).forget = ω ▹ φ.forget := by - induction φ using rec' generalizing n₂ <;> simp [*, rew_rel, rew_nrel, FirstOrder.Semiformula.rew_rel, FirstOrder.Semiformula.rew_nrel] + induction φ using rec' generalizing n₂ <;> + simp [*, rew_rel, rew_nrel, FirstOrder.Semiformula.rew_rel, FirstOrder.Semiformula.rew_nrel, Function.comp_def] end Semiformula @@ -82,41 +83,41 @@ end Sequent namespace Derivation -def forget {Γ : Sequent L} : ⊢ᴸ Γ → ⊢ᵀ Γ.forget - | .identity φ => FirstOrder.Derivation.em (φ := φ.forget) (by simp) (by simp) +def forget {Γ : Sequent L} : ⊢ᴸ Γ → ⊢ᴸᴷ¹ Γ.forget + | .identity φ => FirstOrder.Derivation.close φ.forget (by simp) (by simp) | cut (φ := φ) (Γ := Γ) (Δ := Δ) d₁ d₂ => - have dp : ⊢ᵀ φ.forget :: Sequent.forget (Γ ++ Δ) := d₁.forget.wk (by simp) - have dn : ⊢ᵀ ∼φ.forget :: Sequent.forget (Γ ++ Δ) := d₂.forget.wk (by simp) - dp.cut dn - | exchange d h => d.forget.wk (by have := h.subset; grind) + have dp : ⊢ᴸᴷ¹ φ.forget :: Sequent.forget Γ := d₁.forget.cast (by simp) + have dn : ⊢ᴸᴷ¹ ∼φ.forget :: Sequent.forget Δ := d₂.forget.cast (by simp) + (dp.cut dn).cast (by simp) + | exchange d h => d.forget.contra (by have := h.subset; grind) | one => .verum - | falsum d => d.forget.wk <| by simp + | falsum d => d.forget.contra <| by simp | par (Γ := Γ) (φ := φ) (ψ := ψ) d => - have : ⊢ᵀ φ.forget :: ψ.forget :: Sequent.forget Γ := d.forget.cast (by simp) + have : ⊢ᴸᴷ¹ φ.forget :: ψ.forget :: Sequent.forget Γ := d.forget.cast (by simp) this.or | tensor (Γ := Γ) (Δ := Δ) (φ := φ) (ψ := ψ) d₁ d₂ => - have dφ : ⊢ᵀ φ.forget :: Sequent.forget (Γ ++ Δ) := d₁.forget.wk (by simp) - have dψ : ⊢ᵀ ψ.forget :: Sequent.forget (Γ ++ Δ) := d₂.forget.wk (by simp) + have dφ : ⊢ᴸᴷ¹ φ.forget :: Sequent.forget (Γ ++ Δ) := d₁.forget.contra (by simp) + have dψ : ⊢ᴸᴷ¹ ψ.forget :: Sequent.forget (Γ ++ Δ) := d₂.forget.contra (by simp) dφ.and dψ - | verum _ => .verum' <| by simp + | verum _ => .top <| by simp | .with (Γ := Γ) (φ := φ) (ψ := ψ) d₁ d₂ => - have dφ : ⊢ᵀ φ.forget :: Sequent.forget Γ := d₁.forget.cast (by simp) - have dψ : ⊢ᵀ ψ.forget :: Sequent.forget Γ := d₂.forget.cast (by simp) + have dφ : ⊢ᴸᴷ¹ φ.forget :: Sequent.forget Γ := d₁.forget.cast (by simp) + have dψ : ⊢ᴸᴷ¹ ψ.forget :: Sequent.forget Γ := d₂.forget.cast (by simp) dφ.and dψ | plusRight (Γ := Γ) (φ := φ) (ψ := ψ) d => - have : ⊢ᵀ φ.forget :: ψ.forget :: Sequent.forget Γ := d.forget.wk (by simp) + have : ⊢ᴸᴷ¹ φ.forget :: ψ.forget :: Sequent.forget Γ := d.forget.contra (by simp) this.or | plusLeft (Γ := Γ) (φ := φ) (ψ := ψ) d => - have : ⊢ᵀ φ.forget :: ψ.forget :: Sequent.forget Γ := d.forget.wk (by simp) + have : ⊢ᴸᴷ¹ φ.forget :: ψ.forget :: Sequent.forget Γ := d.forget.contra (by simp) this.or | all (Γ := Γ) (φ := φ) d => - have : ⊢ᵀ φ.forget.free :: (Sequent.forget Γ)⁺ := d.forget.cast (by simp) + have : ⊢ᴸᴷ¹ φ.forget.free :: (Sequent.forget Γ)⁺ := d.forget.cast (by simp) this.all | exs (Γ := Γ) (φ := φ) t d => - have : ⊢ᵀ φ.forget/[t] :: Sequent.forget Γ := d.forget.cast (by simp) + have : ⊢ᴸᴷ¹ φ.forget/[t] :: Sequent.forget Γ := d.forget.cast (by simp) this.exs - | weakening (Γ := Γ) (φ := φ) d => d.forget.wk (by simp) - | contraction (Γ := Γ) (φ := φ) d => d.forget.wk (by simp) + | weakening (Γ := Γ) (φ := φ) d => d.forget.contra (by simp) + | contraction (Γ := Γ) (φ := φ) d => d.forget.contra (by simp) | dereliction (Γ := Γ) (φ := φ) d => d.forget.cast (by simp) | ofCourse d _ => d.forget.cast (by simp) @@ -124,9 +125,9 @@ end Derivation namespace Proof -theorem forget {φ : Sentence L} : 𝐋𝐋 ⊢ φ → 𝐋𝐊 ⊢ φ.forget := fun h ↦ by +theorem forget {φ : Sentence L} : 𝐋𝐋 ⊢ φ → (∅ : Theory L) ⊢ φ.forget := fun h ↦ by have : 𝐋𝐋₀ ⊢ (φ : Proposition L) := h - exact FirstOrder.Proof.cast.mpr ⟨by simpa using Derivation.forget this.get⟩ + exact Theory.Proof.empty_provable_iff_eprovable.mpr ⟨by simpa using Derivation.forget this.get⟩ end Proof @@ -356,24 +357,24 @@ local postfix:max "†" => Semiformula.girard local postfix:max "‡" => Semiformula.Girard local postfix:max "‡" => Sequent.Girard -def toLL {Γ : Sequent L} : ⊢ᵀ Γ → ⊢ᴸ Γ‡ - | .axL R v => +def toLL {Γ : Sequent L} : ⊢ᴸᴷ¹ Γ → ⊢ᴸ Γ‡ + | .identity R v => have : ⊢ᴸ [?!.rel R v, ?.nrel R v] := LinearLogic.Derivation.identity (!.rel R v) |>.dereliction this - | .cut (φ := φ) d₁ d₂ => + | .cut (φ := φ) (Γ := Γ₁) (Δ := Δ₁) d₁ d₂ => match h : φ.polarity with | true => - have b₁ : ⊢ᴸ ?φ† :: Γ‡ := d₁.toLL.cast (by simp [Semiformula.Girard, h]) - have : ⊢ᴸ ∼φ† :: Γ‡ := d₂.toLL.cast (by simp [Semiformula.Girard, h]) - have b₂ : ⊢ᴸ ∼?φ† :: Γ‡ := this.negativeOfCourse <| by simp - (b₁.cut b₂).negativeWk (by simp) (by simp) + have b₁ : ⊢ᴸ ?φ† :: Γ₁‡ := d₁.toLL.cast (by simp [Semiformula.Girard, h]) + have : ⊢ᴸ ∼φ† :: Δ₁‡ := d₂.toLL.cast (by simp [Semiformula.Girard, h]) + have b₂ : ⊢ᴸ ∼?φ† :: Δ₁‡ := this.negativeOfCourse <| by simp + (b₁.cut b₂).cast (by simp) | false => - have b₂ : ⊢ᴸ ∼!φ† :: Γ‡ := d₂.toLL.cast (by simp [Semiformula.Girard, h]) - have : ⊢ᴸ φ† :: Γ‡ := d₁.toLL.cast (by simp [Semiformula.Girard, h]) - have b₁ : ⊢ᴸ !φ† :: Γ‡ := this.negativeOfCourse <| by simp - (b₁.cut b₂).negativeWk (by simp) (by simp) - | .wk d h => d.toLL.negativeWk (List.map_subset Semiformula.Girard h) (by simp) + have b₂ : ⊢ᴸ ∼!φ† :: Δ₁‡ := d₂.toLL.cast (by simp [Semiformula.Girard, h]) + have : ⊢ᴸ φ† :: Γ₁‡ := d₁.toLL.cast (by simp [Semiformula.Girard, h]) + have b₁ : ⊢ᴸ !φ† :: Γ₁‡ := this.negativeOfCourse <| by simp + (b₁.cut b₂).cast (by simp) + | .contraction d h => d.toLL.negativeWk (List.map_subset Semiformula.Girard h) (by simp) | .verum => LinearLogic.Derivation.one.dereliction | .and (Γ := Γ) (φ := φ) (ψ := ψ) d₁ d₂ => match h₁ : φ.polarity, h₂ : ψ.polarity with @@ -428,7 +429,7 @@ def toLL {Γ : Sequent L} : ⊢ᵀ Γ → ⊢ᴸ Γ‡ | false => have : ⊢ᴸ φ†.free :: (Γ‡)⁺ := d.toLL.cast (by simp [Semiformula.Girard, h]) this.all.cast (by simp [Semiformula.Girard, Semiformula.girard, h]) - | .exs (Γ := Γ) (φ := φ) t d => + | .exs (Γ := Γ) (φ := φ) (t := t) d => match h : φ.polarity with | true => have d : ⊢ᴸ (?φ†)/[t] :: Γ‡ := d.toLL.cast (by simp [Semiformula.Girard, h]) @@ -446,14 +447,14 @@ namespace Proof variable [L.DecidableEq] -theorem girard {φ : Sentence L} : 𝐋𝐊 ⊢ φ → 𝐋𝐋 ⊢ φ.Girard := fun h ↦ ⟨by - have : 𝐋𝐊₀ ⊢ (φ : Proposition L) := by simpa using Proof.cast.mp h +theorem girard {φ : Sentence L} : (∅ : Theory L) ⊢ φ → 𝐋𝐋 ⊢ φ.Girard := fun h ↦ ⟨by + have : 𝐋𝐊¹ ⊢ (φ : Proposition L) := by simpa using Theory.Proof.empty_provable_iff_eprovable.mp h simpa using Derivation.toLL this.get⟩ -theorem girard_faithful {φ : Sentence L} : 𝐋𝐋 ⊢ φ.Girard ↔ 𝐋𝐊 ⊢ φ := +theorem girard_faithful {φ : Sentence L} : 𝐋𝐋 ⊢ φ.Girard ↔ (∅ : Theory L) ⊢ φ := ⟨fun h ↦ by simpa using LinearLogic.Proof.forget h, girard⟩ -instance : Entailment.FaithfullyEmbeddable (𝐋𝐊 : Theory L) (𝐋𝐋 : LinearLogic.Symbol L) where +instance : Entailment.FaithfullyEmbeddable (∅ : Theory L) (𝐋𝐋 : LinearLogic.Symbol L) where prop := ⟨Semiformula.Girard, fun _ ↦ girard_faithful⟩ end Proof From 67a8b2822db51ba0597abd8dec9310ead6ff2c56 Mon Sep 17 00:00:00 2001 From: SnO2WMaN Date: Fri, 3 Jul 2026 00:03:09 +0900 Subject: [PATCH 61/61] fix(LinearLogic): state Girard embedding at proposition level per review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use 𝐋𝐊¹/𝐋𝐋₀ over Proposition instead of (∅ : Theory L)/𝐋𝐋 over Sentence. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01S1wqPfbHabyo2rsKAtJm9g --- .../LinearLogic/FirstOrder/ClassicalEmbedding.lean | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Foundation/LinearLogic/FirstOrder/ClassicalEmbedding.lean b/Foundation/LinearLogic/FirstOrder/ClassicalEmbedding.lean index 872f3a0cc..0d0f59532 100644 --- a/Foundation/LinearLogic/FirstOrder/ClassicalEmbedding.lean +++ b/Foundation/LinearLogic/FirstOrder/ClassicalEmbedding.lean @@ -125,9 +125,8 @@ end Derivation namespace Proof -theorem forget {φ : Sentence L} : 𝐋𝐋 ⊢ φ → (∅ : Theory L) ⊢ φ.forget := fun h ↦ by - have : 𝐋𝐋₀ ⊢ (φ : Proposition L) := h - exact Theory.Proof.empty_provable_iff_eprovable.mpr ⟨by simpa using Derivation.forget this.get⟩ +theorem forget {φ : Proposition L} : 𝐋𝐋₀ ⊢ φ → 𝐋𝐊¹ ⊢ φ.forget := fun h ↦ + ⟨by simpa using Derivation.forget h.get⟩ end Proof @@ -447,14 +446,13 @@ namespace Proof variable [L.DecidableEq] -theorem girard {φ : Sentence L} : (∅ : Theory L) ⊢ φ → 𝐋𝐋 ⊢ φ.Girard := fun h ↦ ⟨by - have : 𝐋𝐊¹ ⊢ (φ : Proposition L) := by simpa using Theory.Proof.empty_provable_iff_eprovable.mp h - simpa using Derivation.toLL this.get⟩ +theorem girard {φ : Proposition L} : 𝐋𝐊¹ ⊢ φ → 𝐋𝐋₀ ⊢ φ.Girard := fun h ↦ + ⟨by simpa using Derivation.toLL h.get⟩ -theorem girard_faithful {φ : Sentence L} : 𝐋𝐋 ⊢ φ.Girard ↔ (∅ : Theory L) ⊢ φ := +theorem girard_faithful {φ : Proposition L} : 𝐋𝐋₀ ⊢ φ.Girard ↔ 𝐋𝐊¹ ⊢ φ := ⟨fun h ↦ by simpa using LinearLogic.Proof.forget h, girard⟩ -instance : Entailment.FaithfullyEmbeddable (∅ : Theory L) (𝐋𝐋 : LinearLogic.Symbol L) where +instance : Entailment.FaithfullyEmbeddable (𝐋𝐊¹ : LK L) (𝐋𝐋₀ : LinearLogic.SymbolFV L) where prop := ⟨Semiformula.Girard, fun _ ↦ girard_faithful⟩ end Proof