  This paper presents converse theorems for safety in terms of barrier
functions for unconstrained continuous-time systems modeled as differential
inclusions. Via a counterexample, we show the lack of existence of autonomous
and continuous barrier functions certifying safety for a nonlinear system that
is not only safe but also has a smooth right-hand side. Guided by converse
Lyapunov theorems for (non-asymptotic) stability,time-varying barrier functions
and appropriate infinitesimal conditions are shown to be both necessary as well
as sufficient under mild regularity conditions on the right-hand side of the
system. More precisely, we propose a general construction of a time-varying
barrier function in terms of a marginal function involving the finite-horizon
reachable set. Using techniques from set-valued and nonsmooth analysis, we show
that such a function guarantees safety when the system is safe. Furthermore, we
show that the proposed barrier function construction inherits the regularity
properties of the proposed reachable set. In addition, when the system is safe
and smooth, we build upon the constructed barrier function to show the
existence of a smooth barrier function guaranteeing safety. Comparisons and
relationships to results in the literature are also presented.
