Cyber-Physical Systems (BIL-435), week 14 of 14

Dependability, Safety and Verification

Prof. Dr. Utku Kose, Süleyman Demirel University

Overview

Thirteen weeks have built the campus microgrid with its models, controllers, network, schedules, forecasts, defences and twins. The last week asks whether the campus can trust it when something goes wrong. Dependability is the ability of a system to deliver a service that can justifiably be trusted [1]. The week checks a controller against every state that it can reach and predicts how often parts fail. It then assembles the argument that the critical loads of the campus are supplied safely.

flowchart LR
  A["Faults, errors, failures"] --> B["Model checking"]
  B --> C["Reliability"]
  C --> D["Hidden faults"]
  D --> E["Fault tree"]
  E --> F["Runtime monitor"]
  F --> S["The campus microgrid, stage 14"]
  S --> FT["In the field: The five safety rules"]
  FT --> R["The course in review"]
Python code of this week

Every method on this page is also written as Python code in the Colab notebook of the week. Its code is divided into numbered sections. Each orange box on this page names the section whose code carries out what the text above the box explains. The box says what to run and what to look at in that section, and its button opens the Colab notebook at that place. The virtual laboratories, the practice parts and the self-assessment of the week are in the interactive lab. Each blue box opens one part of the interactive lab. The part ends with a link back to its box on this page, and the Colab notebook is always opened from the orange boxes here.

Python step 14: Organised and tested code

Open in Colab

Python code in the Colab notebook, right after Section 0 (setup). Open the Colab notebook and run this step cell by cell: It consists of short pieces of Python code with their explanations, a quick check and three exercises. Topics: Functions in a module · Assertions · Tests and a small safety monitor.

The step writes two functions into a module of their own and imports them. It then states assumptions with the statement assert and runs small tests, ending with a function that guards the reserve of the battery [2]. Students who have never programmed start with the start-here notebook of the course.

The campus microgrid so far

Weeks 1 to 13 modelled, measured, controlled, scheduled, connected, optimised, forecast and defended the campus. Weeks 12 and 13 built twins of the library and the battery.

This week shows that the critical loads stay supplied safely when parts fail, and argues it in a safety case.

The campus microgrid through the fourteen weeks of the course. The figure marks the stage of this week.
The campus microgrid through the fourteen weeks of the course. The figure marks the stage of this week.

Dependability: Faults, errors and failures

Avizienis and colleagues separate three terms [1]. A fault is the cause, such as a broken wire or a wrong line of code. An activated fault produces an error, a wrong internal state. A failure occurs when the error reaches the service, which then deviates from what it should deliver.

Faults have two broad origins. Development faults are made while a system is designed or programmed, and every copy of the system carries them. Physical faults arise in operation, when parts wear, break or are disturbed. The two call for different means.

MeansWhat it doesIn this week
Fault preventionAvoids faults in the design and in the partsA simple transfer logic with one clear safety rule
Fault removalFinds and removes faults before useModel checking of the transfer logic
Fault toleranceDelivers the service despite faultsTwo island controllers and a reserve in the battery
Fault forecastingEstimates how often faults lead to failuresReliability models and a fault tree

Dependability also has several attributes [1]. Reliability is the continuity of correct service, and availability is the readiness for it. Safety is the absence of catastrophic consequences for people and the environment. For the campus, the supply of the critical loads is a question of availability. A battery that energises the lines of the grid during a repair is a question of safety.

Check your understanding. An island controller contains a wrong comparison in its code that has never been triggered. What is it?

Discuss: Faults on the campus
  1. Name one development fault and one physical fault that could stop the campus from forming its island.
  2. Which of the four means would you apply first to each of them?

Verification: Checking every state

When the grid fails, the island controller must open the breaker at the point of common coupling (PCC). Only then may the inverter of the battery form the island grid. If the inverter formed the grid while the breaker was still closed, the battery would energise the lines of the grid. Line workers who repair the outage could be hurt. The safety rule of the transfer is therefore:

