Synthesizing a trace that satisfies a given Signal Temporal Logic (STL) formula.
Project description
stlts
This is a Python package for synthesizing a trace that satisfies a given Signal Temporal Logic (STL) formula. The package implements the MILP-based synthesis algorithm proposed in the paper:
Sota Sato, Jie An, Zhenya Zhang, Ichiro Hasuo. Optimization-Based Model Checking and Trace Synthesis for Complex STL Specifications. 36th International Conference on Computer-Aided Verification, 2024 [doi] [arXiv]
Requirements
- Python with version 3.8 or higher
- License for Gurobi optimizer
Install
pip install stlts
Optionally, install from the cloned repo (requires pip version 22.0 or higher):
git clone https://github.com/midoriao/stlts
cd stlts
pip install -e .
Usage
You can run a synthesis for example model and spec:
import gurobipy as gp
from stlts import benchmarks
milp = gp.Model()
benchmark_name = 'rnc1'
bound = 5
prob = benchmarks.get_benchmark(milp, benchmark_name, N=bound, delta=0.1)
prob.search_satisfaction()
if prob.has_solution:
print(prob.get_trace_result(interpolation=False))
else:
print(f'No trace found with bound {bound}')
To try another STL formula, it can be specified in a DSL style.
import gurobipy as gp
from stlts import benchmarks
from stlts.linear_expression import LinearExpression as L
from stlts.stl import Atomic, BoundedAlw, Ev
milp = gp.Model()
benchmark_name = 'rnc1'
bound = 5
prob = benchmarks.get_benchmark(milp, benchmark_name, N=bound, delta=0.1)
# Atomic proposition is given in linear inequality form
danger = Atomic(L.f(1.0, 'x1', -1.0, 'x2') <= 10)
stl_spec = Ev(BoundedAlw((0, 5), danger))
prob.initialize_milp_formulation(stl_spec)
prob.search_satisfaction()
Here’s a list of the supported STL operators:
Atomic(p): Atomic proposition. Its contentpis given in linear inequality form.And(psi1, psi2, ...): This operator specifies that all formulaspsi1, psi2, ...hold.Or(psi1, psi2, ...): This operator specifies that at least one formula out ofpsi1, psi2, ...holds.BoundedAlw([a,b], psi): This operator specifies that a property must hold at all times within a given interval[a,b].Alw(psi): This operator specifies that a property must hold at all times. Semantically it is equivalent toBoundedAlw([0, infty], psi).BoundedEv([a,b], psi),Ev(psi): This operator specifies that a property must hold become true at some point within a given interval.BoundedUntil([a,b], psi1, psi2),Until(psi1, psi2): This operator specifies thatpsi1must be true untilpsi2becomes true within an interval[a, b].BoundedRelease([a,b], psi1, psi2),Release(psi1, psi2): This operator is dual to the Until operator and specifies thatpsi2must hold true until and including whenpsi1becomes true, within an interval[a,b].
Note that we do not provide Not operator, since our formula must be in NNF (negation-normal form). Instead, we provide a method phi.negation() to get an equivalent formula in NNF to the negation of phi.
Supplementary Material
The code for replicating the experiments in the paper is available at Zenodo.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stlts-1.0.2.tar.gz.
File metadata
- Download URL: stlts-1.0.2.tar.gz
- Upload date:
- Size: 64.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
59ddf3a53b42534fa7c01ae83c6e7a3743111e42dde3e3dfb3e662e2c871c189
|
|
| MD5 |
a521294b8f6ad0586121c8892f1ccce9
|
|
| BLAKE2b-256 |
8ffeffce03d33f0546a26bc7d96d87b9dfb9014a39c8810b400293d003c713dd
|
Provenance
The following attestation bundles were made for stlts-1.0.2.tar.gz:
Publisher:
publish.yml on midoriao/stlts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stlts-1.0.2.tar.gz -
Subject digest:
59ddf3a53b42534fa7c01ae83c6e7a3743111e42dde3e3dfb3e662e2c871c189 - Sigstore transparency entry: 578691087
- Sigstore integration time:
-
Permalink:
midoriao/stlts@61141dae87d11dfb55e309b56dccbb3cd3dcafe8 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/midoriao
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@61141dae87d11dfb55e309b56dccbb3cd3dcafe8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file stlts-1.0.2-py3-none-any.whl.
File metadata
- Download URL: stlts-1.0.2-py3-none-any.whl
- Upload date:
- Size: 30.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eead4c674365515f7e9e7677e4622a4cb85b65f0772f2c0f89b609cf17af095f
|
|
| MD5 |
251f94df423b2ea3b63e926bb676bbec
|
|
| BLAKE2b-256 |
04c36ee6e2a0cd35db66b6bf8408b6c5438918fa2ba7dbc7131fce738219d3b0
|
Provenance
The following attestation bundles were made for stlts-1.0.2-py3-none-any.whl:
Publisher:
publish.yml on midoriao/stlts
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
stlts-1.0.2-py3-none-any.whl -
Subject digest:
eead4c674365515f7e9e7677e4622a4cb85b65f0772f2c0f89b609cf17af095f - Sigstore transparency entry: 578691096
- Sigstore integration time:
-
Permalink:
midoriao/stlts@61141dae87d11dfb55e309b56dccbb3cd3dcafe8 -
Branch / Tag:
refs/tags/v1.0.2 - Owner: https://github.com/midoriao
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@61141dae87d11dfb55e309b56dccbb3cd3dcafe8 -
Trigger Event:
push
-
Statement type: