G4m and nkm provers for modal logic

Table of Contents

Two provers for propositional modal logic run in the browser, in SWI-Tinker, beside the first-order prover G4+. For a formula and a modal system (K, D, T, B, K4, S4, S5, K5, KD45), they first look for a countermodel; if there is none, G4m gives a proof in a labelled sequent calculus of the G4 family, and names the weakest logic in which the formula holds (minimal, intuitionistic or classical); then nkm gives a proof in labelled natural deduction, as a tree and in the Fitch style of Fitch’s Symbolic Logic (1952). This page is a guide for reading these outputs. It assumes no knowledge of modal logic: it explains the possible worlds, the systems, the labels, and then each kind of proof on examples that can be run with one click.

Try it now: the query builder for modal logic · SWI-Tinker

1. Introduction

Modal logic is the logic of necessity and possibility. To the connectives of propositional logic it adds two operators: \(\Box A\), read “necessarily \(A\)”, and \(\Diamond A\), read “possibly \(A\)”. The same operators serve many other readings: “it is known that”, “it is obligatory that”, “it is provable that”, “it will always be the case that”. What changes from one reading to another is not the language but the principles one accepts, for instance \(\Box A \to A\) (what is necessary is true): this principle is right for necessity and knowledge, wrong for obligation (what is obligatory is not always done). Modal logic is therefore not one logic but a family of systems, and a prover for modal logic must say in which system a formula is valid.

The provers presented here take a formula and a system, and answer in up to three steps:

  1. a countermodel tree: a systematic search for a situation in which the formula is false. If it finds one, the formula is not valid in the system, and the search stops there;
  2. a proof by G4m in a sequent calculus, with the weakest logic in which the formula is valid: minimal, intuitionistic or classical;
  3. a proof by nkm in natural deduction, as a tree and in Fitch style.

G4m is G4+ for modal logic. G4+ is a prover for first-order logic in Roy Dyckhoff’s contraction-free calculus G4 [1], which tells whether a formula is valid in minimal, intuitionistic or classical logic; G4m does the same for modal formulas, with the same layout and the same names of rules. nkm is the modal language of nkt, the temporal logic prover built on Marco Volpe’s labelled natural deduction [2]; it shares nkt’s countermodel trees, its checker and its Fitch proofs.

The page goes step by step. Section 2 explains possible worlds and the modal systems from scratch. Section 3 introduces the one idea on which all three outputs rest: labels, that is, names of worlds written in the proofs. Sections 4, 5 and 6 explain how to read each output, on examples; section 7 puts them side by side. Section 8 shows how to run the provers, and section 9 says what they do not do.

2. Modal logic from scratch

2.1. Possible worlds

The meaning of \(\Box\) and \(\Diamond\) is given by Kripke’s semantics [3] (a good introduction is Hughes and Cresswell [4]). Think of a set \(W\) of worlds: ways things could be. Between worlds there is a relation \(R\) of accessibility: \(w \mathrel{R} v\) means that \(v\) is possible from the point of view of \(w\) (it is an “alternative” to \(w\)). A pair \((W, R)\) is a frame; a model adds, for each atom \(p\), the set of worlds where \(p\) is true.

The connectives are read at each world as usual: \(A \land B\) is true at \(w\) when \(A\) and \(B\) are both true at \(w\), and so on. The two modal operators look at the accessible worlds:

  • \(\Box A\) is true at \(w\) when \(A\) is true at every world \(v\) such that \(w \mathrel{R} v\);
  • \(\Diamond A\) is true at \(w\) when \(A\) is true at some world \(v\) such that \(w \mathrel{R} v\).

So \(\Box\) is a “for every accessible world” and \(\Diamond\) a “there is an accessible world”: the two operators behave like the quantifiers \(\forall\) and \(\exists\), restricted to the worlds that \(R\) reaches. This analogy is the key to everything that follows.

Two consequences are worth noting at once.

  • If no world is accessible from \(w\), then \(\Box A\) is true at \(w\) for every \(A\) (there is no world where \(A\) could fail), and \(\Diamond A\) is false at \(w\) for every \(A\). A world that sees nothing makes everything necessary and nothing possible.
  • \(\Box A\) and \(\neg \Diamond \neg A\) say the same thing (“\(A\) everywhere” and “nowhere not-\(A\)”), and so do \(\Diamond A\) and \(\neg \Box \neg A\). This duality holds in classical logic; we will see in section 5.4 that one half of it is not intuitionistic.

A formula is valid in a frame if it is true at every world of every model on that frame; it is valid in a class of frames if it is valid in each frame of the class.

2.2. The systems

The system K is the set of formulas valid in every frame. Its characteristic principle is the distribution of \(\Box\) over \(\to\): \[ \Box(p \to q) \to (\Box p \to \Box q). \] (If at every accessible world \(p\) implies \(q\), and \(p\) holds at every accessible world, then \(q\) holds at every accessible world.)

The other systems restrict the class of frames by a condition on \(R\), and each condition makes one more principle valid:

condition on \(R\) what it says principle it validates name
serial every world sees at least one world \(\Box p \to \Diamond p\) D
reflexive every world sees itself \(\Box p \to p\) T
symmetric if \(w\) sees \(v\), \(v\) sees \(w\) \(p \to \Box\Diamond p\) B
transitive if \(w\) sees \(v\) and \(v\) sees \(u\), \(w\) sees \(u\) \(\Box p \to \Box\Box p\) 4
euclidean if \(w\) sees \(v\) and \(u\), \(v\) sees \(u\) \(\Diamond p \to \Box\Diamond p\) 5