\[\square\, \neg\left(\text{inverter forms the grid} \wedge \text{breaker closed}\right)\]

The box says that the rule holds in every reachable state. Testing runs a few chosen scenarios and checks the rule in them. Model checking explores every state that a model of the system can reach and checks the rule in each one [3, 4]. If the rule fails, the model checker returns a counterexample, a path from the start to an unsafe state.

The model of the transfer logic has six variables. The first is the mode of the controller: GRID, OPENING, ISLAND, SYNC or FAULT. The others are its timer, the breaker, the inverter, the grid and a breaker that is stuck closed. One step lasts 100 ms. In each step, the grid may fail or return and the breaker may stick, and the controller reacts. Breadth-first search visits the states layer by layer, one step further each time [5].

A worked example. The first version of the logic switches the inverter to grid forming 200 ms after it has commanded the breaker to open, assuming that the breaker has opened by then. The model checker reaches 22 states, and 4 of them break the rule. The shortest counterexample takes three steps. The grid fails while the breaker is stuck closed, the controller waits two steps in OPENING, and the inverter forms the grid with the breaker closed.

The corrected version waits until the breaker reports that it is open. If the breaker is still closed after 300 ms, the controller switches the inverter off and enters FAULT. The model checker reaches 18 states, and none of them breaks the rule. This is a proof for the model, not for the real controller: The model must match the code, and its assumptions about the environment must hold.

Scene: All the states of the transfer. The island controller must never let the inverter form the grid while the breaker is closed. The states of the transfer logic float above a table, one layer for every 100 ms from the start, joined by their transitions. Rings mark a closed breaker. The five buttons follow the model checker from the start to the counterexample and to the corrected logic. The views Front and From the side show the layers from two sides.

Check your understanding. Why did the usual tests of the first version never show the hazard?

Open lab Part A

Interactive lab, Part A. The transfer test bench in 3D: Two island controllers between simulators of the grid, the breaker of the point of common coupling and the inverter. A screen shows the trace. Run test scenarios with both versions of the logic. The results can be copied into the Colab notebook.

Open in Colab

Python code in the Colab notebook, Section 1. Open Section 1 of the Colab notebook and run it. The function step moves the model of the transfer logic by 100 ms, and model_check visits all reachable states with breadth-first search. The code prints the number of states, the unsafe states and the counterexample of both versions. It then runs the three test scenarios of the interactive lab and draws the states of both versions.

Discuss: Proof and test
  1. The model checker proved the corrected logic safe for its model. What could still go wrong in the real controller?
  2. Which other safety rules of the campus would you check this way?

Reliability and redundancy

Physical faults are random. A part with a constant failure rate \(\lambda\) survives a time \(t\) with the reliability \(R(t)\). Its mean time to failure (MTTF) is the inverse of the rate [6]:

\[R(t) = e^{-\lambda t}, \qquad \text{MTTF} = \frac{1}{\lambda}, \qquad R_{series} = \prod_i R_i, \qquad R_{parallel} = 1 - \prod_i \left(1 - R_i\right)\]

Parts in series must all work, so their reliabilities multiply and their failure rates add up. Parts in parallel fail only together, so their unreliabilities multiply. A k-out-of-n system works when at least k of its n parts work. Two-out-of-three voting (2oo3) is common in safety systems, because two healthy parts can outvote a wrong one. For one out of two (1oo2) and for 2oo3 of equal parts:

\[R_{2oo3} = 3R^2 - 2R^3, \qquad \text{MTTF}_{1oo2} = \frac{3}{2\lambda}, \qquad \text{MTTF}_{2oo3} = \frac{5}{6\lambda}\]

A worked example. The island supply needs the battery management system, the inverter, an island controller and the breaker, with failure rates of 0.05, 0.2, 0.1 and 0.02 per year. In series the rates add up to \(\lambda_s = 0.37\) per year, so \(R(1) = e^{-0.37} = 0.691\) and the MTTF is \(1/0.37 = 2.70\) years. One controller survives a year with \(e^{-0.1} = 0.905\). Two in parallel reach \(1 - 0.095^2 = 0.991\), and two out of three reach \(3 \times 0.905^2 \)​\({}- 2 \times 0.905^3 \)​\({}= 0.975\).

