Totally Ordered Finite Sets#
AUTHORS:
Stepan Starosta (2012): Initial version
- class sage.sets.totally_ordered_finite_set.TotallyOrderedFiniteSet(elements, facade=True)#
Bases:
sage.sets.finite_enumerated_set.FiniteEnumeratedSet
Totally ordered finite set.
This is a finite enumerated set assuming that the elements are ordered based upon their rank (i.e. their position in the set).
INPUT:
elements
– A list of elements in the setfacade
– (default:True
) ifTrue
, a facade is used; it should be set toFalse
if the elements do not inherit fromElement
or if you want a funny order. See examples for more details.
See also
EXAMPLES:
sage: S = TotallyOrderedFiniteSet([1,2,3]) sage: S {1, 2, 3} sage: S.cardinality() 3
By default, totally ordered finite set behaves as a facade:
sage: S(1).parent() Integer Ring
It makes comparison fails when it is not the standard order:
sage: T1 = TotallyOrderedFiniteSet([3,2,5,1]) sage: T1(3) < T1(1) False sage: T2 = TotallyOrderedFiniteSet([3,var('x')]) sage: T2(3) < T2(var('x')) 3 < x
To make the above example work, you should set the argument facade to
False
in the constructor. In that case, the elements of the set have a dedicated class:sage: A = TotallyOrderedFiniteSet([3,2,0,'a',7,(0,0),1], facade=False) sage: A {3, 2, 0, 'a', 7, (0, 0), 1} sage: x = A.an_element() sage: x 3 sage: x.parent() {3, 2, 0, 'a', 7, (0, 0), 1} sage: A(3) < A(2) True sage: A('a') < A(7) True sage: A(3) > A(2) False sage: A(1) < A(3) False sage: A(3) == A(3) True
But then, the equality comparison is always False with elements outside of the set:
sage: A(1) == 1 False sage: 1 == A(1) False sage: 'a' == A('a') False sage: A('a') == 'a' False
Since trac ticket #16280, totally ordered sets support elements that do not inherit from
sage.structure.element.Element
, whether they are facade or not:sage: S = TotallyOrderedFiniteSet(['a','b']) sage: S('a') 'a' sage: S = TotallyOrderedFiniteSet(['a','b'], facade = False) sage: S('a') 'a'
Multiple elements are automatically deleted:
sage: TotallyOrderedFiniteSet([1,1,2,1,2,2,5,4]) {1, 2, 5, 4}
- Element#
alias of
TotallyOrderedFiniteSetElement
- le(x, y)#
Return
True
if \(x \le y\) for the order ofself
.EXAMPLES:
sage: T = TotallyOrderedFiniteSet([1,3,2], facade=False) sage: T1, T3, T2 = T.list() sage: T.le(T1,T3) True sage: T.le(T3,T2) True
- class sage.sets.totally_ordered_finite_set.TotallyOrderedFiniteSetElement(parent, data)#
Bases:
sage.structure.element.Element
Element of a finite totally ordered set.
EXAMPLES:
sage: S = TotallyOrderedFiniteSet([2,7], facade=False) sage: x = S(2) sage: print(x) 2 sage: x.parent() {2, 7}