《机器学习》(西瓜书)---周志华习题1.2学习记录

旨在交流和学习,我自学,又没有好的交流方式,于是我想到了在csdn上写博客

西瓜书习题1.2

题目内容:
与使用单个合取式来进行假设表示相比,使用“析合范式”将使得假设空间具有更强的表达能力,例如:

好瓜←→ ((色泽=*)∧(根蒂=蜷缩)∧(敲声=*))∨((色泽=乌黑)∧(根蒂=*)∧(敲声=沉闷))

会把“(色泽=青绿)∧(根蒂=蜷缩)∧(敲声=清脆)”以及“(色泽=青绿)∧(根蒂=蜷缩)∧(敲声=清脆)”都分类为“好瓜”。若使用最多包含k个合取式的析合范式来表达下表西瓜分类问题的假设空间,试估算共有多少中可能的假设。

表1 西瓜数据集

编号色泽根蒂敲声是否是好瓜
1青绿蜷缩浊响
2乌黑蜷缩浊响
3青绿硬挺清脆
4乌黑稍蜷沉闷

题面解析

这题目本身好难理清,若不懂得其中设计到的概念根本无从下手。“单个合取式”,“析合范式”,‘∨’ ‘∧’ ‘←→’是离散数学上的逻辑表达式和逻辑运算符。
假设空间hypothesis space):空间的意思就是集合,若想表示假设空间,找出该集合的所有子集即可。假设空间中的子集包括 空集,1维子集,2维子集,…n(n集合的最大单子集数)维子集。
举例,集合S=[1,2,3,4,5] 1维子集,即为,S→S的映射[1,2,3,4,5],S集合所在假设空间的2维子集为S⊗S→S的映射[^1][(1,1),(1,2),(1,3),…,(5,3),(5,4),(5,5)]

S⊗S⊗S⊗S⊗S→S的映射[(1,1,1,1,1),(1,1,1,1,2),…,(5,5,5,5,4),(5,5,5,5,5)]

下午又考虑到,其实像(1,1,1,1,1)这样的子集的确是假设空间的一个子集,但是实际却没有意义,比如,你说什么是好瓜,你把其中一种可能,罗列五次,即k=5的析合范式,与k=1的合取式是等价的。
k=5的析合范式

((色泽=青绿)∧(根蒂=蜷缩)∧(敲声=清脆))((色泽=青绿)∧(根蒂=蜷缩)∧(敲声=清脆))((色泽=青绿)∧(根蒂=蜷缩)∧(敲声=清脆))((色泽=青绿)∧(根蒂=蜷缩)∧(敲声=清脆))((色泽=青绿)∧(根蒂=蜷缩)∧(敲声=清脆))

与k=1的合取式,是等价的

(色泽=青绿)∧(根蒂=蜷缩)∧(敲声=清脆)

与k=2,3,4也是等价的,
所以上面举例集合S=[1,2,3,4,5] 1维子集,即为,S→S的映射[1,2,3,4,5],S集合所在假设空间的2维子集为S⊗S→S的映射[(1,2),(1,3),(1,4),(1,5),(2,3),(2,4),(2,5),(3,4),(3,5),(4,5)]因为(i,j)与(j,i)所代表的k=2析合范式是等价的

S⊗S⊗S⊗S⊗S→S的映射[(1,2,3,4,5)]
我在解题思路中并没有使用通配符星号,因为我发觉这样会带来不必要的计算,并且,在后面还要去掉所谓的冗余的情况。
这里S集(类比与上面的举例)为2x3x3=18个一维子集,并不考虑通配符的情况,这个问题我考虑了好久,出现通配符的冗余,很困难摒除冗余。若不考虑通配符,问题反而变得简单起来。
[a1b1c1,a1b1c2,a1b1c3,a1b2c1,a1b2c2,a1b2c3,a1b3c1,a1b3c2,a1b3c3,
a2b1c1,a2b1c2,a2b1c3,a2b2c1,a2b2c2,a2b2c3,a2b3c1,a2b3c2,a2b3c3]
其中