Redundancy does not help forever. Two out of three beats one part only as long as \(R > 0.5\), which for one controller means the first \(\ln 2 / 0.1 = 6.93\) years. Its MTTF is even shorter than that of one part, 8.33 years against 10. Redundant parts must therefore be tested and repaired, not just installed.

A repaired part is described by its availability, the share of time in which it works. The inverter fails on average once in five years, an MTTF of 43,800 h, and is repaired within 15 days, a mean time to repair (MTTR) of 360 h:

\[A = \frac{\text{MTTF}}{\text{MTTF} + \text{MTTR}} = \frac{43800}{43800 + 360} = 0.9918, \qquad q = 1 - A = 0.0082\]

Animation. Redundancy over time. Choose the failure rate of one island controller and a time, and compare one controller, two in parallel and two out of three. The dashed red line marks the time after which two out of three is worse than one controller.

Left: The reliability of one controller, two in parallel and two out of three over 20 years, with a failure rate of 0.1 per year. Right: The unavailability of a controller with hidden faults between proof tests every 12 and every 3 months, with its mean.
Left: The reliability of one controller, two in parallel and two out of three over 20 years, with a failure rate of 0.1 per year. Right: The unavailability of a controller with hidden faults between proof tests every 12 and every 3 months, with its mean.

Check your understanding. Three parts with failure rates of 0.1, 0.2 and 0.3 per year work in series. What is the MTTF of the system?

Open in Colab

Python code in the Colab notebook, Section 2. Open Section 2 of the Colab notebook and run it. The functions reliability, series, parallel and k_out_of_n compute the formulas above, and availability the share of time in which a repaired part works. The code prints the island supply in series, the redundant controllers and the availability of the inverter. It then draws the reliability over 20 years.

Discuss: Redundancy on the campus
  1. Which part of the island supply would you double first, and which would you rather test more often?
  2. Why does two out of three lose against a single part after many years?

Hidden faults and common causes

Some faults show themselves at once: An inverter that fails stops and raises an alarm. Others stay hidden until the part is needed. A broken output of an island controller is noticed only when the grid fails, or at the next proof test. With a rate \(\lambda\) of such hidden faults and a proof test every \(\tau\) years, the controller is unavailable on average for \(\lambda\tau/2\) of the time [6, 7]:

\[q_1 = \frac{\lambda\,\tau}{2}, \qquad q_{1oo2} = \beta\,\frac{\lambda\,\tau}{2} + \frac{\left((1 - \beta)\,\lambda\,\tau\right)^2}{3}\]

Two controllers are not independent. A common cause, such as a faulty firmware update or the heat of a failed fan, can stop both at once. The beta factor model gives a share \(\beta\) of all failures to such common causes [6]. The second term covers independent faults of both controllers. Its factor 1/3 instead of 1/4 reflects that both are more likely to have failed late in the test interval.

A worked example. The controllers of the campus have hidden faults at a rate of \(\lambda = 0.1\) per year, a proof test once a year and \(\beta = 0.1\). One controller is unavailable with \(q_1 = 0.1 \times 1/2 = 0.05\). The pair reaches \(q_{1oo2} \)​\({}= 0.1 \times 0.05 \)​\({}+ (0.9 \times 0.1)^2/3 \)​\({}= 0.005 \)​\({}+ 0.0027 \)​\({}= 0.0077\). The common cause dominates, so the second controller helps less than the square \(0.05^2 = 0.0025\) suggests.

Check your understanding. The proof tests come every 3 months instead of every 12. How does the unavailability of one controller change?

Discuss: Common causes
  1. Which common causes could stop both island controllers of the campus at once?
  2. How would you make the two controllers more different from each other?

Fault trees

