First time here? Check out the FAQ!

Ask Your Question
0

How th work with enumerable and infinite set

asked 10 years ago

anonymous user

Anonymous

updated 2 years ago

tmonteil gravatar image

Hello,

I am trying to do following: construct the set B that is the difference between QQ and the set of the prime numbers (note that B is a countable set). Within Sage, I tried the following

X = Set(QQ)
Y = Set(Primes())
B = Set(X.difference(Y))
B.cardinality()

then I press evaluate. I am expecting that the cardinality of B is +Infinity. But Sage does not bring any result.

I tried this also initializing B like

B = InfiniteEnumeratedSets(RR).

Could anybody please give me a hint what I am doing wrong?

Thank you very much and regards.

vbk

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
0

answered 10 years ago

Luca gravatar image

You just found a bug in Sage. Sage does not have enough knowledge to know that the set of rationals that are not prime numbers is infinite. If there was no bug, you'd have an error saying something like "Sage cannot compute the cardinality of B".

However, if you type B.cardinality??, you'll notice that what the function does is simply return len(list(self)), i.e. it constructs the list of ALL rationals that are not prime numbers, and returns its length. You get no answer because it's entered an infinite loop.

Preview: (hide)
link

Comments

Luca gravatar imageLuca ( 10 years ago )

Thank you for the reply. vbk

Vasile gravatar imageVasile ( 10 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 10 years ago

Seen: 425 times

Last updated: Jul 19 '14