|
| 1 | +# Roosterize |
| 2 | + |
| 3 | +Roosterize is a tool for suggesting lemma names in verification |
| 4 | +projects that use the [Coq proof assistant](https://coq.inria.fr). |
| 5 | + |
| 6 | +<b>We are actively updating this repository and will make it ready by |
| 7 | +the end of May. Stay tuned!</b> |
| 8 | + |
| 9 | +## Requirements |
| 10 | + |
| 11 | +- [OCaml 4.07.1](https://ocaml.org) |
| 12 | +- [SerAPI 0.7.1](https://github.com/ejgallego/coq-serapi) |
| 13 | +- [Coq 8.10.2](https://coq.inria.fr/download) |
| 14 | +- [Python 3.7+](https://www.python.org) |
| 15 | +- [PyTorch 1.1.0](https://pytorch.org/get-started/previous-versions/#v110) |
| 16 | + |
| 17 | +## Installation and usage |
| 18 | + |
| 19 | +We strongly recommend installing the required versions of OCaml, Coq, |
| 20 | +and SerAPI via the [OPAM package manager](https://opam.ocaml.org), |
| 21 | +version 2.0.6 or later. We recommend installing the required versions |
| 22 | +of Python and PyTorch using [Conda](https://docs.conda.io/en/latest/). |
| 23 | + |
| 24 | +To set up the OPAM-based OCaml environment, use: |
| 25 | +``` |
| 26 | +opam switch create 4.07.1 |
| 27 | +opam switch 4.07.1 |
| 28 | +eval $(opam env) |
| 29 | +``` |
| 30 | +Then, install Coq and SerAPI, pinning them to avoid unintended upgrades: |
| 31 | +``` |
| 32 | +opam update |
| 33 | +opam pin add coq 8.10.2 |
| 34 | +opam pin add coq-serapi 8.10.0+0.7.1 |
| 35 | +``` |
| 36 | + |
| 37 | +Then, install PyTorch following the instructions |
| 38 | +[here](https://pytorch.org/get-started/previous-versions/#v110), using |
| 39 | +the correct installation command depending on your operating system, |
| 40 | +Python package manager, and whether you want to use it on CPU or GPU. |
| 41 | + |
| 42 | +Next, clone the Roosterize repository and enter the directory: |
| 43 | +``` |
| 44 | +git clone https://github.com/EngineeringSoftware/roosterize.git |
| 45 | +cd roosterize |
| 46 | +``` |
| 47 | + |
| 48 | +To install other required Python libraries (`pip3` is included with |
| 49 | +Python installation): |
| 50 | +``` |
| 51 | +pip3 install -r requirements.txt |
| 52 | +``` |
| 53 | + |
| 54 | +To use Roosterize for suggesting lemma names in a Coq verification |
| 55 | +project using the pre-trained model (provided in this repository), |
| 56 | +where $PROJECT_PATH is the path to the project: |
| 57 | +``` |
| 58 | +python3 -m roosterize.main suggest_lemma_names --project_path=$PROJECT_PATH |
| 59 | +``` |
| 60 | + |
| 61 | +For other usages and command line interfaces of Roosterize, please |
| 62 | +check the manual page: |
| 63 | +``` |
| 64 | +python3 -m roosterize.main help |
| 65 | +``` |
| 66 | + |
| 67 | +## Technique |
| 68 | + |
| 69 | +Roosterize learns and suggests lemma names using neural networks |
| 70 | +that take serialized Coq lemma statements and elaborated terms as input. |
| 71 | +For example, the Coq lemma sentence |
| 72 | +```coq |
| 73 | +Lemma mg_eq_proof L1 L2 (N1 : mgClassifier L1) : L1 =i L2 -> nerode L2 N1. |
| 74 | +``` |
| 75 | +is serialized into the following tokens: |
| 76 | +```lisp |
| 77 | +(Sentence((IDENT Lemma)(IDENT mg_eq_proof)(IDENT L1)(IDENT L2) |
| 78 | + (KEYWORD"(")(IDENT N1)(KEYWORD :)(IDENT mgClassifier) |
| 79 | + (IDENT L1)(KEYWORD")")(KEYWORD :)(IDENT L1)(KEYWORD =i)(IDENT L2) |
| 80 | + (KEYWORD ->)(IDENT nerode)(IDENT L2)(IDENT N1)(KEYWORD .))) |
| 81 | +``` |
| 82 | +and the corresponding elaborated term: |
| 83 | +```lisp |
| 84 | +(Prod (Name (Id char)) ... (Prod (Name (Id L1)) ... |
| 85 | + (Prod (Name (Id L2)) ... (Prod (Name (Id N1)) ... |
| 86 | + (Prod Anonymous (App (Ref (DirPath ((Id ssrbool) (Id ssr) (Id Coq))) (Id eq_mem)) ... |
| 87 | + (Var (Id L1)) ... (Var (Id L2))) |
| 88 | + (App (Ref (DirPath ((Id myhill_nerode) (Id RegLang))) (Id nerode)) ... |
| 89 | + (Var (Id L2)) ... (Var (Id N1)))))))) |
| 90 | +``` |
| 91 | + |
| 92 | +The diagram below illustrates Roosterize's neural network |
| 93 | +architecture, as applied to this example: |
| 94 | + |
| 95 | +<img src="seqtoseq-arch.svg" width="700" title="Roosterize architecture"> |
| 96 | + |
| 97 | +Our [research paper][arxiv-paper] outlines the design of Roosterize, |
| 98 | +and describes an evaluation on a [corpus][math-comp-corpus] |
| 99 | +of serialized Coq code derived from the [Mathematical Components][math-comp-website] |
| 100 | +family of projects. |
| 101 | + |
| 102 | +If you have used Roosterize in a research project, please cite |
| 103 | +the research paper in any related publication: |
| 104 | +```bibtex |
| 105 | +@inproceedings{NieETAL20Roosterize, |
| 106 | + author = {Nie, Pengyu and Palmskog, Karl and Li, Junyi Jessy and Gligoric, Milos}, |
| 107 | + title = {Deep Generation of {Coq} Lemma Names Using Elaborated Terms}, |
| 108 | + booktitle = {International Joint Conference on Automated Reasoning}, |
| 109 | + pages = {To appear}, |
| 110 | + year = {2020}, |
| 111 | +} |
| 112 | +``` |
| 113 | + |
| 114 | +[arxiv-paper]: https://arxiv.org/abs/2004.07761 |
| 115 | +[math-comp-corpus]: https://github.com/EngineeringSoftware/math-comp-corpus |
| 116 | +[math-comp-website]: https://math-comp.github.io |
| 117 | + |
| 118 | +## Authors |
| 119 | + |
| 120 | +- [Pengyu Nie](https://cozy.ece.utexas.edu/~pynie/) |
| 121 | +- [Karl Palmskog](https://setoid.com) |
| 122 | +- [Emilio Jesús Gallego Arias](https://www.irif.fr/~gallego/) |
| 123 | +- [Junyi Jessy Li](http://jessyli.com) |
| 124 | +- [Milos Gligoric](http://users.ece.utexas.edu/~gligoric/) |
0 commit comments