A fault tree starts from an undesired top event and breaks it down with logic gates into basic events [8]. An OR gate passes a failure if any of its inputs fails, an AND gate only if all of them fail. The top event here is that the critical loads lose their supply in an outage of the grid. They are the server room of the library and the freezers of the laboratories, 80 kW together.

In an outage, the island fails if the battery is below its reserve or the battery management system (BMS) blocks the discharge. It also fails if the inverter is under repair, if both island controllers have failed or if the breaker fails to open. The minimal cut sets, the smallest combinations of basic events that cause the top event, are these single events, the common cause and the pair of independent controller faults. With independent basic events, the probability of a loss, the losses per year and the Fussell-Vesely (FV) importance of an event are:

\[P_{loss} = 1 - \prod_i \left(1 - q_i\right), \qquad f = f_{grid}\,P_{loss}, \qquad \text{FV}_i = \frac{q_i \prod_{j \ne i} \left(1 - q_j\right)}{P_{loss}}\]

→ This formula with numbers, step by step: Lab Part B, calculator, steps 1 to 5.

Two outages a year need the island, \(f_{grid} = 2\). The frequency \(f\) of losses is the outage rate times the probability that the island fails. The importance \(\text{FV}_i\) gives the share of the losses to which the basic event \(i\) contributes, and it shows where improvements pay off [8].

The schedules of Week 9 discharge the battery to its floor of 50 kWh in the evening. From 20:00 until it charges again before midnight, 4 hours of the day, it holds less than the reserve of 130 kWh. The reserve would carry the critical loads for one hour. An outage in these hours finds an empty battery, so \(q_R = 4/24 = 0.1667\). The BMS blocked the discharge for 35 hours of the last year, \(q_B = 0.0040\). The maker of the breaker gives \(q_K = 0.0030\) for a failure to open.

A worked example. For the current design, the five probabilities are 0.1667, 0.0040, 0.0082, 0.0077 and 0.0030. The island survives an outage with \(0.8333 \times 0.9960 \times 0.9918\) \(\times\, 0.9923 \times 0.9970 = 0.8144\). So \(P_{loss} = 0.1856\) and \(f = 2 \times 0.1856 = 0.371\) per year. The critical loads lose their supply about once in 2.7 years, and the battery below the reserve has an importance of 0.88.

A reserve rule keeps the 130 kWh in the battery at all times, so \(q_R = 0\). Then \(P_{loss} = 0.0227\) and \(f = 0.045\) per year, once in 22 years, below the target of 0.05 per year that the campus has set. In the schedules of Week 9, planning with the reserve costs 9.68 euro on the clear day and 6.97 euro on the cloudy day, about 3000 euro a year. A second controller costs 600 euro a year and each proof test 250 euro.

DesignLosses per yearYearly cost (euro)
Current: no reserve rule, two controllers, yearly proof tests0.37121100
Reserve rule, one controller, yearly proof tests0.12873250
Reserve rule, one controller, proof tests every 3 months0.05494000
Reserve rule, two controllers, yearly proof tests0.04544100
Reserve rule, two controllers, proof tests every 3 months0.03315600
Left: The fault tree of the critical supply with the probabilities of the current design. Right: The losses per year and the yearly cost of twelve designs, with the target of 0.05 per year.
Left: The fault tree of the critical supply with the probabilities of the current design. Right: The losses per year and the yearly cost of twelve designs, with the target of 0.05 per year.

Check your understanding. Which basic event has the highest Fussell-Vesely importance in the current design?

Open lab Part B

Interactive lab, Part B. The calculator computes the losses step by step: The controller pair, the survival of an outage, the loss probability, the losses per year and the years between them.

Open lab Part C

Interactive lab, Part C. The electrical room in 3D: The breaker of the point of common coupling, the cabinets of two island controllers, the battery inverter and a board with the fault tree. Choose a design and simulate 50,000 years of outages. The results can be copied into the Colab notebook.

Open in Colab