Each line can be understood without any machinery. Take T: if \(w\) sees itself and \(\Box p\) is true at \(w\), then \(p\) is true at every world that \(w\) sees, \(w\) included; so \(p\) is true at \(w\). Without reflexivity this fails: a world that sees nothing makes \(\Box p\) true, whatever \(p\) is, while \(p\) may be false there. We will meet exactly this countermodel in section 4.

The systems are named after their conditions:

system conditions on \(R\)
K none
D serial
T reflexive
B reflexive, symmetric
K4 transitive
S4 reflexive, transitive
S5 reflexive, symmetric, transitive
K5 euclidean
KD45 serial, transitive, euclidean

S4 and S5 go back to C. I. Lewis; S4 is the logic of necessity in Fitch’s book (see section 6.3 below), S5 the logic of a necessity for which every world is possible from every other one. In the provers the conditions can also be combined freely (for instance K4 with a symmetric relation).

2.3. Valid, or not valid: countermodels

To show that a formula is not valid in a system, it is enough to give one model, on a frame of the right class, with a world where the formula is false: a countermodel. To show that it is valid, one needs a proof. The provers do both, in this order.

3. The central idea: labels

All three outputs write the worlds in the proofs. A labelled formula \(w : A\) says “\(A\) is true at the world \(w\)”; a relational formula \(w \mathrel{R} v\) says “\(v\) is accessible from \(w\)”. This is the method of labelled deduction, due for modal logic to Simpson [5] and Viganò [6] in natural deduction, and to Negri [7] in sequent calculus.

With labels, the meaning of \(\Box\) and \(\Diamond\) becomes a pair of rules, exactly like the rules of the quantifiers:

  • to prove \(w : \Box A\), take a new world \(s\), assume \(w \mathrel{R} s\), and prove \(s : A\) (as one proves \(\forall x A(x)\) by proving \(A(a)\) for a new \(a\));
  • to use \(w : \Box A\), take any world \(v\) with \(w \mathrel{R} v\) and conclude \(v : A\) (as one passes from \(\forall x A(x)\) to \(A(t)\));
  • to prove \(w : \Diamond A\), find a world \(v\) with \(w \mathrel{R} v\) and prove \(v : A\);
  • to use \(w : \Diamond A\), take a new world \(s\) with \(w \mathrel{R} s\) and \(s : A\), and reason from there (as one uses \(\exists x A(x)\) by reasoning on a new \(a\) with \(A(a)\)).

The conditions on \(R\) become facts or rules about the relational formulas only: reflexivity gives \(w \mathrel{R} w\), transitivity gives \(w \mathrel{R} u\) from \(w \mathrel{R} v\) and \(v \mathrel{R} u\), and so on. The rules for \(\Box\) and \(\Diamond\) never change from one system to another: only the relation changes. That is why the provers can offer a whole family of systems.

Two conventions are used throughout. A formula written without a label is at the world \(w\): the query \(\Box p \to p\) means \(w : \Box p \to p\). The new worlds are named \(s\), \(t\), \(u\) … in the order in which they are introduced, and the same names are used in all three outputs, which makes them easy to compare.

4. First output: the countermodel tree

4.1. How the tree works

The tree tries to build a model where the formula is false. It starts from the denial of the formula at \(w\) and applies rules that say what must then be true. The tree is unsigned, in the style of Jeffrey [8] and Copeland [9]: its lines are labelled formulas and their negations. Each line has a number, and on the right the rule that produced it and the lines it comes from:

rule from adds
¬→ \(w : \neg(A \to B)\) \(w : A\) and \(w : \neg B\)
→ \(w : A \to B\) two branches: \(w : \neg A\), \(w : B\)
∧, ¬∨ \(w : A \land B\), \(w : \neg(A \lor B)\) both parts
∨, ¬∧ \(w : A \lor B\), \(w : \neg(A \land B)\) two branches
¬¬ \(w : \neg\neg A\) \(w : A\)
¬□ (new world s) \(w : \neg\Box A\) a world \(s\), \(w \mathrel{R} s\), \(s : \neg A\)
◇ (new world s) \(w : \Diamond A\) a world \(s\), \(w \mathrel{R} s\), \(s : A\)
□ \(w : \Box A\) and \(w \mathrel{R} v\) \(v : A\)
¬◇ \(w : \neg\Diamond A\) and \(w \mathrel{R} v\) \(v : \neg A\)
refl, sym, trans, eucl, ser the frame conditions relational lines \(w \mathrel{R} v\)

A branch closes (×) when it contains a formula and its negation at the same world, or \(\bot\): no model can make it all true. If every branch closes, the formula is valid in the system. If a branch stays open (○) when no rule can add anything new, it describes a model, and that model is a countermodel; the prover checks it on the formula before printing it.

4.2. A closed tree: \(\Box p \to p\) in T

Run it in SWI-Tinker

=== □p → p
    system: N(K) + refl (T)
    Countermodel tree:
    1   w : ¬(□p → p)                             denied conclusion
    2   w R w                                     refl
    3   w : □p                                    ¬→ 1
    4   w : ¬p                                    ¬→ 1
    5   w : p                                     □ 3, 2
    ×  closed: 5, 4

    The countermodel tree closes: valid in every reflexive frame.

Read it line by line. Line 1 supposes the formula false at \(w\). Since the system is T, \(w\) sees itself (line 2). A conditional is false when its antecedent is true and its consequent false (lines 3 and 4). From \(w : \Box p\) and \(w \mathrel{R} w\), the rule □ gives \(w : p\) (line 5), which contradicts line 4: the branch closes, and the formula is valid in every reflexive frame.

4.3. An open tree: \(\Box p \to p\) in K

Run it in SWI-Tinker

