Skip to content

Commit f21f1d8

Browse files
committed
iff_context
1 parent 947d25d commit f21f1d8

4 files changed

Lines changed: 155 additions & 21 deletions

File tree

Foundation/FirstOrder/Basic/Calculus.lean

Lines changed: 83 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ def newVar (Γ : Sequent L) : ℕ := (Γ.map Semiformula.fvSup).foldr max 0
2727
lemma not_fvar?_newVar {φ : Proposition L} {Γ : Sequent L} (h : φ ∈ Γ) : ¬FVar? φ Γ.newVar :=
2828
not_fvar?_of_lt_fvSup φ (by simpa [newVar] using List.le_max_of_le (List.mem_map_of_mem h) (by simp))
2929

30+
@[simp] lemma rew_neg_comm {Γ : Sequent L} (ω : Rew L ℕ 00) :
31+
(∼Γ).map (ω ▹ ·) = ∼Γ.map (ω ▹ ·) := by simp [List.tilde_def]
32+
3033
end Sequent
3134

3235
/-! ## Derivation for one-sided $\mathbf{LK}$ -/
@@ -48,8 +51,6 @@ namespace Derivation
4851

4952
open Rewriting LawfulSyntacticRewriting
5053

51-
52-
5354
def height {Δ : Sequent L} : ⊢ᴷ Δ → ℕ
5455
| .id _ _ => 0
5556
| cut dp dn => (max (height dp) (height dn)).succ
@@ -262,10 +263,6 @@ def equiv (𝓢 : Schema L) (φ) :
262263
toFun b := ⟨⟨b.axioms, b.axioms_mem⟩, b.derivation⟩
263264
invFun := fun ⟨⟨Γ, hΓ⟩, d⟩ ↦ ⟨Γ, hΓ, d⟩
264265

265-
lemma provable_iff :
266-
𝓢 ⊢ φ ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ φ :: ∼Γ) := by
267-
simpa using (equiv 𝓢 φ).nonempty_congr
268-
269266
instance : Entailment.Compact (Schema L) where
270267
core b := ⟨fun φ ↦ φ ∈ b.axioms⟩
271268
corePrf b := ⟨b.axioms, by simp, b.derivation⟩
@@ -284,29 +281,96 @@ instance (𝓢 𝓤 : Schema L) : 𝓢 ⪯ 𝓢 ⊔ 𝓤 := weakerThan_of_le (by
284281
instance (𝓢 𝓤 : Schema L) : 𝓤 ⪯ 𝓢 ⊔ 𝓤 := weakerThan_of_le (by simp)
285282

286283
lemma inconsistent_iff :
287-
Entailment.Inconsistent 𝓢 ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ ∼Γ) := calc
288-
_ ↔ 𝓢 ⊢ ⊥ := Entailment.inconsistent_iff_provable_bot
289-
_ ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ ⊥ :: ∼Γ) := by simp [provable_iff]
290-
_ ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ ∼Γ) := by
291-
constructor
292-
· rintro ⟨Γ, hΓ, ⟨d⟩⟩
293-
have : ⊢ᴷ [(∼⊥ : Proposition L)] := Derivation.verum.cast
294-
exact ⟨Γ, hΓ, ⟨(Derivation.cut d this).cast⟩⟩
295-
· rintro ⟨Γ, hΓ, ⟨d⟩⟩
296-
exact ⟨Γ, hΓ, ⟨d.weakening⟩⟩
284+
Entailment.Inconsistent 𝓢 ↔ ∃ Γ : Sequent L, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (⊢ᴷ ∼Γ) :=
285+
OneSidedLK.inconsistent_iff
286+
287+
def rewrite [𝓢.IsClosed] (b : 𝓢 ⊢! φ) (f : ℕ → SyntacticTerm L) :
288+
𝓢 ⊢! Rew.rewrite f ▹ φ where
289+
axioms := b.axioms.map (Rew.rewrite f ▹ ·)
290+
axioms_mem := by
291+
suffices ∀ ψ ∈ b.axioms, Rew.rewrite f ▹ ψ ∈ 𝓢 by simpa
292+
intro ψ hψ
293+
exact Schema.IsClosed.closed (Rew.rewrite f) _ (b.axioms_mem ψ hψ)
294+
derivation := b.derivation.rewrite f |>.cast
297295

