{"id":29884170,"url":"https://github.com/marcelwa/cegis","last_synced_at":"2025-09-13T03:42:05.365Z","repository":{"id":109333241,"uuid":"68818328","full_name":"marcelwa/CEGIS","owner":"marcelwa","description":"Counter-example guided inductive synthesis (CEGIS) implementation for the SMT solver Z3 by Microsoft Research","archived":false,"fork":false,"pushed_at":"2017-01-08T13:58:48.000Z","size":16,"stargazers_count":43,"open_issues_count":0,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-04-22T10:11:35.165Z","etag":null,"topics":["satisfiability-solver","smt-solver","synthesis","z3"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcelwa.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}},"created_at":"2016-09-21T13:14:14.000Z","updated_at":"2024-01-11T01:38:12.000Z","dependencies_parsed_at":"2023-07-26T23:16:22.604Z","dependency_job_id":null,"html_url":"https://github.com/marcelwa/CEGIS","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/marcelwa/CEGIS","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelwa%2FCEGIS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelwa%2FCEGIS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelwa%2FCEGIS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelwa%2FCEGIS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcelwa","download_url":"https://codeload.github.com/marcelwa/CEGIS/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcelwa%2FCEGIS/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268057115,"owners_count":24188614,"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-07-31T02:00:08.723Z","response_time":66,"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":["satisfiability-solver","smt-solver","synthesis","z3"],"created_at":"2025-07-31T14:30:25.247Z","updated_at":"2025-07-31T14:30:30.974Z","avatar_url":"https://github.com/marcelwa.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CEGIS\n\nCounter-example guided inductive synthesis (CEGIS) implementation for the SMT solver\n[Z3](https://github.com/Z3Prover/z3) by Microsoft Research. CEGIS is an approach to tackle\ncomplexity of exact syntheses using satisfiability solvers. It was first introduced by\n*Armando Solar-Lezama* in his Ph.D. Thesis\n[Program Synthesis by Sketching](http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.207.9048\u0026rep=rep1\u0026type=pdf)\nback in 2008.\n\n## What is CEGIS?\n\nSynthesis tasks often have the same structure: an implementation is sought that behaves correctly under all possible\ninputs (with the help of some extra variables, i.e. helper variables).\n\nMore formal: ∃ Implementation : ∀ Inputs : ∃ Helper Variables : Implementation behaves correctly.\n\nIt is absolutely legal to pass such a term to an SMT solver like Z3. A big drawback is the universal quantifier though.\n\nFor many real world problems it is not necessary to consider all inputs to derive an implementation that behaves\ncorrectly for all of them. Following this observation, the problem was just moved to another position: which is the\nminimal subset of inputs one have to consider to ensure a correct synthesis?\n\nThis is the point where CEGIS comes into play. CEGIS is a loop looking for exactly this minimal subset of inputs and\nperforming the implementation synthesis as a \"by-product\". Therefore CEGIS uses one satisfiability solver to generate\nnew implementations based on all the inputs considered so far (starting with zero); and another one to generate counter\nexamples that uncover incorrect behavior in the latest synthesised implementation. Eventually there will be no more\nimplementations possible, i.e. the specification is not realisable, or no more counter examples possible, i.e. the\nlatest implementation must be correct.\n\nThis CEGIS library works with the SMT solver Z3 and requires insight in the synthesis task to be executed, as it has to\nbe specified which variables belong to implementation, inputs, etc. Boundary conditions are to be specified manually as\nwell.\n\n## Building and installing\n\nGit, g++, cmake, a Python interpreter and the Boost Library are necessary in order to build CEGIS.\nIn *Ubuntu* the packages can be installed with\n\n```sh\nsudo apt-get install git g++ cmake python libboost-all-dev\n```\n\nAfterwards, CEGIS is ready to be installed.\n\n```sh\ngit clone https://github.com/marcelwa/CEGIS.git\ncd CEGIS\nmkdir build\ncd build\ncmake ..\nmake\nsudo make install\n```\n\nSince Z3 is automatically downloaded, configured and installed during this procedure, this step may take a while.\nPlease enter your super user password to provide installation rights.\n\nThe standard install prefix is `/usr/local/`. If another prefix is desired, just replace\n`cmake ..` by `cmake -DCMAKE_INSTALL_PREFIX:PATH=/YOUR_PREFIX ..`. If you do not want Z3 to be downloaded and installed\nduring the build step because you have it already set up in your system, simply add `-DINSTALL_Z3=OFF` to your\n`cmake` parameter list. Both options can be configured using `ccmake`, too,  of course.\n\n### Uninstall\n\nIf you want to uninstall the CEGIS library and the downloaded Z3 solver, simply type\n\n```sh\nsudo xargs rm \u003c install_manifest.txt\n```\n\nin the build directory.\n\n## Usage\n\nThe functionality of this library is encapsulated in a class called `CEGISHandler`. This class handles the given\nvariables, constraints and execution of the CEGIS loop as well as runtime measurement and many other tasks.\n\n```cpp\nusing namespace z3;\n\n/* PREVIOUS USAGE */\ncontext c;\n\n// ...a lot of stuff...\n \nsolver s(c);\ns.add(exists(implementation, forall(inputs, exists(helpers, constraints))));\ns.check();\n\n\n/* BETTER CEGIS USAGE */\ncontext c;\n\n// implementation, input and helper variables\nexpr_vector impl(c), inp(c), hlp(c);\n\n// ...fill the vectors...\n\n// implementation constraints, e.g. no cycles allowed\nexpr impl_cons(c);\n// behavior constraints, e.g. desired propagation\nexpr behav_cons(c);\n// correctness constraints, e.g. outputs depend on the inputs in a specifc way\nexpr corr_cons(c);\n\n// ...fill all those...\n\n// let's rock CEGIS\nCEGISHandler handler(\u0026c, impl, inp, hlp, impl_cons, behav_cons, corr_cons);\nauto result = handler.CEGISRoutine();\nresult.print();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcelwa%2Fcegis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcelwa%2Fcegis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcelwa%2Fcegis/lists"}