Ladder Logic
Ladder Logic
Abstract
Dependency relations between objects in a railway yard are tabulated in
control tables. An interlocking, which guarantees validity of these dependencies,
can be implemented in ladder logic. We transform a ladder logic diagram into a
Boolean formula, so that validity of the dependencies in the control tables can
be verified using a theorem prover. Time copies and invariants are added to the
formula, to relate it more firmly to its ladder logic diagram. Program slicing is
applied to reduce the size of the formula.
1 Introduction
Railway signalling has evolved over the last 150 years to provide an extremely high
level of safety, both for the railway staff and their customers. In the last twenty years,
traditional approaches to safety have been modified by the introduction of micropro-
cessors into a number of areas of signalling. New standards call for ever-improved
methods for developing safety systems and software. In addition, safety cases have to
be presented for all new equipment and installations. These trends, together with the
increasing commercial pressures, result in a demand on those in the signalling supply
industries to produce ever more innovative systems, software, and methodologies.
A railway yard is built from objects such as points, signals, track circuits, and
level crossings. The control and management of such a railway yard consists of three
separate layers. First, there is the infrastructure, where the objects can be in different
states; points can be in normal or reverse position, a signal can show several aspects,
track circuits can be occupied or not, level crossings can be open or closed. Second,
in the logistic layer, human experts devise control instructions for the railway yard,
in order to guide the movements of trains. Third, it has to be guaranteed that the
W.J. Fokkink, P.R. Hollingshead
execution of these control instructions does not jeopardise safety; that is, collisions
and derailments have to be avoided. This is done by means of an interlocking, which
is a medium between the infrastructure at the one side, and the logistic layer and its
interfaces at the other side. The interplay of the three layers of a railway yard, logistic
layer, interlocking, and infrastructure, is depicted below.
LOGISTIC LAYER
INTERLOCKING
INFRASTRUCTURE
generality. However, recently developed theorem provers have shown that in many cases
the question of (un)satisfiability of large Boolean formulae need not be problematic.
The program described in [5] transforms a ladder logic diagram into a Boolean formula
that can serve as input to the theorem prover HeerHugo [3].
Certain requirements involve time, for example, “if a track circuit was occupied less
than ten seconds ago, then ...”. For such requirements, we want to describe the depen-
dencies between the objects in the railway yard that are imposed by an interlocking
for a period of time. If a requirement ρ involves n control cycles, then we make time
copies Φ0 , Φ1 , ..., Φn of the Boolean formula Φ, where Φi describes the dependencies
in the railway yard i control cycle ago. The conjunction Φ0 ∧ · · · ∧ Φn describes the
dependencies between the objects in the railway yard in the last n control cycles. We
desire that the formula Φ0 ∧ · · · ∧ Φn ∧ ¬ρ is invalid for all possible values of variables
in this expression.
Ladder logic diagrams are closely related to the methodology of Vital Processor In-
terlocking (VPI). Groote, Koorn, and van Vlijmen [4] presented a specification of VPI,
together with a manual verification of desirable properties of VPI. Furthermore, they
introduced the verification method described above for VPIs. Fokkink [2] formulated
classes of safety criteria for VPIs, and verified instantiations of these classes for the
railway yard at Hoorn-Kersenboogerd, by means of the Stålmarck [9, 10] and HeerHugo
[3] theorem provers. We note that such classes of safety criteria can be obtained from
the control tables of a railway yard. Mertens [6] repeated the verification exercise for
the larger railway yard at Heerhugowaard, and needed invariants to express that points
are never both in normal and in reverse position. Stålmarck and Säflund [11] applied
the Stålmarck theorem prover to verify properties of an interlocking system used by
the Swedish state railways.
Verification of Interlockings
2 Control Tables
A railway yard consists of a collection of linked railway tracks, supplied with objects
such as signals, points, and level crossings. Each of the objects in a railway yard can
attain a certain number of states:
Figure 1 depicts a schematic view of part of the road map of a railway yard. Note
that each separate object in the railway yard is provided with a unique identifier.
SM TM TN
496 766
UH UJ UK 765 UL
498
764 768
VG VH VJ
500 508
• Flank protection: Where possible, the flanks of a route that has been locked
should be protected. That is, around the route, signals should show red, and
points should be in such positions that they do not give immediate access to the
route, even if it is expected that no train will pass such a signal or such points
in the near future.
POINTS REVERSE
POINTS NORMAL
SIGNAL AHEAD
ROUTE No.
TRACKS
ASPECT
EXIT
Y 500 AT R
508 500 VJ VH VG 764 768
A G 500 AT Y
Y 498 AT R
508 498 VJ VH UJ UH 768 764
B-1 G 498 AT Y (UK if 765N or 766R)
Y 498 AT R
508 498 VJ UL UK UJ UH 764 765 766 768
B-2 G 498 AT Y
Y 496 AT R
508 496 VJ UL UK TN TM SM 766 765 768
C G 496 AT Y
Figure 2 presents a somewhat simplified example of a control table for the railway
yard in Figure 1, which deals with several aspects route locking. It distinguishes the
four possible routes that await behind signal 508.
1. Route 508A consists of the track circuits VJ, VH, and VG, and requires that the
points 764 and 768 are in normal position. The exit signal of this route is 500,
and if signal 508 shows green, then signal 500 should show yellow or green.
2. Route 508B-1 consists of the track circuits VJ, VH, UJ, and UH, and requires
that the points 764 and 768 are in reverse and in normal position, respectively.
Verification of Interlockings
Furthermore, if points 765 are in normal position, or if points 766 are in reverse
position, then track circuit UK is also included in the route, The exit signal of
this route is 498, and if signal 508 shows green, then signal 498 should show
yellow or green.
3. Route 508B-2 consists of the track circuits VJ, UL, UK, UJ, and UH, and requires
that the points 764, 765, and 766 are in normal position, and that the points 768
are in reverse position. The exit signal of this route is 498, and if signal 508
shows green, then signal 498 should show yellow or green.
4. Route 508C consists of the track circuits VJ, UL, UK, TN, TM, and SM, and
requires that the points 765 and 768 are in reverse position, and that points 766
are in normal position. The exit signal of this route is 496, and if signal 508
shows green, then signal 496 should show yellow or green.
For exhaustive examples, and more background information on control tables, the
reader is referred to [7, Chapter 3].
where the Φi are of the form `1 ∧ · · · ∧ `m with each `j either a variable x or a negation
of a variable ¬x.
• Input variable: Its value is determined by the environment (i.e., the logistic
layer and the infrastructure).
• Output variable: Its value is computed by means of the ladder logic diagram,
and passed on to the environment.
• Latch: Its value is computed by means of the ladder logic diagram, and not
passed on to the environment, but only used in the computation of values of
other variables.
• Timer: This variable is either on or off, which is determined by the value of its
trigger. If it is off, then its value is 0. If it is on, then its value is increased by
one with every control cycle, until it reaches a preset duration, after which its
trigger is switched off (i.e., is assigned the value 0).
• Trigger: Indicates whether a certain timer operation is on or off.
Input variables, output variables, latches and triggers have Boolean values (i.e., 0 or
1), while the values of timers are natural numbers. Each output variable, latch or
trigger x is the coil of exactly one assignment R : x in the ladder logic diagram. Input
variables and timers are not allowed as coils. Only input variables, latches and triggers
are allowed to occur in the left-hand sides of rungs (so output variables and timers are
excluded from these left-hand sides).
A ladder logic diagram implements an interlocking, and is executed in discrete
control cycles as follows. In the initial control cycle, the values of all variables are set
to 0. Now suppose that we have computed the values of the variables in the n-th control
cycle. Then the values of the variables in the (n + 1)-th control cycle are computed as
follows;
1. The inputs from the logistic layer and the infrastructure are read, to determine
the values of the input variables.
2. The values of timers that are off are set to 0, and the values of timers that are
on are increased by one. If a timer reaches its duration, its trigger is set to 0.
3. The assignments in the ladder logic diagram are applied, from top to bottom, to
compute the values of the output, latch, and trigger variables.
When the computation of the values of all variables in control cycle n+1 is finished, the
values of output variables are transmitted to the logistic layer and the infrastructure.
After completion of control cycle n + 1, the same procedure is repeated to determine
the values of the variables in control cycle n + 2, et cetera.
It is important to note that occurrences of a coil xi in the first i equations of the
ladder logic diagram refer to the value of xi in the n-th control cycle, while occurrences
of xi in the remaining equations of the ladder logic diagram refer to the value of xi in
the (n + 1)-th control cycle.
W.J. Fokkink, P.R. Hollingshead
Dependency relations in control tables can also be transformed into Boolean for-
mulae ρ, by means of a (manual) conversion. For each such formula ρ we want to know
that it is guaranteed by the interlocking at all times. For this purpose we need to verify
that the formula
^
n
( (Φi ↔ xi (0))) ∧ ¬ρ
i=1
is not satisfiable; that is, for all possible valuations of the variables in this formula, the
value of this formula should be 0.
the interlocking are represented more accurately by combination of the ladder logic
diagrams L0 and L1 , which are transformed into a formula Φ0 ∧ Φ1 .
The combination of L0 and L1 contains new loose ends; the coils xi (2). In order
to limit the range of values of these coils, we can construct a time copy L2 , which is
obtained by replacing occurrences of variables y(0) and y(1) in L0 by y(2) and y(3),
respectively. The dependencies in the interlocking are represented more accurately by
the combination of the ladder logic diagrams L0 , L1 , and L2 , which are transformed
into a formula Φ0 ∧ Φ1 ∧ Φ2 .
The combination of L0 , L1 , and L2 contains as loose ends the coils xi (3), et cetera.
In general, a time copy Lj for j > 0 is obtained from L0 by replacing occurrences of
variables y(0) and y(1) in L0 by y(j) and y(j + 1), respectively. The dependencies in
the interlocking can be represented by the combination of ladder logic diagrams Lj for
j = 0, ..., m, which give rise to a formula
Φ0 ∧ Φ1 ∧ · · · ∧ Φm .
Requirements in control tables can incorporate time delays. The formulae that are
obtained from such restrictions contain variables y(j) with j > 0. Consider such a
formula ρ, and let m be the greatest number such that ρ contains an occurrence of a
variable y(m). In order to verify more accurately whether ρ does not hold under any
circumstances, we can construct the time copies Φ1 , ..., Φm of Φ0 , as explained above,
and verify that the formula
Φ0 ∧ Φ1 ∧ · · · ∧ Φm ∧ ¬ρ
is not satisfiable.
4.3 Invariants
For the verification of the requirements in control tables, it is not always sufficient to
restrict to a limited number of time copies. We explained that the operation of an
interlocking based on a ladder logic diagram operates in discrete control cycles. In the
initial control cycle, the values of all variables are set to 0, while the values of variables
in the (n + 1)-th control cycle are computed using the values of variables in the n-th
control cycle. Thus, the fact that initially the values of variables were set to 0 may
influence the values of variables in the future.
In order to verify that the validity of requirements in the control tables is guaranteed
by a ladder logic diagram, it is necessary to derive “invariants”. Let Φ0 be the Boolean
formula that is obtained from the ladder logic diagram, with time copies Φ1 , Φ2 , ... .
An invariant consists of a of Boolean formula I that satisfies the following properties.
1. I holds in the initial control cycle, when the values of all variables are 0.
W.J. Fokkink, P.R. Hollingshead
Φ0 ∧ I1 ∧ · · · ∧ Ik ,
4.4 Timers
The values of timer are natural numbers, so they are not allowed to occur in ladder
logic diagrams. Their meaning is specified outside the ladder logic diagram, where
each timer is given a certain duration. If the trigger of a timer has the value 1, then
the value of the timer is increased by one with every control cycle, until it reaches its
duration, when both the timer and its trigger are assigned the value 0. If the trigger
has the value 0, then its timer has the value 0 too. Thus, each timer has an implicit
influence on the value of its trigger, and vice versa. This relation between a timer and
its trigger can be expressed explicitly by the introduction of a sequence of rungs in the
ladder logic diagram. Let trigger be the trigger of a timer with duration n, and let
the rung for this trigger in the ladder logic diagram be φ : trigger . Then we introduce
fresh Boolean variables yi for i = 1, ..., n, and we replace the rung φ : trigger in the
ladder logic diagram by a string of rungs:
φ ∧ ¬y1 : trigger
y2 ∧ trigger : y1
..
.
yn ∧ trigger : yn−1
trigger : yn .
These rungs together capture the behaviour of the timer with duration n. Initially the
values of the coils trigger and yi for i = 1, ..., n are all 0. If in some control cycle the
value of the formula φ becomes 1, then trigger is assigned the value 1 (because y1 = 0).
Hence, in the same control cycle the coil yn is assigned the value 1. Furthermore, if in
some control cycle trigger and yi+1 have the value 1, then in the next control cycle the
coil yi is assigned the value 1. Then there are two possibilities.
1. The value of the formula φ remains 1 in the next n − 1 control cycles.
Then trigger has the value 1 in the next n − 1 control cycles, so after i control
cycles yn−1 is assigned the value 1, for i = 1, ..., n. Hence, after n − 1 control
Verification of Interlockings
cycles the coil y1 is assigned the value 1. Then in the n-th control cycle, trigger
is assigned the value 0. So in the same control cycle, the values of the coils yi for
i = 1, ..., n become 0.
Hence, the rungs expressed above exactly describe the interplay of the timer and its
trigger.
1. First, we determine the collection C0 of variables in ρ that are coils. For each
x ∈ C0 , we collect the variables in the rung of x that are coils, and add them to
C0 . The resulting collection of coils is denoted by C1 .
This procedure is repeated until Ck+1 = Ck . Then Ck+1 contains all coils that may
influence the values of variables in the requirement ρ. The original ladder logic diagram
can therefore be limited to rungs of which the coil is in Ck+1 . In general the result
of this slicing operation is a considerably smaller ladder logic diagram; see [2]. This
reduced ladder logic diagram is transformed into a Boolean formula Ψ, as explained in
Section 4.1. Then it remains to prove that Ψ ∧ ¬ρ is not satisfiable.
5 Conclusion
An interlocking is a buffer between the logistic layer and the infrastructure of a railway
yard, which filters out unsafe instructions. At Westinghouse Signals, interlockings are
implemented in ladder logic, on the basis of the control tables of a railway yard. The in-
tensive testing procedure for interlockings is time and money consuming, and although
the procedure is thorough and carried out by experts and semi-automated simulation,
W.J. Fokkink, P.R. Hollingshead
it does not give a 100% guarantee that an interlocking satisfies the dependencies in its
control tables.
We explained how a ladder logic diagram can be converted to a Boolean formula Φ.
Furthermore, the dependencies in control tables can be converted to Boolean formulae
ρ. A theorem prover can be applied to verify that the formulae Φ∧¬ρ are not satisfiable.
Thus, the cost of verifying interlockings can be reduced, and it can be guaranteed that
an interlocking agrees with its control tables.
For a given requirement, we can apply program slicing to reduce the size of the
ladder logic diagram, so that it only contains assignments that are related to the
requirement. It is important to determine invariants, which are satisfied in all control
cycles, owing to the fact that initially the values of all Boolean variables are taken to
be 0.
Acknowledgements. Special thanks go to Harry Ryland from Westinghouse Signals
for his support. Thanks also go to Bob Ellard and Nick Smith from Westinghouse Sig-
nals for technical discussions, and to Jan Friso Groote from the CWI for his permission
to use the theorem prover HeerHugo.
References
[1] J.A. Bergstra, W.J. Fokkink, W.M.T. Mennen, and S.F.M. van Vlijmen. Railway
Logic via EURIS. Quaestiones Infinitae XXII, Zeno Institute of Philosophy, 1997.
In Dutch.
[2] W.J. Fokkink. Safety criteria for the vital processor interlocking at Hoorn-
Kersenboogerd. In J. Allan, C.A. Brebbia, R.J. Hill, G. Sciutto, and S. Sone, eds.,
Proceedings of the 5th Conference on Computers in Railways (COMPRAIL’96),
Volume I: Railway Systems and Management, Berlin, pp. 101–110. Computational
Mechanics Publications, 1996.
[3] J.F. Groote. Hiding propositional constants in BDDs. Logic Group Preprint Se-
ries 120, Utrecht University, 1994. Available by ftp from ftp.phil.ruu.nl as
logic/PREPRINTS/preprint120.ps.Z.
[4] J.F. Groote, J.W.C. Koorn, and S.F.M. van Vlijmen. The safety guaranteeing sys-
tem at station Hoorn-Kersenboogerd. In Proceedings of the 10th IEEE Conference
on Computer Assurance (COMPASS’95), Gaithersburg, pp. 131–150. IEEE, 1995.
[6] J. Mertens. Verifying the safety guaranteeing system at railway station Heer-
hugowaard. Master’s Thesis, University of Utrecht, 1996.
Verification of Interlockings
[7] O.S. Nock, ed. Railway Signalling: A Treatise on the Recent Practise of British
Railways. A&C Black, 1980.
[9] G. Stålmarck. A note on the computational complexity of the pure classical im-
plication calculus, Information Processing Letters, 31:277–278, 1989.
[10] G. Stålmarck. Normalization theorems for full first order classical natural deduc-
tion, Journal of Symbolic Logic, 56:129–149, 1991.
[11] G. Stålmarck and M. Säflund. Modelling and verifying systems and software in
propositional logic. In Proceedings of the 9th Conference on Computer Safety,
Reliability and Security (SAFECOMP’90), pp. 31–36. Pergamon Press, 1990.