verse-lib 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. verse_lib-2.0.0/Licence.txt +16 -0
  2. verse_lib-2.0.0/PKG-INFO +337 -0
  3. verse_lib-2.0.0/README.md +271 -0
  4. verse_lib-2.0.0/pyproject.toml +625 -0
  5. verse_lib-2.0.0/setup.cfg +4 -0
  6. verse_lib-2.0.0/tests/test_utils.py +129 -0
  7. verse_lib-2.0.0/tests/test_verse.py +253 -0
  8. verse_lib-2.0.0/verse/__init__.py +8 -0
  9. verse_lib-2.0.0/verse/agents/__init__.py +2 -0
  10. verse_lib-2.0.0/verse/agents/base_agent.py +93 -0
  11. verse_lib-2.0.0/verse/agents/example_agent/__init__.py +3 -0
  12. verse_lib-2.0.0/verse/agents/example_agent/ball_agent.py +43 -0
  13. verse_lib-2.0.0/verse/agents/example_agent/ballg_agent.py +42 -0
  14. verse_lib-2.0.0/verse/agents/example_agent/car_agent.py +254 -0
  15. verse_lib-2.0.0/verse/agents/example_agent/line_agent.py +40 -0
  16. verse_lib-2.0.0/verse/agents/example_agent/origin_agent.py +183 -0
  17. verse_lib-2.0.0/verse/agents/example_agent/prarm.json +184 -0
  18. verse_lib-2.0.0/verse/agents/example_agent/quadrotor_agent.py +249 -0
  19. verse_lib-2.0.0/verse/agents/example_agent/robot_agent.py +37 -0
  20. verse_lib-2.0.0/verse/agents/example_agent/sign_agent.py +15 -0
  21. verse_lib-2.0.0/verse/analysis/__init__.py +6 -0
  22. verse_lib-2.0.0/verse/analysis/analysis_tree.py +571 -0
  23. verse_lib-2.0.0/verse/analysis/dryvr.py +320 -0
  24. verse_lib-2.0.0/verse/analysis/dryvr_disc.py +269 -0
  25. verse_lib-2.0.0/verse/analysis/incremental.py +402 -0
  26. verse_lib-2.0.0/verse/analysis/mixmonotone.py +291 -0
  27. verse_lib-2.0.0/verse/analysis/parsed_wrap/__init__.py +3 -0
  28. verse_lib-2.0.0/verse/analysis/parsed_wrap/_cache.py +95 -0
  29. verse_lib-2.0.0/verse/analysis/parsed_wrap/bounded_angular.py +434 -0
  30. verse_lib-2.0.0/verse/analysis/parsed_wrap/bounded_map.py +53 -0
  31. verse_lib-2.0.0/verse/analysis/parsed_wrap/bounded_piecewise.py +292 -0
  32. verse_lib-2.0.0/verse/analysis/parsed_wrap/parser_wrapper.py +454 -0
  33. verse_lib-2.0.0/verse/analysis/parsed_wrap/sensor_parser.py +582 -0
  34. verse_lib-2.0.0/verse/analysis/parsed_wrap/wrapper_consts.py +29 -0
  35. verse_lib-2.0.0/verse/analysis/simulator.py +893 -0
  36. verse_lib-2.0.0/verse/analysis/verifier.py +1899 -0
  37. verse_lib-2.0.0/verse/automaton/__init__.py +3 -0
  38. verse_lib-2.0.0/verse/automaton/guard.py +1348 -0
  39. verse_lib-2.0.0/verse/automaton/hybrid_automaton.py +34 -0
  40. verse_lib-2.0.0/verse/automaton/hybrid_io_automaton.py +30 -0
  41. verse_lib-2.0.0/verse/automaton/reset.py +110 -0
  42. verse_lib-2.0.0/verse/map/__init__.py +5 -0
  43. verse_lib-2.0.0/verse/map/example_map/__init__.py +2 -0
  44. verse_lib-2.0.0/verse/map/example_map/intersection.py +127 -0
  45. verse_lib-2.0.0/verse/map/example_map/map_tacas.py +262 -0
  46. verse_lib-2.0.0/verse/map/example_map/simple_map.py +31 -0
  47. verse_lib-2.0.0/verse/map/example_map/simple_map2.py +188 -0
  48. verse_lib-2.0.0/verse/map/example_map/simple_map_3d.py +278 -0
  49. verse_lib-2.0.0/verse/map/lane.py +60 -0
  50. verse_lib-2.0.0/verse/map/lane_3d.py +78 -0
  51. verse_lib-2.0.0/verse/map/lane_map.py +120 -0
  52. verse_lib-2.0.0/verse/map/lane_map_3d.py +293 -0
  53. verse_lib-2.0.0/verse/map/lane_segment.py +324 -0
  54. verse_lib-2.0.0/verse/map/lane_segment_3d.py +638 -0
  55. verse_lib-2.0.0/verse/map/opendrive_parser.py +483 -0
  56. verse_lib-2.0.0/verse/parser/__init__.py +2 -0
  57. verse_lib-2.0.0/verse/parser/astunparser.py +989 -0
  58. verse_lib-2.0.0/verse/parser/parser.py +967 -0
  59. verse_lib-2.0.0/verse/plotter/__init__.py +23 -0
  60. verse_lib-2.0.0/verse/plotter/plotter2D.py +2864 -0
  61. verse_lib-2.0.0/verse/plotter/plotter2D_old.py +223 -0
  62. verse_lib-2.0.0/verse/plotter/plotter3D.py +147 -0
  63. verse_lib-2.0.0/verse/plotter/plotter3D_new.py +735 -0
  64. verse_lib-2.0.0/verse/plotter/plotterStar.py +105 -0
  65. verse_lib-2.0.0/verse/scenario/__init__.py +2 -0
  66. verse_lib-2.0.0/verse/scenario/scenario.py +595 -0
  67. verse_lib-2.0.0/verse/sensor/__init__.py +2 -0
  68. verse_lib-2.0.0/verse/sensor/base_sensor.py +135 -0
  69. verse_lib-2.0.0/verse/sensor/base_sensor_stars.py +159 -0
  70. verse_lib-2.0.0/verse/sensor/example_sensor/__init__.py +0 -0
  71. verse_lib-2.0.0/verse/sensor/example_sensor/craft_sensor.py +62 -0
  72. verse_lib-2.0.0/verse/sensor/example_sensor/craft_star_sensor.py +81 -0
  73. verse_lib-2.0.0/verse/sensor/example_sensor/quadrotor_sensor.py +62 -0
  74. verse_lib-2.0.0/verse/sensor/example_sensor/single_sensor.py +179 -0
  75. verse_lib-2.0.0/verse/sensor/example_sensor/thermo_sensor.py +62 -0
  76. verse_lib-2.0.0/verse/stars/__init__.py +3 -0
  77. verse_lib-2.0.0/verse/stars/reach_at_star.py +73 -0
  78. verse_lib-2.0.0/verse/stars/starset.py +889 -0
  79. verse_lib-2.0.0/verse/stars/startests.py +383 -0
  80. verse_lib-2.0.0/verse/utils/__init__.py +2 -0
  81. verse_lib-2.0.0/verse/utils/fixed_points.py +125 -0
  82. verse_lib-2.0.0/verse/utils/star_diams.py +171 -0
  83. verse_lib-2.0.0/verse/utils/star_manhattan.py +232 -0
  84. verse_lib-2.0.0/verse/utils/utils.py +437 -0
  85. verse_lib-2.0.0/verse_lib.egg-info/PKG-INFO +337 -0
  86. verse_lib-2.0.0/verse_lib.egg-info/SOURCES.txt +87 -0
  87. verse_lib-2.0.0/verse_lib.egg-info/dependency_links.txt +1 -0
  88. verse_lib-2.0.0/verse_lib.egg-info/requires.txt +45 -0
  89. verse_lib-2.0.0/verse_lib.egg-info/top_level.txt +1 -0
