# Complement

Note that the complement of a convex set is generally not convex. Hence this set type is not part of the convex-set family `ConvexSet`

.

`LazySets.Complement`

— Type`Complement{N, S<:ConvexSet{N}} <: LazySet{N}`

Type that represents the complement of a set, that is the set

\[Y = \{y ∈ \mathbb{R}^n : y ∉ X\},\]

and it is often denoted with the $C$ superscript, $Y = X^C$.

**Fields**

`X`

– set

**Notes**

Since `X`

is assumed to be closed, unless `X`

is empty or the universe, its complement is open (i.e., not closed). If `X`

is empty, the universe, or a half-space, its complement is convex.

The complement of the complement is the original set again.

**Examples**

```
julia> B = BallInf(zeros(2), 1.);
julia> C = Complement(B)
Complement{Float64, BallInf{Float64, Vector{Float64}}}(BallInf{Float64, Vector{Float64}}([0.0, 0.0], 1.0))
julia> Complement(C)
BallInf{Float64, Vector{Float64}}([0.0, 0.0], 1.0)
```

`LazySets.dim`

— Method`dim(C::Complement)`

Return the dimension of the complement of a set.

**Input**

`C`

– complement of a set

**Output**

The dimension of the complement of a set.

`Base.:∈`

— Method`∈(x::AbstractVector, C::Complement)`

Check whether a given point is contained in the complement of a set.

**Input**

`x`

– point/vector`C`

– complement of a set

**Output**

`true`

iff the vector is contained in the complement.

**Algorithm**

\[ x ∈ X^C ⟺ x ∉ X\]

`Base.isempty`

— Method`isempty(C::Complement)`

Return if the complement of a set is empty or not.

**Input**

`C`

– complement of a set

**Output**

`false`

unless the original set is universal.

**Algorithm**

We use the `isuniversal`

method.

The concrete complement can be computed with the function `complement`

(mind the lowercase, as it is usual for functions).

`LazySets.constraints_list`

— Method`constraints_list(C::Complement)`

Return the list of constraints of the complement of a set.

**Input**

`C`

– lazy set complement

**Output**

A vector of linear constraints.

**Notes**

The method requires that the list of constraints of the complemented set can be obtained. Then, each constraint is complemented and returned in the output array. The set union of such array corresponds to the concrete set complement.