=== □p → p
    system: N(K)
    Countermodel tree:
    1   w : ¬(□p → p)                             denied conclusion
    2   w : □p                                    ¬→ 1
    3   w : ¬p                                    ¬→ 1
    ○  open branch: countermodel

    Countermodel (frame):
      W = {w}
      R = {}
      V(p) = {}
    => not derivable in N(K) (soundness).

In K nothing forces \(w\) to see any world, so the rule □ has nothing to apply to, and the branch stays open. The countermodel is the one announced in section 2.2: a single world \(w\) that sees nothing (\(R\) is empty), where \(p\) is false (\(V(p)\) is empty). There \(\Box p\) is true, since there is no accessible world at all, and \(p\) is false. “Not derivable (soundness)” means: since every derivable formula is valid, a formula with a countermodel cannot be derived. The prover stops here and gives no proof.

4.4. A branching tree: \(\Box(p \lor q) \to \Box p \lor \Box q\) in K

Run it in SWI-Tinker

=== □(p ∨ q) → □p ∨ □q
    system: N(K)
    Countermodel tree:
    1   w : ¬(□(p ∨ q) → □p ∨ □q)                 denied conclusion
    2   w : □(p ∨ q)                              ¬→ 1
    3   w : ¬(□p ∨ □q)                            ¬→ 1
    4   w : ¬□p                                   ¬∨ 3
    5   w : ¬□q                                   ¬∨ 3
    6   w R s                                     ¬□ 4 (new world s)
    7   s : ¬p                                    ¬□ 4, 6
    8   s : p ∨ q                                 □ 2, 6
    ├─ 9   s : p                                  ∨ 8
    │  ×  closed: 9, 7
    └─ 10  s : q                                  ∨ 8
       11  w R w                                  ¬□ 5 (existing world w)
       12  w : ¬q                                 ¬□ 5, 11
       13  w : p ∨ q                              □ 2, 11
       ├─ 14  w : p                               ∨ 13
       │  ○  open branch: countermodel
       └─ 15  w : q                               ∨ 13
          ×  closed: 15, 12

    Countermodel (frame):
      W = {s, w}
      R = {w R s, w R w}
      V(p) = {w}
      V(q) = {s}
    => not derivable in N(K) (soundness).

“Necessarily \(p\) or \(q\)” does not imply “necessarily \(p\), or necessarily \(q\)”: it may be that \(p\) holds at some accessible worlds and \(q\) at the others. The tree finds such a model. Line 4, \(w : \neg\Box p\), asks for an accessible world where \(p\) is false: a new world \(s\) (lines 6 and 7). At \(s\), \(p \lor q\) holds (line 8), so the tree branches (lines 9 and 10); the left branch closes. On the right, line 5 asks for an accessible world where \(q\) is false. Before creating a new world, the tree tries the existing ones, to keep the countermodel small: here it takes \(w\) itself (line 11), which is allowed in K. The left sub-branch stays open, and gives the countermodel: \(w\) sees \(s\) and itself, \(p\) is true at \(w\), \(q\) at \(s\). One can check it by hand: every world seen by \(w\) has \(p\) or \(q\), but not every one has \(p\) (\(s\)), and not every one has \(q\) (\(w\)).

5. Second output: the G4m proof

5.1. Sequents and how to read them

G4m proves sequents. A sequent is written \[ G \;;\; \Gamma \vdash x : A \] where \(G\) is a list of relational formulas (the part of the frame known so far), \(\Gamma\) a list of labelled formulas (the assumptions), and \(x : A\) the goal. It reads: “in any model where the relations \(G\) hold and the formulas \(\Gamma\) are true, \(A\) is true at \(x\)”. When \(G\) is empty, it is omitted.

A proof is built from the bottom up: the sequent to prove is at the bottom (in a tree) or at the top (in the text output, where each step is followed, indented, by the sequents it reduces to). Each step replaces the sequent by simpler ones; a branch ends with an axiom (Ax.): the goal is among the assumptions, or (rule L⊥) \(\bot\) is.

5.2. The rules

The propositional rules are those of G4+, with the same names. Their names say on which side of \(\vdash\) the formula is decomposed (L left, R right) and which connective:

rule it says
R→ to prove \(x : A \to B\), assume \(x : A\) and prove \(x : B\)
R∧, R∨ prove both parts; prove one disjunct
L∧, L∨ split a conjunction; reason by cases on a disjunction
L0→ from \(x : p\) and \(x : p \to B\), keep \(x : B\) (modus ponens on an atom)
L∧→, L∨→, L→→ use \(x : A \to B\) according to the form of \(A\) (Dyckhoff)
L⊥ \(x : \bot\) among the assumptions closes the branch (ex falso; not in minimal logic)
IP to prove \(x : A\), assume \(x : \neg A\) and prove \(x : \bot\) (classical logic only)
Ax. the goal is among the assumptions

The rules L∧→, L∨→, L→→ are Dyckhoff’s contribution [1]. In a naive calculus, using an implication \(A \to B\) among the assumptions means keeping it while trying to prove \(A\); the same step can then be tried again and again, and the search never ends. G4 looks at the form of \(A\) and replaces the implication by something smaller: \((C \land D) \to B\) by \(C \to (D \to B)\), \((C \lor D) \to B\) by \(C \to B\) and \(D \to B\), and so on. Every step makes the sequent smaller, and the search terminates. (Dyckhoff called his calculus LJT; “G4” is its name in the numbering of Troelstra and Schwichtenberg’s Basic Proof Theory.) This is what G4m inherits from G4+.

The modal rules are the rules of labelled sequent calculi (Negri [7], Simpson [5]); they are the four rules of section 3, read on sequents:

rule it says
R□ to prove \(x : \Box A\), take a new world \(s\), add \(x \mathrel{R} s\), prove \(s : A\)
L□ from \(x : \Box A\) and \(x \mathrel{R} v\), add \(v : A\) to the assumptions
R◇ to prove \(x : \Diamond A\), choose \(v\) with \(x \mathrel{R} v\) and prove \(v : A\)
L◇ from \(x : \Diamond A\), take a new world \(s\), add \(x \mathrel{R} s\) and \(s : A\)
L□→, L◇→ use \(x : \Box C \to B\) or \(x : \Diamond C \to B\): prove the antecedent, then use \(x : B\)
ser add a new world \(s\) with \(x \mathrel{R} s\) (system D)

L□→ and L◇→ complete Dyckhoff’s list for modal antecedents; they follow Iemhoff’s construction of G4-style calculi for intuitionistic modal logics [10] [11].

The frame conditions (reflexivity, symmetry, transitivity, euclideanity) are not rules of G4m: they act on \(G\) as a closure. When L□ or R◇ needs \(x \mathrel{R} v\), it may use a relation that follows from \(G\) by the conditions of the system, as in Simpson’s calculus. When it does so, the conditions are written after the rule: L□ (trans) means “the relation used here is not in the sequent, it follows from it by transitivity”. In SWI-Tinker (Ctrl-M) the same information is a subscript, \(L\Box_{\mathrm{trans}}\).

5.3. Examples

5.3.1. Axiom K: \(\Box(p \to q) \to (\Box p \to \Box q)\)

Run it in SWI-Tinker

--- Minimal logic ---

% SZS status Theorem

G4m proof in minimal logic (7 steps, checked)

--- Sequent Calculus Proof ---

   ⊢ w : □(p → q) → □p → □q   (R→)
    w : □(p → q) ⊢ w : □p → □q   (R→)
      w : □p, w : □(p → q) ⊢ w : □q   (R□)
        w R s ; w : □p, w : □(p → q) ⊢ s : q   (L□)
          w R s ; s : p, w : □p, w : □(p → q) ⊢ s : q   (L□)
            w R s ; s : p, s : p → q, w : □p, w : □(p → q) ⊢ s : q   (L0→)
              w R s ; s : p, s : q, w : □p, w : □(p → q) ⊢ s : q   (Ax.)

The first line of the report says that the formula is valid in minimal logic (section 5.4); “SZS status Theorem” is the standard verdict of automated provers. Then the proof, from the top: the two R→ move the antecedents to the left. To prove \(w : \Box q\), R□ introduces a new world \(s\) seen by \(w\), and the goal becomes \(s : q\). The two L□ bring \(p\) and \(p \to q\) from \(w\) down to \(s\), L0→ applies modus ponens at \(s\), and the axiom closes the proof. Everything happens at \(s\), an arbitrary world seen by \(w\): this is the semantic argument of section 2.2, written as a proof.

5.3.2. Axiom 4 in S4: a relation from the closure

Run it in SWI-Tinker

⊢ w : □p → □□p   (R→)
 w : □p ⊢ w : □□p   (R□)
   w R s ; w : □p ⊢ s : □p   (R□)
     s R t, w R s ; w : □p ⊢ t : p   (L□ (trans))
       s R t, w R s ; t : p, w : □p ⊢ t : p   (Ax.)

Two R□ create \(s\) and then \(t\): \(w\) sees \(s\), \(s\) sees \(t\), and the goal is \(t : p\). To use \(w : \Box p\) at \(t\), L□ needs \(w \mathrel{R} t\), which is not in the sequent; but it follows from \(w \mathrel{R} s\) and \(s \mathrel{R} t\) by transitivity, a condition of S4. Hence L□ (trans). In K, where there is no transitivity, the same proof stops here, and the countermodel tree finds the countermodel.

5.3.3. Axiom D: the rule ser

Run it in SWI-Tinker

⊢ w : □p → ◇p   (R→)
 w : □p ⊢ w : ◇p   (ser)
   w R s ; w : □p ⊢ w : ◇p   (R◇)
     w R s ; w : □p ⊢ s : p   (L□)
       w R s ; s : p, w : □p ⊢ s : p   (Ax.)

To prove \(w : \Diamond p\), R◇ needs a world seen by \(w\), and there is none. In D every world sees some world: ser adds a new world \(s\) with \(w \mathrel{R} s\). Then R◇ chooses \(s\), and L□ brings \(p\) from \(w\) to \(s\). Here the relation used by L□ is in the sequent (ser put it there), so no condition is written after the rule.

5.3.4. Possibility: \(\Box(p \to q) \to (\Diamond p \to \Diamond q)\)

Run it in SWI-Tinker

⊢ w : □(p → q) → ◇p → ◇q   (R→)
 w : □(p → q) ⊢ w : ◇p → ◇q   (R→)
   w : □(p → q), w : ◇p ⊢ w : ◇q   (L◇)
     w R s ; s : p, w : □(p → q) ⊢ w : ◇q   (R◇)
       w R s ; s : p, w : □(p → q) ⊢ s : q   (L□)
         w R s ; s : p, s : p → q, w : □(p → q) ⊢ s : q   (L0→)
           w R s ; s : p, s : q, w : □(p → q) ⊢ s : q   (Ax.)

L◇ uses the assumption \(w : \Diamond p\): there is a world, call it \(s\), seen by \(w\), where \(p\) is true. R◇ then chooses this same \(s\) as the world where \(q\) must be shown. Note the order: the new world comes from the assumption (L◇) before it is used for the goal (R◇), as with \(\exists\) on the left and on the right.

5.4. The three levels: minimal, intuitionistic, classical

