{"id":27214580,"url":"https://github.com/rocq-community/bertrand","last_synced_at":"2025-04-10T03:24:22.863Z","repository":{"id":42122942,"uuid":"57116671","full_name":"rocq-community/bertrand","owner":"rocq-community","description":"Coq proof of Bertrand's postulate on existence of primes [maintainer=@thery]","archived":false,"fork":false,"pushed_at":"2024-07-15T12:00:43.000Z","size":258,"stargazers_count":3,"open_issues_count":2,"forks_count":3,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-24T15:06:58.907Z","etag":null,"topics":["coq","coq-extraction","knuth-algorithm","prime-numbers"],"latest_commit_sha":null,"homepage":"","language":"Coq","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rocq-community.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":"2016-04-26T09:44:36.000Z","updated_at":"2024-07-15T12:00:47.000Z","dependencies_parsed_at":"2025-03-24T15:07:02.206Z","dependency_job_id":"157ca7ba-f36d-4437-a642-be1ef4e1f7ae","html_url":"https://github.com/rocq-community/bertrand","commit_stats":null,"previous_names":["rocq-community/bertrand"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rocq-community%2Fbertrand","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rocq-community%2Fbertrand/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rocq-community%2Fbertrand/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rocq-community%2Fbertrand/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rocq-community","download_url":"https://codeload.github.com/rocq-community/bertrand/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248149584,"owners_count":21055786,"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","coq-extraction","knuth-algorithm","prime-numbers"],"created_at":"2025-04-10T03:24:21.985Z","updated_at":"2025-04-10T03:24:22.833Z","avatar_url":"https://github.com/rocq-community.png","language":"Coq","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!---\nThis file was generated from `meta.yml`, please do not edit manually.\nFollow the instructions on https://github.com/coq-community/templates to regenerate.\n---\u003e\n# Bertrand\n\n[![Docker CI][docker-action-shield]][docker-action-link]\n[![Contributing][contributing-shield]][contributing-link]\n[![Code of Conduct][conduct-shield]][conduct-link]\n[![Zulip][zulip-shield]][zulip-link]\n[![DOI][doi-shield]][doi-link]\n\n[docker-action-shield]: https://github.com/coq-community/bertrand/actions/workflows/docker-action.yml/badge.svg?branch=master\n[docker-action-link]: https://github.com/coq-community/bertrand/actions/workflows/docker-action.yml\n\n[contributing-shield]: https://img.shields.io/badge/contributions-welcome-%23f7931e.svg\n[contributing-link]: https://github.com/coq-community/manifesto/blob/master/CONTRIBUTING.md\n\n[conduct-shield]: https://img.shields.io/badge/%E2%9D%A4-code%20of%20conduct-%23f15a24.svg\n[conduct-link]: https://github.com/coq-community/manifesto/blob/master/CODE_OF_CONDUCT.md\n\n[zulip-shield]: https://img.shields.io/badge/chat-on%20zulip-%23c1272d.svg\n[zulip-link]: https://coq.zulipchat.com/#narrow/stream/237663-coq-community-devs.20.26.20users\n\n\n[doi-shield]: https://zenodo.org/badge/DOI/10.1007/10930755_20.svg\n[doi-link]: https://doi.org/10.1007/10930755_20\n\nA Coq proof of Bertrand's postulate, which says that there always\nexists a prime between n and 2n for n greater than 2. Includes\nan application of the postulate to compute partitions.\n\n## Meta\n\n- Author(s):\n  - Laurent Théry (initial)\n- Coq-community maintainer(s):\n  - Laurent Théry ([**@thery**](https://github.com/thery))\n- License: [GNU Lesser General Public License v2.1 or later](LICENSE)\n- Compatible Coq versions: Coq 8.18 or later\n- Additional dependencies: none\n- Coq namespace: `Bertrand`\n- Related publication(s):\n  - [Proving Pearl: Knuth's Algorithm for Prime Numbers](https://link.springer.com/chapter/10.1007%2F10930755_20) doi:[10.1007/10930755_20](https://doi.org/10.1007/10930755_20)\n\n## Building and installation instructions\n\nThe easiest way to install the latest released version of Bertrand\nis via [OPAM](https://opam.ocaml.org/doc/Install.html):\n\n```shell\nopam repo add coq-released https://coq.inria.fr/opam/released\nopam install coq-bertrand\n```\n\nTo instead build and install manually, do:\n\n``` shell\ngit clone https://github.com/coq-community/bertrand.git\ncd bertrand\nmake   # or make -j \u003cnumber-of-cores-on-your-machine\u003e \nmake install\n```\n\n\n## Contents\n\nThis project consists of:\n\n- A Coq proof of Bertrand's postulate: there always exists a prime between\n  n and 2n for n greater than 2 (`Bertrand.v`).\n- A little program in OCaml, based on code extracted from Coq,\n  that generates a partition of 1..2n in pairs (i,j) such that i+j\n  is always prime (`run_partition.ml`). The proof of correctness\n  of this program is a direct consequence of Bertrand's postulate (`Partition.v`).\n  This nice application of Bertrand's postulate was suggested by Gérard Huet.\n- A proof of correctness of an implementation of the algorithm for computing primes\n  described in \"The Art of Computer Programming: Fundamental Algorithms\" by Knuth,\n  pages 147-149. The proof uses the [Why3 tool](http://why3.lri.fr) to generate\n  verification conditions for the WhyML program that implements the algorithm.\n  These verification conditions can then be discharged by Coq and the\n  [Alt-Ergo](https://alt-ergo.ocamlpro.com) prover.\n\n## Extracting and running the OCaml partition program\n\nTo extract code and obtain the program, run\n```shell\nmake run_partition.ml\n```\n\nNext, open an OCaml toplevel (e.g., `ocaml`) and do\n```ocaml\n#use \"run_partition.ml\";;\n```\n\nTo get a partition from 1...30:\n```ocaml\nlet part30 = part 15;;\n```\n\n## Replaying the WhyML program correctness proof\n\nTo replay the proof of correctness for the WhyML program for computing primes,\nfirst make sure the following packages are installed (in addition to Coq 8.18.0\nand the proof of Bertrand's postulate):\n\n- [Alt-Ergo 2.5.4](https://alt-ergo.ocamlpro.com)\n- [Why3 1.4.1](http://why3.lri.fr) and its Coq library\n\nThese packages can be installed via OPAM using the following command:\n```\nopam install alt-ergo.2.5.4 why3.1.7.2 why3-coq.1.7.2\n```\nThen, the proof can be replayed by running\n```\nmake why\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frocq-community%2Fbertrand","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frocq-community%2Fbertrand","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frocq-community%2Fbertrand/lists"}