|
LTL and STL Assignment
|
Practical Information
GoalsIn this assignment, you will use the pyMTL Python library to check temporal properties on traces obtained by simulating different models of complex Cyber-Physical Systems built using formalisms that you will learn in the course. In each later assignment, you will be asked to verify some properties of your model using the same techniques. So ensure you understand the concepts and techniques well. Specifically, in this assignment, you will learn:
You are discouraged but allowed to make use of any GenAI tool in solving the assignment or writing the report (for example, to correct grammatical mistakes) as long as you adhere to the UA Guidelines for students on responsible use of GenAI.
You are required to cite any use of GenAI and describe what portions of the assignment you used it for. Note that a significant part of demonstrating that the learning goals have been achieved includes being able to
This will be evaluated in a short (~15 minute) individual oral evaluation, which will typically be conducted in the week following the deadline of each assignment. pyMTLYou will use pyMTL to perform all the tasks. The library is available to install in your Python environment of choice via PyPI (pip install metric-temporal-logic). pyMTL checks Metric Interval Temporal Logic (MITL). It does not directly accept an LTL or STL formula as you would write it on paper. You translate the formula yourself into the syntax described below, then evaluate it on a trace. import mtl
phi = mtl.parse("G[0, 4] (red -> X yellow)")
trace = {
"red": [(0, True), (1, True), (2, False), (3, False), (4, False)],
"yellow": [(0, False), (1, False), (2, True), (3, False), (4, False)],
}
print(phi(trace, time=0, quantitative=False, dt=1)) # True at time 0
A trace is implemented as a dictionary: each atomic predicate maps to a list of (time, value) pairs.
All Boolean operations must be parenthesised, except for a single negation or a single X. For example:
An interval [a, b] is read as the half-open range [a, b) in pyMTL. An alternative mathematical notation for a half-open interval is [a,b[. The right endpoint is not included. If the last sample is at time T and you want that sample covered, the upper bound must be strictly larger than T. From LTL to MITL. Untimed G and F become bounded intervals over the recorded trace. X, U and W stay, with the parentheses required above.
From STL to MITL. pyMTL does not accept comparisons. A predicate such as $|\theta| \le 1.5$ is not a legal atomic predicate. Compute it yourself while you load the CSV and write the temporal formula over that resultant signal. Use the trace's own time column as the time stamps, not the row index.
import pandas as pd
frame = pd.read_csv("gantry.csv")
trace = {
"angle_ok": list(zip(frame["time"], frame["gantry.theta"].abs() <= 1.5)),
}
phi = mtl.parse("G[0, 20.1] angle_ok")
print(phi(trace, time=0, quantitative=False))
Assignment OverviewThis assignment has two parts. In each part you formalise the listed claims and evaluate them on every provided trace. The result of that evaluation is a CSV file, one per system, in the format described under Practical Issues.
Each part is aligned with one of the learning goals. LTL PropertiesEach system comes with ten traces, <system>_1.csv through <system>_10.csv. A trace has 201 rows. Values in the step column run from 0 to 200. Every other cell-value is 0 or 1. Use the column name as a Boolean atomic predicate: 1 means the condition holds at that step, and 0 means it does not. In your report, for each property, write the LTL formula, the corresponding MITL formula, and any explanation (if needed) for this translation. Simple traffic light![]() Figure 1:simple traffic light. This is a simple traffic light with three colours - red, yellow, and green, constructed as a Petri net (you will learn this formalism in Assignment 4). A color can stay 'on' for several steps in a row. The intended order is red, yellow, green, yellow, red. red, yellow, and green are 1 when that colour is lit. There are 10 traces:
Drivers are fine with this hypothetical traffic light staying red for a while, or green for a while. What they need is that it never shows two colours at once, and that it does not jump from red straight to green, or from green straight back to red. Check if the traffic light satisfies the following properties, based on the provided traces:
Simple production system![]() Figure 2: Petri net of simple production system. This is a small workshop with two machines and one technician, again modelled as a Petri net. One part comes in, is worked on by machine 1, then by machine 2, and is then output. From there the workshop keeps waiting until a new product appears at the input. There is no buffer between the machines. When a machine is working on a part, it may break down with the part still inside it. There is one repair technician available. When he is free, he can be assigned to repair a machine that is down. The machine then resumes working on the part inside it. A machine may break down multiple times when working on a single part.
There are 10 traces:
A workshop like this has maximum one part at any given time. The technician cannot repair both machines at once. The part should visit machine 1 before machine 2. After machine 2 has finished working, the workshop remains idle until a new part arrives. Check if the workshop satisfies the following properties, based on the provided traces:
Pipelined production system![]() Figure 2: Petri net of pipelined production system. This is the same workshop on a busier day. A new part can arrive while an earlier one is still being processed. There is a single buffer between the machines. There can be a maximum of one part in the input queue and one part at the output, before it is shipped. The machine and technician columns mean the same as in the previous system. p_in, p_m1, p_buffer, p_m2, and p_out are 1 when a part is at that stage. Several of them can be 1 at the same time, since this workshop is pipelined. There is no idle column. There are 10 traces:
The technician still cannot repair both machines at once. What is new is that both machines, and the buffer, may hold a part at the same time. A part should still go through machine 1 before machine 2. NOTE: Why a second workshop? A temporal-logic formula can only talk about what the trace records. Here each column tells you whether a stage holds a part, but not which part. With one part in the building, that is enough to follow the part through the whole workshop. Once several parts are in flight, the same columns can no longer tell them apart, so a claim such as "every part visits machine 1 before machine 2" cannot be written with these atomic predicates. What you can still check are claims about stages and single steps: which stages are occupied together, and what one step changes. Choosing properties that the can be expressed based on the available observations, or more commonly, designing an experiment which includes observations that are needed to express desired properties is part of systems engineering. Check if the workshop satisfies the following properties, based on the provided traces:
STL PropertiesEach of the following systems is controlled by a PID controller, tuned by three gains (multiplication factors): Kp (proportional), Ki (integral), and Kd (derivative). Different gains make the same system behave very differently. You will learn more about PID control in the next assignment. Each system comes with ten traces, <system>_kp<Kp>_ki<Ki>_kd<Kd>.csv, one per set of PID gain parameter settings. The first column, time, is the simulation time in seconds. Every other column is a real-valued signal. Build a Boolean signal for each predicate from these columns, and use the time values as the timestamps. In your report, for each property, write the STL formula, the Boolean signals you built, the corresponding MITL formula, and any extra explanation (if needed) for this translation. Cruise control![]() Figure 4: Cruise control system. The figure shows an ego car following a car in front of it. The car (physical) and a PID controller adapting its speed (ultimately realized in software) are modelled in Modelica (which will be introduced in the next lecture) and simulated. The goal for the controller is to keep 10 m between the bumpers. Each trace runs for 60 seconds. Note: This example has been taken from the Modelica assignment of the 2023-2024 iteration of the course. You may learn more about this system on the assignment page.
There are 10 traces:
A gentle tuning eases into the gap and stays there. An unstable one stamps on the accelerator and the brake. One of the runs gets close enough that you would not want to be in the passenger seat. Check if the controller satisfies the following properties, based on the provided traces:
Gantry crane![]() Figure 5: Gantry crane system. This is a pendulum hanging off a trolley attached to a rail (physical) and a PID controller adapting the trolley's speed (ultimately realized in software) again modelled in Modelica and simulated. The goal is for the trolley to reach position 10 mtrs. Each trace runs for 20 seconds. The filename records the PID gains. Note: This example has been taken from the Modelica assignment of the 2024-2025 iteration of the course. You may learn more about this system on the assignment page.
There are 10 traces:
Move too fast and the pendulum swings too much. Move too slow and it never arrives. The trolley cannot overshoot the target position by too much as the length of the rail is limited. Check if the crane satisfies the following properties, based on the provided traces:
Water heating![]() Figure 6: Water heating system. This is a a hot-water tank (physical) and a PID controller (ultimately realized in software) that drives a heater to keep the hot-water tank's water temperature at 50°C (323.15 K). A separate on/off controller (also ultimately realized in software) tops the tank up when the level falls. The system is again modelled in Modelica, and simulated for one day (86400 seconds). The filename records the PID gains. Note: This example has been taken from the Modelica assignment of the 2025-2026 iteration of the course. You may learn more about this system on the assignment page.
There are 10 traces:
Some tunings climb to the setpoint and sit there. Others overshoot. The ones with no integral action never ease off the heater. The level should stay in a comfortable band the whole day. Check if the tank satisfies the following properties, based on the provided traces:
Practical IssuesSubmit one CSV per system, with these exact filenames:
The traffic-light file, for example, begins like this. The true and false values are made up:
|
| Maintained by Hans Vangheluwe. | Last Modified: 2026/10/09 07:39:26. |