Python code in the Colab notebook, Section 3. Open Section 3 of the Colab notebook and run it. The function q_controllers computes the hidden faults with the common cause, events the five basic events of a design and p_loss the fault tree. The code prints the twelve designs with their losses and costs and the importance of each event. It then simulates 50,000 years for four designs and draws the designs against the target.

Discuss: The target
  1. The campus set the target of 0.05 losses per year. Who should decide such a target, and on which grounds?
  2. Which assumption of the fault tree would you check first in the real campus?

Runtime monitoring and the simplex architecture

The reserve rule must hold even when the schedule that drives the battery is wrong, outdated or attacked. A runtime monitor checks every command before it reaches the inverter and corrects the commands that would break the rule. Sha calls this approach using simplicity to control complexity [9]. A complex controller optimises the operation, and a simple, verified safety controller takes over whenever the complex one would leave the safe states.

The monitor of the battery allows a discharge only as far as the reserve permits:

\[d_t \le \left(e_{t-1} - e_{res}\right)\eta, \qquad e_{res} = 50 + 80 = 130\ \text{kWh}\]

Here \(d_t\) is the discharge power in hour \(t\), \(e_{t-1}\) the stored energy before it and \(\eta = 0.95\) the efficiency of Week 9.

A worked example. In the optimal clear day of Week 9, the battery holds 245.9 kWh at 19:00, and the schedule asks for 141.0 kW. The monitor allows \((245.9 - 130) \times 0.95 = 110.1\) kW and keeps 130 kWh. At 20:00 it blocks the planned 45.2 kW completely. The two interventions keep the reserve, but the day costs 1410.34 euro instead of 1379.91, partly because the import peak rises to 489.9 kW. The battery also ends the day with 80 kWh more, worth 12.00 euro at the value of stored energy of Week 9.

Planning with the reserve from the start is cheaper. The linear program of Week 9 with a lower limit of 130 kWh costs 1389.59 euro, 9.68 euro more than the optimum, and the monitor never needs to act. The simplex architecture keeps both: The optimiser plans with the rule, and the monitor stays as a safety net for the day when the plan is wrong.

The stored energy of the battery on the clear day of Week 9: The optimal schedule, the same schedule with the runtime monitor and the schedule planned with the reserve.
The stored energy of the battery on the clear day of Week 9: The optimal schedule, the same schedule with the runtime monitor and the schedule planned with the reserve.

Check your understanding. Why should the monitor be much simpler than the optimiser?

Open in Colab

Python code in the Colab notebook, Section 4. Open Section 4 of the Colab notebook and run it. The function monitor clips the discharges of a schedule, and schedule is the linear program of Week 9 with a lower limit of the stored energy. The code compares the optimal, the monitored and the re-planned day and runs three tests of the monitor with assertions. It then draws the stored energy of the three schedules.

Discuss: Who has the last word?
  1. The monitor overrides the optimiser in two evening hours. Should the operators be told each time, and how?
  2. What happens if the monitor itself fails, and how would you notice it?

Development templates of the week

The folder templates/ of the repository collects small working programs that carry out the methods of the course. Week 14 adds two of them, each with a description, its inputs and outputs and an example run.

TemplateWhat it does
model_check.pyA breadth-first model checker for a finite-state controller with a safety invariant and the shortest counterexample; the example is the transfer logic of the island controller in two versions
fault_tree.pyA fault tree over minimal cut sets with independent basic events, hidden faults with proof tests and a common cause, the importance of each event and a Monte Carlo check; the example is the critical supply of the campus

The engineering side: The safety case

A safety case is a structured argument, supported by evidence, that a system is acceptably safe for a given use in a given environment [10]. The Goal Structuring Notation (GSN) draws the argument as goals, strategies, evidence and context, so that a reviewer can follow each claim to its evidence. Standards of the International Electrotechnical Commission (IEC) for functional safety, such as IEC 61508, give each safety function a safety integrity level (SIL) [7]. The level sets how reliable the function must be and how rigorously it must be developed and verified.

