{"id":29101769,"url":"https://github.com/tyilo/z4","last_synced_at":"2026-02-28T18:01:53.976Z","repository":{"id":62590886,"uuid":"214634865","full_name":"tyilo/z4","owner":"tyilo","description":"z3++","archived":false,"fork":false,"pushed_at":"2024-12-14T19:49:03.000Z","size":48,"stargazers_count":29,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-11-29T05:58:55.109Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tyilo.png","metadata":{"files":{"readme":"README.md","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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-10-12T11:23:37.000Z","updated_at":"2025-11-17T12:50:45.000Z","dependencies_parsed_at":"2024-12-13T14:26:50.272Z","dependency_job_id":"f440ddf8-12db-47f6-abe9-baaa964f6628","html_url":"https://github.com/tyilo/z4","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tyilo/z4","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyilo%2Fz4","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyilo%2Fz4/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyilo%2Fz4/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyilo%2Fz4/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tyilo","download_url":"https://codeload.github.com/tyilo/z4/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tyilo%2Fz4/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29946463,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-28T17:57:52.716Z","status":"ssl_error","status_checked_at":"2026-02-28T17:57:31.974Z","response_time":90,"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":[],"created_at":"2025-06-28T21:08:15.582Z","updated_at":"2026-02-28T18:01:53.954Z","avatar_url":"https://github.com/tyilo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# z4\n\n[![PyPI](https://img.shields.io/pypi/v/z4-solver)](https://pypi.org/project/z4-solver/)\n\n[z3](https://github.com/Z3Prover/z3) with some improvements:\n\n* `BitVec`:\n  * Change the right shift operation to be logical instead of arithmetic\n\n* Add the `ByteVec` class\n* Add some helper methods for solving:\n  * `easy_solve`\n  * `find_all_solutions`\n  * `easy_prove`\n\n* Add some helper methods for optimizing:\n  * `maximize`\n  * `minimize`\n\n* Add some helper functions for z3 variables/constants:\n  * `BoolToInt`\n  * `Sgn`\n  * `TruncDiv`\n\n# Features implemented upstream\n\nThese features were first provided by z4, before z3 included these features.\nThey have now been removed from z4.\n\n* `BoolRef`:\n  * Support `*` for two `BoolRef`'s [`8efaaaf`](https://github.com/Z3Prover/z3/commit/8efaaaf24982ce810b8ea85fdf74eedc3dea29ad), [`ec74a87`](https://github.com/Z3Prover/z3/commit/ec74a874232b6b23b17c741a91fff75f8d2fa6c7)\n  * Support `+` [`f90b10a`](https://github.com/Z3Prover/z3/commit/f90b10a0c8e7f292bbe6288452f6176d1d73e608), [`a9513c1`](https://github.com/Z3Prover/z3/commit/a9513c19989454ac4aeaa83bdb6310cf6386835d)\n  * Support `\u0026`, `|` and `~` [`f90b10a`](https://github.com/Z3Prover/z3/commit/f90b10a0c8e7f292bbe6288452f6176d1d73e608)\n  * Support `^` [`764f0d5`](https://github.com/Z3Prover/z3/commit/764f0d54a436bd93069778a385517e74aea47150)\n\n* Helper functions:\n  * `Abs` [`cf08cdf`](https://github.com/Z3Prover/z3/commit/cf08cdff9c62b8db2805dbd9c4935ccb9569f08d)\n\n## Usage\nInstall with `pip install z4-solver`.\n\n### `easy_solve`\n```python3\nimport z4\n\na, b = z4.Ints(\"a b\")\nprint(z4.easy_solve([a \u003c= 10, b \u003c= 10, a + b == 15]))\n```\n\nOutput:\n```\n[b = 5, a = 10]\n```\n\n### `find_all_solutions`\n```python3\nimport z4\n\na, b = z4.Ints(\"a b\")\nprint(*z4.find_all_solutions([a \u003c= 10, b \u003c= 10, a + b == 15]), sep=\"\\n\")\n```\n\nOutput:\n```\n[b = 5, a = 10]\n[b = 6, a = 9]\n[b = 7, a = 8]\n[b = 8, a = 7]\n[b = 9, a = 6]\n[b = 10, a = 5]\n```\n\n### `easy_prove`\nLet's try and prove that `2 * a \u003e= a` for all integers `a`:\n```python3\nimport z4\n\na = z4.Int(\"a\")\nprint(z4.easy_prove(2 * a \u003e= a))\n```\n\nOutput\n```\nTraceback (most recent call last):\n  ...\nz4.Z3CounterExample: [a = -1]\n```\n\nThis isn't true so we get an exception with the counter-example `a = -1`. Of course `2 * -1 = -2` which is less than `-1`.\n\nLet's try again with the assumption that `a` must be non-negative:\n```python3\nprint(z4.easy_prove(z4.Implies(a \u003e= 0, 2 * a \u003e= a)))\n```\n\nOutput:\n```\nTrue\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyilo%2Fz4","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftyilo%2Fz4","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftyilo%2Fz4/lists"}