G4m first looks for a proof in minimal logic, then in intuitionistic logic, then in classical logic, and reports the first level at which it succeeds, as G4+ does for first-order formulas.

  • Minimal logic has the rules of the connectives and nothing more; \(\bot\) is an atom like the others, and \(\neg A\) abbreviates \(A \to \bot\).
  • Intuitionistic logic adds ex falso: from \(\bot\), anything follows (rule L⊥).
  • Classical logic adds the excluded middle, or equivalently double negation elimination: from \(\neg\neg A\), conclude \(A\). At this level G4m, like G4+, stays in G4 and adds one rule, IP (indirect proof): to prove \(x : A\), assume \(x : \neg A\) and prove \(x : \bot\).

The intuitionistic level of G4m is intuitionistic modal logic in the sense of Simpson [5]: \(\Box\) and \(\Diamond\) are not defined from each other, and the rules of section 5.2 are those of his labelled sequent calculus. Most of the characteristic principles of section 2.2 are already minimal: K, T, D, B, 4 and 5 need no ex falso and no excluded middle. The differences appear with negation. Three examples:

\(\Box p \to \neg\Diamond\neg p\): run it

--- Intuitionistic logic ---
   ⊢ w : □p → ¬◇¬p   (R→)
    w : □p ⊢ w : ¬◇¬p   (R→)
      w : □p, w : ◇¬p ⊢ w : ⊥   (L◇)
        w R s ; s : ¬p, w : □p ⊢ w : ⊥   (L□)
          w R s ; s : p, s : ¬p, w : □p ⊢ w : ⊥   (L0→)
            w R s ; s : ⊥, s : p, w : □p ⊢ w : ⊥   (L⊥)

The contradiction appears at \(s\) (\(s : \bot\)), but the goal is \(w : \bot\): falsity at the world \(w\). Minimal logic cannot pass from one to the other; ex falso can (L⊥). Hence the intuitionistic level. The same holds, in its simplest form, for \(\Diamond\bot \to \bot\) (run it): a world where \(\bot\) holds makes \(\bot\) hold here, by ex falso only.

\(\neg\Diamond\neg p \to \Box p\): run it

--- Classical logic ---
   ⊢ w : ¬◇¬p → □p   (R→)
    w : ¬◇¬p ⊢ w : □p   (R□)
      w R s ; w : ¬◇¬p ⊢ s : p   (IP)
        w R s ; s : ¬p, w : ¬◇¬p ⊢ s : ⊥   (L◇→)
          w R s ; s : ¬p, w : ¬◇¬p ⊢ s : ¬p   (Ax.)
          w R s ; s : ¬p, w : ⊥ ⊢ s : ⊥   (L⊥)

This is the converse, and it is classical: from “there is no accessible world where \(p\) fails” one concludes “\(p\) holds at every accessible world” only by an indirect proof, at each world. Read the proof: to show \(\Box p\), R□ takes a world \(s\) seen by \(w\); there IP supposes \(s : \neg p\) and looks for a contradiction. The assumption \(w : \neg\Diamond\neg p\) is \(\Diamond\neg p \to \bot\) at \(w\): an implication whose antecedent is a \(\Diamond\)-formula, used by L◇→. Its left branch proves the antecedent \(\Diamond\neg p\) by choosing \(s\), where \(\neg p\) has just been supposed (Ax.); its right branch gets \(w : \bot\), and ex falso closes it (L⊥). Without IP the proof is impossible, so the duality of section 2.1 is intuitionistic in one direction and classical in the other; that is why G4m treats \(\Box\) and \(\Diamond\) as two primitive operators.

Two more examples to try: \(\Diamond(p \lor q) \to \Diamond p \lor \Diamond q\) is minimal (run it); \(\Box(p \lor q) \land \Box\neg p \to \Box q\), the modal disjunctive syllogism, is intuitionistic, because eliminating \(p\) uses ex falso (run it).

5.5. G4 at work: \(\Box\neg\neg\)Peirce

Peirce’s law \(((p \to q) \to p) \to p\) is classical, but its double negation is intuitionistic, and so is its necessitation in K:

Run it in SWI-Tinker

--- Intuitionistic logic ---
   ⊢ w : □¬¬(((p → q) → p) → p)   (R□)
    w R s ; ⊢ s : ¬¬(((p → q) → p) → p)   (R→)
      w R s ; s : ¬(((p → q) → p) → p) ⊢ s : ⊥   (L→→)
        w R s ; s : ¬p, s : (p → q) → p ⊢ s : p   (L→→)
          w R s ; s : p, s : ¬p, s : q → p ⊢ s : q   (L0→)
            w R s ; s : ⊥, s : p, s : q → p ⊢ s : q   (L⊥)
          w R s ; s : p, s : ¬p ⊢ s : p   (Ax.)
        w R s ; s : ⊥ ⊢ s : ⊥   (Ax.)

The modal part is a single step: R□ takes a new world \(s\), and \(w \mathrel{R} s\) is then carried along unchanged. Everything above it happens at \(s\), and is, label for label, the proof that G4+ finds for \(\neg\neg(((p \to q) \to p) \to p)\) (run it). This is why the example is instructive: the modal layer is thin, and what shows through is the propositional engine, G4, and what distinguishes it from a G3 calculus.

In the intuitionistic sequent calculus G3 of Troelstra and Schwichtenberg, the rule for an implication among the assumptions keeps it in the left premiss: to use \(A \to B\), prove \(A\) with \(A \to B\) still available, then go on with \(B\). The assumption \(\neg(((p \to q) \to p) \to p)\) must here be used twice: once to reduce the goal \(\bot\) to Peirce’s law, and once more, higher up, under the assumption \(p\), to get \(\bot\) again and hence \(q\) by ex falso. Since the formula stays in the sequent, a search procedure may also use it a third time, a fourth time, and so on: this is where G3 loops.