PracticeWhy it matters on the campus
State the hazards and the tolerable risk firstThe target of 0.05 losses per year and the rule against back-feed decide every later choice
Verify the logic, not only test itThe stuck breaker was missing from every test scenario
Model common causesOne faulty firmware update can stop both island controllers
Test hidden faults at fixed intervalsA broken controller is found either by the proof test or by the next outage
Put a simple monitor in front of complex softwareThe optimiser of Week 9 never had to know about the reserve
Keep the safety case aliveEvery change of the campus, from a new load to a new schedule, can break an argument
Discuss: Evidence
  1. Which evidence of the safety case would a fire brigade or a regulator ask to see first?
  2. How would the safety case change if the campus added a second battery?

The campus microgrid, stage 14: The safety case

Stage 14 assembles the safety case of the island supply. Its top goal is that the critical loads of the campus are supplied safely during outages of the grid. Two sub-goals cover the two hazards: The supply is lost less than 0.05 times a year, and the battery never energises the lines of the grid. A third sub-goal keeps the reserve in the battery.

ClaimEvidenceResult
The transfer logic never forms the grid with the breaker closedModel checking of the corrected logic18 reachable states, none unsafe; the first version had 4 unsafe states
The supply is lost less than 0.05 times a yearFault tree of the cheapest design that meets the target0.0454 losses per year with the reserve rule, two controllers and yearly proof tests, 4100 euro a year
The fault tree is plausible50,000 simulated years of outages0.0462 losses per year
The battery keeps its reserveRuntime monitor with three testsTwo interventions on the optimal clear day, none on the day planned with the reserve
The reserve is affordableLinear program of Week 99.68 euro on the clear day, about 3000 euro a year

The safety case closes the project of the course. Fourteen stages have turned a sketch of a power balance into a campus microgrid that is modelled, controlled, connected, optimised, defended, twinned and argued to be safe.

The campus microgrid, stage 14: The safety case of the island supply in the Goal Structuring Notation, with the evidence of this week. The values come from Section 5 of the Colab notebook.
The campus microgrid, stage 14: The safety case of the island supply in the Goal Structuring Notation, with the evidence of this week. The values come from Section 5 of the Colab notebook.

Check your understanding. The safety case claims 0.0454 losses per year. Which assumption would weaken this claim most if it were wrong?

Open lab Part D

Interactive lab, Part D. Stage 14 by hand: The reliability of a part after 5 years, the availability of a repaired part and the reliability of two out of three.

Open in Colab

Python code in the Colab notebook, Section 5. Open Section 5 of the Colab notebook and run it. The code collects the results of stage 14 in the dictionary STAGE14 and draws the safety case with its evidence.

In the field: Working on the dead inverter

The safety case of this lecture argues about the system in operation. Maintenance asks another question: How does a person work on the hardware without harm? The European Norm (EN) 50110-1 answers with five rules in a fixed order [11]. First, disconnect completely. Second, secure against reconnection, for example with a padlock and a tag on each switch. Third, verify the absence of voltage at the place of work. Fourth, earth and short-circuit. Fifth, protect against adjacent live parts.

An inverter has more than one supply. Its alternating-current side hangs on a breaker, its direct-current side on the switch of the battery, and its fans may run from an auxiliary supply. The capacitors of its direct-current link keep their charge for minutes after the switch opens. With a time constant of 2 minutes, 760 V fall to \(760\,e^{-10/2} = 5\) V in 10 minutes.

The voltage tester itself is tested on a proving unit before and after the measurement, because a broken tester shows no voltage anywhere. At low voltage, earthing and short-circuiting matter where a part could become live again, for example through a second supply. The battery side of the switch stays live during the whole work and is covered. After the work, the rules are lifted in the reverse order.

Open lab Part E

Interactive lab, Part E. The field task: The battery inverter, its three supplies and a voltage tester. Replace the fan under the five safety rules and return the inverter to service.

The course in review

The course followed one campus through fourteen stages. Each stage added a method and left a result that the later stages used. Cyber-physical systems join computation, networking and physical processes [12], and the table shows how the stages of the course joined them on the campus.

