{"id":14966296,"url":"https://github.com/ejgallego/pycoq","last_synced_at":"2025-10-25T16:30:45.821Z","repository":{"id":39375446,"uuid":"409587275","full_name":"ejgallego/pycoq","owner":"ejgallego","description":"Python bindings for the Coq interactive proof assistant","archived":false,"fork":false,"pushed_at":"2022-01-10T16:11:16.000Z","size":40,"stargazers_count":52,"open_issues_count":25,"forks_count":4,"subscribers_count":4,"default_branch":"v8.14","last_synced_at":"2025-01-31T07:51:28.750Z","etag":null,"topics":["coq","machine-learning","python","verification"],"latest_commit_sha":null,"homepage":"","language":"OCaml","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/ejgallego.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-23T12:42:22.000Z","updated_at":"2025-01-15T12:30:24.000Z","dependencies_parsed_at":"2022-09-20T01:42:47.204Z","dependency_job_id":null,"html_url":"https://github.com/ejgallego/pycoq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejgallego%2Fpycoq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejgallego%2Fpycoq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejgallego%2Fpycoq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejgallego%2Fpycoq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ejgallego","download_url":"https://codeload.github.com/ejgallego/pycoq/tar.gz/refs/heads/v8.14","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238174122,"owners_count":19428629,"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","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":["coq","machine-learning","python","verification"],"created_at":"2024-09-24T13:36:10.721Z","updated_at":"2025-10-25T16:30:45.507Z","avatar_url":"https://github.com/ejgallego.png","language":"OCaml","funding_links":[],"categories":["Projects"],"sub_categories":["Tools"],"readme":"## PyCoq: Access Coq from Python!\n\n[![Build Status][action-badge]][action-link]\n[![Zulip][zulip-badge]][zulip-link]\n\n[action-badge]: https://github.com/ejgallego/pycoq/actions/workflows/ci.yml/badge.svg?branch=v8.13\n[action-link]: https://github.com/ejgallego/pycoq/actions/workflows/ci.yml?query=branch%3Av8.13\n\n[zulip-badge]: https://img.shields.io/badge/Zulip-chat-informational.svg\n[zulip-link]: https://coq.zulipchat.com/#narrow/stream/301571-PyCoq\n\n![Temporary logo][tmp-logo]\n\n[tmp-logo]: http://1.bp.blogspot.com/-gG_8XR3MKJU/TtVO_VjsP6I/AAAAAAAAAUc/T-zU36EYp7s/s400/tattoo-rae-rooster-snake.jpg\n\nPyCoq is a set of bindings and libraries allowing to interact with the\n[Coq interactive proof assistant](https://github.com/coq/coq) from\ninside Python 3.\n\nThis way, typical operations such as parsing Coq documents, and\nchecking them, can be performed programatically using Python.\n\nThis project is **extremely experimental**, and we don't provide a\nrelease yet. Use at your own risk.\n\nHelp is more than welcome; don't hesitate to open issues, suggest\nimprovements, or help with documentation\n\nWe have a [contributing guide](CONTRIBUTING.md) and a [Code of Conduct](CODE_OF_CONDUCT.md)\n\n### Build Instructions\n\nTo build PyCoq, you need Python 3 and an OCaml environment able to\nbuild SerAPI; usually, this can be achieved using the OPAM package\nmanager and doing:\n```\n$ opam install --deps-only coq-serapi\n$ opam install pythonlib\n```\nfor the 0.13 version that targets Coq v8.13; note that OCaml \u003e= 4.11.0\nis recommended, and \u003e= 4.08.0 required by the dependencies.\n\nIf that's your first checkout, you'll also have to update the `git`\nsubmodules, usually using `git submodule update --init --recursive`.\n\nFor the moment, PyCoq requires a special version of `ppx_python`, while the situation stabilizes\nin the OPAM repository we have vendored it in the SerAPI branch we use.\n\nOnce the right dependencies have been installed, you can do:\n```\n$ make install \u0026\u0026 dune build examples/test.py \u0026\u0026 dune exec -- python3 _build/default/examples/test.py\n```\n\nIf you want an interactive environment, use:\n```\n$ make install \u0026\u0026 dune exec -- python3\n\u003e\u003e\u003e import os\n\u003e\u003e\u003e os.chdir('_build/default')\n\u003e\u003e\u003e import pycoq, coq\n```\n\nOur continuous integration should contain up-to-date build\ninstructions.\n\n### Documentation\n\nAs of today, the only documentation we have is the small example below.\n\nNote however, that if you are familiar with the [SerAPI protocol](https://github.com/ejgallego/coq-serapi), you will quickly\nget used to the current API as it basically mirrors the one there [and it is derived automatically, so SerAPI's documentation could\nbe considered as canonical for pyCoq for now]\n\n### Use example:\n\n```python\nimport pycoq, coq\n\n# Some common definitions we'll use\nppopts = { \"pp_format\": (\"PpSer\",None), \"pp_depth\": 1000, \"pp_elide\": \"...\", \"pp_margin\": 90}\n\n# Add a full document chunk [mainly parsing]\nopts = {\"newtip\": None, \"ontop\": 1, \"lim\": 20 }\nres = coq.add(\"Lemma addnC n m : n + m = m + n. Proof. now induction n; simpl; auto; rewrite IHn. Qed.\", opts)\n\n# Check the proof.\nres = coq.exec(5)\n\n# We can show the goals at the tactic point\nopts = {\"limit\": 100, \"preds\": [], \"sid\": 3, \"pp\": ppopts, \"route\": 0}\ncmd = ('Goals', None)\nres = coq.query(opts, cmd)\nprint(res)\n\n# We can also output the ast for example, of the main tactic in our\n# document\nopts = {\"limit\": 100, \"preds\": [], \"sid\": 3, \"pp\": ppopts, \"route\": 0}\ncmd = ('Ast', None)\nres_ast = coq.query(opts, cmd)\nprint(res)\n\n# Such AST can be actually pretty-printed\nobj = res[0][1][0][0]\nopts = { \"pp\": { \"pp_format\": (\"PpStr\",None) } }\nres = coq.print(obj, opts)\nprint(res)\n```\n\n### TODO and Roadmap\n\nAs a nascent project, the roadmap is still in flux; issues should\ntrack the more concrete items, but indeed a lot more work is needed in\norder for PyCoq to be useful.\n\nFor a start, we need handle errors correctly and to adhere to Python\nconventions. A large amount of feedback is required from Python\nexperts as I am not familiar with Python myself at all.\n\n### Acknowledgments\n\n- `ppx_python` and `pythonlib` developers were very helpful and resolved our issues quickly, thanks!\n- Current setup was bootstrapped from https://github.com/jonathan-laurent/pyml_example , thanks a lot!\n\n### Developer team\n\n- [Emilio Jesus Gallego Arias](https://www.irif.fr/~gallego), Inria, Université de Paris, IRIF, Paris\n- [Thierry Martinez](https://github.com/thierry-martinez), Inria Paris\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejgallego%2Fpycoq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fejgallego%2Fpycoq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejgallego%2Fpycoq/lists"}