{'fraction_non_alphanumeric': 0.0491021714922049, 'fraction_numerical': 0.011936247216035634, 'mean_word_length': 4.062004579883741, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 5, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
The viability of switched nonlinear systems with piecewise smooth Lyapunov functions

In this paper, we focus on the viability and attraction for switched nonlinear systems with nonsmooth Lyapunov functions. We determine the viable set and region of attraction for switched systems in which Lyapunov functions are piecewise smooth. The switching law is constructed by using the directional derivatives of a piecewise smooth Lyapunov function along the trajectories of the subsystems. Sufficient conditions are derived to guarantee the viability and attraction of switched nonlinear systems on the level set of a piecewise smooth Lyapunov function. We further extend the method to switched systems involving possible sliding motions. The approach in the paper provides a unified framework for studying viability and attraction with a systematic consideration of sliding motions. Finally, considering two certain classes of piecewise smooth functions, the related conditions of the viability and attraction for the level set are developed.


1.
Introduction. Viability theory [1] designs and develops a mathematical method for investigating the adaptation to viability constraints of evolutions governed by a complex uncertainty system. Based on the viability theory, we can describe all the possible evolution trajectories for a given system under the viability constraints and find the appropriate controls which allow the system to be evolved forever. This provides a new approach of dealing with the security evolution [17,22] and sustainable development [23] for a system. Therefore, the research on viability has an important practical significance and the results have been applied in many fields involving economics [2], finance [3], renewable resources management [21] and environmental sciences [24,25].
Determining the viability for a dynamical system on the constraint region is difficult and important in the research on the viability. Although the viability condition is given in [1], it is not available in implementation as we need to check the condition for all the boundary points on the constraint region. In order to get a feasible method, researchers discuss the viability of a linear system on the special forms of regions involving polyhedron region [6,8,11] and ellipsoid region [6]. Chen in [8] considers the viability of a linear system on an unbounded polyhedron, and the viability verification is transformed into solving a finite number of linear programming problems. Gao in [11] gives a method of verifying viability condition for a set with nonsmooth boundary under a differential inclusion which is a convex hull of finitely many functions. Blanchini in [6] discusses the viability of the ellipsoidal sets and the polyhedral sets, and presents the main properties and the most successful applications of viable sets in control engineering. Due to the complexity of a nonlinear system, it is a hard work to determine the viability for a nonlinear system. Tan in [27] studies the viability of a nonlinear system with a nonsmooth Lyapunov function and presents a condition that the level set is viable when the Lyapunov function is max-type or min-type function. Since the piecewise smooth function is a more broad class of nonsmooth functions which widely used in nonsmooth analysis and control, Gao in [12] generalizes the results of [27] to the case where Lyapunov function is piecewise smooth.
In recent years, switched systems [13,14,16] have drawn considerable attention due to their broad range of applications. In spite of the simplicity of each subsystem, switched systems may exhibit complicated dynamical behaviors because of the switching law between the subsystems. Viability of such systems turned out to be an important and challenging problem, which has been studied in many literatures (see [10,15,16,18,19,20,30,32,33] and references therein). The viability of the switched systems is usually guaranteed by the existence of a common quadratic Lyapunov function (CQLF) [16]. The CQLF has been the most popular tool for synthesis of linear systems since they usually lead to linear matrix inequalities (LMIs), which can be manipulated with LMIs-based numerical algorithms. Then, a composite quadratic Lyapunov function is constructed from a family of quadratic functions (without additional parameters) and is natural extensions of quadratic function [15,32]. Three types of composite quadratic Lyapunov functions, the max of quadratics, the min of quadratics and the convex hull of quadratics are used for deriving matrix conditions of stabilization and for constructing switching law [15]. However, a common Lyapunov function may be difficult to find or may not exist. To overcome this difficulty, a multiple Lyapunov function approach has been considered in [7,31]. In addition, some researchers consider the viability by using a switched Lyapunov function [10] and a smooth control Lyapunov function [5,18,20]. Valentino and Faria investigate the viability of switched systems by using Takagi-Sugeno fuzzy modelling [29]. Due to the intrinsic discontinuity and nonlinearity of switched systems, it is not necessary to restrict to a smooth Lyapunov function. Bacciotti and Ceragioli study the stability and stabilization of discontinuous systems by using a nonsmooth Lyapunov function in [4]. Hu and Ma investigate the viability of switched linear systems by the tool of a nonsmooth Lyapunov function in [15]. It turned out to be very effective in dealing with some constrained control systems. Then, the method of [15] is extended to the uncertain switched systems in [32,33].
The aforementioned results on the viability of switched systems have several limitations. Firstly, most of the existing results are developed for switched linear systems [15,16,19,32,33] and viability of switched nonlinear systems has not been adequately studied [20,30]. Secondly, these results are established based on the existence of a common quadratic Lyapunov function or composite quadratic Lyapunov function [15,16,32]. These conditions could be rather conservative especially when the number of subsystems is large. Due to the discontinuous of switched systems, a nonsmooth Lyapunov function may work better than a smooth Lyapunov function. Although several forms of nonsmooth Lyapunov functions have been considered in [4,15], most of the existing methods are developed for some special forms of switched systems. Lastly, there is a lack of systematic way to analyze sliding motions. In fact, viability analysis without considering sliding motions may lead to incorrect conclusions about the actual behavior of switched systems.
In order to overcome these limitations, we try to consider the viability of switched nonlinear systems excluding and including sliding motions by using the tool of a nonsmooth Lyapunov function. Since the piecewise smooth function is a more broad class of nonsmooth functions, we study the viability and attraction of switched nonlinear systems where Lyapunov function is piecewise smooth, and discuss the condition of the viability and attraction for the level set of piecewise smooth function. Our main contribution lies in a general procedure proposed for the construction of a viable set and systematic consideration of sliding motions. In contrast to the existing results, the framework and approach of our paper are suited for the general switched nonlinear systems. The rest of the paper is organized as follows: Section 2 states some necessary preliminaries. Section 3 discusses the viability and attraction for switched systems based on the piecewise smooth Lyapunov function, and a sufficient condition for viable set and region of attraction is presented. Moreover, we consider the viability for switched systems involving possible sliding motions, and the corresponding sufficient condition is obtained. In Section 4, we take two special classes of piecewise smooth functions as Lyapunov functions, related conditions for viability are developed.

2.
Preliminaries. We consider the following switched nonlinear systemṡ where x ∈ R n denotes the continuous state of system, f i : R n → R n denotes the vector field of the subsystem, and σ(t) denotes the switching law that determines the active subsystem at time t ≥ 0. We assume that the vector field of each subsystem is locally Lipschitzian continuous on R n . In addition, the origin is assumed to be a common equilibrium for all the subsystems. We first introduce a notion of piecewise smooth function. (ii) h is continuously differentiable on D i , i ∈ I; (iii) ∂D i is a differentiable manifold for each i ∈ I and ∂D = i∈I ∂D i , where ∂D i denotes the boundary of D i .
In Definition 2.1, each partition D i is not required to be connected. In addition, since each D i is a full-dimensional open set in R n , its boundary ∂D i must have measure zero. This means that µ(∂D i ) = 0. h i : clD i → R denotes the restriction of the function h to the set clD i . By Definition 1, h i is continuously differentiable on D i . For a piecewise smooth function h, the index set is said to be the active index set of h at x.
A useful property of the piecewise smooth function is the existence of directional derivative anywhere in the state space as stated in the following lemma.
Lemma 2.2. [26]A piecewise smooth function h in the definition 1 is directionally differentiable on R n , i.e. for any x, η ∈ R n , the limit We next give some notions relevant to nonsmooth analysis.
[9] Let f : R n → R be locally Lipschitzian and let D f denote the set where f is differentiable. The subdifferential in the sense of Clarke of f at x, denoted by ∂f (x), is defined as The Clarke subdifferential is a generalization for the notion of the classical gradient. When f is continuously differentiable, its Clarke subdifferential happens to be a singleton, i.e. ∂f (x) = {∇f (x)}.
Based on the Clarke subdifferential, there are a mean-value theorem and a chain rule for a locally Lipschitzian function.
Lemma 2.4. (mean-value theorem, see [9])Let f : R n → R be locally Lipschitzian. Then, for any x 1 , x 2 ∈ R n there existsx on the line-segment with x 1 and x 2 as its end points and ξ ∈ ∂f (x) such that Lemma 2.5. (chain rule, see [9]) Suppose that F : R m → R n and g : R n → R are locally Lipschitzian. Then, the composite function f (x) = g(F (x)) is locally Lipschitzian and its Clarke subdifferential has the form of In addition, we need to give the definition of viable set which will be used later in the paper.
Definition 2.6. [9] A set K ⊂ R n is said to be viable under the system (2.1) if for any initial point x 0 ∈ K, the solution x(t) of (2.1) remains in K for any t > 0. Moreover, K is said to be a region of attraction if lim t→∞ x(t) = 0.
3. Viability and attraction. In the study of switched systems, sliding motions play an important role as they can ideally represent some complicated dynamics found in the real world. For this reason, we consider the viability and attraction for switched nonlinear systems excluding and including sliding motions, respectively. In this section, the approach of Lyapunov function is used to research the viability and attraction for the system (2.1). For a general Lyapunov function V : R n → R, we define the level set as follows where r > 0. To simplify notation, Ω V,1 is replaced by Ω V in the rest of the paper.
In what follows we proceed to discuss the viability and attraction of the level set Ω V for system (2.1) excluding and including sliding motions.
3.1. Excluding sliding motions. We consider switched nonlinear systems have no sliding motions, then the trajectories of the system on the switching surface are as shown in Figure 1. Based on the viability theory, we determine the viability and attraction for the level set of the system (2.1). A sufficient condition is proposed by using the tools of piecewise smooth Lyapunov function. If system (2.1) admits a piecewise smooth Lyapunov function, then it can be used to construct a stabilizing switching law. The main idea is to select the subsystem along whose vector field the piecewise smooth Lyapunov function decreases at the fastest rate. The switching law is constructed by the following formula: σ(x) is a set-valued mapping. Let |σ(x)| denote the number of elements in the set σ(x). If |σ(x)| > 1 , we can take any subsystem inσ(x) as the active subsystem. The switching lawσ(x) designed above is dependent on the state of the system. Theorem 3.1. Let V : R n → R be piecewise smooth with piece functions V i (i ∈ I) and piecewise regions S i (i ∈ I). I is a finite index set. Suppose that V is positive definite and Ω V is bounded. For any x ∈ Ω V , there exists an index set Then, Ω V is viable and a subset of the region of attraction for the system (2.1). In other words, for any initial point Proof. We first prove that the set Ω V is viable. For any fixed x ∈ R n , we have two cases as follows. and Case 2: x is on the boundary of some piece regions, i.e.x ∈ loss of generality, we assume that On the other hand, we obtain the following conclusion.
According to the discussion above, for any i ∈ I V (x), there exists Thus, we get the subdifferential ξ < 0 for all ξ ∈ ∂V (x(t)). This means that V is decreasing along one of the subsystems. For any initial point It implies that the set Ω V is viable. We next prove that the set Ω V is attractive. Constructing the following sets: for each j ∈ I and i ∈ Λ. Hence, the set D i is also open for each i ∈ Λ. In addition, the boundaries ∂D i , i ∈ Λ and their union ∂D are all of measure zero. In summary, the sets {D i } i∈Λ are open and disjoint. For any x ∈ D i , we have Given a number > 0, denote According to (3.1) and the definition of the set S , one can obtain that Furthermore, δ > 0 implies that there existst > 0 such that V (x(t)) < for all t >t. This means that lim t→∞ V (x(t)) = 0 if x 0 ∈ Ω V . Let > 0 and let Evidently, the set Ω is compact with 0 / ∈ Ω . Since V is continuous and positive definite, there exists γ ∈ (0, 1) such that V (x(t)) ≥ γ, ∀x ∈ Ω . On the other hand, lim t→∞ V (x(t)) = 0 implies that there exists t 0 such that V (x(t)) < γ for all t > t 0 . This yields that x(t) / ∈ Ω , it means that x(t) < , i.e. lim t→∞ x(t) = 0.This completes the proof of the theorem. Theorem 3.1 gives us a method for determining the viability and attraction of switched nonlinear systems by taking piecewise smooth function as a Lyapunov function. If the system (2.1) has multiple piecewise smooth Lyapunov functions, we can compute the level sets corresponding to each function. By analyzing the inclusion relation of these sets, a larger viable set can be selected.
As a discriminating condition of viability and attraction for switched systems, the formula (3.1) is not very strong. Roughly speaking, the key of viability and attraction analysis is to ensure the piecewise smooth Lyapunov function V decreases along any of trajectories. It is equivalent to the directional derivative at any state along a subsystem less than zero. In fact, this indicates that the energy of the system shall decreases during its evolution along the subsystem. Thus, it ensures the viability and attraction for switched systems. Since there exists the directional derivative in every state space along a subsystem, we only need to verify or calculate the directional derivative along which subsystem is less than zero. For example, switched systems that contain two subsystems as follows: Let V be a piecewise smooth Lyapunov function with piece functions V i and piece regions S i , i = 1, 2. We need to calculate the directional derivatives and The results of viability and attraction are guaranteed if one of the directional derivatives is negative.
As a further interpretation of Theorem 3.1, we consider a special system as followṡ where I is an index set. The number of subsystems is equal to the number of piece regions. Moreover, are satisfied. In other words, the directional derivative decreases at the fastest rate along the subsystemẋ(t) = f i (x) for the points in the region S i . The switching law of system (3.5) is dependent on the state of the system. We construct the switching law as where int(S i ) denotes the interior of S i . It assigns each state to a unique subsystem. If the system (3.5) admits a piecewise smooth Lyapunov function V , and ∇V i (x) T f i (x) < 0 for any x ∈ S i , then the level set Ω V = {x|V (x) ≤ 1} is viable and a subset of the region of attraction for the system (3.5).

3.2.
Including sliding motions. From a practical point of view, sliding motions are very important and unavoidable in switched systems. So we need to pay attention to the sliding motions which occur along trajectories. If the sliding motions occur, then the trajectories of the system on the switching surface are as shown in Figure 2.
More precisely, if we have a nontrivial time interval (t 1 , t 2 ) such thatẋ = f i (x) for almost all t ∈ (t 1 , t 2 ) and i ∈ Λ, then this part of the trajectory is called sliding motions where the velocity of the stateẋ can take any value within the set co{f i , i ∈ Λ}. Thus, sliding motions can only occur on the switching boundaries along the trajectory. Let I sm (x) be the set of indices of subsystems involved in the sliding motions. When sliding motions occur, the velocity satisfies thaṫ α i = 1. The coefficients α i can be determined if the sliding surface equation is known, which can be find in [28].
Roughly speaking, the key problem of viability analysis is to ensure the piecewise smooth Lyapunov function V decreases along one of closed loop trajectory x(t). If we consider the system (2.1) excluding the sliding motions, we haveẋ = f i (x), i ∈ Λ. In this case, we only need to check the directional derivative along the subsystem. If we consider the system (2.1) including the sliding motions, we haveẋ = f i (x), i ∈ Λ. There exists a nontrivial time interval t ∈ (t 1 , t 2 ) such thaṫ for almost all t ∈ (t 1 , t 2 ). In this case, merely looking at DV (x; f k (x)), k ∈ Λ is no longer enough. We need to guarantee that V decreases along the switching boundaries. In other words, we must check for any boundary points.
In what follows, we discuss the main results on the viability and attraction for the system (2.1) which including the sliding motions.
Theorem 3.2. Consider the system (2.1) including the sliding motions. Let V : R n → R be piecewise smooth with piece functions V i (i ∈ I) and piecewise regions S i (i ∈ I). I is a finite index set. Suppose that V is positive definite and Ω V is bounded. For any x ∈ Ω V , there exists an index set I V (x) = {i ∈ I|V (x) = V i (x)} and I sm (x), the following conditions are satisfied, Then, Ω V is viable and a subset of the region of attraction for the system (2.1). In other words, for any initial point x(0) ∈ Ω V , the solution x(t) of (2.1) under the switching lawσ(x) satisfies x(t) ∈ Ω V and lim t→∞ x(t) = 0.
Proof. We first prove that the set Ω V is viable. For a fixed piece region S j , we construct the set D j,i the same as (3.2). For each i ∈ Λ, we define the sets D i = j∈I D j,i and ∂D = i∈Λ ∂D i . The set D j,i is an open set of R n for each j ∈ I and i ∈ Λ. Hence, the set D i is also open for each i ∈ Λ. According to the constructing method, the directional derivative of function V along the subsystemẋ(t) = f i (x) is less than the other subsystemsẋ(t) = f j (x)(j = i, j ∈ Λ) for all points in the set D i . By Theorem 3.1, we only need to focus on the part of trajectory that involves sliding motions. Let (t 1 , t 2 ) be the time interval that sliding motions occur, i.e.
for almost all t ∈ (t 1 , t 2 ). The sliding motions may occur on the following two types of regions: smooth region {S i } i∈I and nonsmooth boundary ∂S = i∈Λ ∂S i . We try to prove that in both cases V satisfies DV (x;ẋ(t)) < 0 for almost all t ∈ (t 1 , t 2 ). Case 1: There exists a piece region S j (j ∈ I) such that x(t) ∈ S j for almost all t ∈ (t 1 , t 2 ). V j is continuously differentiable at x and thus DV (x; η) = ∇V j (x) T η.

It follows that
DV (x;ẋ(t)) = DV j (x; where k∈Ism(x) α k = 1. By the formula (3.7), for all k ∈ I sm (x), we have According to the coefficients of convex combination α k > 0, k ∈ I sm (x), we get the following conclusion Case 2: If the sliding motions occur on nonsmooth boundary, we only need to discuss the case in which the point on both the region boundary ∂S and switching boundary ∂D, i.e. x ∈ ∂S ∩ ∂D. In fact, the case x ∈ ∂S \ ∂D is proved in Theorem 3.1. On the other hand, the case x ∈ ∂D \ ∂S comes back to Case 1. For a fixed x ∈ ∂S ∩ ∂D, we assume that I V (x) = {i 1 , i 2 , ..., i r }. So the following formula holds This means that the function V is decreasing along the sliding motions. For any initial point x(0) ∈ Ω V , we have It indicates that the level set Ω V is viable.
We next prove that the set Ω V is attractive. Given a number > 0, denote According to (3.6) and the definition of the set S , one can obtain that For any x ∈ S ∩ D j , j ∈ Λ, we assume that I * j = {i 1 , i 2 , ..., i p }. Then, there exists δ j1 > 0 for the piecewise region S i1 such that Similarly, there exists δ jp > 0 for the piece region S ip , such that

Thus, we have
Since the sliding motions occur on switching boundaries, we need to consider the subdifferential of the points in the set S ∩ ∂D. It is known that the points of S ∩ ∂D are divided into two parts, one is on the interior of S i , i ∈ I, the other is on the boundary of S. Suppose that I sm (x) = {k 1 , k 2 , ..., k r }. In what follows we discuss the directional derivative.
Since the elements of I and Λ are finite, we denote and such δ exists. Obviously, I V (x) ⊆ I and I * j ⊆ I, according to the discussion above, we have shown that where k ∈ argmin j∈Λ DV (x; f j (x)). The rest of the proof is similar to that of Theorem 3.1. This completes the proof of the theorem.
We have shown that if the system (2.1) admits a piecewise smooth Lyapunov function and satisfies conditions (3.6) and (3.7), then the level set of the Lyapunov function is viable and a subset of the region of attraction for the system (2.1) including sliding motions. According to the proof of Theorem 3.2 and the construction of the sets D i = j∈I D j,i and ∂D = i∈Λ ∂D i , we can also construct the switching law as follows: The level set of the Lyapunov function is viable and a subset of the region of attraction for the system (2.1) under the switching law σ * (x).
Since switched linear systems can be considered as a special form of switched nonlinear systems, the results derived on switched nonlinear systems could be applied to switched linear systems. We consider the following switched linear systemṡ where σ(t) = i(i ∈ Λ) denotes the subsystemẋ(t) = A i x is activated. Matrices A i for i ∈ Λ are referred to as the subsystems of (3.8). We assume that the system (3.8) has one or more unstable subsystems and admits a piecewise smooth function V with piece functions V i (i ∈ I) and piece regions S i (i ∈ I). I is a finite index set. V is positive definite and Ω V is bounded. For any x ∈ Ω V , there exists an index set We construct the switching law as followŝ So we can obtain that Ω V is viable and a subset of the region of attraction for the system (3.8) under the switching lawσ(x). In other words, for any initial point holds, we can obtain that Ω V is viable and a subset of the region of attraction for the system (3.8) involving sliding motions.
4. Special classes of piecewise smooth functions. In this section, we consider two classes of piecewise smooth Lyapunov functions. One is the sum of min-type function and max-type function, the other is minmax-type function. These two classes of piecewise smooth functions are widely used in nonsmooth analysis. We try to find their specific pieces and regions, then present conditions of viability and attraction.
4.1. The sum of min-type function and max-type function. Let us restrict our attention to the piecewise smooth function as follows where U i : R n → R, i ∈ I and W j : R n → R, j ∈ J are continuously differentiable, both I and J are finite index sets. Our aim is to find specific pieces for the function V given in (4.1). Given a pair of indices (s, t) ∈ I × J, define set S st as the following For a fixed x ∈ R n , the index set I × J is denoted by Evidently, ∪ s∈I,t∈J S st = R n and for any x ∈ R n , the index set (I ×J)(x) is nonempty.
Let x ∈ R n be a fixed point. Then, there exist s * ∈ I, t * ∈ J such that x ∈ S s * t * and V (x) = U s * + W t * . In addition, V (x) = U s + W t for any (s, t) ∈ (I × J)(x). Thus, V is a piecewise smooth function with S st as piecewise regions and U s +W t as piecewise functions. By the definitions of index set (I × J)(x) and S st , we introduce the following conclusion. Proposition 1. Let piecewise smooth Lyapunov function V has the form of (4.1). The set Ω V = {x ∈ R n |V (x) ≤ 1}, is bounded. There exists k ∈ Λ such that the following condition holds Then, the set Ω V is viable and a subset of the region of attraction for the system (2.1). In other words, for any initial point x(0) ∈ Ω V , the solution x(t) of (2.1) satisfies x(t) ∈ Ω V and lim t→∞ x(t) = 0.
Proposition 1 provides a condition for the viability and attraction of the system (2.1) excluding the sliding motions. If the sliding motions occur in the system (2.1), the results of viability and attraction can be stated by the following corollary. DV (x; f k (x)) = max Then, the set Ω V is viable and an attraction region for the system (2.1).

4.2.
The minmax-type function. In the research of Lyapunov function for switched systems, both max-type Lyapunov function (see [15,32]) and min-type Lyapunov function (see [15]) are discussed. To our best knowledge, no publications deals with the minmax-type Lyapunov function for switched systems. However, minmax-type function is a wide and important class of piecewise smooth functions. In this subsection, we develop an approach to address the aforementioned problem.
Let us consider a piecewise smooth function as where V ij : R n → R, i ∈ I, j ∈ J are continuously differentiable, I and J are finite index sets. In what follows we try to find their specific pieces for the function V given in (4.3). Given a pair of indices (s, t) ∈ I × J, define set S st as the following: It is easy to see that ∪ s∈I,t∈J S st = R n and V is a piecewise smooth function with S st as piecewise regions and V st as piecewise functions. Given a fixed x ∈ R n , define index sets as follows: By the definitions of J s (x) and I(x), we present a conclusion which can be found in [12]. According to Theorem 3.1 and Lemma 4.2, we obtain a condition of viability and attraction for the system (2.1) on the set Ω V , which V is a piecewise smooth function given in (4.3).
Proposition 2. Let us consider the system (2.1) and piecewise smooth Lyapunov function V given in (4.3). Assume that the set Ω V is bounded and the following condition holds Then, the set Ω V is viable and a subset of the region of attraction for the system (2.1). In other words, for any initial point x(0) ∈ Ω V , the solution x(t) of (2.1) satisfies x(t) ∈ Ω V and lim t→∞ x(t) = 0.
The results extended to the case where the system including sliding motions. DV (x; f k (x)) = max Then, the set Ω V is viable and an attraction region for the system (2.1).
For the other types of piecewise smooth Lyapunov functions, the corresponding determining conditions and viable sets can be developed similarly.
Then, the switched systems are stable under the switching law σ. Figure 4 shows the state responses of the systems starting from z = [2, −3] T under the switching law σ. Conclusions. In the paper, the problem of viability and attraction for switched nonlinear systems has been investigated. Sufficient conditions are derived to ensure viability and attraction of switched nonlinear systems for both excluding and including sliding motions. It implies that the level set of Lyapunov function for switched systems excluding sliding motions is a viable set if the directional derivative of piecewise smooth Lyapunov function along one of the subsystems is less than zero. It also shows that the level set of switched systems including sliding motions is a viable set under an additional condition on the subsystems involved in the sliding motions. Since the piecewise smooth functions are widely used in nonsmooth analysis and control, the results can be applied to the practical problems. As an application of the theoretical results, taking the sum of min-type function and max-type function, minmax-type function as Lyapunov functions, viability and attraction conditions are developed respectively.