{"id":21451830,"url":"https://github.com/reity/logical","last_synced_at":"2026-02-16T06:02:47.232Z","repository":{"id":57438812,"uuid":"298712449","full_name":"reity/logical","owner":"reity","description":"Callable subclass of the tuple type for representing logical operators/connectives based on their truth tables.","archived":false,"fork":false,"pushed_at":"2022-10-10T02:12:04.000Z","size":76,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-21T02:55:35.988Z","etag":null,"topics":["boolean-operations","boolean-operators","finite-maps","logic-operations","logic-operators","logical-operators","python-constants","python-library","python-logic","python-operations","python-operators"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/logical","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reity.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-26T01:17:44.000Z","updated_at":"2024-01-21T15:58:30.000Z","dependencies_parsed_at":"2022-09-08T09:50:10.614Z","dependency_job_id":null,"html_url":"https://github.com/reity/logical","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/reity/logical","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reity%2Flogical","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reity%2Flogical/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reity%2Flogical/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reity%2Flogical/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reity","download_url":"https://codeload.github.com/reity/logical/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reity%2Flogical/sbom","scorecard":{"id":769535,"data":{"date":"2025-08-11","repo":{"name":"github.com/reity/logical","commit":"e74d63d699c92b9b6314607aa61321ad7797ba8f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/lint-test-cover-docs.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint-test-cover-docs.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/reity/logical/lint-test-cover-docs.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/lint-test-cover-docs.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/reity/logical/lint-test-cover-docs.yml/main?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/lint-test-cover-docs.yml:20","Warn: pipCommand not pinned by hash: .github/workflows/lint-test-cover-docs.yml:25","Warn: pipCommand not pinned by hash: .github/workflows/lint-test-cover-docs.yml:32","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'main'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-23T01:51:56.003Z","repository_id":57438812,"created_at":"2025-08-23T01:51:56.003Z","updated_at":"2025-08-23T01:51:56.003Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29501364,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-16T05:57:17.024Z","status":"ssl_error","status_checked_at":"2026-02-16T05:56:49.929Z","response_time":115,"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-operations","boolean-operators","finite-maps","logic-operations","logic-operators","logical-operators","python-constants","python-library","python-logic","python-operations","python-operators"],"created_at":"2024-11-23T04:26:18.213Z","updated_at":"2026-02-16T06:02:47.217Z","avatar_url":"https://github.com/reity.png","language":"Python","readme":"=======\nlogical\n=======\n\nCallable subclass of the tuple type for representing logical operators/connectives based on their truth tables.\n\n|pypi| |readthedocs| |actions| |coveralls|\n\n.. |pypi| image:: https://badge.fury.io/py/logical.svg\n   :target: https://badge.fury.io/py/logical\n   :alt: PyPI version and link.\n\n.. |readthedocs| image:: https://readthedocs.org/projects/logical/badge/?version=latest\n   :target: https://logical.readthedocs.io/en/latest/?badge=latest\n   :alt: Read the Docs documentation status.\n\n.. |actions| image:: https://github.com/reity/logical/workflows/lint-test-cover-docs/badge.svg\n   :target: https://github.com/reity/logical/actions/workflows/lint-test-cover-docs.yml\n   :alt: GitHub Actions status.\n\n.. |coveralls| image:: https://coveralls.io/repos/github/reity/logical/badge.svg?branch=main\n   :target: https://coveralls.io/github/reity/logical?branch=main\n   :alt: Coveralls test coverage summary.\n\nInstallation and Usage\n----------------------\nThis library is available as a `package on PyPI \u003chttps://pypi.org/project/logical\u003e`__::\n\n    python -m pip install logical\n\nThe library can be imported in the usual ways::\n\n    import logical\n    from logical import *\n\nExamples\n^^^^^^^^\n\n.. |logical| replace:: ``logical``\n.. _logical: https://logical.readthedocs.io/en/2.0.0/_source/logical.html#logical.logical.logical\n\n.. |tuple| replace:: ``tuple``\n.. _tuple: https://docs.python.org/3/library/functions.html#func-tuple\n\nEach instance of the |logical|_ class (derived from the built-in |tuple|_ class) represents a boolean function that accepts ``n`` inputs by specifying its output values across all possible inputs. In other words, an instance represents the *output column* of a `truth table \u003chttps://en.wikipedia.org/wiki/Truth_table\u003e`__ for a function (under the assumption that the input vectors to which each output value corresponds are sorted in ascending order). Thus, each instance representing a function that accepts ``n`` inputs must have length ``2**n``.\n\nFor example, consider the truth table below for a boolean function *f* that accepts three inputs:\n\n+-----+-----+-----+---------------------+\n| *x* | *y* | *z* | *f* (*x*, *y*, *z*) |\n+-----+-----+-----+---------------------+\n|  0  |  0  |  0  | 1                   |\n+-----+-----+-----+---------------------+\n|  0  |  0  |  1  | 0                   |\n+-----+-----+-----+---------------------+\n|  0  |  1  |  0  | 1                   |\n+-----+-----+-----+---------------------+\n|  0  |  1  |  1  | 0                   |\n+-----+-----+-----+---------------------+\n|  1  |  0  |  0  | 0                   |\n+-----+-----+-----+---------------------+\n|  1  |  0  |  1  | 1                   |\n+-----+-----+-----+---------------------+\n|  1  |  1  |  0  | 1                   |\n+-----+-----+-----+---------------------+\n|  1  |  1  |  1  | 0                   |\n+-----+-----+-----+---------------------+\n\nNotice that the input vectors (*i.e.*, the left-most three column values in each row) are sorted in ascending order from top to bottom. If we always assume this order for input vectors, the entire function *f* can be represented using the right-most column. For the example function *f* defined by the table above, this can be done in the manner illustrated below::\n\n    \u003e\u003e\u003e from logical import *\n    \u003e\u003e\u003e f = logical((1, 0, 1, 0, 0, 1, 1, 0)) \n\nIt is then possible to `apply \u003chttps://logical.readthedocs.io/en/2.0.0/_source/logical.html#logical.logical.logical.__call__\u003e`__ the instance ``f`` defined above to any three-component input vector::\n\n    \u003e\u003e\u003e f(0, 1, 1)\n    0\n    \u003e\u003e\u003e f(1, 1, 0)\n    1\n\n.. |call| replace:: ``__call__``\n.. _call: https://logical.readthedocs.io/en/2.0.0/_source/logical.html#logical.logical.logical.__call__\n\nIt is also possible to create a new |logical|_ instance that has a ``function`` attribute corresponding to a `compiled Python function \u003chttps://logical.readthedocs.io/en/2.0.0/_source/logical.html#logical.logical.logical.compiled\u003e`__ that has the same behavior as the |call|_ method (at least, on valid inputs). This Python function does not check that inputs are of the correct type and format, but has an execution time that is usually at most half of the execution time of the |call|_ method::\n\n    \u003e\u003e\u003e f = logical((1, 0, 0, 1, 0, 1, 0, 1))\n    \u003e\u003e\u003e g = f.compiled()\n    \u003e\u003e\u003e g.function(0, 0, 0)\n    1\n    \u003e\u003e\u003e g.function(1, 1, 0)\n    0\n\nPre-defined instances are provided for all nullary, unary, and binary boolean functions. These are available both as constants and as attributes of the |logical|_ class::\n\n    \u003e\u003e\u003e logical.xor_(1, 0)\n    1\n    \u003e\u003e\u003e and_(1, 0)\n    0\n\n.. |nullary| replace:: ``nullary``\n.. _nullary: https://logical.readthedocs.io/en/2.0.0/_source/logical.html#logical.logical.logical.nullary\n\n.. |unary| replace:: ``unary``\n.. _unary: https://logical.readthedocs.io/en/2.0.0/_source/logical.html#logical.logical.logical.unary\n\n.. |binary| replace:: ``binary``\n.. _binary: https://logical.readthedocs.io/en/2.0.0/_source/logical.html#logical.logical.logical.binary\n\nThe constants |nullary|_, |unary|_, and |binary|_ are also defined. Each is a set containing exactly those instances of |logical|_ that represent functions having that arity::\n\n    \u003e\u003e\u003e unary\n    {(0, 0), (1, 0), (1, 1), (0, 1)}\n    \u003e\u003e\u003e len(binary)\n    16\n\n.. |every| replace:: ``every``\n.. _every: https://logical.readthedocs.io/en/2.0.0/_source/logical.html#logical.logical.logical.every\n\nFor convenience, the constant |every|_ is defined as the union of |nullary|_, |unary|_, and |binary|_.\n\nDevelopment\n-----------\nAll installation and development dependencies are fully specified in ``pyproject.toml``. The ``project.optional-dependencies`` object is used to `specify optional requirements \u003chttps://peps.python.org/pep-0621\u003e`__ for various development tasks. This makes it possible to specify additional options (such as ``docs``, ``lint``, and so on) when performing installation using `pip \u003chttps://pypi.org/project/pip\u003e`__::\n\n    python -m pip install .[docs,lint]\n\nDocumentation\n^^^^^^^^^^^^^\nThe documentation can be generated automatically from the source files using `Sphinx \u003chttps://www.sphinx-doc.org\u003e`__::\n\n    python -m pip install .[docs]\n    cd docs\n    sphinx-apidoc -f -E --templatedir=_templates -o _source .. \u0026\u0026 make html\n\nTesting and Conventions\n^^^^^^^^^^^^^^^^^^^^^^^\nAll unit tests are executed and their coverage is measured when using `pytest \u003chttps://docs.pytest.org\u003e`__ (see the ``pyproject.toml`` file for configuration details)::\n\n    python -m pip install .[test]\n    python -m pytest\n\nAlternatively, all unit tests are included in the module itself and can be executed using `doctest \u003chttps://docs.python.org/3/library/doctest.html\u003e`__::\n\n    python src/logical/logical.py -v\n\nStyle conventions are enforced using `Pylint \u003chttps://pylint.pycqa.org\u003e`__::\n\n    python -m pip install .[lint]\n    python -m pylint src/logical\n\nContributions\n^^^^^^^^^^^^^\nIn order to contribute to the source code, open an issue or submit a pull request on the `GitHub page \u003chttps://github.com/reity/logical\u003e`__ for this library.\n\nVersioning\n^^^^^^^^^^\nThe version number format for this library and the changes to the library associated with version number increments conform with `Semantic Versioning 2.0.0 \u003chttps://semver.org/#semantic-versioning-200\u003e`__.\n\nPublishing\n^^^^^^^^^^\nThis library can be published as a `package on PyPI \u003chttps://pypi.org/project/logical\u003e`__ by a package maintainer. First, install the dependencies required for packaging and publishing::\n\n    python -m pip install .[publish]\n\nEnsure that the correct version number appears in ``pyproject.toml``, and that any links in this README document to the Read the Docs documentation of this package (or its dependencies) have appropriate version numbers. Also ensure that the Read the Docs project for this library has an `automation rule \u003chttps://docs.readthedocs.io/en/stable/automation-rules.html\u003e`__ that activates and sets as the default all tagged versions. Create and push a tag for this version (replacing ``?.?.?`` with the version number)::\n\n    git tag ?.?.?\n    git push origin ?.?.?\n\nRemove any old build/distribution files. Then, package the source into a distribution archive::\n\n    rm -rf build dist src/*.egg-info\n    python -m build --sdist --wheel .\n\nFinally, upload the package distribution archive to `PyPI \u003chttps://pypi.org\u003e`__::\n\n    python -m twine upload dist/*\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freity%2Flogical","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freity%2Flogical","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freity%2Flogical/lists"}