(c) Copyright, Antonella Bilotta, Marco Maggesi, Cosimo Perini Brogi, Leonardo Quartini 2024.
(c) Copyright, Antonella Bilotta, Marco Maggesi, Cosimo Perini Brogi 2025.
See the website for a brief overview of our HOLMS library for the HOL Light theorem prover.
This repository presents a second version of HOLMS (HOL-Light Library for Modal Systems), a modular framework designed to implement modal reasoning within the HOL Light proof assistant.
Extending our previous work on Gödel-Löb logic (GL), we generalise our approach to formalise modal adequacy proofs for axiomatic calculi, thereby enabling the coverage of a broader range of normal modal systems. If the first version of HOLMS, presented at Overlay 2024, partially parametrised the completeness proof for GL and added the minimal system K, this second version of HOLMS fully generalises our method and, as a demonstration of the flexibility of our methodology, four modal system and their adequacy proofs are now implemented in HOLMS:
- K: the minimal system is developed in
k_completeness.ml
; - K4: a system properly extended by GL is developed in
k4_completeness.ml
; - GL: provability logic is developed and fully parametrised in
gl_completeness.ml
; - T: a system that is not extended by GL or K4, nor is an extension of GL or K4 is developed in
t_completeness.ml
.
HOLMS lays the foundation for a comprehensive tool for modal reasoning in HOL, offering a high level of confidence and full automation by providing the essential mathematical components of principled decision algorithms for modal systems. The prototypical automated theorem prover and countermodel constructor for K, T, K4, and GL (implemented in k_decid.ml
, t_decid.ml
, k4_decid.ml
, and gl_decid.ml
, resp.) serve as evidence of the feasibility of this approach merging general purpose proof assistants, enriched sequent calculi, and formalised mathematics.
The top-level file is make.ml
.
For each normal system
-
-
Identification of the set of frames appropriate to
proves that a certain set of finite frames, distinguished by a certain property of the accessibility relation, is the set of frames appropriate to ; i.e. for each frame in this set if a modal formula is a theorem of , then is valid in it.
and equivalently ( APPRS_APPR_S
)
-
Identification of the set of frames appropriate to
-
-
Soundness of
with respect to
proves that if something is a theorem of, then it is valid in its set of appropriate frames.
( S_APPRS_VALID
)
-
Soundness of
-
-
Consistency of S
proves thatcannot prove the false.
( S_CONSISTENT
)
-
Consistency of S
-
-
Completeness of
related to
proves that if something holds in the set appropriate to, then it is a theorem of .
( S_COMPLETENESS_THM
)
-
Completeness of
For example, in t_completeness.ml
we prove: (1) RF_APPR_T
; (2) T_RF_VALID
; (3) T_CONSISTENT
; (4) T_COMPLETENESS_THM
.
Moreover, HOLMS implements fully automated theorem prover and countermodel constructor for the modal logics
HOLMS_RULE
automatically proves theorems of these systems;HOLMS_BUILD_COUNTERMODEL
outputs a countermodel if the given formula is not a theorem of the logic under analysis.
To generalise and parametrise the proofs of completeness for normal systems as much as possible, we develop four main theorems in gen_completeness.ml
:
GEN_TRUTH_LEMMA
;GEN_ACCESSIBILITY_LEMMA
;GEN_COUNTERMODEL_ALT
;GEN_LEMMA_FOR_GEN_COMPLETENESS
.
We define a ternary predicate
Notice that, by doing so, we conceptualise derivability from
We inductively define the axioms of the minimal calculus K (K_AXIOMS
).
let KAXIOM_RULES,KAXIOM_INDUCT,KAXIOM_CASES = new_inductive_definition
`(!p q. KAXIOM (p --> (q --> p))) /\
(!p q r. KAXIOM ((p --> q --> r) --> (p --> q) --> (p --> r))) /\
(!p. KAXIOM (((p --> False) --> False) --> p)) /\
(!p q. KAXIOM ((p <-> q) --> p --> q)) /\
(!p q. KAXIOM ((p <-> q) --> q --> p)) /\
(!p q. KAXIOM ((p --> q) --> (q --> p) --> (p <-> q))) /\
KAXIOM (True <-> False --> False) /\
(!p. KAXIOM (Not p <-> p --> False)) /\
(!p q. KAXIOM (p && q <-> (p --> q --> False) --> False)) /\
(!p q. KAXIOM (p || q <-> Not(Not p && Not q))) /\
(!p q. KAXIOM (Box (p --> q) --> Box p --> Box q))`;;
Then, we inductively introduce the derivability relation of our calculus (MODPROVES
).
let MODPROVES_RULES,MODPROVES_INDUCT,MODPROVES_CASES =
new_inductive_definition
`(!H p. KAXIOM p ==> [S . H |~ p]) /\
(!H p. p IN S ==> [S . H |~ p]) /\
(!H p. p IN H ==> [S . H |~ p]) /\
(!H p q. [S . H |~ p --> q] /\ [S . H |~ p] ==> [S . H |~ q]) /\
(!H p. [S . {} |~ p] ==> [S . H |~ Box p])`;;
This lemma guarantees the reduction of the common notion of derivability of modal formula
MODPROVES_DEDUCTION_LEMMA
|- !S H p q. [S . H |~ p --> q] <=> [S . p INSERT H |~ q]
We define, by induction on the complexity of a formula, that a certain modal formula
let holds =
let pth = prove
(`(!WP. P WP) <=> (!W:W->bool R:W->W->bool. P (W,R))`,
MATCH_ACCEPT_TAC FORALL_PAIR_THM) in
(end_itlist CONJ o map (REWRITE_RULE[pth] o GEN_ALL) o CONJUNCTS o
new_recursive_definition form_RECURSION)
`(holds WR V False (w:W) <=> F) /\
(holds WR V True w <=> T) /\
(holds WR V (Atom s) w <=> V s w) /\
(holds WR V (Not p) w <=> ~(holds WR V p w)) /\
(holds WR V (p && q) w <=> holds WR V p w /\ holds WR V q w) /\
(holds WR V (p || q) w <=> holds WR V p w \/ holds WR V q w) /\
(holds WR V (p --> q) w <=> holds WR V p w ==> holds WR V q w) /\
(holds WR V (p <-> q) w <=> holds WR V p w <=> holds WR V q w) /\
(holds WR V (Box p) w <=>
!w'. w' IN FST WR /\ SND WR w w' ==> holds WR V p w')`;;
We say that a formula
let holds_in = new_definition
`holds_in (W,R) p <=> !V w:W. w IN W ==> holds (W,R) V p w`;;
We say that a formula
let valid = new_definition
`L |= p <=> !f:(W->bool)#(W->W->bool). f IN L ==> holds_in f p`;;
The innovative definition of Kripke's model stands on the notion of modal frame, namely an ordered pair where the first object is a non-empty set (domain of the possible worlds) and the second one is a binary relation on the first set (accessibility relation).
let FRAME_DEF = new_definition
`FRAME = {(W:W->bool,R:W->W->bool) | ~(W = {}) /\
(!x y:W. R x y ==> x IN W /\ y IN W)}`;;
We define the set of frames appropriate to S, i.e. the set of all the finite frames such that if p is a theorem of S, then p holds in this frame.
{
let APPR_DEF = new_definition
`APPR S = {(W:W->bool,R:W->W->bool) |
(W,R) IN FINITE_FRAME /\
(!p. [S. {} |~ p] ==> holds_in (W,R) p)}`;;
For each one of the normal system S developed in HOLMS we prove what set of frames is appropriate to S (
We prove that the set of finite frames is the one appropriate to
FINITE_FRAME_APPR_K
|- FINITE_FRAME:(W->bool)#(W->W->bool)->bool = APPR {}
We prove that the set of finite reflexive frames is the one appropriate to
let T_AX = new_definition
`T_AX = {Box p --> p | p IN (:form)}`;;
let RF_DEF = new_definition
`RF =
{(W:W->bool,R:W->W->bool) |
~(W = {}) /\
(!x y:W. R x y ==> x IN W /\ y IN W) /\
FINITE W /\
(!x. x IN W ==> R x x)}`;;
RF_APPR_T
|- RF: (W->bool)#(W->W->bool)->bool = APPR T_AX
We prove that the set of finite transitive frames is the one appropriate to
let K4_AX = new_definition
`K4_AX = {Box p --> Box Box p | p IN (:form)}`;;
let TF_DEF = new_definition
`TF =
{(W:W->bool,R:W->W->bool) |
~(W = {}) /\
(!x y:W. R x y ==> x IN W /\ y IN W) /\
FINITE W /\
(!x y z. x IN W /\ y IN W /\ z IN W /\ R x y /\ R y z ==> R x z)}`;;
TF_APPR_K4
|- TF: (W->bool)#(W->W->bool)->bool = APPR K4_AX
We prove that the set of finite transitive and irreflexive frames is the one appropriate to
let GL_AX = new_definition
`GL_AX = {Box (Box p --> p) --> Box p | p IN (:form)}`;;
let ITF_DEF = new_definition
`ITF =
{(W:W->bool,R:W->W->bool) |
~(W = {}) /\
(!x y:W. R x y ==> x IN W /\ y IN W) /\
FINITE W /\
(!x. x IN W ==> ~R x x) /\
(!x y z. x IN W /\ y IN W /\ z IN W /\ R x y /\ R y z ==> R x z)}`;;
ITF_APPR_GL
|- ITF: (W->bool)#(W->W->bool)->bool = APPR GL_AX
We parametrically demonstrate the soundness of each
GEN_APPR_VALID
|- !S p. [S. {} |~ p] ==> APPR S:(W->bool)#(W->W->bool)->bool |= p
Then, by specializing the proof of GEN_APPR_VALID
, we prove the soundness of each normal system S_APPRS_VALID
.
let K_FINITE_FRAME_VALID = prove
(`!p. [{} . {} |~ p] ==> FINITE_FRAME:(W->bool)#(W->W->bool)->bool |= p`,
ASM_MESON_TAC[GEN_APPR_VALID; FINITE_FRAME_APPR_K]);;
let K_CONSISTENT = prove
(`~ [{} . {} |~ False]`,
REFUTE_THEN (MP_TAC o MATCH_MP (INST_TYPE [`:num`,`:W`] K_FINITE_FRAME_VALID)) THEN
REWRITE_TAC[NOT_IN_EMPTY] THEN
REWRITE_TAC[valid; holds; holds_in; FORALL_PAIR_THM; IN_FINITE_FRAME; NOT_FORALL_THM] THEN
MAP_EVERY EXISTS_TAC [`{0}`; `\x:num y:num. F`] THEN
REWRITE_TAC[NOT_INSERT_EMPTY; FINITE_SING; IN_SING] THEN MESON_TAC[]);;
let T_RF_VALID = prove
(`!p. [T_AX . {} |~ p] ==> RF:(W->bool)#(W->W->bool)->bool |= p`,
MESON_TAC[GEN_APPR_VALID; RF_APPR_T]);;
let T_CONSISTENT = prove
(`~ [T_AX . {} |~ False]`,
REFUTE_THEN (MP_TAC o MATCH_MP (INST_TYPE [`:num`,`:W`] T_RF_VALID)) THEN
REWRITE_TAC[valid; holds; holds_in; FORALL_PAIR_THM;
IN_RF; NOT_FORALL_THM] THEN
MAP_EVERY EXISTS_TAC [`{0}`; `\x:num y:num. x = 0 /\ x = y`] THEN
REWRITE_TAC[NOT_INSERT_EMPTY; FINITE_SING; IN_SING] THEN MESON_TAC[]);;
let K4_TF_VALID = prove
(`!p. [K4_AX . {} |~ p] ==> TF:(W->bool)#(W->W->bool)->bool |= p`,
MESON_TAC[GEN_APPR_VALID; TF_APPR_K4]);;
let K4_CONSISTENT = prove
(`~ [K4_AX . {} |~ False]`,
REFUTE_THEN (MP_TAC o MATCH_MP (INST_TYPE [`:num`,`:W`] K4_TF_VALID)) THEN
REWRITE_TAC[valid; holds; holds_in; FORALL_PAIR_THM;
IN_TF; NOT_FORALL_THM] THEN
MAP_EVERY EXISTS_TAC [`{0}`; `\x:num y:num. F`] THEN
REWRITE_TAC[NOT_INSERT_EMPTY; FINITE_SING; IN_SING] THEN MESON_TAC[]);;
let GL_ITF_VALID = prove
(`!p. [GL_AX . {} |~ p] ==> ITF:(W->bool)#(W->W->bool)->bool |= p`,
ASM_MESON_TAC[GEN_APPR_VALID; ITF_APPR_GL]);;
let GL_consistent = prove
(`~ [GL_AX . {} |~ False]`,
REFUTE_THEN (MP_TAC o MATCH_MP (INST_TYPE [`:num`,`:W`] GL_ITF_VALID)) THEN
REWRITE_TAC[valid; holds; holds_in; FORALL_PAIR_THM;
IN_ITF; NOT_FORALL_THM] THEN
MAP_EVERY EXISTS_TAC [`{0}`; `\x:num y:num. F`] THEN
REWRITE_TAC[NOT_INSERT_EMPTY; FINITE_SING; IN_SING] THEN MESON_TAC[]);;
We first sketch the idea behind the demonstration and, then, we will present a three-step proof.
Given a modal system
val it : goalstack = 1 subgoal (1 total)
`!p. APPR S |= p ==> [S. {} |~ p]`
-
1. Rewriting
S_COMPLETENESS
's statement
By using some tautologies and rewritings, we can show that the completeness theorem is equivalent to a more handy sentence:
- A. We rewrote the sentence by contraposition.
e GEN_REWRITE_TAC I [GSYM CONTRAPOS_THM];;
- B. We rewrote validity in a set of frames (
valid
) as validity in a certain world of a certain model (holds
) and we exploited some propositional tautologies.
e (REWRITE_TAC[valid; NOT_FORALL_THM; FORALL_PAIR_THM; holds_in; NOT_IMP]);;
- A. We rewrote the sentence by contraposition.
val it : goalstack = 1 subgoal (1 total)
`!p. ~[S . {} |~ p]
==> ?W R. (W,R) IN APPR S /\
(?V m. m IN W /\ ~holds (W,R) V p w)`
To prove this rewritten statement, we need to construct a countermodel
We can observe that, by working with HOL, we identify all those lines of reasoning that are parametric with respect to
-
2. Reducing a model-theoretic notion to a list-theoretic concept
The canonical proof of completeness, illustrated in classical textbooks like George Boolos's "The Logic of Provability", exploits the idea of working in a context (countermodel) such that:.
Observe that, in such a context, the members of the domainare lists of modal formulas. If we are able to construct a countermodel with these constraints, we will easily construct a counterworld that is a list of formulas not including p.
Then our subgoal would be to prove:
val it : goalstack = 1 subgoal (1 total)
`!p. ~[S . {} |~ p]
==> ?W R. (W,R) IN APPR S /\
(?M. M IN W /\ ~ MEM p M)`
This subgoal is much more manageable than the previous one, indeed it reduces the model-theoretic notion of validity (holds (W,R) V p w
) to the list-theoretic concept of membership (MEM p w
).
-
3. What do we need to prove?
Given our aim of proving, we need a countermodel and counterworld following these constraints:
- A. The Kripke's frame
must be appropriate to S.
- B. The Kripke's model
must allow us to reduce validity to membership for every subformula of p.
Namely, for our modelholds , where denotes the subformula relation.
- C. The counterworld
must not contain .
- D.
must be a set of formulas lists
APPR S:(form list->bool)#(form list->form list->bool)->bool
.
- A. The Kripke's frame
We partially identify the countermodel S_STANDARD_MODEL
in step 1 is fully parametric and does not involve any peculiarities of the modal system gen_completeness.ml
as GEN_STANDARD_MODEL
.
Before we build up the countermodel, we define in consistent.ml
some properties that hold for formulas lists and that will be useful to define the domain of the countermodel.
A list of formulas
let CONSISTENT = new_definition
`CONSISTENT S (X:form list) <=> ~[S . {} |~ Not (CONJLIST X)]`;;
A list of formulas
let MAXIMAL_CONSISTENT = new_definition
`MAXIMAL_CONSISTENT S p X <=>
CONSISTENT S X /\ NOREPETITION X /\
(!q. q SUBFORMULA p ==> MEM q X \/ MEM (Not q) X)`;;
Lindenbaum Lemma:
EXTEND_MAXIMAL_CONSISTENT
|- !S p X. CONSISTENT S X /\
(!q. MEM q X ==> q SUBSENTENCE p)
==> ?M. MAXIMAL_CONSISTENT S p M /\
(!q. MEM q M ==> q SUBSENTENCE p) /\
X SUBLIST M
We define a standard model such that:
-
A: The Domain
is { }
As requested, the domain is a set of lists of formulas and, in particular, it is a subclass of maximal consistent sets of formulas.
Observe that, in principle, we can employ general sets of formulas in the formalisation. However, from the practical viewpoint, lists without repetitions are better suited in HOL since they are automatically finite and we can easily manipulate them by structural recursion.
We prove, as requested for the domain of a frame, thatis non-empty by using NONEMPTY_MAXIMAL_CONSISTENT
, a corollary of the lemma of extension of maximal consistent lists.
NONEMPTY_MAXIMAL_CONSISTENT
|- !S p. ~ [S . {} |~ p]
==> ?M. MAXIMAL_CONSISTENT S p M /\
MEM (Not p) M /\
(!q. MEM q M ==> q SUBSENTENCE p)
-
B: The Accessibility Relation
should meet two conditions - R1:
.
This condition ensures that our list-theoretic translation follows Kripke's semantics. - R2:
.
This second condition guarantees one of the four initial constraints.
- R1:
-
C: The Evaluation Relation
is defined as follows
In particular, in HOLMS's gen_completeness.ml
we develop a parametric (to GEN_STANDARD_FRAME
and GEN_STANDARD_MODEL
and then we specialize these definitions for each normal system.
let GEN_STANDARD_FRAME_DEF = new_definition
`GEN_STANDARD_FRAME S p =
APPR S INTER
{(W,R) | W = {w | MAXIMAL_CONSISTENT S p w /\
(!q. MEM q w ==> q SUBSENTENCE p)} /\
(!q w. Box q SUBFORMULA p /\ w IN W
==> (MEM (Box q) w <=> !x. R w x ==> MEM q x))}`;;
let GEN_STANDARD_MODEL_DEF = new_definition
`GEN_STANDARD_MODEL S p (W,R) V <=>
(W,R) IN GEN_STANDARD_FRAME S p /\
(!a w. w IN W ==> (V a w <=> MEM (Atom a) w /\ Atom a SUBFORMULA p))`;;
Because the definitions of K_STANDARD_MODEL
, T_STANDARD_MODEL
, K4_STANDARD_MODEL
and GL_STANDARD_MODEL
are just instances of GEN_STANDARD_FRAME
and GEN_STANDARD_MODEL
with the parameters {}
, T_AX
, K4_AX
and GL_AX
, here we present only the definitions for
Definitions in k4_completeness.ml
(S
=K4_AX
)
let K4_STANDARD_FRAME_DEF = new_definition
`K4_STANDARD_FRAME p = GEN_STANDARD_FRAME K4_AX p`;;
IN_K4_STANDARD_FRAME
|- !p W R. (W,R) IN K4_STANDARD_FRAME p <=>
W = {w | MAXIMAL_CONSISTENT K4_AX p w /\
(!q. MEM q w ==> q SUBSENTENCE p)} /\
(W,R) IN TF /\
(!q w. Box q SUBFORMULA p /\ w IN W
==> (MEM (Box q) w <=> !x. R w x ==> MEM q x))
let K4_STANDARD_MODEL_DEF = new_definition
`K4_STANDARD_MODEL = GEN_STANDARD_MODEL K4_AX`;;
K4_STANDARD_MODEL_CAR
|- !W R p V.
K4_STANDARD_MODEL p (W,R) V <=>
(W,R) IN K4_STANDARD_FRAME p /\
(!a w. w IN W ==> (V a w <=> MEM (Atom a) w /\ Atom a SUBFORMULA p))
The definition of a standard acessibility relation cannot be fully parametrised, at least following the approach presented in classical textbook.
Consequently, to avoid code repetition, we will:
- A: Define a parametric
GEN_STANDARD_REL
ingen_completeness.ml
, - B: Complete the definition of
S_STANDARD_REL
in its spefic fileS_completeness.ml
, in a way that guarantees the conditions R1 and R2. In particular, we will show:- The most difficult verse of R1's implication in
S_ACCESSIBILITY_LEMMA
- R2 holds for
S_STANDARD_REL in S_MAXIMAL_CONSISTENT
.
S_STANDARD_REL Then SF_IN_STANDARD_S_FRAMEE
follows as corollary and, given the hypotesis, S_STANDARD_REL is an S_STANDARD_MODEL
.
- The most difficult verse of R1's implication in
let GEN_STANDARD_REL = new_definition
`GEN_STANDARD_REL S p w x <=>
MAXIMAL_CONSISTENT S p w /\ (!q. MEM q w ==> q SUBSENTENCE p) /\
MAXIMAL_CONSISTENT S p x /\ (!q. MEM q x ==> q SUBSENTENCE p) /\
(!B. MEM (Box B) w ==> MEM B x)`;;
let K_STANDARD_REL_DEF = new_definition
`K_STANDARD_REL p = GEN_STANDARD_REL {} p`;;
K_STANDARD_REL_CAR
|- K_STANDARD_REL p w x <=>
MAXIMAL_CONSISTENT {} p w /\ (!q. MEM q w ==> q SUBSENTENCE p) /\
MAXIMAL_CONSISTENT {} p x /\ (!q. MEM q x ==> q SUBSENTENCE p) /\
(!B. MEM (Box B) w ==> MEM B x)
Accessibility lemma for K that ensures the most difficult verse of R1's implication.
K_ACCESSIBILITY_LEMMA
|- !p w q. ~ [{} . {} |~ p] /\
MAXIMAL_CONSISTENT {} p w /\
(!q. MEM q w ==> q SUBSENTENCE p) /\
Box q SUBFORMULA p /\
(!x. K_STANDARD_REL p w x ==> MEM q x)
==> MEM (Box q) w`
Maximal consistent lemma for K ensures R2.
K_MAXIMAL_CONSISTENT
|- !p. ~ [{} . {} |~ p]
==> ({M | MAXIMAL_CONSISTENT {} p M /\
(!q. MEM q M ==> q SUBSENTENCE p)},
K_STANDARD_REL p)
IN FINITE_FRAME`,
Proof of the corollary that ensures that our construction for K is a standard frame.
g `!p. ~ [{} . {} |~ p]
==> ({M | MAXIMAL_CONSISTENT {} p M /\ (!q. MEM q M ==> q SUBSENTENCE p)},
K_STANDARD_REL p)
IN K_STANDARD_FRAME p`;;
e (INTRO_TAC "!p; not_theor_p");;
e (REWRITE_TAC [IN_K_STANDARD_FRAME]);;
e CONJ_TAC;;
e (MATCH_MP_TAC K_MAXIMAL_CONSISTENT);;
e (ASM_REWRITE_TAC[]);;
e (INTRO_TAC "!q w; subform w_in");;
e EQ_TAC;;
e (ASM_MESON_TAC[K_STANDARD_REL_CAR]);;
e (INTRO_TAC "Implies_Mem_q");;
e (HYP_TAC "w_in" (REWRITE_RULE[IN_ELIM_THM]));;
e (MATCH_MP_TAC K_ACCESSIBILITY_LEMMA);;
e (EXISTS_TAC `p:form`);;
e (ASM_REWRITE_TAC[]);;
let KF_IN_STANDARD_K_FRAME = top_thm();;
let T_STANDARD_REL_DEF = new_definition
`T_STANDARD_REL p w x <=>
GEN_STANDARD_REL T_AX p w x`;;
T_STANDARD_REL_CAR
|- !p w x.
T_STANDARD_REL p w x <=>
MAXIMAL_CONSISTENT T_AX p w /\ (!q. MEM q w ==> q SUBSENTENCE p) /\
MAXIMAL_CONSISTENT T_AX p x /\ (!q. MEM q x ==> q SUBSENTENCE p) /\
(!B. MEM (Box B) w ==> MEM B x)
Accessibility lemma for T that ensures the most difficult verse of R1's implication.
T_ACCESSIBILITY_LEMMA
|- !p w q.
~ [T_AX . {} |~ p] /\
MAXIMAL_CONSISTENT T_AX p w /\
(!q. MEM q w ==> q SUBSENTENCE p) /\
Box q SUBFORMULA p /\
(!x. T_STANDARD_REL p w x ==> MEM q x)
==> MEM (Box q) w
Maximal consistent lemma for T that ensures R2.
RF_MAXIMAL_CONSISTENT
|- !p. ~ [T_AX . {} |~ p]
==> ({M | MAXIMAL_CONSISTENT T_AX p M /\
(!q. MEM q M ==> q SUBSENTENCE p)},
T_STANDARD_REL p)
IN RF `
Proof of the corollary that ensures that our construction for T is a standard frame.
g `!p. ~ [T_AX . {} |~ p]
==> ({M | MAXIMAL_CONSISTENT T_AX p M /\ (!q. MEM q M ==> q SUBSENTENCE p)},
T_STANDARD_REL p) IN T_STANDARD_FRAME p`;;
e (INTRO_TAC "!p; not_theor_p");;
e (REWRITE_TAC [IN_T_STANDARD_FRAME]);;
e CONJ_TAC;;
e (MATCH_MP_TAC RF_MAXIMAL_CONSISTENT);;
e (ASM_REWRITE_TAC[]);;
e (ASM_REWRITE_TAC[IN_ELIM_THM]);;
e (INTRO_TAC "!q w; boxq maxw subw");;
e EQ_TAC;;
e (ASM_MESON_TAC[T_STANDARD_REL_CAR]);;
e (ASM_MESON_TAC[T_ACCESSIBILITY_LEMMA]);;
let RF_IN_T_STANDARD_FRAME = top_thm();;
let K4_STANDARD_REL_DEF = new_definition
`K4_STANDARD_REL p w x <=>
GEN_STANDARD_REL K4_AX p w x /\
(!B. MEM (Box B) w ==> MEM (Box B) x)`;;
K4_STANDARD_REL_CAR
|- !p w x.
K4_STANDARD_REL p w x <=>
MAXIMAL_CONSISTENT K4_AX p w /\ (!q. MEM q w ==> q SUBSENTENCE p) /\
MAXIMAL_CONSISTENT K4_AX p x /\ (!q. MEM q x ==> q SUBSENTENCE p) /\
(!B. MEM (Box B) w ==> MEM (Box B) x /\ MEM B x)
Accessibility lemma for K4 that ensures the most difficult verse of R1's implication.
K4_ACCESSIBILITY_LEMMA
|- !p w q.
~ [K4_AX . {} |~ p] /\
MAXIMAL_CONSISTENT K4_AX p w /\
(!q. MEM q w ==> q SUBSENTENCE p) /\
Box q SUBFORMULA p /\
(!x. K4_STANDARD_REL p w x ==> MEM q x)
==> MEM (Box q) w
Maximal consistent lemma for K4 that ensures R2.
TF_MAXIMAL_CONSISTENT
|- !p. ~ [K4_AX . {} |~ p]
==> ({M | MAXIMAL_CONSISTENT K4_AX p M /\
(!q. MEM q M ==> q SUBSENTENCE p)},
K4_STANDARD_REL p)
IN TF `
Proof of the corollary that ensures that our construction for K4 is a standard frame.
g `!p. ~ [K4_AX . {} |~ p]
==> ({M | MAXIMAL_CONSISTENT K4_AX p M /\ (!q. MEM q M ==> q SUBSENTENCE p)},
K4_STANDARD_REL p) IN K4_STANDARD_FRAME p`;;
e (INTRO_TAC "!p; not_theor_p");;
e (REWRITE_TAC[IN_K4_STANDARD_FRAME]);;
e CONJ_TAC;;
e (MATCH_MP_TAC TF_MAXIMAL_CONSISTENT);;
e (ASM_REWRITE_TAC[]);;
e (ASM_REWRITE_TAC[IN_ELIM_THM]);;
e (INTRO_TAC "!q w; boxq maxw subw");;
e EQ_TAC;;
e (ASM_MESON_TAC[K4_STANDARD_REL_CAR]);;
e (ASM_MESON_TAC[K4_ACCESSIBILITY_LEMMA]);;
let K4F_IN_K4_STANDARD_FRAME = top_thm();;
let GL_STANDARD_REL_DEF = new_definition
`GL_STANDARD_REL p w x <=>
GEN_STANDARD_REL GL_AX p w x /\
(!B. MEM (Box B) w ==> MEM (Box B) x) /\
(?E. MEM (Box E) x /\ MEM (Not (Box E)) w)`;;
GL_STANDARD_REL_CAR
|- !p w x.
GL_STANDARD_REL p w x <=>
MAXIMAL_CONSISTENT GL_AX p w /\ (!q. MEM q w ==> q SUBSENTENCE p) /\
MAXIMAL_CONSISTENT GL_AX p x /\ (!q. MEM q x ==> q SUBSENTENCE p) /\
(!B. MEM (Box B) w ==> MEM (Box B) x /\ MEM B x) /\
(?E. MEM (Box E) x /\ MEM (Not (Box E)) w)
Accessibility Lemma for GL that ensures the most difficult verse of R1's implication.
GL_ACCESSIBILITY_LEMMA
|- !p w q.
~ [GL_AX . {} |~ p] /\
MAXIMAL_CONSISTENT GL_AX p w /\
(!q. MEM q w ==> q SUBSENTENCE p) /\
Box q SUBFORMULA p /\
(!x. GL_STANDARD_REL p w x ==> MEM q x)
==> MEM (Box q) w
Maximal Consistent Lemma for GL that ensures R2.
ITF_MAXIMAL_CONSISTENT
|- !p. ~ [GL_AX . {} |~ p]
==> ({M | MAXIMAL_CONSISTENT GL_AX p M /\
(!q. MEM q M ==> q SUBSENTENCE p)},
GL_STANDARD_REL p)
IN ITF
Proof of the corollary that ensures that our construction for GL is a standard frame.
g `!p. ~ [GL_AX . {} |~ p]
==> ({M | MAXIMAL_CONSISTENT GL_AX p M /\ (!q. MEM q M ==> q SUBSENTENCE p)},
GL_STANDARD_REL p)
IN GL_STANDARD_FRAME p`;;
e (INTRO_TAC "!p; not_theor_p");;
e (REWRITE_TAC [IN_GL_STANDARD_FRAME]);;
e CONJ_TAC;;
e (MATCH_MP_TAC ITF_MAXIMAL_CONSISTENT);;
e (ASM_REWRITE_TAC[]);;
e (ASM_REWRITE_TAC[IN_ELIM_THM]);;
e (INTRO_TAC "!q w; subform max_cons_w implies_w");;
e EQ_TAC;;
e (ASM_MESON_TAC[GL_STANDARD_REL_CAR]);;
e (ASM_MESON_TAC[GL_ACCESSIBILITY_LEMMA]);;
let GLF_IN_GL_STANDARD_FRAME = top_thm();;
In this step, we prove that, given a standard model and holds (W,R) V q w
to the list-theoretic one of membership MEM q w
.
Observe that we prove this foundamental lemma in a fully parametric way and, moreover, the proof of completeness does not need to specify this lemma for the normal system in analysis.
GEN_TRUTH_LEMMA
|- !S W R p V q.
~ [S . {} |~ p] /\
GEN_STANDARD_MODEL S p (W,R) V /\
q SUBFORMULA p
==> !w. w IN W ==> (MEM q w <=> holds (W,R) V q w)
We built up a countermodel
- A:
that is to say is ; - B:
Thanks to our theorem NONEMPTY_MAXIMAL_CONSISTENT
GEN_COUNTERMODEL_ALT
. Observe, indeed, that
NONEMPTY_MAXIMAL_CONSISTENT
|- !S p. ~ [S . {} |~ p]
==> ?M. MAXIMAL_CONSISTENT S p M /\
MEM (Not p) M /\
(!q. MEM q M ==> q SUBSENTENCE p)
g `!S W R p. ~ [S . {} |~ p] /\
(W,R) IN GEN_STANDARD_FRAME S p
==>
~holds_in (W,R) p`;;
e (INTRO_TAC "!S W R p; p_not_theor in_standard_frame");;
e (REWRITE_TAC[holds_in; NOT_FORALL_THM; NOT_IMP; IN_ELIM_THM]);;
e (EXISTS_TAC `\a M. Atom a SUBFORMULA p /\ MEM (Atom a) M`);;
e (DESTRUCT_TAC "@M. max mem subf" (MATCH_MP NONEMPTY_MAXIMAL_CONSISTENT (ASSUME `~ [S . {} |~ p]`)));;
e (EXISTS_TAC `M:form list` THEN ASM_REWRITE_TAC[]);;
e (SUBGOAL_THEN `GEN_STANDARD_MODEL S p (W,R) (\a M. Atom a SUBFORMULA p /\ MEM (Atom a) M) ` MP_TAC);;
e (ASM_MESON_TAC[GEN_STANDARD_MODEL_DEF]);;
e (INTRO_TAC "standard_model");;
e CONJ_TAC;;
e (HYP_TAC "in_standard_frame" (REWRITE_RULE[IN_GEN_STANDARD_FRAME]));;
e (ASM_REWRITE_TAC[IN_ELIM_THM]);;
e (MP_TAC (ISPECL
[`S: form ->bool`;
`W: (form)list->bool`;
`R: (form)list-> (form)list ->bool`;
`p:form`;
`(\a M. Atom a SUBFORMULA p /\ MEM (Atom a) M):((char)list->(form)list->bool)`;
`p:form`] GEN_TRUTH_LEMMA));;
e (ANTS_TAC );;
e (ASM_REWRITE_TAC[SUBFORMULA_REFL]);;
e (DISCH_THEN (MP_TAC o SPEC `M:form list`));;
e ANTS_TAC;;
e (HYP_TAC "standard_model" (REWRITE_RULE[GEN_STANDARD_MODEL_DEF; IN_GEN_STANDARD_FRAME]));;
e (ASM_REWRITE_TAC[IN_ELIM_THM]);;
e (DISCH_THEN (SUBST1_TAC o GSYM));;
e (ASM_MESON_TAC[MAXIMAL_CONSISTENT; CONSISTENT_NC]);;
let GEN_COUNTERMODEL_ALT = top_thm();;
Given the fully parametrised GEN_COUNTERMODEL_ALT
and SF_IN_STANDARD_S_FRAME
, the completeness theorems for every
g `!p. FINITE_FRAME:(form list->bool)#(form list->form list->bool)->bool |= p
==> [{} . {} |~ p]`;;
e (GEN_TAC THEN GEN_REWRITE_TAC I [GSYM CONTRAPOS_THM] );;
e (INTRO_TAC "p_not_theor");;
e (REWRITE_TAC[valid; NOT_FORALL_THM]);;
e (EXISTS_TAC `({M | MAXIMAL_CONSISTENT {} p M /\
(!q. MEM q M ==> q SUBSENTENCE p)},
K_STANDARD_REL p)`);;
e (REWRITE_TAC[NOT_IMP] THEN CONJ_TAC );;
e (MATCH_MP_TAC K_MAXIMAL_CONSISTENT);;
e (ASM_REWRITE_TAC[]);;
e (SUBGOAL_THEN `({M | MAXIMAL_CONSISTENT {} p M /\
(!q. MEM q M ==> q SUBSENTENCE p)},
K_STANDARD_REL p) IN GEN_STANDARD_FRAME {} p`
MP_TAC);;
e (ASM_MESON_TAC[KF_IN_STANDARD_K_FRAME; K_STANDARD_FRAME_DEF]);;
e (ASM_MESON_TAC[GEN_COUNTERMODEL_ALT]);;
let K_COMPLETENESS_THM = top_thm ();;
g `!p. RF:(form list->bool)#(form list->form list->bool)->bool |= p
==> [T_AX . {} |~ p]`;;
e (GEN_TAC THEN GEN_REWRITE_TAC I [GSYM CONTRAPOS_THM]);;
e (INTRO_TAC "p_not_theor");;
e (REWRITE_TAC[valid; NOT_FORALL_THM]);;
e (EXISTS_TAC `({M | MAXIMAL_CONSISTENT T_AX p M /\
(!q. MEM q M ==> q SUBSENTENCE p)},
T_STANDARD_REL p)`);;
e (REWRITE_TAC[NOT_IMP] THEN CONJ_TAC);;
e (MATCH_MP_TAC RF_MAXIMAL_CONSISTENT);;
e (ASM_REWRITE_TAC[]);;
e (SUBGOAL_THEN `({M | MAXIMAL_CONSISTENT T_AX p M /\
(!q. MEM q M ==> q SUBSENTENCE p)},
T_STANDARD_REL p) IN GEN_STANDARD_FRAME T_AX p`
MP_TAC);;
e (ASM_MESON_TAC[RF_IN_T_STANDARD_FRAME; T_STANDARD_FRAME_DEF]);;
e (ASM_MESON_TAC[GEN_COUNTERMODEL_ALT]);;
let T_COMPLETENESS_THM = top_thm ();;
g `!p. TF:(form list->bool)#(form list->form list->bool)->bool |= p
==> [K4_AX . {} |~ p]`;;
e (GEN_TAC THEN GEN_REWRITE_TAC I [GSYM CONTRAPOS_THM]);;
e (INTRO_TAC "p_not_theor");;
e (REWRITE_TAC[valid; NOT_FORALL_THM]);;
e (EXISTS_TAC `({M | MAXIMAL_CONSISTENT K4_AX p M /\
(!q. MEM q M ==> q SUBSENTENCE p)},
K4_STANDARD_REL p)`);;
e (REWRITE_TAC[NOT_IMP] THEN CONJ_TAC);;
e (MATCH_MP_TAC TF_MAXIMAL_CONSISTENT);;
e (ASM_REWRITE_TAC[]);;
e (SUBGOAL_THEN `({M | MAXIMAL_CONSISTENT K4_AX p M /\
(!q. MEM q M ==> q SUBSENTENCE p)},
K4_STANDARD_REL p)
IN GEN_STANDARD_FRAME K4_AX p`
MP_TAC);;
e (ASM_MESON_TAC[K4F_IN_K4_STANDARD_FRAME; K4_STANDARD_FRAME_DEF]);;
e (ASM_MESON_TAC[GEN_COUNTERMODEL_ALT]);;
let K4_COMPLETENESS_THM = top_thm ();;
g `!p. ITF:(form list->bool)#(form list->form list->bool)->bool |= p
==> [GL_AX . {} |~ p]`;;
e (GEN_TAC THEN GEN_REWRITE_TAC I [GSYM CONTRAPOS_THM] );;
e (INTRO_TAC "p_not_theor");;
e (REWRITE_TAC[valid; NOT_FORALL_THM]);;
e (EXISTS_TAC `({M | MAXIMAL_CONSISTENT GL_AX p M /\ (!q. MEM q M ==> q SUBSENTENCE p)},
GL_STANDARD_REL p)`);;
e (REWRITE_TAC[NOT_IMP] THEN CONJ_TAC);;
e (MATCH_MP_TAC ITF_MAXIMAL_CONSISTENT);;
e (ASM_REWRITE_TAC[]);;
e (SUBGOAL_THEN `({M | MAXIMAL_CONSISTENT GL_AX p M /\ (!q. MEM q M ==> q SUBSENTENCE p)},
GL_STANDARD_REL p) IN GEN_STANDARD_FRAME GL_AX p`
MP_TAC);;
e (ASM_MESON_TAC[GLF_IN_GL_STANDARD_FRAME; GL_STANDARD_FRAME_DEF]);;
e (ASM_MESON_TAC[GEN_COUNTERMODEL_ALT]);;
let GL_COMPLETENESS_THM = top_thm ();;
Observe that our proof of completeness requires that APPR S
is not just a set of appropriate frames (APPR S:(W->bool)#(W->W->bool)->bool
) but a set of appropriate frames sitting on the type of formulas' lists (APPR S:(form list->bool)#(form list->form list->bool)->bool
). Nevertheless, thanks to the parametric lemma GEN_LEMMA_FOR_GEN_COMPLETENESS
, we can quickly generalise each completeness theorem for models on domains with a generic infinite type.
In gen_completeness.ml
.
GEN_LEMMA_FOR_GEN_COMPLETENESS
|- !S. INFINITE (:A)
==> !p. APPR S:(A->bool)#(A->A->bool)->bool |= p
==> APPR S:(form list->bool)#(form list->form list->bool)->bool |= p
As corollaries of GEN_LEMMA_FOR_GEN_COMPLETENESS
, in the specific files.
K_COMPLETENESS_THM_GEN
|- !p. INFINITE (:A) /\ FINITE_FRAME:(A->bool)#(A->A->bool)->bool |= p
==> [{} . {} |~ p]
T_COMPLETENESS_THM_GEN
|- !p. INFINITE (:A) /\ RF:(A->bool)#(A->A->bool)->bool |= p
==> [T_AX . {} |~ p]
K4_COMPLETENESS_THM_GEN
|- !p. INFINITE (:A) /\ TF:(A->bool)#(A->A->bool)->bool |= p
==> [K4_AX . {} |~ p]
GL_COMPLETENESS_THM_GEN
|- !p. INFINITE (:A) /\ ITF:(A->bool)#(A->A->bool)->bool |= p
==> [GL_AX . {} |~ p]
Construction of the countermodels.
let K_STDWORLDS_RULES,K_STDWORLDS_INDUCT,K_STDWORLDS_CASES = new_inductive_set
`!M. MAXIMAL_CONSISTENT {} p M /\
(!q. MEM q M ==> q SUBSENTENCE p)
==> set_of_list M IN K_STDWORLDS p`;;
let K_STDREL_RULES,K_STDREL_INDUCT,K_STDREL_CASES = new_inductive_definition
`!w1 w2. K_STANDARD_REL p w1 w2
==> K_STDREL p (set_of_list w1) (set_of_list w2)`;;
Theorem of existence of the finite countermodel.
k_COUNTERMODEL_FINITE_SETS
|- !p. ~[{} . {} |~ p] ==> ~holds_in (K_STDWORLDS p, K_STDREL p) p
Construction of the countermodels.
let T_STDWORLDS_RULES,T_STDWORLDS_INDUCT,T_STDWORLDS_CASES =
new_inductive_set
`!M. MAXIMAL_CONSISTENT T_AX p M /\
(!q. MEM q M ==> q SUBSENTENCE p)
==> set_of_list M IN T_STDWORLDS p`;;
let T_STDREL_RULES,T_STDREL_INDUCT,T_STDREL_CASES = new_inductive_definition
`!w1 w2. T_STANDARD_REL p w1 w2
==> T_STDREL p (set_of_list w1) (set_of_list w2)`;;
Theorem of existence of the finite countermodel.
T_COUNTERMODEL_FINITE_SETS
|- !p. ~ [T_AX . {} |~ p] ==> ~holds_in (T_STDWORLDS p, T_STDREL p) p
Construction of the countermodels.
let K4_STDWORLDS_RULES,K4_STDWORLDS_INDUCT,K4_STDWORLDS_CASES =
new_inductive_set
`!M. MAXIMAL_CONSISTENT K4_AX p M /\
(!q. MEM q M ==> q SUBSENTENCE p)
==> set_of_list M IN K4_STDWORLDS p`;;
let K4_STDREL_RULES,K4_STDREL_INDUCT,K4_STDREL_CASES = new_inductive_definition
`!w1 w2. K4_STANDARD_REL p w1 w2
==> K4_STDREL p (set_of_list w1) (set_of_list w2)`;;
Theorem of existence of the finite countermodel.
K4_COUNTERMODEL_FINITE_SETS
|- !p. ~ [K4_AX . {} |~ p] ==> ~holds_in (K4_STDWORLDS p, K4_STDREL p) p
Construction of the countermodels.
let GL_STDWORLDS_RULES,GL_STDWORLDS_INDUCT,GL_STDWORLDS_CASES =
new_inductive_set
`!M. MAXIMAL_CONSISTENT GL_AX p M /\
(!q. MEM q M ==> q SUBSENTENCE p)
==> set_of_list M IN GL_STDWORLDS p`;;
let GL_STDREL_RULES,GL_STDREL_INDUCT,GL_STDREL_CASES = new_inductive_definition
`!w1 w2. GL_STANDARD_REL p w1 w2
==> GL_STDREL p (set_of_list w1) (set_of_list w2)`;;
Theorem of existence of the finite countermodel.
GL_COUNTERMODEL_FINITE_SETS
|- !p. ~ [GL_AX . {} |~ p] ==> ~holds_in (GL_STDWORLDS p, GL_STDREL p) p
Our tactic HOLMS_TAC
and its associated rule HOLMS_RULE
can automatically prove theorems in the modal logics K, T, K4 and GL by performing a root-first proof search in the associated labelled sequent calculus.
When the tactic halts witout reaching a proof, the proof state holds a countermodel. The procedure HOLMS_BUILD_COUNTERMODEL
outputs the generated countermodel.
Here we report two basic examples.
More examples of proofs and countermodels can be found in the file tests.ml
.
Automatic proof of the Formal Second Incompleteness Theorem in the Gödel–Löb modal logic:
# HOLMS_RULE `[GL_AX . {} |~ Not Box False --> Not Box Diam True]`;;
Generation of a countermodel to the Löb schema in the modal logic K:
# HOLMS_BUILD_COUNTERMODEL `[{} . {} |~ Box (Box a --> a) --> Box a]`;;
Countermodel found:
R y y' /\
y' IN W /\
R w y /\
y IN W /\
holds (W,R) V (Box (Box a --> a)) w /\
w IN W /\
~holds (W,R) V a y /\
~holds (W,R) V a y'