Kripke.Soundness


universe u


namespace Kripke

open Syntax

open Pf


def soundness {W : Type u}[Frame W] {Γ : Ctxt}{tm : Tm} : Pf Γ tm  → Entails W Γ tm
  | Pf.assume =>
W : Type u
inst✝ : Frame W
Γ : Ctxt
tm✝ : Tm
tm : Tm
Γ✝ : Ctxt
⊢ Entails W (tm :: Γ✝) tm
by
W : Type u
inst✝ : Frame W
Γ : Ctxt
tm✝ : Tm
tm : Tm
Γ✝ : Ctxt
⊢ Entails W (tm :: Γ✝) tm
apply Semantics.assumption | Pf.wk h pf =>
W : Type u
inst✝ : Frame W
Γ✝¹ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
Γ✝ : Ctxt
h : Γ✝ ≤ Γ
pf : Pf Γ✝ tm
⊢ Entails W Γ tm
by
W : Type u
inst✝ : Frame W
Γ✝¹ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
Γ✝ : Ctxt
h : Γ✝ ≤ Γ
pf : Pf Γ✝ tm
⊢ Entails W Γ tm
exact Semantics.wk (Γ := _) (Δ := _) (t := _) h (soundness pf) | Pf.and_I p q =>
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p : Pf Γ P✝
q : Pf Γ Q✝
⊢ Entails W Γ (P✝ ∧ Q✝)
by
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p : Pf Γ P✝
q : Pf Γ Q✝
⊢ Entails W Γ (P✝ ∧ Q✝)
apply Semantics.and_I
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p : Pf Γ P✝
q : Pf Γ Q✝
⊢ Entails W Γ P✝
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p : Pf Γ P✝
q : Pf Γ Q✝
⊢ Entails W Γ Q✝
apply soundness p
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p : Pf Γ P✝
q : Pf Γ Q✝
⊢ Entails W Γ Q✝
apply soundness q | Pf.and_E₁ p =>
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
Q✝ : Tm
p : Pf Γ (tm ∧ Q✝)
⊢ Entails W Γ tm
by
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
Q✝ : Tm
p : Pf Γ (tm ∧ Q✝)
⊢ Entails W Γ tm
apply Semantics.and_E₁
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
Q✝ : Tm
p : Pf Γ (tm ∧ Q✝)
⊢ Entails W Γ (tm ∧ ?q)
q
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
Q✝ : Tm
p : Pf Γ (tm ∧ Q✝)
⊢ Tm
apply soundness p | Pf.and_E₂ p =>
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
p : Pf Γ (P✝ ∧ tm)
⊢ Entails W Γ tm
by
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
p : Pf Γ (P✝ ∧ tm)
⊢ Entails W Γ tm
apply Semantics.and_E₂
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
p : Pf Γ (P✝ ∧ tm)
⊢ Entails W Γ (?p ∧ tm)
p
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
p : Pf Γ (P✝ ∧ tm)
⊢ Tm
apply soundness p | or_I₁ p =>
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p : Pf Γ P✝
⊢ Entails W Γ (P✝ ∨ Q✝)
by
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p : Pf Γ P✝
⊢ Entails W Γ (P✝ ∨ Q✝)
apply Semantics.or_I₁
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p : Pf Γ P✝
⊢ Entails W Γ P✝
apply soundness p | or_I₂ q =>
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
q : Pf Γ Q✝
⊢ Entails W Γ (P✝ ∨ Q✝)
by
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
q : Pf Γ Q✝
⊢ Entails W Γ (P✝ ∨ Q✝)
apply Semantics.or_I₂
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
q : Pf Γ Q✝
⊢ Entails W Γ Q✝
apply soundness q | or_E p_or_q c_ass_p c_ass_q =>
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p_or_q : Pf Γ (P✝ ∨ Q✝)
c_ass_p : Pf (P✝ :: Γ) tm
c_ass_q : Pf (Q✝ :: Γ) tm
⊢ Entails W Γ tm
by
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p_or_q : Pf Γ (P✝ ∨ Q✝)
c_ass_p : Pf (P✝ :: Γ) tm
c_ass_q : Pf (Q✝ :: Γ) tm
⊢ Entails W Γ tm
apply Semantics.or_E
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p_or_q : Pf Γ (P✝ ∨ Q✝)
c_ass_p : Pf (P✝ :: Γ) tm
c_ass_q : Pf (Q✝ :: Γ) tm
⊢ Entails W Γ (?p ∨ ?q)
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p_or_q : Pf Γ (P✝ ∨ Q✝)
c_ass_p : Pf (P✝ :: Γ) tm
c_ass_q : Pf (Q✝ :: Γ) tm
⊢ Entails W (?p :: Γ) tm
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p_or_q : Pf Γ (P✝ ∨ Q✝)
c_ass_p : Pf (P✝ :: Γ) tm
c_ass_q : Pf (Q✝ :: Γ) tm
⊢ Entails W (?q :: Γ) tm
p
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p_or_q : Pf Γ (P✝ ∨ Q✝)
c_ass_p : Pf (P✝ :: Γ) tm
c_ass_q : Pf (Q✝ :: Γ) tm
⊢ Tm
q
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p_or_q : Pf Γ (P✝ ∨ Q✝)
c_ass_p : Pf (P✝ :: Γ) tm
c_ass_q : Pf (Q✝ :: Γ) tm
⊢ Tm
apply soundness p_or_q
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p_or_q : Pf Γ (P✝ ∨ Q✝)
c_ass_p : Pf (P✝ :: Γ) tm
c_ass_q : Pf (Q✝ :: Γ) tm
⊢ Entails W (?p :: Γ) tm
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p_or_q : Pf Γ (P✝ ∨ Q✝)
c_ass_p : Pf (P✝ :: Γ) tm
c_ass_q : Pf (Q✝ :: Γ) tm
⊢ Entails W (?q :: Γ) tm
apply soundness c_ass_p
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p_or_q : Pf Γ (P✝ ∨ Q✝)
c_ass_p : Pf (P✝ :: Γ) tm
c_ass_q : Pf (Q✝ :: Γ) tm
⊢ Entails W (?q :: Γ) tm
apply soundness c_ass_q | Pf.imp_I p =>
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p : Pf (P✝ :: Γ) Q✝
⊢ Entails W Γ (P✝ ⇒ Q✝)
by
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p : Pf (P✝ :: Γ) Q✝
⊢ Entails W Γ (P✝ ⇒ Q✝)
apply Semantics.imp_I
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm : Tm
Γ : Ctxt
P✝ : Tm
Q✝ : Tm
p : Pf (P✝ :: Γ) Q✝
⊢ Entails W (P✝ :: Γ) Q✝
apply soundness p | Pf.imp_E p q =>
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
p : Pf Γ (P✝ ⇒ tm)
q : Pf Γ P✝
⊢ Entails W Γ tm
by
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
p : Pf Γ (P✝ ⇒ tm)
q : Pf Γ P✝
⊢ Entails W Γ tm
apply Semantics.imp_E
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
p : Pf Γ (P✝ ⇒ tm)
q : Pf Γ P✝
⊢ Entails W Γ (?p ⇒ tm)
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
p : Pf Γ (P✝ ⇒ tm)
q : Pf Γ P✝
⊢ Entails W Γ ?p
p
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
p : Pf Γ (P✝ ⇒ tm)
q : Pf Γ P✝
⊢ Tm
apply soundness p
a
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
P✝ : Tm
p : Pf Γ (P✝ ⇒ tm)
q : Pf Γ P✝
⊢ Entails W Γ ?p
apply soundness q | Pf.tt_I => fun _ _ => trivial | Pf.ff_E p =>
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
p : Pf Γ Tm.ff
⊢ Entails W Γ tm
by
W : Type u
inst✝ : Frame W
Γ✝ : Ctxt
tm✝ : Tm
tm : Tm
Γ : Ctxt
p : Pf Γ Tm.ff
⊢ Entails W Γ tm
exact Semantics.ff_E (Γ := _) (p := _) (soundness p)