WeekStageMethods
Week 1The power balance of the campusFeedback loops, energy and power, models of the sun and the wind, peak shaving
Week 2Dynamic models of the battery, a building and the frequencyDifferential equations, the Euler method, a resistor-capacitor model of a building, the swing equation
Week 3Operating modes and protectionState machines, hybrid automata, overcurrent relays, the modes of an island
Week 4Measuring the microgridCalibration, sampling and aliasing, quantisation, filtering, smart meters
Week 5Frequency control by the batteryProportional-integral (PI) and proportional-integral-derivative (PID) control, the Routh-Hurwitz criterion, anti-windup
Week 6Estimating the state of the microgridInverse-variance weighting, the Kalman filter, weighted least squares, the chi-square test
Week 7Real-time tasks of the microgrid controllerRate-monotonic (RM) and earliest-deadline-first (EDF) scheduling, response-time analysis, the scan cycle of a programmable logic controller (PLC)
Week 8The communication design with a delay budgetModbus, MQTT, IEC 61850 GOOSE, queues, delay margin
Week 9The dispatch of the microgridEconomic dispatch, linear programming of the battery, demand response of the car park
Week 10Forecasts of load and generationRegression with temperature and calendar, cloud forecasts, residuals and the CUSUM
Week 11Attacks and defencesFalse data injection, replay and watermarking, message authentication
Week 12A digital twin that follows the libraryCalibration, synchronisation, drift and recalibration
Week 13What-if analysis and maintenance with the twinWhat-if scenarios, Monte Carlo, remaining useful life
Week 14The safety case of the microgridModel checking, reliability, fault trees, runtime monitoring

The same steps apply far beyond a campus. Model the physics, measure it, control it and connect it. Then optimise it, defend it, mirror it in a twin and argue that it is safe.

Your application

Every system that must keep working when parts fail has a fault tree. The Colab notebook holds an application switch with six systems. They are the emergency power of a hospital ward, the cooling of a data center, the brake of an elevator, a railway crossing, a pumping station and traffic lights.

Open in Colab

Python code in the Colab notebook, Section 6. Open Section 6 of the Colab notebook, set APP to one of the six names in the comment and run the cell. The function app_tree computes the probability of the top event from the minimal cut sets and prints the importance of each basic event.

Learning machines and safety

Learning controllers, such as a policy trained by reinforcement learning (RL), can find better schedules than rules written by hand. They are also hard to verify, because their behaviour is learned rather than written. Seshia and colleagues describe the challenges of verifying such systems, from modelling their environment to specifying what the learned part should do [13].

Alshiekh and colleagues place a shield between a learning agent and its environment [14]. The shield is synthesised from a formal specification and corrects an action only if it would break the specification. The monitor of the battery is a shield of this kind: Any schedule, learned or optimised, passes through it before it reaches the inverter.

A learning battery behind a shield

Suppose that the campus trains a policy that learns from prices and forecasts when to charge and discharge the battery. Behind the shield, the policy may explore and earn money, while the reserve of 130 kWh holds in every hour. The safety case then needs evidence for the shield only, not for the learned policy.

Discuss: Trusting learned controllers
  1. What would you need to know about a learned policy before you let it operate without a shield?
  2. Which parts of the campus would you never hand to a learning controller?

Review cards

Select a card to turn it over.

