Skip to content

Commit

Permalink
Add special cases for disjointness and inclusion involving universe (#…
Browse files Browse the repository at this point in the history
…2964)

* add special cases for disjointness and inclusion involving universe

* Update src/ConcreteOperations/issubset.jl

Co-authored-by: Christian Schilling <[email protected]>

* fix ambiguities

Co-authored-by: Marcelo <[email protected]>
Co-authored-by: Christian Schilling <[email protected]>
  • Loading branch information
3 people authored May 14, 2022
1 parent f390b6c commit 508d38d
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/ConcreteOperations/isdisjoint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1373,3 +1373,22 @@ end
@inline function _det(L1::Line2D, L2::Line2D)
@inbounds det = L1.a[1] * L2.a[2] - L1.a[2] * L2.a[1]
end

for ST in (AbstractZonotope, AbstractSingleton)
@eval @commutative function isdisjoint(C::CartesianProduct{N, <:LazySet, <:Universe}, Z::$(ST)) where N
X = C.X
Zp = project(Z, 1:dim(X))
return isdisjoint(X, Zp)
end

@eval @commutative function isdisjoint(C::CartesianProduct{N, <:Universe, <:LazySet}, Z::$(ST)) where N
Y = C.Y
Zp = project(Z, dim(C.X)+1:dim(C))
return isdisjoint(Y, Zp)
end

# disambiguation
@eval @commutative function isdisjoint(C::CartesianProduct{N, <:Universe, <:Universe}, Z::$(ST)) where N
return false
end
end
19 changes: 19 additions & 0 deletions src/ConcreteOperations/issubset.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1091,3 +1091,22 @@ function ⊆(Z::AbstractZonotope, H::AbstractHyperrectangle, witness::Bool=false
end
return true
end

for ST in (AbstractZonotope, AbstractSingleton, LineSegment)
@eval function (Z::$(ST), C::CartesianProduct{N, <:LazySet, <:Universe}) where N
X = C.X
Zp = project(Z, 1:dim(X))
return (Zp, X)
end

@eval function (Z::$(ST), C::CartesianProduct{N, <:Universe, <:LazySet}) where N
Y = C.Y
Zp = project(Z, dim(C.X)+1:dim(C))
return (Zp, Y)
end

# disambiguation
@eval function (Z::$(ST), C::CartesianProduct{N, <:Universe, <:Universe}) where N
return true
end
end

0 comments on commit 508d38d

Please sign in to comment.