[英]How to define a coding function for all finite subsets of N?
For working with countable sets I have to define a coding function of all finite subsets of N (natural numbers).为了处理可数集,我必须定义 N(自然数)的所有有限子集的编码 function。 How can I do this?
我怎样才能做到这一点? I started with finding a function for all natural numbers: f(n)=1+2+...+(n-1)+n.
我开始为所有自然数找到一个 function:f(n)=1+2+...+(n-1)+n。 But how can I express a coding function for all possible subsets of f?
但是我如何为 f 的所有可能子集表达编码 function? And how can I say that f contains all finite natural numbers?
我怎么能说 f 包含所有有限自然数呢? I can not say n=infinity-1 because infinity-1 is still infinity.
我不能说 n=infinity-1 因为 infinity-1 仍然是无穷大。 Is there a formal way constitute all finite natural numbers?
有没有一种形式化的方式来构成所有的有限自然数?
If I understand you correctly, you wish to define a function that would count through all finite subsets of N. One way to achieve this is to use the 1
s in the binary representation of a number n
to encode the elements of f(n)
, that is f(n) = {k \in N | the k-th binary digit of n is 1}
如果我理解正确的话,您希望定义一个 function 来计算 N 的所有有限子集。实现此目的的一种方法是使用数字
n
的二进制表示中的1
来编码f(n)
的元素, 即f(n) = {k \in N | the k-th binary digit of n is 1}
f(n) = {k \in N | the k-th binary digit of n is 1}
. f(n) = {k \in N | the k-th binary digit of n is 1}
。
In programming terms, say for instance in Python (here I'm using lists to represent subsets of N) this would look like在编程术语中,例如在 Python 中(这里我使用列表来表示 N 的子集)这看起来像
def f(n):
result = []
k = 1
while n != 0:
if n % 2 == 1:
result.append(k)
k += 1
n //= 2
return result
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.