Ask Your Question
0

How th work with enumerable and infinite set

asked 2014-07-18 15:51:01 +0200

anonymous user

Anonymous

updated 2023-01-09 23:59:34 +0200

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2014-07-18 16:25:06 +0200

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.

edit flag offensive delete link more

Comments

Luca gravatar imageLuca ( 2014-07-18 16:37:45 +0200 )edit

Thank you for the reply. vbk

Vasile gravatar imageVasile ( 2014-07-21 08:42:06 +0200 )edit

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: 2014-07-18 15:51:01 +0200

Seen: 303 times

Last updated: Jul 19 '14