Skip to content

Commit cdadb08

Browse files
committed
refactor file structure
1 parent 2d6c4ef commit cdadb08

File tree

4 files changed

+151
-133
lines changed

4 files changed

+151
-133
lines changed

ModalTableau.lean

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
-- This module serves as the root of the `ModalTableau` library.
2-
-- Import modules here that should be built as part of the library.
3-
import ModalTableau.Basic
1+
import ModalTableau.Basic
2+
3+
import ModalTableau.Gentzen.Basic
4+
import ModalTableau.Gentzen.Soundness

ModalTableau/Basic.lean

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ namespace LabelTerm
1818

1919
def evaluated {M : Kripke.Model} (f : Assignment M) : LabelTerm → Prop := λ ⟨x, y⟩ => M.Rel (f x) (f y)
2020

21+
def replace (σ : Label → Label) : LabelTerm → LabelTerm := λ (x, y) => ⟨σ x, σ y⟩
22+
2123
end LabelTerm
2224

2325

@@ -30,6 +32,8 @@ namespace LabelledFormula
3032

3133
notation:95 x " ∶ " φ => LabelledFormula.mk x φ
3234

35+
def labelReplace (σ : Label → Label) : LabelledFormula → LabelledFormula := λ ⟨x, φ⟩ => ⟨σ x, φ⟩
36+
3337
def Satisfies (M : Kripke.Model) (f : Assignment M) : LabelledFormula → Prop := λ (x ∶ φ) => (f x) ⊧ φ
3438

3539
namespace Satisfies

ModalTableau/Gentzen/Basic.lean

Lines changed: 11 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -79,136 +79,17 @@ abbrev Derivable (S : Sequent) : Prop := Nonempty (⊢ᵍ S)
7979
prefix:70 "⊢ᵍ! " => Derivable
8080

8181

82-
section
83-
84-
theorem soundness {S : Sequent} : ⊢ᵍ S → ∀ (M : Kripke.Model), ∀ (f : Assignment M), S.Satisfies M f := by
85-
intro d;
86-
induction d with
87-
| axA =>
88-
rintro M f ⟨hΓ, hX⟩;
89-
simp_all;
90-
| axBot =>
91-
rintro M f ⟨hΓ, hX⟩;
92-
simp at hΓ;
93-
| @impL Γ Δ x φ ψ d₁ d₂ ih₁ ih₂ =>
94-
rintro M f ⟨hΓ, hX⟩;
95-
have ⟨hΓ₁, hΓ₂⟩ : f ⊧ (x ∶ φ ➝ ψ) ∧ ∀ a ∈ Γ.fmls, f ⊧ a := by simpa using hΓ;
96-
replace hX : ∀ x y, ⟨x, y⟩ ∈ Γ.rels → LabelTerm.evaluated f ⟨x, y⟩ := by simpa using hX;
97-
have : ¬(f x ⊧ φ) ∨ (f x ⊧ ψ) := by
98-
simpa [LabelledFormula.Satisfies.imp_def, Semantics.Imp.realize_imp, imp_iff_not_or] using hΓ₁;
99-
rcases this with (_ | h);
100-
. replace ih₁ :
101-
(∀ lφ ∈ Γ.fmls, f ⊧ lφ) →
102-
(∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated f (a, b)) →
103-
((f x) ⊧ φ ∨ ∃ a ∈ Δ.fmls, f ⊧ a) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated f (a, b)
104-
:= by simpa [Sequent.Satisfies] using ih₁ M f;
105-
rcases ih₁ hΓ₂ hX with (_ | ⟨lψ, _, _⟩) | _;
106-
. simp_all;
107-
. left; use lψ;
108-
. simp_all;
109-
. replace ih₂ :
110-
(f x) ⊧ ψ →
111-
(∀ a ∈ Γ.fmls, f ⊧ a) →
112-
(∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated f (a, b)) →
113-
(∃ lφ ∈ Δ.fmls, f ⊧ lφ) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated f (a, b)
114-
:= by simpa [Sequent.Satisfies] using ih₂ M f;
115-
rcases ih₂ h hΓ₂ hX with _ | _ <;> simp_all;
116-
| @impR Γ Δ x φ ψ d ih =>
117-
rintro M f ⟨hΓ, hX⟩;
118-
suffices ((¬(f x) ⊧ φ ∨ (f x) ⊧ ψ) ∨ ∃ a ∈ Δ.fmls, f ⊧ a) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated f (a, b) by
119-
simpa [LabelledFormula.Satisfies.imp_def, Semantics.Imp.realize_imp, imp_iff_not_or];
120-
wlog _ : (f x) ⊧ φ;
121-
. tauto;
122-
replace ih :
123-
(f ⊧ x ∶ φ) →
124-
(∀ a ∈ Γ.fmls, f ⊧ a) →
125-
(∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated f (a, b)) →
126-
((f ⊧ x ∶ ψ) ∨ ∃ a ∈ Δ.fmls, f ⊧ a) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated f (a, b)
127-
:= by simpa [Sequent.Satisfies] using ih M f;
128-
rcases ih (by simpa) (by simpa using hΓ) (by simpa using hX) with (h | _) | _;
129-
. tauto;
130-
. simp_all;
131-
. simp_all;
132-
| @boxL Γ Δ x y φ d ih =>
133-
rintro M f ⟨hΓ, hX⟩;
134-
135-
have ⟨hxbφ, hΓ₂⟩ : (f ⊧ x ∶ □φ) ∧ ∀ a ∈ Γ.fmls, f ⊧ a := by simpa using hΓ;
136-
have ⟨hxy, hX₂⟩ : LabelTerm.evaluated f (x, y) ∧ ∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated f (a, b) := by simpa using hX;
137-
have hyφ : f ⊧ y ∶ φ := Formula.Kripke.Satisfies.box_def.mp (LabelledFormula.Satisfies.box_def.mp hxbφ) _ hxy;
138-
139-
replace ih :
140-
(f ⊧ x ∶ □φ) →
141-
(f ⊧ y ∶ φ) →
142-
(∀ a ∈ Γ.fmls, f ⊧ a) →
143-
LabelTerm.evaluated f (x, y) →
144-
(∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated f (a, b)) →
145-
(∃ lφ ∈ Δ.fmls, f ⊧ lφ) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated f (a, b) := by simpa [Sequent.Satisfies] using ih M f;
146-
147-
rcases ih hxbφ hyφ hΓ₂ hxy hX₂ with _ | _ <;> simp_all;
148-
| @boxR Γ Δ x y φ hxy hyΓ hyΔ d ih =>
149-
rintro M f ⟨hΓ, hX⟩;
150-
151-
suffices ((f ⊧ x ∶ □φ) ∨ ∃ a ∈ Δ.fmls, f ⊧ a) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated f (a, b) by simpa;
152-
apply or_iff_not_imp_right.mpr;
153-
intro hΔ₁; push_neg at hΔ₁;
154-
apply or_iff_not_imp_right.mpr;
155-
intro hΔ₂; push_neg at hΔ₂;
156-
157-
intro w hw;
158-
let g : Assignment M := λ z => if z = y then w else f z;
159-
160-
replace ih :
161-
(∀ lφ ∈ Γ.fmls, g ⊧ lφ) →
162-
LabelTerm.evaluated g (x, y) →
163-
(∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated g (a, b)) →
164-
((g ⊧ y ∶ φ) ∨ ∃ a ∈ Δ.fmls, g ⊧ a) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated g (a, b)
165-
:= by simpa [Sequent.Satisfies] using ih M g;
166-
have : ∀ lφ ∈ Γ.fmls, g ⊧ lφ := by
167-
rintro ⟨a, ψ⟩ hz;
168-
have ha : a ≠ y := by
169-
rintro rfl;
170-
have := SequentPart.not_include_labelledFml_of_isFreshLabel hyΓ ψ;
171-
contradiction;
172-
simpa [g, ha] using hΓ _ hz
173-
have : LabelTerm.evaluated g (x, y) := by simpa [LabelTerm.evaluated, g, hxy];
174-
have : ∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated g (a, b) := (by
175-
intro a b r;
176-
have ha : a ≠ y := by
177-
rintro rfl;
178-
have := SequentPart.not_include_relTerm_of_isFreshLabel₁ hyΓ b;
179-
contradiction;
180-
have hb : b ≠ y := by
181-
rintro rfl;
182-
have := SequentPart.not_include_relTerm_of_isFreshLabel₂ hyΓ a;
183-
contradiction;
184-
simpa [LabelTerm.evaluated, g, ha, hb] using hX (a, b) r;
185-
)
186-
rcases ih (by assumption) (by assumption) (by assumption) with (h | ⟨⟨z, ψ⟩, h₁, h₂⟩) | ⟨a, b, h₁, h₂⟩;
187-
. simpa [g, LabelledFormula.Satisfies.iff_models] using h;
188-
. have hz : z ≠ y := by
189-
rintro rfl;
190-
have := SequentPart.not_include_labelledFml_of_isFreshLabel hyΔ ψ;
191-
contradiction;
192-
have : f ⊧ z ∶ ψ := by simpa [g, hz] using h₂;
193-
have : ¬f ⊧ z ∶ ψ := hΔ₂ _ h₁;
194-
contradiction;
195-
. have ha : a ≠ y := by
196-
rintro rfl;
197-
have := SequentPart.not_include_relTerm_of_isFreshLabel₁ hyΔ b;
198-
contradiction;
199-
have hb : b ≠ y := by
200-
rintro rfl;
201-
have := SequentPart.not_include_relTerm_of_isFreshLabel₂ hyΔ a;
202-
contradiction;
203-
have : (f a) ≺ (f b) := by simpa [LabelTerm.evaluated, g, ha, hb] using h₂;
204-
have : ¬(f a) ≺ (f b) := hΔ₁ a b h₁;
205-
contradiction;
206-
207-
theorem soundness_fml : ⊢ᵍ! ⟨⟨∅, ∅⟩, ⟨{0 ∶ φ}, ∅⟩⟩ → ∀ (M : Kripke.Model), ∀ (f : Assignment M), f 0 ⊧ φ := by
208-
rintro ⟨d⟩ M f;
209-
simpa [Sequent.Satisfies] using soundness d M f
210-
211-
end
82+
section height
83+
84+
def Derivation.height {S : Sequent} : ⊢ᵍ S → ℕ
85+
| axA => 1
86+
| axBot => 1
87+
| impL d₁ d₂ => max d₁.height d₂.height + 1
88+
| impR d => d.height + 1
89+
| boxL d => d.height + 1
90+
| boxR _ _ _ d => d.height + 1
91+
92+
end height
21293