@@ -0,0 +1,16 @@
1
+ University of Illinois/NCSA Open Source License
2
+
3
+ Copyright (c) 2023 Reliable Autonomy Group at University of Illinois, Urbana-Champaign. All rights reserved.
4
+
5
+ Developed by: Reliable Autonomy Research Group (RARG) At University of Illinois
6
+ Lab Url: https://mitras.ece.illinois.edu/group.html
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal with the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
+
10
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimers.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimers in the documentation and/or other materials provided with the distribution.
13
+
14
+ * Neither the names of RARG nor the names of its contributors may be used to endorse or promote products derived from this Software without specific prior written permission.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS WITH THE SOFTWARE.
@@ -0,0 +1,337 @@
1
+ Metadata-Version: 2.4
2
+ Name: verse-lib
3
+ Version: 2.0.0
4
+ Summary: Verse: reachability analysis and verification of multi-agent hybrid systems, with sensor programs
5
+ Author: Yangge Li, Alex Yuan, Haoqing Zhu, Sayan Mitra, Reliable Autonomy Group, UIUC
6
+ License-Expression: NCSA
7
+ Project-URL: Homepage, https://github.com/AutoVerse-ai/Verse-library
8
+ Project-URL: Documentation, https://autoverse-ai.github.io/Verse-library/
9
+ Project-URL: Issues, https://github.com/AutoVerse-ai/Verse-library/issues
10
+ Keywords: reachability,verification,hybrid systems,multi-agent,cyber-physical systems
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: Topic :: Scientific/Engineering
14
+ Classifier: Operating System :: MacOS
15
+ Classifier: Operating System :: POSIX :: Linux
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+ License-File: Licence.txt
24
+ Requires-Dist: numpy>=1.26
25
+ Requires-Dist: scipy>=1.11
26
+ Requires-Dist: sympy>=1.12
27
+ Requires-Dist: matplotlib>=3.7
28
+ Requires-Dist: plotly>=5.18
29
+ Requires-Dist: dash>=2.14
30
+ Requires-Dist: imageio>=2.31
31
+ Requires-Dist: pillow>=10.0
32
+ Requires-Dist: polytope>=0.2.5
33
+ Requires-Dist: z3-solver>=4.12
34
+ Requires-Dist: cvxpy>=1.4
35
+ Requires-Dist: highspy>=1.7
36
+ Requires-Dist: ray>=2.9
37
+ Requires-Dist: networkx>=3.0
38
+ Requires-Dist: graphviz>=0.20
39
+ Requires-Dist: portion>=2.4
40
+ Requires-Dist: Pympler>=1.0
41
+ Requires-Dist: intervaltree>=3.1
42
+ Requires-Dist: astunparse>=1.6.3
43
+ Requires-Dist: six>=1.16
44
+ Requires-Dist: beautifulsoup4>=4.12
45
+ Requires-Dist: lxml>=4.9
46
+ Requires-Dist: tqdm>=4.66
47
+ Requires-Dist: typing_extensions>=4.7
48
+ Requires-Dist: torch>=2.2
49
+ Provides-Extra: crown
50
+ Requires-Dist: torch<2.12,>=2.2; extra == "crown"
51
+ Requires-Dist: appdirs>=1.4.4; extra == "crown"
52
+ Requires-Dist: packaging>=20.0; extra == "crown"
53
+ Provides-Extra: export
54
+ Requires-Dist: kaleido>=0.2.1; extra == "export"
55
+ Provides-Extra: dev
56
+ Requires-Dist: pytest>=7; extra == "dev"
57
+ Requires-Dist: black; extra == "dev"
58
+ Requires-Dist: pylint; extra == "dev"
59
+ Requires-Dist: pre-commit; extra == "dev"
60
+ Provides-Extra: docs
61
+ Requires-Dist: sphinx; extra == "docs"
62
+ Requires-Dist: myst-parser; extra == "docs"
63
+ Requires-Dist: sphinx_rtd_theme; extra == "docs"
64
+ Requires-Dist: numpydoc; extra == "docs"
65
+ Dynamic: license-file
66
+
67
+ # Verse
68
+
69
+ Verse is a library for modeling, simulating and verifying scenarios in which several decision-making agents
70
+ interact: cars on a highway, drones on flight corridors, spacecraft approaching a station. Each agent has continuous
71
+ dynamics, written as an ordinary Python simulation function, and decision logic, written in a subset of Python with
72
+ `if` statements over the agent's own state and what it perceives of the others. Verse turns these pieces into a hybrid
73
+ system and computes the reachable set from every branch of their
74
+ decisions. Safety requirements written as `assert` statements in the decision logic are checked on that set.
75
+
76
+ <p align="center">
77
+ <img src="docs/source/figs/gallery/highway_animation.gif" width="95%"/><br/>
78
+ <em>A controlled car approaches a slower car and may change lanes on either side. Solid blocks: where each car can
79
+ be at the time shown (its reachable positions enlarged by the car's footprint); faint trail: earlier reachable sets.</em>
80
+ </p>
81
+
82
+ <table>
83
+ <tr>
84
+ <td width="50%"><img src="docs/source/figs/gallery/spacecraft_reach_avoid.png"/></td>
85
+ <td width="50%"><img src="docs/source/figs/gallery/spacecraft_switch_track.png"/></td>
86
+ </tr>
87
+ <tr>
88
+ <td>Spacecraft reach-avoid: every position the deputy can reach while it approaches the chief and steers around a
89
+ second spacecraft, stacked over 50 minutes (time runs upward).</td>
90
+ <td>Two deputies switching tracks. Each estimates its position from angles-only, ground-station and proximity
91
+ sensors; Verse bounds what those sensors report over the whole reachable set.</td>
92
+ </tr>
93
+ <tr>
94
+ <td><img src="docs/source/figs/gallery/drone_figure8.png"/></td>
95
+ <td><img src="docs/source/figs/gallery/curved_highway.png"/></td>
96
+ </tr>
97
+ <tr>
98
+ <td>Two quadrotors on three stacked figure-8 tracks. The first may climb or descend to pass the second; both
99
+ branches are verified.</td>
100
+ <td>A curved three-lane road imported from OpenDRIVE. The controlled car's reachable set splits where it may
101
+ overtake.</td>
102
+ </tr>
103
+ <tr>
104
+ <td colspan="2" align="center"><img src="docs/source/figs/gallery/highway.png" width="60%"/></td>
105
+ </tr>
106
+ <tr>
107
+ <td colspan="2">Highway with two controlled cars among five others; each lane change is a branch of the reachable
108
+ set.</td>
109
+ </tr>
110
+ </table>
111
+
112
+ Verse is developed by the [Reliable Autonomy Group](https://mitras.ece.illinois.edu/group.html) at the University of
113
+ Illinois Urbana-Champaign.
114
+
115
+ ## What Verse does
116
+
117
+ * **Scenarios from parts.** A scenario combines agents, a map (lanes and tracks, written in Python or imported from
118
+ [OpenDRIVE](https://www.asam.net/standards/detail/opendrive/) files), and a sensor that decides what each agent
119
+ perceives. The same agent can be reused across maps and scenarios.
120
+ * **Simulation and verification.** `scenario.simulate(T, dt)` returns one execution; `scenario.verify(T, dt)` returns
121
+ a tree of reachable sets, one branch per possible sequence of decisions.
122
+ * **Reachability engines.** DryVR (sampled simulations with bloating; the default), mixed-monotone decomposition for
123
+ systems with uncertain inputs, NeuReach, and star sets. The engine is a configuration option.
124
+ * **Sensor programs.** A sensor can compute what the agent perceives with a Python function: range, bearing, field of
125
+ view, noisy position fixes. During verification Verse computes sound bounds on that function's output over every
126
+ reachable state, so decisions that depend on noisy or partial observations are verified exactly as written.
127
+ * **Scale.** Verification can run in parallel with [Ray](https://www.ray.io/) and reuse earlier results incrementally
128
+ when a scenario changes.
129
+
130
+ ## Installation
131
+
132
+ Verse needs Python 3.10 or newer and runs on Linux and macOS.
133
+
134
+ ```sh
135
+ pip install verse-lib
136
+ ```
137
+
138
+ or, from a clone of this repository (to run the demos and the tutorial),
139
+
140
+ ```sh
141
+ pip install -e .
142
+ ```
143
+
144
+ ### Sensor programs and CROWN
145
+
146
+ Bounds on nonlinear sensor functions are computed with [auto_LiRPA](https://github.com/Verified-Intelligence/auto_LiRPA)
147
+ (CROWN). It is optional; without it, the rest of Verse works and a CROWN bound raises an error that says how to install
148
+ it. auto_LiRPA 0.8 is not yet on PyPI, so install it from GitHub:
149
+
150
+ ```sh
151
+ pip install "verse-lib[crown]"
152
+ pip install "auto_LiRPA @ git+https://github.com/Verified-Intelligence/auto_LiRPA.git@e393035"
153
+ ```
154
+
155
+ auto_LiRPA 0.8 declares Python 3.11 only, but its CROWN bounds are identical on Python 3.10–3.13; on those versions
156
+ add `--ignore-requires-python` to the second command.
157
+
158
+ ## A first scenario
159
+
160
+ ```sh
161
+ python demo/ball/ball_bounces.py # simulation
162
+ python demo/highway/m1_1c1n/m1_1c1n_dryvr_ver.py # verification of a lane change
163
+ ```
164
+
165
+ A scenario is a few lines of Python. From `demo/highway/m1_1c1n/m1_1c1n_dryvr_ver.py`: car `car1` follows the
166
+ decision logic in `example_controller4.py`, and an NPC car keeps its lane ahead of it.
167
+
168
+ ```python
169
+ from verse import Scenario, ScenarioConfig
170
+ from verse.agents.example_agent import CarAgent, NPCAgent
171
+ from verse.map.example_map.map_tacas import M1
172
+ from verse.plotter.plotter2D import reachtube_tree
173
+
174
+ scenario = Scenario(ScenarioConfig(init_seg_length=1, parallel=False))
175
+ scenario.add_agent(CarAgent("car1", file_name="example_controller4.py",
176
+ initial_state=[[0, -0.5, 0, 1.0], [0.01, 0.5, 0, 1.0]], # box of x, y, heading, speed
177
+ initial_mode=(AgentMode.Normal, TrackMode.T1)))
178
+ scenario.add_agent(NPCAgent("car2", initial_state=[[15, -0.3, 0, 0.5], [15, 0.3, 0, 0.5]],
179
+ initial_mode=(AgentMode.Normal, TrackMode.T1)))
180
+ scenario.set_map(M1()) # three straight lanes
181
+ tree = scenario.verify(40, 0.05) # reachable sets for 40 s, every branch of car1's decisions
182
+ reachtube_tree(tree, M1(), None, 1, 2).show()
183
+ ```
184
+
185
+ The decision logic is Python over the agent's own state, the states of the others and the map. When a car is close
186
+ ahead, `car1` may switch to either neighboring lane, and it returns to `Normal` once it is in the new lane:
187
+
188
+ ```python
189
+ def decisionLogic(ego: State, others: List[State], track_map):
190
+ output = copy.deepcopy(ego)
191
+ if ego.agent_mode == AgentMode.Normal:
192
+ if vehicle_front(ego, others, track_map):
193
+ if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft):
194
+ output.agent_mode = AgentMode.SwitchLeft
195
+ output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft)
196
+ if vehicle_front(ego, others, track_map):
197
+ if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight):
198
+ output.agent_mode = AgentMode.SwitchRight
199
+ output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight)
200
+ lat_dist = track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y])
201
+ if ego.agent_mode == AgentMode.SwitchLeft and lat_dist >= 2.5:
202
+ output.agent_mode = AgentMode.Normal
203
+ output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal)
204
+ if ego.agent_mode == AgentMode.SwitchRight and lat_dist <= -2.5:
205
+ output.agent_mode = AgentMode.Normal
206
+ output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal)
207
+ return output
208
+ ```
209
+
210
+ Both `if` branches can fire from the same state, so verification follows both lane changes.
211
+
212
+ The [tutorial notebook](tutorial/tutorial.ipynb) builds such scenarios step by step, and the
213
+ [documentation](https://autoverse-ai.github.io/Verse-library/) describes agents, maps, sensors and plotting.
214
+
215
+ ## Sensors and sensor programs
216
+
217
+ What an agent's decision logic sees is produced by the scenario's sensor. The default `BaseSensor` is omniscient: every
218
+ agent sees the exact state of every other. A custom sensor implements `sense(agent, state_dict, lane_map, simulate)` and
219
+ returns the variables the decision logic reads (`ego.x`, `others.dist`, ...). In simulation they are numbers; in
220
+ verification they are intervals that must contain every value the sensor can report.
221
+
222
+ Computing those intervals by hand is where sensor models usually go wrong. With sensor programs, the sensor is an
223
+ ordinary function and Verse computes the intervals. A field-of-view sensor for a ground robot, from
224
+ `demo/aprod/vis_dubins_rdvz/car_sensor_parser.py`:
225
+
226
+ ```python
227
+ def vis_sensor_piecewise(psi, phi): # which sector of the field of view the target is in
228
+ if psi >= 0 and psi <= phi:
229
+ return -1
230
+ elif psi < 0 and psi >= -phi:
231
+ return 1
232
+ elif psi > phi:
233
+ return -2
234
+ else:
235
+ return 2
236
+
237
+ def vis_sensor(x, y, x_other, y_other, phi, theta):
238
+ rel_x = x_other - x
239
+ rel_y = y_other - y
240
+ eta = atan2(rel_y, rel_x) # bearing to the target
241
+ psi = minus_angular(eta, theta) # relative to the robot's heading
242
+ obs = vis_sensor_piecewise(psi, phi)
243
+ return obs
244
+ ```
245
+
246
+ In the sensor's verification branch, one call bounds the observation over the reachable box:
247
+
248
+ ```python
249
+ from verse.analysis.parsed_wrap import parse_function
250
+
251
+ bounds, _ = parse_function(vis_sensor, {"x": [(x_lo, x_hi)], "y": [(y_lo, y_hi)], ...}, [vis_sensor_piecewise])
252
+ cont["ego.cur_sense"] = list(bounds["obs"][0])
253
+ ```
254
+
255
+ `parse_function` walks the function statement by statement. Arithmetic and trigonometry are bounded with CROWN, angles
256
+ with interval arithmetic that handles wrap-around, map queries with the map's own geometry, and piecewise functions with
257
+ Z3. Splitting the input box (`parse_function_array(..., num_splits=3)`) tightens the bounds. Results are cached on disk,
258
+ keyed by the function's source code and its inputs.
259
+
260
+ The spacecraft scenarios in [`demo/spacecraft/`](demo/spacecraft/) use sensor programs for angles-only navigation,
261
+ ground-station fixes and proximity sensing; their README lists the runtimes and the paper results each reproduces.
262
+
263
+ ## Examples
264
+
265
+ | Folder | What it shows |
266
+ |---|---|
267
+ | [`demo/spacecraft/`](demo/spacecraft/) | autonomous rendezvous, docking, reach-avoid and track switching with sensor programs |
268
+ | [`demo/highway/`](demo/highway/), [`demo/intersection/`](demo/intersection/), [`demo/AEB/`](demo/AEB/) | cars changing lanes, crossing an intersection, emergency braking |
269
+ | [`demo/quadrotor/`](demo/quadrotor/) | quadrotors on 3-D tracks with neural-network controllers |
270
+ | [`demo/aprod/`](demo/aprod/) | ground robots and cars with field-of-view and multi-agent sensors |
271
+ | [`demo/dryvr_demo/`](demo/dryvr_demo/) | ARCH-COMP benchmarks: Van der Pol, Laub–Loomis, gearbox, 3-D heat, spacecraft rendezvous (also with star sets) |
272
+ | [`demo/fp_demos/`](demo/fp_demos/) | verification that stops at a fixed point (reachable set no longer grows) |
273
+ | [`demo/uncertain_dynamics/`](demo/uncertain_dynamics/) | mixed-monotone reachability with uncertain inputs |
274
+ | [`demo/incremental/`](demo/incremental/) | incremental verification after a change to the decision logic |
275
+ | [`demo/traffic_signalB/`](demo/traffic_signalB/), [`demo/robot_swarm/`](demo/robot_swarm/), [`demo/ball/`](demo/ball/) | a car at a traffic light, a robot swarm, bouncing balls |
276
+
277
+ The figures above are regenerated by `python docs/gallery/make_gallery.py`.
278
+
279
+ ## Library structure
280
+
281
+ * `verse/scenario`: scenarios and their configuration
282
+ * `verse/agents`: the agent base class and example agents
283
+ * `verse/map`: lanes, maps and the OpenDRIVE importer
284
+ * `verse/parser`, `verse/automaton`: decision logic to guards and resets
285
+ * `verse/analysis`: simulator, verifier and reachability engines; `analysis/parsed_wrap` is the sensor-program parser
286
+ * `verse/stars`: star sets
287
+ * `verse/plotter`: 2-D and 3-D plots of simulations and reachable sets
288
+
289
+ NeuReach is a git submodule: `git submodule update --init` fetches it.
290
+
291
+ ## Development
292
+
293
+ ```sh
294
+ pip install -e ".[dev]"
295
+ pre-commit install
296
+ python tests/test_verse.py
297
+ ```
298
+
299
+ ## Team
300
+
301
+ Core developers: Yangge Li, Alex Yuan, Haoqing Zhu, Katherine Braught, Sayan Mitra.
302
+ Contributors: Nitish Bhupathi Raju, Keyi Shen, Louis Sungwoo Cho, Daniel Zhuang.
303
+
304
+ ## Publications
305
+
306
+ **[Verse: Semantics and Verification of Hybrid Multi-Agent Scenarios](https://arxiv.org/abs/2610.35680).**
307
+ Yangge Li, Katherine Braught, Alex Yuan, Sayan Mitra. arXiv:2610.35680, 2026.
308
+
309
+ **[Formal reasoning for perceptual multi-agent systems: verification, contracts, and synthesis](https://mitras.ece.illinois.edu/research/2026/PhD_YanggeLi.pdf).**
310
+ Yangge Li. PhD dissertation, Department of Electrical and Computer Engineering, University of Illinois Urbana-Champaign,
311
+ 2026.
312
+
313
+ **[Tools for formal verification of observation-driven autonomous systems](https://mitras.ece.illinois.edu/research/2026/MS_YUAN2026.pdf).**
314
+ Alex Yuan. MS thesis, Department of Electrical and Computer Engineering, University of Illinois Urbana-Champaign, 2026.
315
+
316
+ **[Verse: A Python library for reasoning about multi-agent hybrid system scenarios](https://link.springer.com/chapter/10.1007/978-3-031-37706-8_18).**
317
+ Yangge Li, Haoqing Zhu, Katherine Braught, Keyi Shen, Sayan Mitra.
318
+ Computer Aided Verification (CAV), LNCS 13964, pages 351–364, 2023.
319
+
320
+ **[Parallel and incremental verification of hybrid automata with Ray and Verse](https://link.springer.com/chapter/10.1007/978-3-031-45329-8_5).**
321
+ Haoqing Zhu, Yangge Li, Keyi Shen, Sayan Mitra.
322
+ Automated Technology for Verification and Analysis (ATVA), 2023.
323
+
324
+ **[Verification of L1 adaptive control using Verse Library: a case study of quadrotors](https://arxiv.org/abs/2303.13819).**
325
+ Lin Song, Yangge Li, Sheng Cheng, Pan Zhao, Sayan Mitra, Naira Hovakimyan.
326
+ Work in Progress Session, International Conference on Cyber-Physical Systems (WiP-ICCPS), 2023.
327
+
328
+ **[Parallelization and incremental algorithms in the Verse hybrid system verification library](https://www.ideals.illinois.edu/items/127392).**
329
+ Haoqing Zhu. Master's thesis, University of Illinois Urbana-Champaign, 2023.
330
+
331
+ ## Sponsors
332
+
333
+ [NASA ULI Aviate](https://aviate.illinois.edu/event/nasa-uli-annual-review/)
334
+
335
+ ## License
336
+
337
+ University of Illinois/NCSA Open Source License; see [Licence.txt](Licence.txt).
@@ -0,0 +1,271 @@
1
+ # Verse
2
+
3
+ Verse is a library for modeling, simulating and verifying scenarios in which several decision-making agents
4
+ interact: cars on a highway, drones on flight corridors, spacecraft approaching a station. Each agent has continuous
5
+ dynamics, written as an ordinary Python simulation function, and decision logic, written in a subset of Python with
6
+ `if` statements over the agent's own state and what it perceives of the others. Verse turns these pieces into a hybrid
7
+ system and computes the reachable set from every branch of their
8
+ decisions. Safety requirements written as `assert` statements in the decision logic are checked on that set.
9
+
10
+ <p align="center">
11
+ <img src="docs/source/figs/gallery/highway_animation.gif" width="95%"/><br/>
12
+ <em>A controlled car approaches a slower car and may change lanes on either side. Solid blocks: where each car can
13
+ be at the time shown (its reachable positions enlarged by the car's footprint); faint trail: earlier reachable sets.</em>
14
+ </p>
15
+
16
+ <table>
17
+ <tr>
18
+ <td width="50%"><img src="docs/source/figs/gallery/spacecraft_reach_avoid.png"/></td>
19
+ <td width="50%"><img src="docs/source/figs/gallery/spacecraft_switch_track.png"/></td>
20
+ </tr>
21
+ <tr>
22
+ <td>Spacecraft reach-avoid: every position the deputy can reach while it approaches the chief and steers around a
23
+ second spacecraft, stacked over 50 minutes (time runs upward).</td>
24
+ <td>Two deputies switching tracks. Each estimates its position from angles-only, ground-station and proximity
25
+ sensors; Verse bounds what those sensors report over the whole reachable set.</td>
26
+ </tr>
27
+ <tr>
28
+ <td><img src="docs/source/figs/gallery/drone_figure8.png"/></td>
29
+ <td><img src="docs/source/figs/gallery/curved_highway.png"/></td>
30
+ </tr>
31
+ <tr>
32
+ <td>Two quadrotors on three stacked figure-8 tracks. The first may climb or descend to pass the second; both
33
+ branches are verified.</td>
34
+ <td>A curved three-lane road imported from OpenDRIVE. The controlled car's reachable set splits where it may
35
+ overtake.</td>
36
+ </tr>
37
+ <tr>
38
+ <td colspan="2" align="center"><img src="docs/source/figs/gallery/highway.png" width="60%"/></td>
39
+ </tr>
40
+ <tr>
41
+ <td colspan="2">Highway with two controlled cars among five others; each lane change is a branch of the reachable
42
+ set.</td>
43
+ </tr>
44
+ </table>
45
+
46
+ Verse is developed by the [Reliable Autonomy Group](https://mitras.ece.illinois.edu/group.html) at the University of
47
+ Illinois Urbana-Champaign.
48
+
49
+ ## What Verse does
50
+
51
+ * **Scenarios from parts.** A scenario combines agents, a map (lanes and tracks, written in Python or imported from
52
+ [OpenDRIVE](https://www.asam.net/standards/detail/opendrive/) files), and a sensor that decides what each agent
53
+ perceives. The same agent can be reused across maps and scenarios.
54
+ * **Simulation and verification.** `scenario.simulate(T, dt)` returns one execution; `scenario.verify(T, dt)` returns
55
+ a tree of reachable sets, one branch per possible sequence of decisions.
56
+ * **Reachability engines.** DryVR (sampled simulations with bloating; the default), mixed-monotone decomposition for
57
+ systems with uncertain inputs, NeuReach, and star sets. The engine is a configuration option.
58
+ * **Sensor programs.** A sensor can compute what the agent perceives with a Python function: range, bearing, field of
59
+ view, noisy position fixes. During verification Verse computes sound bounds on that function's output over every
60
+ reachable state, so decisions that depend on noisy or partial observations are verified exactly as written.
61
+ * **Scale.** Verification can run in parallel with [Ray](https://www.ray.io/) and reuse earlier results incrementally
62
+ when a scenario changes.
63
+
64
+ ## Installation
65
+
66
+ Verse needs Python 3.10 or newer and runs on Linux and macOS.
67
+
68
+ ```sh
69
+ pip install verse-lib
70
+ ```
71
+
72
+ or, from a clone of this repository (to run the demos and the tutorial),
73
+
74
+ ```sh
75
+ pip install -e .
76
+ ```
77
+
78
+ ### Sensor programs and CROWN
79
+
80
+ Bounds on nonlinear sensor functions are computed with [auto_LiRPA](https://github.com/Verified-Intelligence/auto_LiRPA)
81
+ (CROWN). It is optional; without it, the rest of Verse works and a CROWN bound raises an error that says how to install
82
+ it. auto_LiRPA 0.8 is not yet on PyPI, so install it from GitHub:
83
+
84
+ ```sh
85
+ pip install "verse-lib[crown]"
86
+ pip install "auto_LiRPA @ git+https://github.com/Verified-Intelligence/auto_LiRPA.git@e393035"
87
+ ```
88
+
89
+ auto_LiRPA 0.8 declares Python 3.11 only, but its CROWN bounds are identical on Python 3.10–3.13; on those versions
90
+ add `--ignore-requires-python` to the second command.
91
+
92
+ ## A first scenario
93
+
94
+ ```sh
95
+ python demo/ball/ball_bounces.py # simulation
96
+ python demo/highway/m1_1c1n/m1_1c1n_dryvr_ver.py # verification of a lane change
97
+ ```
98
+
99
+ A scenario is a few lines of Python. From `demo/highway/m1_1c1n/m1_1c1n_dryvr_ver.py`: car `car1` follows the
100
+ decision logic in `example_controller4.py`, and an NPC car keeps its lane ahead of it.
101
+
102
+ ```python
103
+ from verse import Scenario, ScenarioConfig
104
+ from verse.agents.example_agent import CarAgent, NPCAgent
105
+ from verse.map.example_map.map_tacas import M1
106
+ from verse.plotter.plotter2D import reachtube_tree
107
+
108
+ scenario = Scenario(ScenarioConfig(init_seg_length=1, parallel=False))
109
+ scenario.add_agent(CarAgent("car1", file_name="example_controller4.py",
110
+ initial_state=[[0, -0.5, 0, 1.0], [0.01, 0.5, 0, 1.0]], # box of x, y, heading, speed
111
+ initial_mode=(AgentMode.Normal, TrackMode.T1)))
112
+ scenario.add_agent(NPCAgent("car2", initial_state=[[15, -0.3, 0, 0.5], [15, 0.3, 0, 0.5]],
113
+ initial_mode=(AgentMode.Normal, TrackMode.T1)))
114
+ scenario.set_map(M1()) # three straight lanes
115
+ tree = scenario.verify(40, 0.05) # reachable sets for 40 s, every branch of car1's decisions
116
+ reachtube_tree(tree, M1(), None, 1, 2).show()
117
+ ```
118
+
119
+ The decision logic is Python over the agent's own state, the states of the others and the map. When a car is close
120
+ ahead, `car1` may switch to either neighboring lane, and it returns to `Normal` once it is in the new lane:
121
+
122
+ ```python
123
+ def decisionLogic(ego: State, others: List[State], track_map):
124
+ output = copy.deepcopy(ego)
125
+ if ego.agent_mode == AgentMode.Normal:
126
+ if vehicle_front(ego, others, track_map):
127
+ if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft):
128
+ output.agent_mode = AgentMode.SwitchLeft
129
+ output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchLeft)
130
+ if vehicle_front(ego, others, track_map):
131
+ if track_map.h_exist(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight):
132
+ output.agent_mode = AgentMode.SwitchRight
133
+ output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.SwitchRight)
134
+ lat_dist = track_map.get_lateral_distance(ego.track_mode, [ego.x, ego.y])
135
+ if ego.agent_mode == AgentMode.SwitchLeft and lat_dist >= 2.5:
136
+ output.agent_mode = AgentMode.Normal
137
+ output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal)
138
+ if ego.agent_mode == AgentMode.SwitchRight and lat_dist <= -2.5:
139
+ output.agent_mode = AgentMode.Normal
140
+ output.track_mode = track_map.h(ego.track_mode, ego.agent_mode, AgentMode.Normal)
141
+ return output
142
+ ```
143
+
144
+ Both `if` branches can fire from the same state, so verification follows both lane changes.
145
+
146
+ The [tutorial notebook](tutorial/tutorial.ipynb) builds such scenarios step by step, and the
147
+ [documentation](https://autoverse-ai.github.io/Verse-library/) describes agents, maps, sensors and plotting.
148
+
149
+ ## Sensors and sensor programs
150
+
151
+ What an agent's decision logic sees is produced by the scenario's sensor. The default `BaseSensor` is omniscient: every
152
+ agent sees the exact state of every other. A custom sensor implements `sense(agent, state_dict, lane_map, simulate)` and
153
+ returns the variables the decision logic reads (`ego.x`, `others.dist`, ...). In simulation they are numbers; in
154
+ verification they are intervals that must contain every value the sensor can report.
155
+
156
+ Computing those intervals by hand is where sensor models usually go wrong. With sensor programs, the sensor is an
157
+ ordinary function and Verse computes the intervals. A field-of-view sensor for a ground robot, from
158
+ `demo/aprod/vis_dubins_rdvz/car_sensor_parser.py`:
159
+
160
+ ```python
161
+ def vis_sensor_piecewise(psi, phi): # which sector of the field of view the target is in
162
+ if psi >= 0 and psi <= phi:
163
+ return -1
164
+ elif psi < 0 and psi >= -phi:
165
+ return 1
166
+ elif psi > phi:
167
+ return -2
168
+ else:
169
+ return 2
170
+
171
+ def vis_sensor(x, y, x_other, y_other, phi, theta):
172
+ rel_x = x_other - x
173
+ rel_y = y_other - y
174
+ eta = atan2(rel_y, rel_x) # bearing to the target
175
+ psi = minus_angular(eta, theta) # relative to the robot's heading
176
+ obs = vis_sensor_piecewise(psi, phi)
177
+ return obs
178
+ ```
179
+
180
+ In the sensor's verification branch, one call bounds the observation over the reachable box:
181
+
182
+ ```python
183
+ from verse.analysis.parsed_wrap import parse_function
184
+
185
+ bounds, _ = parse_function(vis_sensor, {"x": [(x_lo, x_hi)], "y": [(y_lo, y_hi)], ...}, [vis_sensor_piecewise])
186
+ cont["ego.cur_sense"] = list(bounds["obs"][0])
187
+ ```
188
+
189
+ `parse_function` walks the function statement by statement. Arithmetic and trigonometry are bounded with CROWN, angles
190
+ with interval arithmetic that handles wrap-around, map queries with the map's own geometry, and piecewise functions with
191
+ Z3. Splitting the input box (`parse_function_array(..., num_splits=3)`) tightens the bounds. Results are cached on disk,
192
+ keyed by the function's source code and its inputs.
193
+
194
+ The spacecraft scenarios in [`demo/spacecraft/`](demo/spacecraft/) use sensor programs for angles-only navigation,
195
+ ground-station fixes and proximity sensing; their README lists the runtimes and the paper results each reproduces.
196
+
197
+ ## Examples
198
+
199
+ | Folder | What it shows |
200
+ |---|---|
201
+ | [`demo/spacecraft/`](demo/spacecraft/) | autonomous rendezvous, docking, reach-avoid and track switching with sensor programs |
202
+ | [`demo/highway/`](demo/highway/), [`demo/intersection/`](demo/intersection/), [`demo/AEB/`](demo/AEB/) | cars changing lanes, crossing an intersection, emergency braking |
203
+ | [`demo/quadrotor/`](demo/quadrotor/) | quadrotors on 3-D tracks with neural-network controllers |
204
+ | [`demo/aprod/`](demo/aprod/) | ground robots and cars with field-of-view and multi-agent sensors |
205
+ | [`demo/dryvr_demo/`](demo/dryvr_demo/) | ARCH-COMP benchmarks: Van der Pol, Laub–Loomis, gearbox, 3-D heat, spacecraft rendezvous (also with star sets) |
206
+ | [`demo/fp_demos/`](demo/fp_demos/) | verification that stops at a fixed point (reachable set no longer grows) |
207
+ | [`demo/uncertain_dynamics/`](demo/uncertain_dynamics/) | mixed-monotone reachability with uncertain inputs |
208
+ | [`demo/incremental/`](demo/incremental/) | incremental verification after a change to the decision logic |
209
+ | [`demo/traffic_signalB/`](demo/traffic_signalB/), [`demo/robot_swarm/`](demo/robot_swarm/), [`demo/ball/`](demo/ball/) | a car at a traffic light, a robot swarm, bouncing balls |
210
+
211
+ The figures above are regenerated by `python docs/gallery/make_gallery.py`.
212
+
213
+ ## Library structure
214
+
215
+ * `verse/scenario`: scenarios and their configuration
216
+ * `verse/agents`: the agent base class and example agents
217
+ * `verse/map`: lanes, maps and the OpenDRIVE importer
218
+ * `verse/parser`, `verse/automaton`: decision logic to guards and resets
219
+ * `verse/analysis`: simulator, verifier and reachability engines; `analysis/parsed_wrap` is the sensor-program parser
220
+ * `verse/stars`: star sets
221
+ * `verse/plotter`: 2-D and 3-D plots of simulations and reachable sets
222
+
223
+ NeuReach is a git submodule: `git submodule update --init` fetches it.
224
+
225
+ ## Development
226
+
227
+ ```sh
228
+ pip install -e ".[dev]"
229
+ pre-commit install
230
+ python tests/test_verse.py
231
+ ```
232
+
233
+ ## Team
234
+
235
+ Core developers: Yangge Li, Alex Yuan, Haoqing Zhu, Katherine Braught, Sayan Mitra.
236
+ Contributors: Nitish Bhupathi Raju, Keyi Shen, Louis Sungwoo Cho, Daniel Zhuang.
237
+
238
+ ## Publications
239
+
240
+ **[Verse: Semantics and Verification of Hybrid Multi-Agent Scenarios](https://arxiv.org/abs/2610.35680).**
241
+ Yangge Li, Katherine Braught, Alex Yuan, Sayan Mitra. arXiv:2610.35680, 2026.
242
+
243
+ **[Formal reasoning for perceptual multi-agent systems: verification, contracts, and synthesis](https://mitras.ece.illinois.edu/research/2026/PhD_YanggeLi.pdf).**
244
+ Yangge Li. PhD dissertation, Department of Electrical and Computer Engineering, University of Illinois Urbana-Champaign,
245
+ 2026.
246
+
247
+ **[Tools for formal verification of observation-driven autonomous systems](https://mitras.ece.illinois.edu/research/2026/MS_YUAN2026.pdf).**
248
+ Alex Yuan. MS thesis, Department of Electrical and Computer Engineering, University of Illinois Urbana-Champaign, 2026.
249
+
250
+ **[Verse: A Python library for reasoning about multi-agent hybrid system scenarios](https://link.springer.com/chapter/10.1007/978-3-031-37706-8_18).**
251
+ Yangge Li, Haoqing Zhu, Katherine Braught, Keyi Shen, Sayan Mitra.
252
+ Computer Aided Verification (CAV), LNCS 13964, pages 351–364, 2023.
253
+
254
+ **[Parallel and incremental verification of hybrid automata with Ray and Verse](https://link.springer.com/chapter/10.1007/978-3-031-45329-8_5).**
255
+ Haoqing Zhu, Yangge Li, Keyi Shen, Sayan Mitra.
256
+ Automated Technology for Verification and Analysis (ATVA), 2023.
257
+
258
+ **[Verification of L1 adaptive control using Verse Library: a case study of quadrotors](https://arxiv.org/abs/2303.13819).**
259
+ Lin Song, Yangge Li, Sheng Cheng, Pan Zhao, Sayan Mitra, Naira Hovakimyan.
260
+ Work in Progress Session, International Conference on Cyber-Physical Systems (WiP-ICCPS), 2023.
261
+
262
+ **[Parallelization and incremental algorithms in the Verse hybrid system verification library](https://www.ideals.illinois.edu/items/127392).**
263
+ Haoqing Zhu. Master's thesis, University of Illinois Urbana-Champaign, 2023.
264
+
265
+ ## Sponsors
266
+
267
+ [NASA ULI Aviate](https://aviate.illinois.edu/event/nasa-uli-annual-review/)
268
+
269
+ ## License
270
+
271
+ University of Illinois/NCSA Open Source License; see [Licence.txt](Licence.txt).