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