npn
v1.1
这个包是布尔匹配项。它简单地计算出每个NPN等效类别的规范代表,对于由真实表表示的给定布尔函数。
该软件包的后端由C ++实现,以提高效率。
当前,此软件包支持Boolean功能,其中输入数量<= 8。
pip install npn import npn
# the truth table of f(x_2, x_1, x_0) as [f(0, 0, 0), f(0, 0, 1), f(0, 1, 0), f(0, 1, 1), ...]
tt = [ True , True , True , False , True , True , True , True ]
c = npn . npn_canonical_representative ( tt ) # [True, True, True, True, True, True, True, False]
c_int = npn . tt_to_int ( c ) # 254 (11111110)
c , phase , perm , output_inv = npn . npn_canonical_representative ( tt , return_details = True , refinement = True )return_details参数设置为True ,以返回NPN变换信息( phase, perm, output_inv )。例如,这里的phase = [False, False, True] , perm = [0, 1, 2]和output_inv = False均值(x_0, x_1, x_2)应映射到(x_0, x_1, x_2) ,然后应倒入第三个变量( x_2 ),不应倒入最终结果。refinement参数设置为True加速计算,同时打破真相表的词典词法顺序。有关详细信息,请参见“构建更好的布尔匹配器和对称探测器”。 编译共享库libnpn.dll和libnpn.so通过Windows和Linux环境上的cmake,将它们放在npn文件夹中,然后将其放在
python setup.py sdist要上传到PYPI,请运行
twine upload . d ist n pn-X.X.tar.gzpip install pytest # if you haven't install it
python -m pytest