Dependability
The ability to deliver a service that can justifiably be trusted [1].
Fault, error, failure
The cause, the wrong internal state it produces and the deviation of the service that follows [1].
Development fault
A fault made while a system is designed or programmed; every copy carries it.
Physical fault
A fault that arises in operation, when parts wear, break or are disturbed.
Model checking
The exploration of every reachable state of a model to check a property [3, 4].
Safety invariant
A condition that must hold in every reachable state, such as no grid forming with the breaker closed.
Counterexample
A path from the start to a state that breaks the property, returned by the model checker.
Reliability
\(R(t) = e^{-\lambda t}\): The probability that a part works without failure up to the time \(t\).
Mean time to failure (MTTF)
The expected time to the first failure, \(1/\lambda\) for a constant rate.
Availability
\(\text{MTTF}/(\text{MTTF} + \text{MTTR})\): The share of time in which a repaired part works.
k out of n
A system that works when at least k of its n parts work, such as two-out-of-three voting.
Hidden fault and proof test
A fault that stays undetected until the part is needed or tested; with tests every \(\tau\) the part is unavailable for \(\lambda\tau/2\) [6].
Common cause failure
A single cause that stops several redundant parts at once; the beta factor gives it a share of all failures.
Fault tree
A tree of logic gates from a top event down to basic events [8].
Minimal cut set
A smallest combination of basic events that causes the top event.
Fussell-Vesely (FV) importance
The share of the probability of the top event to which a basic event contributes.
Simplex architecture
A complex controller with a simple, verified safety controller that takes over when needed [9].
Safety case
A structured argument, supported by evidence, that a system is acceptably safe [10].
Safety integrity level (SIL)
The level of IEC 61508 that sets how reliable a safety function must be [7].
Shield
A component that corrects the actions of a learning agent only when they would break a specification [14].

References

[1] Avizienis, A., Laprie, J.-C., Randell, B., & Landwehr, C. (2004). Basic concepts and taxonomy of dependable and secure computing. IEEE Transactions on Dependable and Secure Computing, 1(1), 11-33. https://doi.org/10.1109/TDSC.2004.2

[2] Van Rossum, G., & Drake, F. L. (2009). Python 3 Reference Manual. CreateSpace.

[3] Clarke, E. M., Emerson, E. A., & Sistla, A. P. (1986). Automatic verification of finite-state concurrent systems using temporal logic specifications. ACM Transactions on Programming Languages and Systems, 8(2), 244-263. https://doi.org/10.1145/5397.5399

[4] Baier, C., & Katoen, J.-P. (2008). Principles of Model Checking. MIT Press.

[5] Alur, R. (2015). Principles of Cyber-Physical Systems. MIT Press. https://cis.upenn.edu/~alur/pcps.html

[6] Rausand, M., & Høyland, A. (2004). System Reliability Theory: Models, Statistical Methods, and Applications (2nd ed.). Wiley.

[7] International Electrotechnical Commission. (2010). Functional safety of electrical/electronic/programmable electronic safety-related systems – Part 1: General requirements (IEC 61508-1:2010, Edition 2.0). IEC. https://webstore.iec.ch/publication/5515

[8] Ruijters, E., & Stoelinga, M. (2015). Fault tree analysis: A survey of the state-of-the-art in modeling, analysis and tools. Computer Science Review, 15-16, 29-62. https://doi.org/10.1016/j.cosrev.2015.03.001

[9] Sha, L. (2001). Using simplicity to control complexity. IEEE Software, 18(4), 20-28. https://doi.org/10.1109/MS.2001.936213

[10] Kelly, T. (2004). A systematic approach to safety case management (SAE Technical Paper 2004-01-1779). SAE International. https://doi.org/10.4271/2004-01-1779

[11] European Committee for Electrotechnical Standardization. (2023). Operation of electrical installations - Part 1: General requirements (EN 50110-1:2023). CENELEC.

[12] Lee, E. A., & Seshia, S. A. (2017). Introduction to Embedded Systems: A Cyber-Physical Systems Approach (2nd ed.). MIT Press. https://ptolemy.berkeley.edu/books/leeseshia/

[13] Seshia, S. A., Sadigh, D., & Sastry, S. S. (2022). Toward verified artificial intelligence. Communications of the ACM, 65(7), 46-55. https://doi.org/10.1145/3503914

[14] Alshiekh, M., Bloem, R., Ehlers, R., Könighofer, B., Niekum, S., & Topcu, U. (2018). Safe reinforcement learning via shielding. Proceedings of the AAAI Conference on Artificial Intelligence, 32(1), 2669-2678. https://doi.org/10.1609/aaai.v32i1.11797