Skip to content

Commit 70da633

Browse files
SnO2WMaNCopilot
andcommitted
cut elimination wip
Co-authored-by: Copilot <copilot@github.com>
1 parent e84cb16 commit 70da633

1 file changed

Lines changed: 133 additions & 0 deletions

File tree

SeqPL/Basic.lean

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,14 @@ namespace Provable
154154

155155
variable {Γ Δ : FormulaFinset} {A B C : Formula}
156156

157+
lemma axm (A) : ⊢ ({A} ⟹ {A}) := ⟨Proof.axm A⟩
158+
lemma botL : ⊢ ({⊥} ⟹ ∅) := ⟨Proof.botL⟩
159+
lemma wkL {Γ Γ' Δ} (h : ⊢ (Γ ⟹ Δ)) (h' : Γ ⊆ Γ') : ⊢ (Γ' ⟹ Δ) := ⟨Proof.wkL h.some h'⟩
160+
lemma wkR {Γ Δ Δ'} (h : ⊢ (Γ ⟹ Δ)) (h' : Δ ⊆ Δ') : ⊢ (Γ ⟹ Δ') := ⟨Proof.wkR h.some h'⟩
161+
lemma impL {Γ Δ A B} (h₁ : ⊢ (Γ ⟹ insert A Δ)) (h₂ : ⊢ (insert B Γ ⟹ Δ)) : ⊢ ((insert (A 🡒 B) Γ) ⟹ Δ) := ⟨Proof.impL h₁.some h₂.some⟩
162+
lemma impR {Γ Δ A B} (h : ⊢ ((insert A Γ) ⟹ (insert B Δ))) : ⊢ (Γ ⟹ (insert (A 🡒 B) Δ)) := ⟨Proof.impR h.some⟩
163+
lemma boxGL {Γ A} (h : ⊢ ((insert (□A) (Γ ∪ Γ.box)) ⟹ {A})) : ⊢ (Γ.box ⟹ {□A}) := ⟨Proof.boxGL h.some⟩
164+
157165
lemma axiomŁ1 : ⊢ (∅ ⟹ {A 🡒 B 🡒 A}) := ⟨Proof.axiomŁ1
158166
lemma axiomŁ2 : ⊢ (∅ ⟹ {(A 🡒 B 🡒 C) 🡒 (A 🡒 B) 🡒 (A 🡒 C)}) := ⟨Proof.axiomŁ2
159167
lemma axiomŁ3 : ⊢ (∅ ⟹ {(∼A 🡒 ∼B) 🡒 (B 🡒 A)}) := ⟨Proof.axiomŁ3
@@ -313,6 +321,7 @@ theorem soundness (h : ⊢ S) : ∀ {κ}, ∀ M : Model κ, [M.IsGL] → M ⊧ S
313321
| impR _ ih => exact valid_impR ih
314322
| boxGL _ ih => exact valid_boxGL ih
315323

324+
theorem finite_soundness (h : ⊢ S) : ∀ {κ}, ∀ M : Model κ, [M.IsFiniteGL] → M ⊧ S := by sorry;
316325

317326
def trivial_GL_model : Model (Fin 1) where
318327
Rel' := λ _ _ => False
@@ -328,4 +337,128 @@ lemma not_provable_empty : ⊬ (∅ ⟹ ∅) := by
328337

329338
end soundness
330339

