{"id":13936393,"url":"https://github.com/welchbj/tt","last_synced_at":"2025-09-16T10:28:10.900Z","repository":{"id":104125883,"uuid":"48415518","full_name":"welchbj/tt","owner":"welchbj","description":"a Pythonic toolkit for working with Boolean expressions","archived":false,"fork":false,"pushed_at":"2025-05-08T02:27:02.000Z","size":698,"stargazers_count":219,"open_issues_count":4,"forks_count":12,"subscribers_count":7,"default_branch":"develop","last_synced_at":"2025-07-19T22:39:06.539Z","etag":null,"topics":["boolean","boolean-algebra","boolean-expression","python","sat","sat-solver","satisfiability","transformations","truth-table"],"latest_commit_sha":null,"homepage":"https://tt.brianwel.ch","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/welchbj.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"zenodo":null}},"created_at":"2015-12-22T06:49:35.000Z","updated_at":"2025-06-29T02:33:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"b0a63532-3354-4be8-8aa4-228d7b75ae5e","html_url":"https://github.com/welchbj/tt","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/welchbj/tt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welchbj%2Ftt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welchbj%2Ftt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welchbj%2Ftt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welchbj%2Ftt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/welchbj","download_url":"https://codeload.github.com/welchbj/tt/tar.gz/refs/heads/develop","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/welchbj%2Ftt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275403931,"owners_count":25458811,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-16T02:00:10.229Z","response_time":65,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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","boolean-algebra","boolean-expression","python","sat","sat-solver","satisfiability","transformations","truth-table"],"created_at":"2024-08-07T23:02:37.574Z","updated_at":"2025-09-16T10:28:10.886Z","avatar_url":"https://github.com/welchbj.png","language":"Python","readme":"Synopsis\n--------\n\ntt (**t**\\ ruth **t**\\ able) is a library aiming to provide a toolkit for working with Boolean expressions and truth tables. Please see the `project site`_ for guides and documentation.\n\nInstallation\n------------\n\ntt is tested on the latest three major versions of CPython. You can get the latest release from PyPI with::\n\n    pip install ttable\n\nFeatures\n--------\n\nParse expressions::\n\n    \u003e\u003e\u003e from tt import BooleanExpression\n    \u003e\u003e\u003e b = BooleanExpression('A impl not (B nand C)')\n    \u003e\u003e\u003e b.tokens\n    ['A', 'impl', 'not', '(', 'B', 'nand', 'C', ')']\n    \u003e\u003e\u003e print(b.tree)\n    impl\n    `----A\n    `----not\n         `----nand\n              `----B\n              `----C\n\nEvaluate expressions::\n\n    \u003e\u003e\u003e b = BooleanExpression('(A /\\\\ B) -\u003e (C \\\\/ D)')\n    \u003e\u003e\u003e b.evaluate(A=1, B=1, C=0, D=0)\n    False\n    \u003e\u003e\u003e b.evaluate(A=1, B=1, C=1, D=0)\n    True\n\nInteract with expression structure::\n\n    \u003e\u003e\u003e b = BooleanExpression('(A and ~B and C) or (~C and D) or E')\n    \u003e\u003e\u003e b.is_dnf\n    True\n    \u003e\u003e\u003e for clause in b.iter_dnf_clauses():\n    ...     print(clause)\n    ...\n    A and ~B and C\n    ~C and D\n    E\n\nApply expression transformations::\n\n    \u003e\u003e\u003e from tt import to_primitives, to_cnf\n    \u003e\u003e\u003e to_primitives('A xor B')\n    \u003cBooleanExpression \"(A and not B) or (not A and B)\"\u003e\n    \u003e\u003e\u003e to_cnf('(A nand B) impl (C or D)')\n    \u003cBooleanExpression \"(A or C or D) and (B or C or D)\"\u003e\n\nOr create your own::\n\n    \u003e\u003e\u003e from tt import tt_compose, apply_de_morgans, coalesce_negations, twice\n    \u003e\u003e\u003e b = BooleanExpression('not (not (A or B))')\n    \u003e\u003e\u003e f = tt_compose(apply_de_morgans, twice)\n    \u003e\u003e\u003e f(b)\n    \u003cBooleanExpression \"not not A or not not B\"\u003e\n    \u003e\u003e\u003e g = tt_compose(f, coalesce_negations)\n    \u003e\u003e\u003e g(b)\n    \u003cBooleanExpression \"A or B\"\u003e\n\nExhaust SAT solutions::\n\n    \u003e\u003e\u003e b = BooleanExpression('~(A or B) xor C')\n    \u003e\u003e\u003e for sat_solution in b.sat_all():\n    ...     print(sat_solution)\n    ...\n    A=0, B=0, C=0\n    A=1, B=0, C=1\n    A=0, B=1, C=1\n    A=1, B=1, C=1\n\nFind just a few::\n\n    \u003e\u003e\u003e with b.constrain(A=1):\n    ...     for sat_solution in b.sat_all():\n    ...         print(sat_solution)\n    ...\n    A=1, B=0, C=1\n    A=1, B=1, C=1\n\nOr just one::\n\n    \u003e\u003e\u003e b.sat_one()\n    \u003cBooleanValues [A=0, B=0, C=0]\u003e\n\nBuild truth tables::\n\n    \u003e\u003e\u003e from tt import TruthTable\n    \u003e\u003e\u003e t = TruthTable('A iff B')\n    \u003e\u003e\u003e print(t)\n    +---+---+---+\n    | A | B |   |\n    +---+---+---+\n    | 0 | 0 | 1 |\n    +---+---+---+\n    | 0 | 1 | 0 |\n    +---+---+---+\n    | 1 | 0 | 0 |\n    +---+---+---+\n    | 1 | 1 | 1 |\n    +---+---+---+\n\nAnd `much more`_!\n\nLicense\n-------\n\ntt uses the `MIT License`_.\n\n\n.. _MIT License: https://opensource.org/licenses/MIT\n.. _project site: https://tt.brianwel.ch\n.. _bool.tools: http://www.bool.tools\n.. _much more: https://tt.brianwel.ch/en/latest/user_guide.html\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwelchbj%2Ftt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwelchbj%2Ftt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwelchbj%2Ftt/lists"}