G4 never uses the same implication twice. Read the first L→→: the assumption \(\neg(((p \to q) \to p) \to p)\), that is \(((C \to D) \to B)\) with \(C = (p \to q) \to p\), \(D = p\), \(B = \bot\), is consumed, and its left premiss receives \(C\) and a smaller formula, \(D \to B = p \to \bot = \neg p\). This residue \(\neg p\) does the work of the second use: three lines higher, L0→ applies it to \(s : p\) and gets \(s : \bot\), and L⊥ gives \(s : q\). The big formula has been replaced by a smaller piece of itself, the sequents get smaller at every step, and the search ends without any loop check. This is Dyckhoff’s idea [1] at work.

The two natural deductions (nkm’s tree, and G4+’s on the propositional formula) show the same fact from the other side: the assumption \([\neg(((p \to q) \to p) \to p)]^1\) is discharged twice. In natural deduction the double use cannot be avoided; G4 compiles it into the rule L→→, and the rule \(\to\to\)E of G4+’s natural deductions is its trace.

One caveat: Negri’s G3K [7] is a classical calculus, with several formulas on the right of \(\vdash\); it proves Peirce’s law directly, and has no need of the double negation. The contrast drawn here is with the intuitionistic G3, at the level where this proof lives.

6. Third output: natural deduction (nkm)

6.1. The rules

nkm derives labelled formulas in natural deduction, in the style of Simpson [5] and Viganò [6], on the core of nkt [2]. Its logic is classical: its rule \(\bot\)E concludes \(x : A\) from a derivation of \(\bot\) under the assumption \(x : \neg A\) (reductio ad absurdum). Besides the rules for the connectives (\(\to\)I, \(\to\)E, \(\land\)I, \(\land\)E, \(\lor\)I, \(\lor\)E, \(\bot\)E), it has the four modal rules of section 3 and one rule per frame condition:

rule from infer proviso
□I a derivation of \(s : A\) from \([w \mathrel{R} s]\) \(w : \Box A\) \(s\) new
□E \(w : \Box A\) and \(w \mathrel{R} v\) \(v : A\)  
◇I \(v : A\) and \(w \mathrel{R} v\) \(w : \Diamond A\)  
◇E \(w : \Diamond A\) and a derivation of \(C\) from \([s : A]\), \([w \mathrel{R} s]\) \(C\) \(s\) new
refl a derivation of \(C\) from \([w \mathrel{R} w]\) \(C\)  
sym \(w \mathrel{R} v\) and a derivation of \(C\) from \([v \mathrel{R} w]\) \(C\)  
trans \(w \mathrel{R} v\), \(v \mathrel{R} u\) and a derivation of \(C\) from \([w \mathrel{R} u]\) \(C\)  
eucl \(w \mathrel{R} v\), \(w \mathrel{R} u\) and a derivation of \(C\) from \([v \mathrel{R} u]\) \(C\)  
ser a derivation of \(C\) from \([w \mathrel{R} s]\) \(C\) \(s\) new

Square brackets mark assumptions that the rule discharges: the rule □I, for instance, uses a derivation that may depend on \(w \mathrel{R} s\), and the conclusion \(w : \Box A\) no longer depends on it. The relational rules all have the same shape: “if the frame condition gives you this relation, you may use it as an assumption”. Every derivation found is checked by an independent checker before it is printed.

6.2. The tree

Axiom D: run it

[w : □p]¹    [w R s]²
────────────────────── □E
        s : p                [w R s]²
─────────────────────────────────────── ◇I
                w : ◇p
──────────────────────────────────────────── ser, 2
                   w : ◇p
───────────────────────────────────────────────────── →I, 1
                     w : □p → ◇p

A tree is read from the top (the assumptions) to the bottom (the conclusion). Each horizontal line is one application of the rule written on its right. The small numbers link an assumption to the rule that discharges it: \([w : \Box p]^1\) is discharged by “→I, 1”, \([w \mathrel{R} s]^2\) by “ser, 2”. Here: assume \(\Box p\) at \(w\) and a world \(s\) seen by \(w\); by □E, \(p\) holds at \(s\); by ◇I, \(\Diamond p\) holds at \(w\). The rule ser says that such an \(s\) exists in every serial frame, so the assumption \(w \mathrel{R} s\) can be dropped; →I discharges \(w : \Box p\). It is the same argument as the G4m proof of section 5.3, read in the other direction.

6.3. Fitch style: Fitch’s strict subproofs

The Fitch presentation writes the same derivation as a list of numbered lines; an assumption opens a subproof, drawn as a vertical bar with a horizontal stroke under the assumption, and the bar ends when the assumption is discharged. The justification on the right gives the rule and the lines it uses (\(i\)–\(j\) for a subproof).

nkm follows Fitch’s own treatment of necessity, in his Symbolic Logic [12], sections 11 and 12, with the worlds kept as labels. Fitch proves \(\Box A\) with a strict subproof: a subproof marked \(\Box\) in the margin, into which only necessary formulas may be brought (“reiterated”). In nkm a strict subproof is a subproof about a world: its flag, the boxed label \([s]\), is the world it reasons about, and the relation from the outer world to \(s\) is implicit. The rules of Fitch then read as follows:

rule Fitch’s name it says frame
R□ reiteration \(\Box A\) outside, \(A\) inside the strict subproof for \(s\) any
R4 reiteration \(\Box A\) outside, \(\Box A\) inside (Fitch’s own reiteration) transitive
□E nec elim \(\Box A\) gives \(A\) at the same world reflexive
◇I pos int \(v : A\) gives \(\Diamond A\) at a world that sees \(v\); at \(v\) itself, Fitch’s pos int any; reflexive for pos int
□I nec int a strict subproof for \(s\) ending with \(s : A\) gives \(\Box A\) any
◇E pos elim \(\Diamond A\), and a strict subproof from \(s : A\) to \(C\), give \(C\) any

In Fitch’s book the reiteration of \(\Box A\) as \(\Box A\) is the only one allowed, and his system is essentially S4 (his section 11.9). In section 11.10 he considers a reiteration that drops the box, \(\Box A\) outside and \(A\) inside, which gives a system close to Lewis’s S2; in nkm this reiteration, R□, is the rule of K, and R4 is added only when the relation is transitive. In SWI-Tinker (Ctrl-M) the \(\Box\) of a strict subproof is drawn in the margin, to the left of its vertical bar, as in Fitch’s book, and R□ and R4 are written \(R_\Box\) and \(R_4\).

6.3.1. Axiom 4 in S4: Fitch’s proof 11.8

Run it in SWI-Tinker

1  │ │ w : □p                              AS
   │ ├────────
2  │ │□│ [s]                               AS
   │ │ ├────────
3  │ │ │ s : □p                            R4 1
4  │ │ w : □□p                             □I 2-3
5  │ w : □p → □□p                          →I 1-4

Line 1 assumes \(\Box p\) at \(w\). Line 2 opens a strict subproof about a world \(s\) seen by \(w\) (the □ in the margin, the flag \([s]\)). Line 3 brings \(\Box p\) into it as \(\Box p\): this is Fitch’s reiteration, and it is legitimate because the relation is transitive (whatever \(s\) sees, \(w\) sees too). Line 4 closes the subproof: since \(\Box p\) holds at an arbitrary world seen by \(w\), \(\Box\Box p\) holds at \(w\). This is Fitch’s proof 11.8, with labels. The tree of the same derivation, in the same output, uses the rule trans explicitly; the Fitch proof shows what it does.

6.3.2. \(\Box p \to p\) in T: nec elim

1  │ │ w : □p                              AS
   │ ├────────
2  │ │ w : p                               □E 1
3  │ w : □p → p                            →I 1-2

In a reflexive frame, \(\Box A\) at \(w\) gives \(A\) at \(w\) itself: this is Fitch’s “nec elim”, and no subproof is needed.

6.3.3. Possibility: pos elim

Run it in SWI-Tinker

1  │ │ w : □(p → q)                        AS
   │ ├──────────────
2  │ │ │ w : ◇p                            AS
   │ │ ├────────
3  │ │ │□│ [s] s : p                       AS
   │ │ │ ├────────
4  │ │ │ │ s : p → q                       R□ 1
5  │ │ │ │ s : q                           →E 4,3
6  │ │ │ w : ◇q                            ◇E 2,3-5
7  │ │ w : ◇p → ◇q                         →I 2-6
8  │ w : □(p → q) → ◇p → ◇q                →I 1-7

Line 3 opens a strict subproof about a world \(s\) where \(p\) is true (the world promised by \(w : \Diamond p\)). Line 4 brings \(p \to q\) into it from line 1, dropping the box (R□). Line 5 is modus ponens at \(s\). Line 6 is Fitch’s pos elim: from \(\Diamond p\) (line 2) and a strict subproof that goes from \(p\) to \(q\) (lines 3–5), conclude \(\Diamond q\).

6.3.4. Symmetry and euclideanity: beyond Fitch

Axiom B: run it

1  │ │ w : p                               AS
   │ ├────────
2  │ │□│ [s]                               AS
   │ │ ├────────
3  │ │ │ │ s R w                           AS
   │ │ │ ├────────
4  │ │ │ │ s : ◇p                          ◇I 1,3
5  │ │ │ s : ◇p                            sym 2,3-4
6  │ │ w : □◇p                             □I 2-5
7  │ w : p → □◇p                           →I 1-6

Fitch’s system stops at S4. For symmetry (B) and euclideanity (K5, S5) there is no strict-subproof rule: these conditions look backwards, from \(s\) to the world that sees it, while a strict subproof only looks inwards. nkm then keeps the relation as an explicit line: line 3 assumes \(s \mathrel{R} w\), which the rule sym (line 5) justifies from \(w \mathrel{R} s\) (the implicit relation of the strict subproof, line 2). Line 4 is ◇I across worlds: \(p\) is true at \(w\), and \(w\) is seen by \(s\), so \(\Diamond p\) is true at \(s\). Here the labels do what Fitch’s notation cannot do alone.

The option fitch(labelled), or the box “labelled Fitch proof” in the query builder, gives the Fitch proof without strict subproofs, with every relation written as a line.

7. The three outputs side by side

The three outputs show the same frame conditions at work, each in its own way. For axiom 4 in S4:

output where transitivity appears
countermodel tree a line “w R t trans 6, 10” that closes the branch
G4m the rule L□ (trans): a relation of the closure
nkm, tree the rule trans, which discharges \([w \mathrel{R} t]\)
nkm, Fitch the reiteration R4 of \(\Box p\) into the strict subproof

And they answer different questions:

output it tells it does not tell
countermodel tree whether the formula is valid, and if not, why how to prove it
G4m a proof, and the weakest logic for it why a formula is not valid
nkm a proof in natural deduction (tree and Fitch) the logic level (nkm is classical)

This is why they are run in this order: the tree decides, G4m measures, nkm explains in the form closest to ordinary reasoning.

8. Using the provers

