icon

pyspect

  • Home
Tutorials
  • Getting Started
  • Creating Sets
Paper Examples
  • Examples for CDC '25
Implementations
  • hj_reachability
  • ZonoOpt
Helper Implementations
  • Base
  • Axes
  • Plotly
  • Debug
Reference
  • Set Builders
  • Logic Fragments
  • Temporal Logic Trees
  • TLT Primitives

Getting Started

Previous Next

Follow these steps to install pyspect and run your first spec.

0. Prerequisites¶

  • Python >= 3.12

1. Installation¶

pip install pyspect

# With optional implementation
pip install pyspect[hj_reachability]

2. Write your first spec¶

In [1]:
Copied!
from pyspect.logics import *
from pyspect.tlt import TLT, ContLTL
from pyspect.set_builder import AlignedBoxSet, Union, HalfSpaceSet
from pyspect.impls.hj_reachability import TVHJImpl

# Choose fragment
TLT.select(ContLTL)

# Write spec: avoid D, stay in corridor, reach goal
phi = UNTIL(AND(NOT('D'), 'corridor'), 'goal')

# Bind propositions later
tlt = TLT(phi, where={
    'D': Union(AlignedBoxSet(...), AlignedBoxSet(...)),
    'corridor': AlignedBoxSet(...),
    'goal': HalfSpaceSet(...),
})

# Realize on a backend
impl = TVHJImpl(...)
Phi = tlt.realize(impl)
print("Satisfaction set:", Phi)
from pyspect.logics import * from pyspect.tlt import TLT, ContLTL from pyspect.set_builder import AlignedBoxSet, Union, HalfSpaceSet from pyspect.impls.hj_reachability import TVHJImpl # Choose fragment TLT.select(ContLTL) # Write spec: avoid D, stay in corridor, reach goal phi = UNTIL(AND(NOT('D'), 'corridor'), 'goal') # Bind propositions later tlt = TLT(phi, where={ 'D': Union(AlignedBoxSet(...), AlignedBoxSet(...)), 'corridor': AlignedBoxSet(...), 'goal': HalfSpaceSet(...), }) # Realize on a backend impl = TVHJImpl(...) Phi = tlt.realize(impl) print("Satisfaction set:", Phi)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[1], line 2
      1 from pyspect.logics import *
----> 2 from pyspect.tlt import TLT, ContLTL
      3 from pyspect.set_builder import AlignedBoxSet, Union, HalfSpaceSet
      4 from pyspect.impls.hj_reachability import TVHJImpl
      5 

ImportError: cannot import name 'ContLTL' from 'pyspect.tlt' (/home/runner/work/pyspect/pyspect/src/pyspect/tlt.py)

3. Next Steps¶

  • Set Builders Guide — step-by-step tutorial with figures (start here before temporal logic)
  • Set Builders reference — full API
Home Creating Sets
Menu
Home
Tutorials
Getting Started Creating Sets
Paper Examples
Examples for CDC '25
Implementations
hj_reachability ZonoOpt
Helper Implementations
Base Axes Plotly Debug
Reference
Set Builders Logic Fragments Temporal Logic Trees TLT Primitives

On This Page

0. Prerequisites 1. Installation 2. Write your first spec 3. Next Steps
Built by Kaj Munhoz Arfvidsson — shadcn theme provided by @asiffer