21394
def axF {Γ Δ : SequentPart} {x} {φ} : ⊢ᵍ (⟨(x ∶ φ) ::ₘ Γ.fmls, Γ.rels⟩ ⟹ ⟨(x ∶ φ) ::ₘ Δ.fmls, Δ.rels⟩) := by
21495
induction φ using Formula.rec' generalizing Γ Δ x with

ModalTableau/Gentzen/Soundness.lean

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import ModalTableau.Gentzen.Basic
2+
3+
namespace LO.Modal.Labelled.Gentzen
4+
5+
theorem soundness {S : Sequent} : ⊢ᵍ S → ∀ (M : Kripke.Model), ∀ (f : Assignment M), S.Satisfies M f := by
6+
intro d;
7+
induction d with
8+
| axA =>
9+
rintro M f ⟨hΓ, hX⟩;
10+
simp_all;
11+
| axBot =>
12+
rintro M f ⟨hΓ, hX⟩;
13+
simp at hΓ;
14+
| @impL Γ Δ x φ ψ d₁ d₂ ih₁ ih₂ =>
15+
rintro M f ⟨hΓ, hX⟩;
16+
have ⟨hΓ₁, hΓ₂⟩ : f ⊧ (x ∶ φ ➝ ψ) ∧ ∀ a ∈ Γ.fmls, f ⊧ a := by simpa using hΓ;
17+
replace hX : ∀ x y, ⟨x, y⟩ ∈ Γ.rels → LabelTerm.evaluated f ⟨x, y⟩ := by simpa using hX;
18+
have : ¬(f x ⊧ φ) ∨ (f x ⊧ ψ) := by
19+
simpa [LabelledFormula.Satisfies.imp_def, Semantics.Imp.realize_imp, imp_iff_not_or] using hΓ₁;
20+
rcases this with (_ | h);
21+
. replace ih₁ :
22+
(∀ lφ ∈ Γ.fmls, f ⊧ lφ) →
23+
(∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated f (a, b)) →
24+
((f x) ⊧ φ ∨ ∃ a ∈ Δ.fmls, f ⊧ a) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated f (a, b)
25+
:= by simpa [Sequent.Satisfies] using ih₁ M f;
26+
rcases ih₁ hΓ₂ hX with (_ | ⟨lψ, _, _⟩) | _;
27+
. simp_all;
28+
. left; use lψ;
29+
. simp_all;
30+
. replace ih₂ :
31+
(f x) ⊧ ψ →
32+
(∀ a ∈ Γ.fmls, f ⊧ a) →
33+
(∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated f (a, b)) →
34+
(∃ lφ ∈ Δ.fmls, f ⊧ lφ) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated f (a, b)
35+
:= by simpa [Sequent.Satisfies] using ih₂ M f;
36+
rcases ih₂ h hΓ₂ hX with _ | _ <;> simp_all;
37+
| @impR Γ Δ x φ ψ d ih =>
38+
rintro M f ⟨hΓ, hX⟩;
39+
suffices ((¬(f x) ⊧ φ ∨ (f x) ⊧ ψ) ∨ ∃ a ∈ Δ.fmls, f ⊧ a) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated f (a, b) by
40+
simpa [LabelledFormula.Satisfies.imp_def, Semantics.Imp.realize_imp, imp_iff_not_or];
41+
wlog _ : (f x) ⊧ φ;
42+
. tauto;
43+
replace ih :
44+
(f ⊧ x ∶ φ) →
45+
(∀ a ∈ Γ.fmls, f ⊧ a) →
46+
(∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated f (a, b)) →
47+
((f ⊧ x ∶ ψ) ∨ ∃ a ∈ Δ.fmls, f ⊧ a) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated f (a, b)
48+
:= by simpa [Sequent.Satisfies] using ih M f;
49+
rcases ih (by simpa) (by simpa using hΓ) (by simpa using hX) with (h | _) | _;
50+
. tauto;
51+
. simp_all;
52+
. simp_all;
53+
| @boxL Γ Δ x y φ d ih =>
54+
rintro M f ⟨hΓ, hX⟩;
55+
56+
have ⟨hxbφ, hΓ₂⟩ : (f ⊧ x ∶ □φ) ∧ ∀ a ∈ Γ.fmls, f ⊧ a := by simpa using hΓ;
57+
have ⟨hxy, hX₂⟩ : LabelTerm.evaluated f (x, y) ∧ ∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated f (a, b) := by simpa using hX;
58+
have hyφ : f ⊧ y ∶ φ := Formula.Kripke.Satisfies.box_def.mp (LabelledFormula.Satisfies.box_def.mp hxbφ) _ hxy;
59+
60+
replace ih :
61+
(f ⊧ x ∶ □φ) →
62+
(f ⊧ y ∶ φ) →
63+
(∀ a ∈ Γ.fmls, f ⊧ a) →
64+
LabelTerm.evaluated f (x, y) →
65+
(∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated f (a, b)) →
66+
(∃ lφ ∈ Δ.fmls, f ⊧ lφ) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated f (a, b) := by simpa [Sequent.Satisfies] using ih M f;
67+
68+
rcases ih hxbφ hyφ hΓ₂ hxy hX₂ with _ | _ <;> simp_all;
69+
| @boxR Γ Δ x y φ hxy hyΓ hyΔ d ih =>
70+
rintro M f ⟨hΓ, hX⟩;
71+
72+
suffices ((f ⊧ x ∶ □φ) ∨ ∃ a ∈ Δ.fmls, f ⊧ a) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated f (a, b) by simpa;
73+
apply or_iff_not_imp_right.mpr;
74+
intro hΔ₁; push_neg at hΔ₁;
75+
apply or_iff_not_imp_right.mpr;
76+
intro hΔ₂; push_neg at hΔ₂;
77+
78+
intro w hw;
79+
let g : Assignment M := λ z => if z = y then w else f z;
80+
81+
replace ih :
82+
(∀ lφ ∈ Γ.fmls, g ⊧ lφ) →
83+
LabelTerm.evaluated g (x, y) →
84+
(∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated g (a, b)) →
85+
((g ⊧ y ∶ φ) ∨ ∃ a ∈ Δ.fmls, g ⊧ a) ∨ ∃ a b, (a, b) ∈ Δ.rels ∧ LabelTerm.evaluated g (a, b)
86+
:= by simpa [Sequent.Satisfies] using ih M g;
87+
have : ∀ lφ ∈ Γ.fmls, g ⊧ lφ := by
88+
rintro ⟨a, ψ⟩ hz;
89+
have ha : a ≠ y := by
90+
rintro rfl;
91+
have := SequentPart.not_include_labelledFml_of_isFreshLabel hyΓ ψ;
92+
contradiction;
93+
simpa [g, ha] using hΓ _ hz
94+
have : LabelTerm.evaluated g (x, y) := by simpa [LabelTerm.evaluated, g, hxy];
95+
have : ∀ a b, (a, b) ∈ Γ.rels → LabelTerm.evaluated g (a, b) := (by
96+
intro a b r;
97+
have ha : a ≠ y := by
98+
rintro rfl;
99+
have := SequentPart.not_include_relTerm_of_isFreshLabel₁ hyΓ b;
100+
contradiction;
101+
have hb : b ≠ y := by
102+
rintro rfl;
103+
have := SequentPart.not_include_relTerm_of_isFreshLabel₂ hyΓ a;
104+
contradiction;
105+
simpa [LabelTerm.evaluated, g, ha, hb] using hX (a, b) r;
106+
)
107+
rcases ih (by assumption) (by assumption) (by assumption) with (h | ⟨⟨z, ψ⟩, h₁, h₂⟩) | ⟨a, b, h₁, h₂⟩;
108+
. simpa [g, LabelledFormula.Satisfies.iff_models] using h;
109+
. have hz : z ≠ y := by
110+
rintro rfl;
111+
have := SequentPart.not_include_labelledFml_of_isFreshLabel hyΔ ψ;
112+
contradiction;
113+
have : f ⊧ z ∶ ψ := by simpa [g, hz] using h₂;
114+
have : ¬f ⊧ z ∶ ψ := hΔ₂ _ h₁;
115+
contradiction;
116+
. have ha : a ≠ y := by
117+
rintro rfl;
118+
have := SequentPart.not_include_relTerm_of_isFreshLabel₁ hyΔ b;
119+
contradiction;
120+
have hb : b ≠ y := by
121+
rintro rfl;
122+
have := SequentPart.not_include_relTerm_of_isFreshLabel₂ hyΔ a;
123+
contradiction;
124+
have : (f a) ≺ (f b) := by simpa [LabelTerm.evaluated, g, ha, hb] using h₂;
125+
have : ¬(f a) ≺ (f b) := hΔ₁ a b h₁;
126+
contradiction;
127+
128+
theorem soundness_fml : ⊢ᵍ! ⟨⟨∅, ∅⟩, ⟨{0 ∶ φ}, ∅⟩⟩ → ∀ (M : Kripke.Model), ∀ (f : Assignment M), f 0 ⊧ φ := by
129+
rintro ⟨d⟩ M f;
130+
simpa [Sequent.Satisfies] using soundness d M f
131+
132+
end LO.Modal.Labelled.Gentzen

0 commit comments

Comments
 (0)