The provers run in SWI-Tinker, SWI-Prolog in the browser, at g4-mic.vidal-rosset.net/wasm/tinker. The simplest way is the query builder: type a formula with the buttons (\(\Box\), \(\Diamond\), \(\neg\), \(\land\), \(\lor\), \(\to\), \(\bot\), \(\vdash\)), choose a system, and press “Run in SWI-Tinker”. In SWI-Tinker, Ctrl-M shows the proofs rendered (G4m as “G4 Sequent Calculus”, then the two natural deductions); the countermodel tree is given as text.

The queries can also be typed directly:

?- nkm("□p → □□p", s4).                  % tree, G4m, natural deduction
?- nkm("□p ⊢ ◇p", d).                    % a sequent: premisses ⊢ conclusion
?- nkm("w : □p, w R v ⊢ v : p", k).      % labels and relations
?- nkm("p → □◇p", [k4, sym]).            % a system with one more condition
?- nkm("□p → □□p", [s4, output(text)]).  % text instead of LaTeX
?- nkm("□p → □□p", [s4, sequent(false)]).% without the G4m proof
?- g4m("□p → □□p", s4).                  % G4m alone
?- nkm_help.

ASCII works as well: [] for \(\Box\), <> for \(\Diamond\), ~, &, |, =>, <=> for \(\leftrightarrow\), # for \(\bot\) and |- for \(\vdash\). The letter v is a name (of an atom or a world), not a disjunction. As in G4+, there is no rule for \(\leftrightarrow\): inside a formula, \(A \leftrightarrow B\) is read as \((A \to B) \land (B \to A)\), and a principal biconditional is proved in its two directions, each with its own report. With \(\Box p \leftrightarrow \neg\Diamond\neg p\), G4m thus finds the two levels of section 5.4 in one query (run it).

Examples to run:

9. Limits

  • Propositional only. G4+ handles quantifiers; G4m and nkm do not.
  • Bounded search. The searches are bounded, so a formula may in principle be valid without a proof being found within the bounds. For a non-theorem G4m answers “SZS status Unknown” (no proof found), never “not valid”: a refutation comes from the countermodel tree, which is run first.
  • Termination and transitivity. In classical logic, Negri bounds the search of her labelled calculi for K, T, B, S4 and S5 [7]; for intuitionistic modal logic, Simpson proves decidability for the systems without transitivity (IK, IKD, IT, IKB …) and leaves IK4 and IS4 open [5]. With transitivity, chains of worlds can grow; intuitionistic S4 was shown decidable only recently, by a delicate loop check [13]. The provers do not implement these bounds: they rely on their own search bounds.
  • An open question. G4m combines Dyckhoff’s left rules with labelled modal rules. That this combination proves exactly what Simpson’s calculus proves is expected, by an extension of Iemhoff’s method [10], but has not been proved. Every proof found is checked, so what G4m prints is correct; what is not proved is that it finds everything.

10. Conclusion

A modal formula is a claim about a whole space of possible worlds. The three outputs make that space visible: the countermodel tree builds the worlds where the formula could fail, G4m and nkm reason about the worlds where it must hold, and the labels name these worlds in the same way in all three. Reading them together is perhaps the shortest way into modal logic: the countermodel says what the formula claims, the G4m proof says how little logic it needs, and the Fitch proof, with its strict subproofs, says it in the form Fitch gave it in 1952.

G4m is written on the model of G4+, nkm on the core of nkt. The source will be made public on GitHub.

11. References

1.
Dyckhoff, R. Contraction-Free Sequent Calculi for Intuitionistic Logic. Journal of Symbolic Logic, 1992, 57(3), 795–807, [Online]. Available: http://www.jstor.org/stable/2275431?origin=JSTOR-pdf.
2.
Volpe, M. Labeled Natural Deduction for Temporal Logics. Department of Computer Science, University of Verona, Verona, Italy, 2010.
3.
Kripke, S. A. Semantical Analysis of Modal Logic I. Normal Modal Propositional Calculi. Zeitschrift für mathematische Logik und Grundlagen der Mathematik, 1963, 9(5-6), 67–96.
4.
Hughes, G. E., Cresswell, M. J. A New Introduction to Modal Logic. Routledge, 1996.
5.
Simpson, A. K. The Proof Theory and Semantics of Intuitionistic Modal Logic. University of Edinburgh, 1994.
6.
Viganò, L. Labelled Non-Classical Logics. Dordrecht: Kluwer Academic Publishers, 2000.
7.
Negri, S. Proof Analysis in Modal Logic. Journal of Philosophical Logic, 2005, 34, 507–544.
8.
Jeffrey, R. C. Formal Logic: Its Scope and Limits. New York: McGraw-Hill, 1967.
9.
Copeland, B. J. Tense trees: a tree system for $ K_ t$. Notre Dame Journal of Formal Logic, 1983, 24(3), 318–322, doi: 10.1305/ndjfl/1093870374.
10.
Iemhoff, R. The G4i Analogue of a G3i Sequent Calculus. Studia Logica, 2022, 110(6), 1493–1506, doi: 10.1007/s11225-022-10008-3.
11.
Iemhoff, R. Terminating Sequent Calculi for Two Intuitionistic Modal Logics. Journal of Logic and Computation, 2018, 28(7), 1701–1712.
12.
Fitch, F. B. Symbolic Logic: An Introduction. New York: The Ronald Press Company, 1952.
13.
Girlando, M., Kuznets, R., Marin, S., Morales, M., Straßburger, L. Intuitionistic S4 is Decidable. Proceedings of the 38th Annual ACM/IEEE Symposium on Logic in Computer Science (LICS 2023), 2023.

Published: 2026-10-18