298296
end Schema.Proof
299297

298+
namespace Derivation
299+
300+
open Entailment
301+
302+
variable {Γ Δ : Sequent L}
303+
304+
def eCut (d₁ : ⊢ᴷ φ :: Γ) (d₂ : ⊢ᴷ ψ :: Δ) (e : ∼φ = ψ := by simp) : ⊢ᴷ Γ ++ Δ := cut d₁ (d₂.cast (by simp [e]))
305+
306+
def disj₂ {Γ Δ : Sequent L} : ⊢ᴷ (Γ ++ Δ) → ⊢ᴷ ⋁Γ :: Δ := fun d ↦
307+
match Γ with
308+
| [] => d.weakening
309+
| [φ] => d
310+
| [φ, ψ] => d.or
311+
| φ :: ψ :: χ :: Γ =>
312+
let Φ := ⋁(χ :: Γ)
313+
have : ⊢ᴷ (φ ⋎ ψ :: χ :: Γ) ++ Δ := d.or
314+
have d₁ : ⊢ᴷ (φ ⋎ ψ) ⋎ Φ :: Δ := this.disj₂
315+
have d₂ : ⊢ᴷ [(∼φ ⋏ ∼ψ) ⋏ ∼Φ, φ ⋎ ψ ⋎ Φ] :=
316+
have : ⊢ᴷ [φ, ψ ⋎ Φ, (∼φ ⋏ ∼ψ) ⋏ ∼Φ] :=
317+
((identity φ).rotate.tensor (identity ψ).rotate).tensor
318+
(identity Φ).rotate |>.rotate.rotate.or.weakening
319+
this.or.rotate
320+
d₂.eCut d₁
321+
termination_by _ => Γ.length
322+
323+
def conj₂ {Γ Δ : Sequent L} (d : (φ : Proposition L) → φ ∈ Γ → ⊢ᴷ φ :: Δ) : ⊢ᴷ ⋀Γ :: Δ :=
324+
match Γ with
325+
| [] => verum.weakening
326+
| [φ] => d φ (by simp)
327+
| φ :: ψ :: Γ =>
328+
have : ⊢ᴷ ⋀(ψ :: Γ) :: Δ := conj₂ (Γ := ψ :: Γ) (fun χ h ↦ d χ (by simp_all))
329+
(d φ (by simp)).and this
330+
331+
def disjClosure : ⊢ᴷ Γ → 𝐋𝐊¹ ⊢! ⋁Γ := fun d ↦
332+
have : ⊢ᴷ Γ ++ [] := d.cast
333+
this.disj₂
334+
335+
def disjClosureInv : 𝐋𝐊¹ ⊢! ⋁Γ → ⊢ᴷ Γ := fun d ↦
336+
have d₁ : ⊢ᴷ [⋁Γ] := d
337+
have d₂ : ⊢ᴷ ⋀(∼Γ) :: Γ := conj₂ fun φ h ↦ close φ (by simp) (by simp_all)
338+
d₁.eCut d₂
339+
340+
lemma nonempty_iff_provable_disj : Nonempty (⊢ᴷ Γ) ↔ 𝐋𝐊¹ ⊢ ⋁Γ :=
341+
by rintro ⟨d⟩; exact ⟨d.disjClosure⟩, by rintro ⟨d⟩; exact ⟨d.disjClosureInv⟩⟩
342+
343+
end Derivation
344+
345+
namespace Schema.Proof
346+
347+
variable {𝓢 : Schema L}
348+
349+
open Derivation
350+
351+
lemma iff_context : 𝓢 ⊢ φ ↔ 𝓢 *⊢[𝐋𝐊¹] φ := by
352+
constructor
353+
· rintro ⟨d⟩
354+
have : 𝐋𝐊¹ ⊢! ⋀d.axioms ➝ φ :=
355+
have : ⊢ᴷ ∼d.axioms ++ [φ] := d.derivation.weakening
356+
this.disj₂.or.cast <| by simp [Semiformula.imp_eq]
357+
refine ⟨⟨d.axioms, by simpa using d.axioms_mem, this⟩⟩
358+
· rintro ⟨Γ, h, d⟩
359+
have d : ⊢ᴷ [⋁(∼Γ) ⋎ φ] := d.cast (by simp [Semiformula.imp_eq])
360+
have : ⊢ᴷ ⋀Γ ⋏ ∼φ :: φ :: ∼Γ :=
361+
have : ⊢ᴷ ⋀Γ :: ∼Γ := Derivation.conj₂ fun φ h ↦ close φ (by simp) (by simp [h])
362+
this.tensor (identity φ).rotate |>.weakening
363+
refine ⟨⟨Γ, h, (d.eCut this).cast⟩⟩
364+
365+
end Schema.Proof
300366

301367
/-!
302368
### Theory of schemata
303369
-/
304370

305-
abbrev Theory (L : Language) := Set (Sentence L)
306-
307371
def Schema.theory (𝓢 : Schema L) : Theory L := {σ | 𝓢 ⊢ ↑σ}
308372

309-
@[simp] lemma Schema.mem_theory {𝓢 : Schema L} {σ : Sentence L} :
373+
@[simp] lemma Schema.mem_theory {𝓢 : Schema L} :
310374
σ ∈ 𝓢.theory ↔ 𝓢 ⊢ ↑σ := by simp [Schema.theory]
311375

312376
namespace Theory

Foundation/FirstOrder/Basic/Syntax/Schema.lean

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace LO.FirstOrder
1616
structure Schema (L : Language) where
1717
Mem : Proposition L → Prop
1818

19+
abbrev Theory (L : Language) := Set (Sentence L)
1920
namespace Schema
2021

2122
variable {L : Language}
@@ -119,6 +120,13 @@ instance sentence (σ : Sentence L) : IsClosed (σ : Schema L) where
119120

120121
end IsClosed
121122

123+
def uniClosure (𝓢 : Schema L) : Theory L := Set.image Semiformula.univCl {φ | φ ∈ 𝓢}
124+
125+
variable {𝓢 : Schema L}
126+
127+
@[simp] lemma mem_uniClosure :
128+
σ ∈ 𝓢.uniClosure ↔ ∃ φ ∈ 𝓢, Semiformula.univCl φ = σ := by simp [uniClosure]
129+
122130
end Schema
123131

124132
end LO.FirstOrder

Foundation/Logic/Calculus.lean

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ open Entailment
6060

6161
variable {S : Type*} [Entailment S F] [AdjunctiveSet F S] [OneSidedLK.Entailment 𝔇 S]
6262

63+
omit [DeMorgan F] [NegInvolutive F] [OneSidedLK 𝔇] in
64+
lemma provable_iff {𝓢 : S} :
65+
𝓢 ⊢ φ ↔ ∃ Γ : List F, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (𝔇 (φ :: ∼Γ)) := by
66+
simpa using OneSidedLK.Entailment.equiv.nonempty_congr
67+
6368
def toProof (𝓢 : S) (d : 𝔇 [φ]) : 𝓢 ⊢! φ := OneSidedLK.Entailment.equiv.symm ⟨⟨[], by simp⟩, d⟩
6469

6570
def ofAxiom {𝓢 : S} (h : φ ∈ 𝓢) : 𝓢 ⊢! φ :=
@@ -74,7 +79,7 @@ instance : Entailment.Axiomatized S where
7479
prfAxm h := ofAxiom h
7580
weakening h d := ofAxiomSubset d h
7681

77-
variable [OneSidedLK.Cut 𝔇] [OneSidedLK.Entailment 𝔇 S]
82+
variable [OneSidedLK.Cut 𝔇]
7883

7984
instance (𝓢 : S) : Entailment.ModusPonens 𝓢 where
8085
mdp {φ ψ} b₁ b₂ :=
@@ -107,6 +112,18 @@ instance : Entailment.DeductiveExplosion S where
107112
have : 𝔇 [∼⊥] := cast verum (by simp)
108113
wk (cut b this) (by simp) ⟩
109114