123
a色泽=青绿色泽=乌黑----
b根蒂=蜷缩根蒂=稍蜷根蒂=硬挺
c敲声=浊响敲声=清脆敲声=沉闷

把上集合简化为[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]
k=1,时所有的析合式为:
[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18]
k=2,时,所有的析合范式为:
[(1,2),(1,3),(1,4),(1,5),…,(1,17),(1,18),(2,3),(2,4),(2,5),…(2,18),…,(16,17),(16,17),(16,18),(17,18)] 所有可能的析合范式的个数为,17+16+15+…+3+2 即为152
k=3时,[(1,2,3),(1,2,4),(1,2,5),…(1,3,4),(1,3,5),(1,3,6).(1,3,7),…(1,16,17)

result=0
for i in range(1,17):
    for j in range((i+1),19):
        for k in range((j+1),19):
            print((i,j,k))
            result=result+1

print(result)

运行结果

(1, 2, 3)
(1, 2, 4)
(1, 2, 5)
(1, 2, 6)
(1, 2, 7)
(1, 2, 8)
(1, 2, 9)
(1, 2, 10)
(1, 2, 11)
(1, 2, 12)
(1, 2, 13)
(1, 2, 14)
(1, 2, 15)
(1, 2, 16)
(1, 2, 17)
(1, 2, 18)
(1, 3, 4)
(1, 3, 5)
(1, 3, 6)
(1, 3, 7)
(1, 3, 8)
(1, 3, 9)
(1, 3, 10)
(1, 3, 11)
(1, 3, 12)
(1, 3, 13)
(1, 3, 14)
(1, 3, 15)
(1, 3, 16)
(1, 3, 17)
(1, 3, 18)
(1, 4, 5)
(1, 4, 6)
(1, 4, 7)
(1, 4, 8)
(1, 4, 9)
(1, 4, 10)
(1, 4, 11)
(1, 4, 12)
(1, 4, 13)
(1, 4, 14)
(1, 4, 15)
(1, 4, 16)
(1, 4, 17)
(1, 4, 18)
(1, 5, 6)
(1, 5, 7)
(1, 5, 8)
(1, 5, 9)
(1, 5, 10)
(1, 5, 11)
(1, 5, 12)
(1, 5, 13)
(1, 5, 14)
(1, 5, 15)
(1, 5, 16)
(1, 5, 17)
(1, 5, 18)
(1, 6, 7)
(1, 6, 8)
(1, 6, 9)
(1, 6, 10)
(1, 6, 11)
(1, 6, 12)
(1, 6, 13)
(1, 6, 14)
(1, 6, 15)
(1, 6, 16)
(1, 6, 17)
(1, 6, 18)
(1, 7, 8)
(1, 7, 9)
(1, 7, 10)
(1, 7, 11)
(1, 7, 12)
(1, 7, 13)
(1, 7, 14)
(1, 7, 15)
(1, 7, 16)
(1, 7, 17)
(1, 7, 18)
(1, 8, 9)
(1, 8, 10)
(1, 8, 11)
(1, 8, 12)
(1, 8, 13)
(1, 8, 14)
(1, 8, 15)
(1, 8, 16)
(1, 8, 17)
(1, 8, 18)
(1, 9, 10)
(1, 9, 11)
(1, 9, 12)
(1, 9, 13)
(1, 9, 14)
(1, 9, 15)
(1, 9, 16)
(1, 9, 17)
(1, 9, 18)
(1, 10, 11)
(1, 10, 12)
(1, 10, 13)
(1, 10, 14)
(1, 10, 15)
(1, 10, 16)
(1, 10, 17)
(1, 10, 18)
(1, 11, 12)
(1, 11, 13)
(1, 11, 14)
(1, 11, 15)
(1, 11, 16)
(1, 11, 17)
(1, 11, 18)
(1, 12, 13)
(1, 12, 14)
(1, 12, 15)
(1, 12, 16)
(1, 12, 17)
(1, 12, 18)
(1, 13, 14)
(1, 13, 15)
(1, 13, 16)
(1, 13, 17)
(1, 13, 18)
(1, 14, 15)
(1, 14, 16)
(1, 14, 17)
(1, 14, 18)
(1, 15, 16)
(1, 15, 17)
(1, 15, 18)
(1, 16, 17)
(1, 16, 18)
(1, 17, 18)
(2, 3, 4)
(2, 3, 5)
(2, 3, 6)
(2, 3, 7)
(2, 3, 8)
(2, 3, 9)
(2, 3, 10)
(2, 3, 11)
(2, 3, 12)
(2, 3, 13)
(2, 3, 14)
(2, 3, 15)
(2, 3, 16)
(2, 3, 17)
(2, 3, 18)
(2, 4, 5)
(2, 4, 6)
(2, 4, 7)
(2, 4, 8)
(2, 4, 9)
(2, 4, 10)
(2, 4, 11)
(2, 4, 12)
(2, 4, 13)
(2, 4, 14)
(2, 4, 15)
(2, 4, 16)
(2, 4, 17)
(2, 4, 18)
(2, 5, 6)
(2, 5, 7)
(2, 5, 8)
(2, 5, 9)
(2, 5, 10)
(2, 5, 11)
(2, 5, 12)
(2, 5, 13)
(2, 5, 14)
(2, 5, 15)
(2, 5, 16)
(2, 5, 17)
(2, 5, 18)
(2, 6, 7)
(2, 6, 8)
(2, 6, 9)
(2, 6, 10)
(2, 6, 11)
(2, 6, 12)
(2, 6, 13)
(2, 6, 14)
(2, 6, 15)
(2, 6, 16)
(2, 6, 17)
(2, 6, 18)
(2, 7, 8)
(2, 7, 9)
(2, 7, 10)
(2, 7, 11)
(2, 7, 12)
(2, 7, 13)
(2, 7, 14)
(2, 7, 15)
(2, 7, 16)
(2, 7, 17)
(2, 7, 18)
(2, 8, 9)
(2, 8, 10)
(2, 8, 11)
(2, 8, 12)
(2, 8, 13)
(2, 8, 14)
(2, 8, 15)
(2, 8, 16)
(2, 8, 17)
(2, 8, 18)
(2, 9, 10)
(2, 9, 11)
(2, 9, 12)
(2, 9, 13)
(2, 9, 14)
(2, 9, 15)
(2, 9, 16)
(2, 9, 17)
(2, 9, 18)
(2, 10, 11)
(2, 10, 12)
(2, 10, 13)
(2, 10, 14)
(2, 10, 15)
(2, 10, 16)
(2, 10, 17)
(2, 10, 18)
(2, 11, 12)
(2, 11, 13)
(2, 11, 14)
(2, 11, 15)
(2, 11, 16)
(2, 11, 17)
(2, 11, 18)
(2, 12, 13)
(2, 12, 14)
(2, 12, 15)
(2, 12, 16)
(2, 12, 17)
(2, 12, 18)
(2, 13, 14)
(2, 13, 15)
(2, 13, 16)
(2, 13, 17)
(2, 13, 18)
(2, 14, 15)
(2, 14, 16)
(2, 14, 17)
(2, 14, 18)
(2, 15, 16)
(2, 15, 17)
(2, 15, 18)
(2, 16, 17)
(2, 16, 18)
(2, 17, 18)
(3, 4, 5)
(3, 4, 6)
(3, 4, 7)
(3, 4, 8)
(3, 4, 9)
(3, 4, 10)
(3, 4, 11)
(3, 4, 12)
(3, 4, 13)
(3, 4, 14)
(3, 4, 15)
(3, 4, 16)
(3, 4, 17)
(3, 4, 18)
(3, 5, 6)
(3, 5, 7)
(3, 5, 8)
(3, 5, 9)
(3, 5, 10)
(3, 5, 11)
(3, 5, 12)
(3, 5, 13)
(3, 5, 14)
(3, 5, 15)
(3, 5, 16)
(3, 5, 17)
(3, 5, 18)
(3, 6, 7)
(3, 6, 8)
(3, 6, 9)
(3, 6, 10)
(3, 6, 11)
(3, 6, 12)
(3, 6, 13)
(3, 6, 14)
(3, 6, 15)
(3, 6, 16)
(3, 6, 17)
(3, 6, 18)
(3, 7, 8)
(3, 7, 9)
(3, 7, 10)
(3, 7, 11)
(3, 7, 12)
(3, 7, 13)
(3, 7, 14)
(3, 7, 15)
(3, 7, 16)
(3, 7, 17)
(3, 7, 18)
(3, 8, 9)
(3, 8, 10)
(3, 8, 11)
(3, 8, 12)
(3, 8, 13)
(3, 8, 14)
(3, 8, 15)
(3, 8, 16)
(3, 8, 17)
(3, 8, 18)
(3, 9, 10)
(3, 9, 11)
(3, 9, 12)
(3, 9, 13)
(3, 9, 14)
(3, 9, 15)
(3, 9, 16)
(3, 9, 17)
(3, 9, 18)
(3, 10, 11)
(3, 10, 12)
(3, 10, 13)
(3, 10, 14)
(3, 10, 15)
(3, 10, 16)
(3, 10, 17)
(3, 10, 18)
(3, 11, 12)
(3, 11, 13)
(3, 11, 14)
(3, 11, 15)
(3, 11, 16)
(3, 11, 17)
(3, 11, 18)
(3, 12, 13)
(3, 12, 14)
(3, 12, 15)
(3, 12, 16)
(3, 12, 17)
(3, 12, 18)
(3, 13, 14)
(3, 13, 15)
(3, 13, 16)
(3, 13, 17)
(3, 13, 18)
(3, 14, 15)
(3, 14, 16)
(3, 14, 17)
(3, 14, 18)
(3, 15, 16)
(3, 15, 17)
(3, 15, 18)
(3, 16, 17)
(3, 16, 18)
(3, 17, 18)
(4, 5, 6)
(4, 5, 7)
(4, 5, 8)
(4, 5, 9)
(4, 5, 10)
(4, 5, 11)
(4, 5, 12)
(4, 5, 13)
(4, 5, 14)
(4, 5, 15)
(4, 5, 16)
(4, 5, 17)
(4, 5, 18)
(4, 6, 7)
(4, 6, 8)
(4, 6, 9)
(4, 6, 10)
(4, 6, 11)
(4, 6, 12)
(4, 6, 13)
(4, 6, 14)
(4, 6, 15)
(4, 6, 16)
(4, 6, 17)
(4, 6, 18)
(4, 7, 8)
(4, 7, 9)
(4, 7, 10)
(4, 7, 11)
(4, 7, 12)
(4, 7, 13)
(4, 7, 14)
(4, 7, 15)
(4, 7, 16)
(4, 7, 17)
(4, 7, 18)
(4, 8, 9)
(4, 8, 10)
(4, 8, 11)
(4, 8, 12)
(4, 8, 13)
(4, 8, 14)
(4, 8, 15)
(4, 8, 16)
(4, 8, 17)
(4, 8, 18)
(4, 9, 10)
(4, 9, 11)
(4, 9, 12)
(4, 9, 13)
(4, 9, 14)
(4, 9, 15)
(4, 9, 16)
(4, 9, 17)
(4, 9, 18)
(4, 10, 11)
(4, 10, 12)
(4, 10, 13)
(4, 10, 14)
(4, 10, 15)
(4, 10, 16)
(4, 10, 17)
(4, 10, 18)
(4, 11, 12)
(4, 11, 13)
(4, 11, 14)
(4, 11, 15)
(4, 11, 16)
(4, 11, 17)
(4, 11, 18)
(4, 12, 13)
(4, 12, 14)
(4, 12, 15)
(4, 12, 16)
(4, 12, 17)
(4, 12, 18)
(4, 13, 14)
(4, 13, 15)
(4, 13, 16)
(4, 13, 17)
(4, 13, 18)
(4, 14, 15)
(4, 14, 16)
(4, 14, 17)
(4, 14, 18)
(4, 15, 16)
(4, 15, 17)
(4, 15, 18)
(4, 16, 17)
(4, 16, 18)
(4, 17, 18)
(5, 6, 7)
(5, 6, 8)
(5, 6, 9)
(5, 6, 10)
(5, 6, 11)
(5, 6, 12)
(5, 6, 13)
(5, 6, 14)
(5, 6, 15)
(5, 6, 16)
(5, 6, 17)
(5, 6, 18)
(5, 7, 8)
(5, 7, 9)
(5, 7, 10)
(5, 7, 11)
(5, 7, 12)
(5, 7, 13)
(5, 7, 14)
(5, 7, 15)
(5, 7, 16)
(5, 7, 17)
(5, 7, 18)
(5, 8, 9)
(5, 8, 10)
(5, 8, 11)
(5, 8, 12)
(5, 8, 13)
(5, 8, 14)
(5, 8, 15)
(5, 8, 16)
(5, 8, 17)
(5, 8, 18)
(5, 9, 10)
(5, 9, 11)
(5, 9, 12)
(5, 9, 13)
(5, 9, 14)
(5, 9, 15)
(5, 9, 16)
(5, 9, 17)
(5, 9, 18)
(5, 10, 11)
(5, 10, 12)
(5, 10, 13)
(5, 10, 14)
(5, 10, 15)
(5, 10, 16)
(5, 10, 17)
(5, 10, 18)
(5, 11, 12)
(5, 11, 13)
(5, 11, 14)
(5, 11, 15)
(5, 11, 16)
(5, 11, 17)
(5, 11, 18)
(5, 12, 13)
(5, 12, 14)
(5, 12, 15)
(5, 12, 16)
(5, 12, 17)
(5, 12, 18)
(5, 13, 14)
(5, 13, 15)
(5, 13, 16)
(5, 13, 17)
(5, 13, 18)
(5, 14, 15)
(5, 14, 16)
(5, 14, 17)
(5, 14, 18)
(5, 15, 16)
(5, 15, 17)
(5, 15, 18)
(5, 16, 17)
(5, 16, 18)
(5, 17, 18)
(6, 7, 8)
(6, 7, 9)
(6, 7, 10)
(6, 7, 11)
(6, 7, 12)
(6, 7, 13)
(6, 7, 14)
(6, 7, 15)
(6, 7, 16)
(6, 7, 17)
(6, 7, 18)
(6, 8, 9)
(6, 8, 10)
(6, 8, 11)
(6, 8, 12)
(6, 8, 13)
(6, 8, 14)
(6, 8, 15)
(6, 8, 16)
(6, 8, 17)
(6, 8, 18)
(6, 9, 10)
(6, 9, 11)
(6, 9, 12)
(6, 9, 13)
(6, 9, 14)
(6, 9, 15)
(6, 9, 16)
(6, 9, 17)
(6, 9, 18)
(6, 10, 11)
(6, 10, 12)
(6, 10, 13)
(6, 10, 14)
(6, 10, 15)
(6, 10, 16)
(6, 10, 17)
(6, 10, 18)
(6, 11, 12)
(6, 11, 13)
(6, 11, 14)
(6, 11, 15)
(6, 11, 16)
(6, 11, 17)
(6, 11, 18)
(6, 12, 13)
(6, 12, 14)
(6, 12, 15)
(6, 12, 16)
(6, 12, 17)
(6, 12, 18)
(6, 13, 14)
(6, 13, 15)
(6, 13, 16)
(6, 13, 17)
(6, 13, 18)
(6, 14, 15)
(6, 14, 16)
(6, 14, 17)
(6, 14, 18)
(6, 15, 16)
(6, 15, 17)
(6, 15, 18)
(6, 16, 17)
(6, 16, 18)
(6, 17, 18)
(7, 8, 9)
(7, 8, 10)
(7, 8, 11)
(7, 8, 12)
(7, 8, 13)
(7, 8, 14)
(7, 8, 15)
(7, 8, 16)
(7, 8, 17)
(7, 8, 18)
(7, 9, 10)
(7, 9, 11)
(7, 9, 12)
(7, 9, 13)
(7, 9, 14)
(7, 9, 15)
(7, 9, 16)
(7, 9, 17)
(7, 9, 18)
(7, 10, 11)
(7, 10, 12)
(7, 10, 13)
(7, 10, 14)
(7, 10, 15)
(7, 10, 16)
(7, 10, 17)
(7, 10, 18)
(7, 11, 12)
(7, 11, 13)
(7, 11, 14)
(7, 11, 15)
(7, 11, 16)
(7, 11, 17)
(7, 11, 18)
(7, 12, 13)
(7, 12, 14)
(7, 12, 15)
(7, 12, 16)
(7, 12, 17)
(7, 12, 18)
(7, 13, 14)
(7, 13, 15)
(7, 13, 16)
(7, 13, 17)
(7, 13, 18)
(7, 14, 15)
(7, 14, 16)
(7, 14, 17)
(7, 14, 18)
(7, 15, 16)
(7, 15, 17)
(7, 15, 18)
(7, 16, 17)
(7, 16, 18)
(7, 17, 18)
(8, 9, 10)
(8, 9, 11)
(8, 9, 12)
(8, 9, 13)
(8, 9, 14)
(8, 9, 15)
(8, 9, 16)
(8, 9, 17)
(8, 9, 18)
(8, 10, 11)
(8, 10, 12)
(8, 10, 13)
(8, 10, 14)
(8, 10, 15)
(8, 10, 16)
(8, 10, 17)
(8, 10, 18)
(8, 11, 12)
(8, 11, 13)
(8, 11, 14)
(8, 11, 15)
(8, 11, 16)
(8, 11, 17)
(8, 11, 18)
(8, 12, 13)
(8, 12, 14)
(8, 12, 15)
(8, 12, 16)
(8, 12, 17)
(8, 12, 18)
(8, 13, 14)
(8, 13, 15)
(8, 13, 16)
(8, 13, 17)
(8, 13, 18)
(8, 14, 15)
(8, 14, 16)
(8, 14, 17)
(8, 14, 18)
(8, 15, 16)
(8, 15, 17)
(8, 15, 18)
(8, 16, 17)
(8, 16, 18)
(8, 17, 18)
(9, 10, 11)
(9, 10, 12)
(9, 10, 13)
(9, 10, 14)
(9, 10, 15)
(9, 10, 16)
(9, 10, 17)
(9, 10, 18)
(9, 11, 12)
(9, 11, 13)
(9, 11, 14)
(9, 11, 15)
(9, 11, 16)
(9, 11, 17)
(9, 11, 18)
(9, 12, 13)
(9, 12, 14)
(9, 12, 15)
(9, 12, 16)
(9, 12, 17)
(9, 12, 18)
(9, 13, 14)
(9, 13, 15)
(9, 13, 16)
(9, 13, 17)
(9, 13, 18)
(9, 14, 15)
(9, 14, 16)
(9, 14, 17)
(9, 14, 18)
(9, 15, 16)
(9, 15, 17)
(9, 15, 18)
(9, 16, 17)
(9, 16, 18)
(9, 17, 18)
(10, 11, 12)
(10, 11, 13)
(10, 11, 14)
(10, 11, 15)
(10, 11, 16)
(10, 11, 17)
(10, 11, 18)
(10, 12, 13)
(10, 12, 14)
(10, 12, 15)
(10, 12, 16)
(10, 12, 17)
(10, 12, 18)
(10, 13, 14)
(10, 13, 15)
(10, 13, 16)
(10, 13, 17)
(10, 13, 18)
(10, 14, 15)
(10, 14, 16)
(10, 14, 17)
(10, 14, 18)
(10, 15, 16)
(10, 15, 17)
(10, 15, 18)
(10, 16, 17)
(10, 16, 18)
(10, 17, 18)
(11, 12, 13)
(11, 12, 14)
(11, 12, 15)
(11, 12, 16)
(11, 12, 17)
(11, 12, 18)
(11, 13, 14)
(11, 13, 15)
(11, 13, 16)
(11, 13, 17)
(11, 13, 18)
(11, 14, 15)
(11, 14, 16)
(11, 14, 17)
(11, 14, 18)
(11, 15, 16)
(11, 15, 17)
(11, 15, 18)
(11, 16, 17)
(11, 16, 18)
(11, 17, 18)
(12, 13, 14)
(12, 13, 15)
(12, 13, 16)
(12, 13, 17)
(12, 13, 18)
(12, 14, 15)
(12, 14, 16)
(12, 14, 17)
(12, 14, 18)
(12, 15, 16)
(12, 15, 17)
(12, 15, 18)
(12, 16, 17)
(12, 16, 18)
(12, 17, 18)
(13, 14, 15)
(13, 14, 16)
(13, 14, 17)
(13, 14, 18)
(13, 15, 16)
(13, 15, 17)
(13, 15, 18)
(13, 16, 17)
(13, 16, 18)
(13, 17, 18)
(14, 15, 16)
(14, 15, 17)
(14, 15, 18)
(14, 16, 17)
(14, 16, 18)
(14, 17, 18)
(15, 16, 17)
(15, 16, 18)
(15, 17, 18)
(16, 17, 18)
816

所以k=3时,所有可能的析合范式为816个。
k=4时,所有可能的析合范式为3060个,下面是Python的实现代码

result=0
for a1 in range(1,16):#这里16和循环次数相加就等于20
    for a2 in range((a1+1),19):
        for a3 in range((a2+1),19):
            for a4  in range((a3  + 1), 19):
                print((a1 ,a2 ,a3 ,a4 ))
                result=result+1

print(result)

k=0是,空集(个数仍为1)
k=1时,result=18
k=2时,result=152
k=3时,result=816
k=4时,result=3060
k=5时,result=8568
k=6时,,result=18564
k=7时,,result=31824
k=8时,,result=43758
k=9时,,result=48620
k=10时,,result=43758
k=11时,,result=31824
k=12时,,result=18564
k=13时,,result=8568
k=14时,,result=3060
k=15时,,result=816
k=16时,,result=152
k=17时,,result=18
k=18时,,result=1

sum (k,(0,18))=

1.这里并没有考虑k=2的析合范式(1,1)即a1b1c1∨a1b1c1因为它和单个合取式(1)←→a1b1c1,是等价
同理(i,i,i,i…i)←→(i)
2.(i,j,)<==>(j,i)是等价的,其中i,j∈(1,2,3,…,17,18),比如(1,2)(2,1)
3.又如:k=6的一种析合范式(1,2,2,3,4,4)←→k=4 的析合范式(1,2,3,4)是等价的
4,(1,2,3),(1,3,2)是等价的,所以左边的元素不要大于右边的元素,始终让他们处于自然排序。
下面是MATLAB语言实现析合范式的穷举,和计数。

[^1] 这里我原本用值域一词,可我考虑用映射也挺合适,因为从集合[(1,1),(1,2),(1,3),…,(5,3),(5,4),(5,5)]能看出映射S⊗S→S来,那为什么还叫它值域呢,就叫他映射吧。

已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页