Skip to main content

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

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 content p is given in linear inequality form.
  • And(psi1, psi2, ...): This operator specifies that all formulas psi1, psi2, ... hold.
  • Or(psi1, psi2, ...): This operator specifies that at least one formula out of psi1, 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 to BoundedAlw([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 that psi1 must be true until psi2becomes true within an interval [a, b].
  • BoundedRelease([a,b], psi1, psi2), Release(psi1, psi2): This operator is dual to the Until operator and specifies that psi2 must hold true until and including when psi1 becomes 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

stlts-1.0.2.tar.gz (64.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

stlts-1.0.2-py3-none-any.whl (30.7 kB view details)

Uploaded Python 3

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

Hashes for stlts-1.0.2.tar.gz
Algorithm Hash digest
SHA256 59ddf3a53b42534fa7c01ae83c6e7a3743111e42dde3e3dfb3e662e2c871c189
MD5 a521294b8f6ad0586121c8892f1ccce9
BLAKE2b-256 8ffeffce03d33f0546a26bc7d96d87b9dfb9014a39c8810b400293d003c713dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for stlts-1.0.2.tar.gz:

Publisher: publish.yml on midoriao/stlts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for stlts-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 eead4c674365515f7e9e7677e4622a4cb85b65f0772f2c0f89b609cf17af095f
MD5 251f94df423b2ea3b63e926bb676bbec
BLAKE2b-256 04c36ee6e2a0cd35db66b6bf8408b6c5438918fa2ba7dbc7131fce738219d3b0

See more details on using hashes here.

Provenance

The following attestation bundles were made for stlts-1.0.2-py3-none-any.whl:

Publisher: publish.yml on midoriao/stlts

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page