340+
341+
section completeness
342+
343+
theorem completeness {S : Sequent} (h : ∀ {κ}, ∀ M : Model κ, [M.IsFiniteGL] → M ⊧ S) : ⊢ S := by sorry;
344+
345+
lemma deduction_theorem : ⊢ (insert A Γ ⟹ {B}) ↔ ⊢ (Γ ⟹ {A 🡒 B}) := by
346+
constructor;
347+
. intro h;
348+
apply completeness.{0};
349+
intro κ M _ x _;
350+
use A 🡒 B;
351+
constructor;
352+
. simp;
353+
. intro hA;
354+
exact (Sequent.forced_succ_singleton.mp $ finite_soundness h M x) (by grind);
355+
. intro h;
356+
apply completeness.{0};
357+
intro κ M _ x;
358+
apply Sequent.forced_succ_singleton.mpr;
359+
intro H;
360+
exact (Sequent.forced_succ_singleton.mp $ finite_soundness h M x) (by grind) (by grind);
361+
362+
end completeness
363+
331364
end Semantics
365+
366+
367+
inductive ProofWithCut : Sequent → Type
368+
| axm (A) : ProofWithCut ({A} ⟹ {A})
369+
| botL : ProofWithCut ({⊥} ⟹ ∅)
370+
| wkL {Γ Γ' Δ} : ProofWithCut (Γ ⟹ Δ) → (_ : Γ ⊆ Γ' := by grind) → ProofWithCut (Γ' ⟹ Δ)
371+
| wkR {Γ Δ Δ'} : ProofWithCut (Γ ⟹ Δ) → (_ : Δ ⊆ Δ' := by grind) → ProofWithCut (Γ ⟹ Δ')
372+
| impL {Γ Δ A B} : ProofWithCut (Γ ⟹ (insert A Δ)) → ProofWithCut (insert B Γ ⟹ Δ) → ProofWithCut ((insert (A 🡒 B) Γ) ⟹ Δ)
373+
| impR {Γ Δ A B} : ProofWithCut ((insert A Γ) ⟹ (insert B Δ)) → ProofWithCut (Γ ⟹ (insert (A 🡒 B) Δ))
374+
| boxGL {Γ A} : ProofWithCut ((insert (□A) (Γ ∪ Γ.box)) ⟹ {A}) → ProofWithCut (Γ.box ⟹ {□A})
375+
| cut {Γ₁ Γ₂ Δ₁ Δ₂ A} : ProofWithCut (Γ₁ ⟹ insert A Δ₁) → ProofWithCut (insert A Γ₂ ⟹ Δ₂) → ProofWithCut (Γ₁ ∪ Γ₂ ⟹ Δ₁ ∪ Δ₂)
376+
377+
prefix:120 "⊢ᶜ! " => ProofWithCut
378+
379+
abbrev ProvableWithCut (S : Sequent) : Prop := Nonempty (⊢ᶜ! S)
380+
prefix:120 "⊢ᶜ " => ProvableWithCut
381+
382+
namespace ProvableWithCut
383+
384+
def ofProof : ⊢! S → ⊢ᶜ! S
385+
| .axm A => .axm A
386+
| .botL => .botL
387+
| .wkL h h' => .wkL (ofProof h) h'
388+
| .wkR h h' => .wkR (ofProof h) h'
389+
| .impL h₁ h₂ => .impL (ofProof h₁) (ofProof h₂)
390+
| .impR h => .impR (ofProof h)
391+
| .boxGL h => .boxGL (ofProof h)
392+
393+
lemma axm (A) : ⊢ᶜ ({A} ⟹ {A}) := ⟨ProofWithCut.axm A⟩
394+
lemma botL : ⊢ᶜ ({⊥} ⟹ ∅) := ⟨ProofWithCut.botL⟩
395+
lemma wkL {Γ Γ' Δ} (h : ⊢ᶜ (Γ ⟹ Δ)) (h' : Γ ⊆ Γ') : ⊢ᶜ (Γ' ⟹ Δ) := ⟨ProofWithCut.wkL h.some h'⟩
396+
lemma wkR {Γ Δ Δ'} (h : ⊢ᶜ (Γ ⟹ Δ)) (h' : Δ ⊆ Δ') : ⊢ᶜ (Γ ⟹ Δ') := ⟨ProofWithCut.wkR h.some h'⟩
397+
lemma impL {Γ Δ A B} (h₁ : ⊢ᶜ (Γ ⟹ insert A Δ)) (h₂ : ⊢ᶜ (insert B Γ ⟹ Δ)) : ⊢ᶜ ((insert (A 🡒 B) Γ) ⟹ Δ) := ⟨ProofWithCut.impL h₁.some h₂.some⟩
398+
lemma impR {Γ Δ A B} (h : ⊢ᶜ ((insert A Γ) ⟹ (insert B Δ))) : ⊢ᶜ (Γ ⟹ (insert (A 🡒 B) Δ)) := ⟨ProofWithCut.impR h.some⟩
399+
lemma boxGL {Γ A} (h : ⊢ᶜ ((insert (□A) (Γ ∪ Γ.box)) ⟹ {A})) : ⊢ᶜ (Γ.box ⟹ {□A}) := ⟨ProofWithCut.boxGL h.some⟩
400+
lemma cut {Γ₁ Γ₂ Δ₁ Δ₂ A} (h₁ : ⊢ᶜ (Γ₁ ⟹ insert A Δ₁)) (h₂ : ⊢ᶜ (insert A Γ₂ ⟹ Δ₂)) : ⊢ᶜ (Γ₁ ∪ Γ₂ ⟹ Δ₁ ∪ Δ₂) := ⟨ProofWithCut.cut h₁.some h₂.some⟩
401+
402+
lemma rec
403+
{motive : (S : Sequent) → ⊢ᶜ S → Prop}
404+
(axm : ∀ A, motive ({A} ⟹ {A}) (ProvableWithCut.axm A))
405+
(botL : motive ({⊥} ⟹ ∅) ProvableWithCut.botL)
406+
(wkL : ∀ {Γ Γ' Δ} (h : ⊢ᶜ (Γ ⟹ Δ)) (h' : Γ ⊆ Γ'), motive (Γ ⟹ Δ) h → motive (Γ' ⟹ Δ) (wkL h h'))
407+
(wkR : ∀ {Γ Δ Δ'} (h : ⊢ᶜ (Γ ⟹ Δ)) (h' : Δ ⊆ Δ'), motive (Γ ⟹ Δ) h → motive (Γ ⟹ Δ') (wkR h h'))
408+
(impL : ∀ {Γ Δ A B} (h₁ : ⊢ᶜ (Γ ⟹ insert A Δ)) (h₂ : ⊢ᶜ (insert B Γ ⟹ Δ)),
409+
motive (Γ ⟹ insert A Δ) h₁ → motive (insert B Γ ⟹ Δ) h₂ → motive ((insert (A 🡒 B) Γ) ⟹ Δ) (impL h₁ h₂)
410+
)
411+
(impR : ∀ {Γ Δ A B} (h : ⊢ᶜ ((insert A Γ) ⟹ (insert B Δ))),
412+
motive ((insert A Γ) ⟹ (insert B Δ)) h → motive (Γ ⟹ (insert (A 🡒 B) Δ)) (impR h)
413+
)
414+
(boxGL : ∀ {Γ A} (h : ⊢ᶜ ((insert (□A) (Γ ∪ Γ.box)) ⟹ {A})),
415+
motive ((insert (□A) (Γ ∪ Γ.box)) ⟹ {A}) h → motive (Γ.box ⟹ {□A}) (boxGL h)
416+
)
417+
(cut : ∀ {Γ₁ Γ₂ Δ₁ Δ₂ A}
418+
(h₁ : ⊢ᶜ (Γ₁ ⟹ insert A Δ₁)) (h₂ : ⊢ᶜ (insert A Γ₂ ⟹ Δ₂)),
419+
(motive (Γ₁ ⟹ insert A Δ₁) h₁) → (motive (insert A Γ₂ ⟹ Δ₂) h₂) →
420+
motive (Γ₁ ∪ Γ₂ ⟹ Δ₁ ∪ Δ₂) (ProvableWithCut.cut h₁ h₂)
421+
)
422+
: ∀ {S : Sequent} (h : ⊢ᶜ S), motive S h := by
423+
rintro S ⟨h⟩;
424+
induction h with
425+
| axm A => apply axm;
426+
| botL => apply botL;
427+
| wkL h h' ih => apply wkL ⟨h⟩ h' ih;
428+
| wkR h h' ih => apply wkR ⟨h⟩ h' ih;
429+
| cut h₁ h₂ ih₁ ih₂ => apply cut ⟨h₁⟩ ⟨h₂⟩ ih₁ ih₂;
430+
| impL h₁ h₂ ih₁ ih₂ => apply impL ⟨h₁⟩ ⟨h₂⟩ ih₁ ih₂;
431+
| impR h ih => apply impR ⟨h⟩ ih;
432+
| boxGL h ih => apply boxGL ⟨h⟩ ih;
433+
434+
end ProvableWithCut
435+
436+
lemma provableWithCut_of_provable : ⊢ S → ⊢ᶜ S := λ ⟨p⟩ => ⟨ProvableWithCut.ofProof p⟩
437+
438+
theorem cut_elimination : ⊢ᶜ S → ⊢ S := by
439+
intro h;
440+
induction h using ProvableWithCut.rec with
441+
| axm A => exact Provable.axm A
442+
| botL => exact Provable.botL
443+
| wkL h h' ih => exact Provable.wkL ih h'
444+
| wkR h h' ih => exact Provable.wkR ih h'
445+
| impL h₁ h₂ ih₁ ih₂ => exact Provable.impL ih₁ ih₂
446+
| impR h ih => exact Provable.impR ih
447+
| boxGL _ ih => exact Provable.boxGL ih
448+
| cut _ _ ih₁ ih₂ =>
449+
apply completeness.{0};
450+
intro κ M _ x;
451+
have := finite_soundness ih₁ M x;
452+
have := finite_soundness ih₂ M x;
453+
grind;
454+
455+
namespace Provable
456+
457+
variable {Γ Δ : FormulaFinset} {A B C : Formula}
458+
459+
lemma mdp : ⊢ (∅ ⟹ {A 🡒 B}) → ⊢ (∅ ⟹ {A}) → ⊢ (∅ ⟹ {B}) := λ p q => by
460+
replace p := provableWithCut_of_provable $ deduction_theorem.mpr p;
461+
replace q : ⊢ᶜ (∅ ⟹ insert A ∅) := provableWithCut_of_provable q;
462+
exact cut_elimination $ ProvableWithCut.cut q p;
463+
464+
end Provable

0 commit comments

Comments
 (0)