Returns the intersection of two objects inheriting from class Set.

setintersect(x, y)

# S3 method for Interval
setintersect(x, y)

# S3 method for ConditionalSet
setintersect(x, y)

# S3 method for UnionSet
setintersect(x, y)

# S3 method for ComplementSet
setintersect(x, y)

# S3 method for ProductSet
setintersect(x, y)

# S3 method for Set
&(x, y)

Arguments

x, y

Set

Value

A Set consisting of elements in both x and y.

Details

The intersection of two sets, \(X, Y\), is defined as the set of elements that exist in both sets, $$X \cap Y = \{z : z \epsilon X \quad and \quad z \epsilon Y\}$$ In the case where no elements are common to either set, then the empty set is returned.

The intersection of two ConditionalSets is defined by combining their defining functions by an 'and', &, operator. See examples.

The intersection of fuzzy and crisp sets first coerces fuzzy sets to crisp sets by finding their support.

See also

Other operators: powerset(), setcomplement(), setpower(), setproduct(), setsymdiff(), setunion()

Examples

# intersection of two sets

Set$new(-2:4) & Set$new(2:5)
#> {2, 3, 4} 
setintersect(Set$new(1, 4, "a"), Set$new("a", 6))
#> {a} 
Set$new(1:4) & Set$new(5:7)
#>

# intersection of two intervals

Interval$new(1, 10) & Interval$new(5, 15)
#> [5,10] 
Interval$new(1, 2) & Interval$new(2, 3)
#> {2,...,2} 
Interval$new(1, 5, class = "integer") &
  Interval$new(2, 7, class = "integer")
#> {2, 3, 4, 5} 

# intersection of mixed set types

Set$new(1:10) & Interval$new(5, 15)
#> {10, 5,...,8, 9} 
Set$new(5, 7) & Tuple$new(6, 8, 7)
#> {7} 

# Ignores membership of FuzzySet

FuzzySet$new(1, 0.1, 2, 0.5) & Set$new(2:5)
#> {2} 

# intersection of conditional sets

ConditionalSet$new(function(x, y) x >= y) &
  ConditionalSet$new(function(x, y) x == y)
#> {x ∈ 𝕍, y ∈ 𝕍 : x >= y & x == y} 
ConditionalSet$new(function(x) x == 2) &
  ConditionalSet$new(function(y) y == 3)
#> {x ∈ 𝕍, y ∈ 𝕍 : x == 2 & y == 3} 

# But be careful not to make an empty set

ConditionalSet$new(function(x) x == 2) &
  ConditionalSet$new(function(x) x == 3)
#> {x ∈ 𝕍 : x == 2 & x == 3}