115+
lemma inconsistent_iff {𝓢 : S} :
116+
Entailment.Inconsistent 𝓢 ↔ ∃ Γ : List F, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (𝔇 (∼Γ)) := calc
117+
_ ↔ 𝓢 ⊢ ⊥ := Entailment.inconsistent_iff_provable_bot
118+
_ ↔ ∃ Γ : List F, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (𝔇 (⊥ :: ∼Γ)) := by simp [provable_iff]
119+
_ ↔ ∃ Γ : List F, (∀ ψ ∈ Γ, ψ ∈ 𝓢) ∧ Nonempty (𝔇 (∼Γ)) := by
120+
constructor
121+
· rintro ⟨Γ, hΓ, ⟨d⟩⟩
122+
have : 𝔇 [(∼⊥ : F)] := cast verum
123+
exact ⟨Γ, hΓ, ⟨cast (cut d this)⟩⟩
124+
· rintro ⟨Γ, hΓ, ⟨d⟩⟩
125+
exact ⟨Γ, hΓ, ⟨wk d (by simp)⟩⟩
126+
110127
instance (𝓢 : S) : Entailment.Cl 𝓢 where
111128
negEquiv {φ} := Entailment.cast
112129
(show 𝓢 ⊢! (φ ⋎ ∼φ ⋎ ⊥) ⋏ (φ ⋏ ⊤ ⋎ ∼φ) from

Foundation/Logic/LogicSymbol.lean

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,32 @@ variable [Tilde α]
344344

345345
instance : Tilde (List α) := ⟨fun l ↦ l.map (∼·)⟩
346346

347+
lemma tilde_def (l : List α) : ∼l = l.map (∼·) := rfl
348+
347349
@[simp] lemma tilde_nil : ∼([] : List α) = [] := rfl
348350

349351
@[simp] lemma tilde_cons (a : α) (l : List α) : ∼(a :: l) = ∼a :: ∼l := rfl
350352

351353
@[simp] lemma tilde_append (l k : List α) : ∼(l ++ k) = ∼l ++ ∼k := by
352354
induction l with
353-
| nil => simp [*]
355+
| nil => simp [*]
354356
| cons a as ih => simp [*, List.cons_append]
355357

358+
@[simp] lemma mem_tilde_iff [NegInvolutive α] {a : α} {l : List α} : a ∈ ∼l ↔ ∼a ∈ l := by
359+
induction l with
360+
| nil => simp [*]
361+
| cons b bs ih =>
362+
suffices a = ∼b ↔ ∼a = b by
363+
simp [ih, this]
364+
constructor <;> {rintro rfl; simp}
365+
366+
instance [NegInvolutive α] : NegInvolutive (List α) where
367+
neg_involutive l := by
368+
induction l with
369+
| nil => simp [*]
370+
| cons a as ih =>
371+
simp [ih, NegInvolutive.neg_involutive a]
372+
356373
end tilde
357374

358375
section conjunction
@@ -437,6 +454,34 @@ def disj' (f : ι → α) (l : List ι) : α := (l.map f).disj₂
437454

438455
end disjunction
439456

457+
section tilde
458+
459+
variable [LogicalConnective α] [DeMorgan α]
460+
461+
@[simp] lemma tilde_conj (l : List α) : ∼l.disj = (∼l).conj := by
462+
match l with
463+
| [] => simp
464+
| a :: l => simp [tilde_conj l]
465+
466+
@[simp] lemma tilde_disj (l : List α) : ∼l.conj = (∼l).disj := by
467+
match l with
468+
| [] => simp
469+
| a :: l => simp [tilde_disj l]
470+
471+
@[simp] lemma tilde_conj₂ (l : List α) : ∼⋁l = ⋀(∼l) := by
472+
match l with
473+
| [] => simp
474+
| [a] => simp
475+
| a :: b :: l => simp [tilde_conj₂ (b :: l)]
476+
477+
@[simp] lemma tilde_disj₂ (l : List α) : ∼⋀l = ⋁(∼l) := by
478+
match l with
479+
| [] => simp
480+
| [a] => simp
481+
| a :: b :: l => simp [tilde_disj₂ (b :: l)]
482+
483+
end tilde
484+
440485
section
441486

442487
variable [LogicalConnective α] [LogicalConnective β] [FunLike G α β] [LogicalConnective.HomClass G α β]

0 commit comments

Comments
 (0)