  In this paper, we introduce a flexible notion of safety verification for
nonlinear autonomous systems by measuring how much time the system spends in
given unsafe regions. We consider this problem in the particular case of
nonlinear systems with a polynomial dynamics and unsafe regions described by a
collection of polynomial inequalities. In this context, we can quantify the
amount of time spent in the unsafe regions as the solution to an
infinite-dimensional linear program (LP). This LP measures the volume of the
unsafe region with respect to the occupation measure of the system
trajectories. Using Lasserre hierarchy, we approximate the solution to the
infinite-dimensional LP using a sequence of finite-dimensional semidefinite
programs (SDPs). The solutions to the SDPs in this hierarchy provide
monotonically converging upper bounds on the optimal solution to the
infinite-dimensional LP. Finally, we validate the performance of our framework
using numerical simulations.
