{"id":20447349,"url":"https://github.com/snowkylin/npn","last_synced_at":"2026-04-21T13:31:43.144Z","repository":{"id":177853168,"uuid":"661002492","full_name":"snowkylin/npn","owner":"snowkylin","description":"A boolean matcher that computes the NPN canonical representative for a given boolean function.","archived":false,"fork":false,"pushed_at":"2024-03-24T02:38:19.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-19T21:09:16.762Z","etag":null,"topics":["boolean-matcher","cpp","eda","logic-synthesis","npn","pypi-package","python"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/snowkylin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-01T13:33:22.000Z","updated_at":"2024-07-03T16:52:07.000Z","dependencies_parsed_at":"2024-03-24T03:27:02.275Z","dependency_job_id":"f3504a3d-74f9-4ba0-82a1-04146ceed4d6","html_url":"https://github.com/snowkylin/npn","commit_stats":null,"previous_names":["snowkylin/npn"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/snowkylin/npn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowkylin%2Fnpn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowkylin%2Fnpn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowkylin%2Fnpn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowkylin%2Fnpn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/snowkylin","download_url":"https://codeload.github.com/snowkylin/npn/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/snowkylin%2Fnpn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32094345,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T11:25:29.218Z","status":"ssl_error","status_checked_at":"2026-04-21T11:25:28.499Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["boolean-matcher","cpp","eda","logic-synthesis","npn","pypi-package","python"],"created_at":"2024-11-15T10:25:56.073Z","updated_at":"2026-04-21T13:31:43.115Z","avatar_url":"https://github.com/snowkylin.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NPN: Compute canonical representatives for boolean functions\n\nThis package is a boolean matcher. It simply computes the canonical representative, which is unique for each NPN equivalence class, for a given boolean function represented by truth table.\n\nThe backend of this package is implemented by C++ for efficiency.\n\nCurrently, this package supports boolean functions with number of inputs \u003c= 8.\n\n## Install\n\n```bash\npip install npn\n```\n\n## Usage\n\n```python\nimport npn\n\n# 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), ...]\ntt = [True, True, True, False, True, True, True, True]\nc = npn.npn_canonical_representative(tt)    # [True, True, True, True, True, True, True, False]\nc_int = npn.tt_to_int(c)                    # 254 (11111110)\nc, phase, perm, output_inv = npn.npn_canonical_representative(tt, return_details=True, refinement=True)\n```\n\n- Set `return_details` parameter to `True` to return the NPN transformation information (`phase, perm, output_inv`).\nFor example, here `phase = [False, False, True]`, `perm = [0, 1, 2]` and `output_inv = False` \nmeans `(x_0, x_1, x_2)` should be mapped to `(x_0, x_1, x_2)`, then the third variable (`x_2`) should be inverted\nand the final result should not be inverted.\n- Set `refinement` parameter to `True` to accelerate computation while breaking the lexicographical order of truth tables.\nSee \"Building a Better Boolean Matcher and Symmetry Detector\" for details.\n\n## Build\n\nCompile the shared library `libnpn.dll` and `libnpn.so` via CMake on Windows and Linux environment, place them in the `\\npn` folder, then\n\n```bash\npython setup.py sdist\n```\n\nTo upload to PyPI, run\n\n```bash\ntwine upload .\\dist\\npn-X.X.tar.gz\n```\n\n## Test\n\n```bash\npip install pytest  # if you haven't install it\npython -m pytest\n```\n\n## References\n1. Chai, D., and A. Kuehlmann. “Building a Better Boolean Matcher and Symmetry Detector.” In Proceedings of the Design Automation \u0026 Test in Europe Conference, 1:1–6, 2006. https://doi.org/10.1109/DATE.2006.243959.\n2. Debnath, D., and T. Sasao. “Efficient Computation of Canonical Form for Boolean Matching in Large Libraries.” In ASP-DAC 2004: Asia and South Pacific Design Automation Conference 2004 (IEEE Cat. No.04EX753), 591–96, 2004. https://doi.org/10.1109/ASPDAC.2004.1337660.\n3. Hinsberger, U., and R. Kolla. “Boolean Matching for Large Libraries.” In Proceedings 1998 Design and Automation Conference. 35th DAC. (Cat. No.98CH36175), 206–11, 1998. https://doi.org/10.1145/277044.277100.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnowkylin%2Fnpn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsnowkylin%2Fnpn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsnowkylin%2Fnpn/lists"}