LoginSignup
0
0

More than 3 years have passed since last update.

【初心者向け】集合論①部分集合(subset)と真部分集合(proper subset)について。

Last updated at Posted at 2020-03-27

【Rで球面幾何学】等比数列(算術数列)① 数直線(Number Line)概念の導入(Introduction)について。
数直線010.png
上掲の投稿では、以下の概念の導入(Introduce)を余儀なくされました。

  1. 自然数列(Natural sequence)は整数列(Integer sequence)の真部分集合(proper subset)として存在する。
  2. 偶数列(Even sequence)や奇数列(Odd sequence)もまた整数列の真部分集合として存在する。

まぁ、一連の投稿の舞台に選んだ加算直積可能世界(The Countable and Productable Sets)におけるSets(単数形Set)概念の大源流でもあるので無碍には出来ないのです。
部分集合 - Wikipedia
集合の記号の意味まとめ

集合 A の要素がすべて集合 B の要素でもあるとき、すなわち、
∀x(x∈A→x∈B)
が成り立つとき、A は B の部分集合であるといい、
A⊆B
で表す。A が B の部分集合であることを
AはBに部分集合として含まれるcontained;包含される)」
AはBに包まれるincluded;包摂あるいは内包される)」
などということもある。
またこのときBはAの上位集合superset)であるということもある。
要するにAは集合Bの要素(element)でもある。

B以外の集合でBの部分集合であるようなものは、Bの真部分集合(proper subset)あるいは狭義strict;強い意味で)の部分集合と呼ばれる。すなわち、集合Aが集合Bの真部分集合であるとはA⊆BかつA≠Bが成り立つことである。AがBの真部分集合であることを
A⊂B
で表す。

#整数列(-6~6)
> Z0<-seq(-6L,6L,by=1L)
> Z0
 [1] -6 -5 -4 -3 -2 -1  0  1  2  3  4  5  6

#自然数列(1~6)
> N0<-seq(1L,6L,by=1L)
> N0
[1] 1 2 3 4 5 6

#偶数列(1~6)
> E0<-seq(-6L,6L,by=2L)
> E0
[1] -6 -4 -2  0  2  4  6

#奇数列(1~6)
> O0<-seq(-5L,5L,by=2L)
> O0
[1] -5 -3 -1  1  3  5

#intersect(A,B)関数
#両方にふくまれている文字列を抽出する(Aにもあって、Bにもある)
> intersect(Z0,N0)
[1] 1 2 3 4 5 6
> intersect(Z0,E0)
[1] -6 -4 -2  0  2  4  6
> intersect(Z0,O0)
[1] -5 -3 -1  1  3  5

#setdiff(A,B)関数
#Aのみにふくまれている文字列を抽出する(Aにあって、Bにない)
> setdiff(Z0,N0)
[1] -6 -5 -4 -3 -2 -1  0
> setdiff(Z0,E0)
[1] -5 -3 -1  1  3  5
> setdiff(Z0,O0)
[1] -6 -4 -2  0  2  4  6

#setdiff(B,A)関数
#Bのみにふくまれている文字列を抽出する(Bにあって、Aにない)
> setdiff(N0,Z0)
integer(0)#長さ0の空集合
> setdiff(E0,Z0)
integer(0)#長さ0の空集合
> setdiff(O0,Z0)
integer(0)#長さ0の空集合

#全て真部分集合関係なのでこうなる。

Rでの集合操作については、こんなサイトも。
Rで集合操作を色々やっておく

#集合を直積する関数
write.direct.product <- function(x,y){
  e <- expand.grid(x,y)
  m <- mapply(function(x,y){paste("(",x,",",y,")",sep="")},e[,1],e[,2])
  return(paste("{",paste(m,collapse=","),"}",sep=""))
}
#動作例
> write.direct.product(1:3,4:6)
[1] "{(1,4),(2,4),(3,4),(1,5),(2,5),(3,5),(1,6),(2,6),(3,6)}"

#冪集合を生成する関数。
write.list <- function(list){
  write.vector <- function(vector){
    return(paste("{",paste(vector,collapse=","),"}",sep=""))
  }
  write.list.intern <- function(list){
    ifelse(is.list(list),Reduce(function(init,x){paste(init,write.list.intern(x),sep="")},list,""),write.vector(list))
  }
  gsub("NA","",paste("{",gsub("\\}\\{","\\},\\{",write.list.intern(list)),"}",sep=""))
}
#動作例
> write.list(list("a","b","c","d",list(1:10,list(1,2))))
[1] "{{a},{b},{c},{d},{1,2,3,4,5,6,7,8,9,10},{1},{2}}"

とりあえず以下続報…

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0