Realsets

jordi.saludes

Multilingual Online Translation

Examples

A closed interval:

? RealSet.cc_interval(1,4); 
[ 1 :: 4 ]

A single point:

? RealSet.singleton(1)
{1}

Union

Union is supported with intervals and can be nested :

? I = RealSet.co_interval(1, 4)
? J = RealSet.co_interval(4, 5)
? M = RealSet.oc_interval(7, 8)
? I.union(J).union(M)
[ 1 :: 5 [ ∪ ] 7 :: 8 ]

Intersection

? I.intersection(J)
()
? I.intersection(RealSet.cc_interval(2,5))
[ 2 :: 4 [

Queries

Is a point in the set?

? I = RealSet.oo_interval(1, 3)
? 2 in I
True
? 3 in I
False

Is a set discrete (i.e: does not contain intervals)?

? RealSet.oo_interval(0,1).discrete
False
? RealSet(points=(1,2,3)).discrete
True

Size of a discrete is the number of points:

? RealSet(points=range(5)).size
5
? RealSet.oo_interval(0,3).size
+Infinity

A is subset of B

? A = RealSet.oo_interval(0,1)
? B = RealSet.cc_interval(0,1)
? RealSet().subset(A)
True
? B.subset(A)
False
? A.subset(B)
True
? A.subset(A)
True
? A.subset(A, proper=True)
False

Return the infimum (greatest lower bound)

? RealSet(points=range(3)).infimum()
0
? RealSet.oo_interval(1,3).infimum()
1

The opposite of a set: –A = {-x | x ∈ A}

? -RealSet.oo_interval(1,2)
] -2 :: -1 [

Return the supremum (least upper bound)

? RealSet(points=range(3)).supremum()
2
? RealSet.oo_interval(1,3).supremum()
3

The complementary of a set:

? RealSet.oo_interval(2,3).complement()
] -Infinity :: 2 ] ∪ [ 3 :: +Infinity [
? RealSet(points=range(3)).complement()
] 0 :: 1 [ ∪ ] 1 :: 2 [ ∪ ] 2 :: +Infinity [ ∪ ] -Infinity :: 0 [

The set difference of A and B: \{x \in A, x\notin B\}

? I = RealSet.oo_interval(2,+Infinity)
? J = RealSet.oo_interval(-Infinity, 5)
? I.setdiff(J)
[ 5 :: +Infinity [
? J.setdiff(I)
] -Infinity :: 2 ]