section Consistency

namespace Consistency

/-- A trivial boolean Kripke frame
    w0 []
 -/
inductive Triv where
  | w0


instance : LE Triv where
  le _x _y := True


instance : Preorder Triv where
  le_refl x := by
x : Triv
⊢ x ≤ x
simp [LE.le] le_trans x y z := by
x : Triv
y : Triv
z : Triv
⊢ x ≤ y → y ≤ z → x ≤ z
simp [LE.le]


instance : Frame Triv where
  val _w _i := False
  le_val := by
⊢ ∀ {w w' : Triv} {i : ℕ}, w ≤ w' → False → False
intro w w'
w : Triv
w' : Triv
⊢ ∀ {i : ℕ}, w ≤ w' → False → False
i
w : Triv
w' : Triv
i : ℕ
⊢ w ≤ w' → False → False
hle
w : Triv
w' : Triv
i : ℕ
hle : w ≤ w'
⊢ False → False
hval
w : Triv
w' : Triv
i : ℕ
hle : w ≤ w'
hval : False
⊢ False
assumption


open Triv


def consistency : ¬ Pf [] Tm.ff := by
  intro pf
pf : Pf [] Tm.ff
⊢ False
change at_world w0 Tm.ff apply soundness pf w0 simp


end Consistency

end Consistency



section ExcludedMiddle

namespace ExcludedMiddle

/-- A Kripke frame that refutes the Law of Excluded Middle.

                w1 [P]
               /
              /
             w0 []
              \
               \
                w2 [¬P]
 -/
inductive EMFrame where
  | w0 | w1 | w2


instance : LE EMFrame where
  le x y := match x, y with
    | .w0, _ => True
    | .w1, .w1 => True
    | .w2, .w2 => True
    | _, _ => False


instance : Preorder EMFrame where
  le_refl x := by
⊢ x ≤ x
cases x <;> simp [LE.le] le_trans x y z := by
⊢ x ≤ y → y ≤ z → x ≤ z
cases x
w0
⊢ EMFrame.w0 ≤ y → y ≤ z → EMFrame.w0 ≤ z
w1
⊢ EMFrame.w1 ≤ y → y ≤ z → EMFrame.w1 ≤ z
w2
⊢ EMFrame.w2 ≤ y → y ≤ z → EMFrame.w2 ≤ z
<;>
w0
⊢ EMFrame.w0 ≤ y → y ≤ z → EMFrame.w0 ≤ z
w1
⊢ EMFrame.w1 ≤ y → y ≤ z → EMFrame.w1 ≤ z
w2
⊢ EMFrame.w2 ≤ y → y ≤ z → EMFrame.w2 ≤ z
cases y <;> cases z <;> simp [LE.le]


instance : Frame EMFrame where
  val w i := match w, i with
    | .w1, 0 => True
    | _, _ => False
  le_val := by
⊢ ∀ {w w' : EMFrame} {i : ℕ}, w ≤ w' → (match w, i with | EMFrame.w1, 0 => True | x, x_1 => False) → match w', i with | EMFrame.w1, 0 => True | x, x_1 => False
intro w w'
⊢ ∀ {i : ℕ}, w ≤ w' → (match w, i with | EMFrame.w1, 0 => True | x, x_1 => False) → match w', i with | EMFrame.w1, 0 => True | x, x_1 => False
i
w' : EMFrame
i : ℕ
⊢ w ≤ w' → (match w, i with | EMFrame.w1, 0 => True | x, x_1 => False) → match w', i with | EMFrame.w1, 0 => True | x, x_1 => False
hle
w' : EMFrame
i : ℕ
hle : w ≤ w'
⊢ (match w, i with | EMFrame.w1, 0 => True | x, x_1 => False) → match w', i with | EMFrame.w1, 0 => True | x, x_1 => False
hval
w' : EMFrame
i : ℕ
hle : w ≤ w'
hval : match w, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match w', i with | EMFrame.w1, 0 => True | x, x_1 => False
cases w
w0
w' : EMFrame
i : ℕ
hle : EMFrame.w0 ≤ w'
hval : match EMFrame.w0, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match w', i with | EMFrame.w1, 0 => True | x, x_1 => False
w1
w' : EMFrame
i : ℕ
hle : EMFrame.w1 ≤ w'
hval : match EMFrame.w1, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match w', i with | EMFrame.w1, 0 => True | x, x_1 => False
w2
w' : EMFrame
i : ℕ
hle : EMFrame.w2 ≤ w'
hval : match EMFrame.w2, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match w', i with | EMFrame.w1, 0 => True | x, x_1 => False
<;>
w0
w' : EMFrame
i : ℕ
hle : EMFrame.w0 ≤ w'
hval : match EMFrame.w0, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match w', i with | EMFrame.w1, 0 => True | x, x_1 => False
w1
w' : EMFrame
i : ℕ
hle : EMFrame.w1 ≤ w'
hval : match EMFrame.w1, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match w', i with | EMFrame.w1, 0 => True | x, x_1 => False
w2
w' : EMFrame
i : ℕ
hle : EMFrame.w2 ≤ w'
hval : match EMFrame.w2, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match w', i with | EMFrame.w1, 0 => True | x, x_1 => False
cases w'
w2.w0
i : ℕ
hval : match EMFrame.w2, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match EMFrame.w0, i with | EMFrame.w1, 0 => True | x, x_1 => False
w2.w1
i : ℕ
hval : match EMFrame.w2, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match EMFrame.w1, i with | EMFrame.w1, 0 => True | x, x_1 => False
w2.w2
i : ℕ
hval : match EMFrame.w2, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match EMFrame.w2, i with | EMFrame.w1, 0 => True | x, x_1 => False
<;>
w0.w0
i : ℕ
hval : match EMFrame.w0, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match EMFrame.w0, i with | EMFrame.w1, 0 => True | x, x_1 => False
w0.w1
i : ℕ
hval : match EMFrame.w0, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match EMFrame.w1, i with | EMFrame.w1, 0 => True | x, x_1 => False
w0.w2
i : ℕ
hval : match EMFrame.w0, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match EMFrame.w2, i with | EMFrame.w1, 0 => True | x, x_1 => False
w1.w0
i : ℕ
hval : match EMFrame.w1, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match EMFrame.w0, i with | EMFrame.w1, 0 => True | x, x_1 => False
w1.w1
i : ℕ
hval : match EMFrame.w1, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match EMFrame.w1, i with | EMFrame.w1, 0 => True | x, x_1 => False
w1.w2
i : ℕ
hval : match EMFrame.w1, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match EMFrame.w2, i with | EMFrame.w1, 0 => True | x, x_1 => False
w2.w0
i : ℕ
hval : match EMFrame.w2, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match EMFrame.w0, i with | EMFrame.w1, 0 => True | x, x_1 => False
w2.w1
i : ℕ
hval : match EMFrame.w2, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match EMFrame.w1, i with | EMFrame.w1, 0 => True | x, x_1 => False
w2.w2
i : ℕ
hval : match EMFrame.w2, i with | EMFrame.w1, 0 => True | x, x_1 => False
⊢ match EMFrame.w2, i with | EMFrame.w1, 0 => True | x, x_1 => False
simp [LE.le] at * exact hval


open Tm

open EMFrame


theorem em_not_provable : ¬ Pf [] (var 0 ∨ (var 0 ⇒ ff)) := by
  intro h
⊢ False
-- EM for P := var 0, is neither probable nor refutable at w0 let EM_pf_at_w := soundness (W := EMFrame) h w0 (by simp [all_at_world]) simp [at_world] at EM_pf_at_w
EM_pf_at_w : Frame.val w0 0 ∨ ∀ (w' : EMFrame), w0 ≤ w' → ¬Frame.val w' 0
⊢ False
rcases EM_pf_at_w with pf_p | pf_not_p
inl
pf_p : Frame.val w0 0
⊢ False
inr
pf_not_p : ∀ (w' : EMFrame), w0 ≤ w' → ¬Frame.val w' 0
⊢ False
·
inl
pf_p : Frame.val w0 0
⊢ False
-- case 1: w0 forced at p, -- But by def of val it is not forced here simp [Frame.val] at pf_p ·
inr
pf_not_p : ∀ (w' : EMFrame), w0 ≤ w' → ¬Frame.val w' 0
⊢ False
-- Case 2: w0 forces p -> ⊥ -- At every world accessible from w0, if p is true, then ⊥ is true. -- But w1 is accessible from w0, and p is true at w1 while ⊥ is never true. have w0_le_w1 : w0 ≤ w1 := by simp [LE.le] have p_at_w1 : at_world w1 (var 0) := by simp [at_world, Frame.val] exact pf_not_p w1 w0_le_w1 p_at_w1


end ExcludedMiddle

end ExcludedMiddle


end Kripke