Package: graph2tac
Graph2TacGraph2Tac is a novel neural network architecture for predicting tactics in the Coq theorem prover,
and for assigning embeddings to new definitions (including theorems).
More details can be found inthe paper.
This python project makes it possible to train and run Graph2Tac models
to be used insideTactician,
an automated theorem proving system for Coq.Using Graph2Tac within CoqThe simplest way to use the Graph2Tac model trained for the paper is via Tactician.
See the instructions for theTactician API.Using the graph2tac libraryInstallationGraph2Tac has been tested with Linux and x86 MacOS, but may work on other systems as well.
It requires Python 3.9, 3.10, or 3.11, and can be installed withpipinstallgraph2tacIt is highly recommended that you use avirtual environmentorcondaenvironment.TrainingTo get started on training a model, the following code
(where paths are relative to therepositoryroot)
trains on a small portion of the Coq standard library use for testing this project.g2t-train-tfgnn\--data-dirtests/data/mini_stdlib/dataset/\--dataset-configgraph2tac/tfgnn/default_dataset_config.yml\--prediction-task-configgraph2tac/tfgnn/default_global_argument_prediction.yml\--trainer-configgraph2tac/tfgnn/default_trainer_config.yml\--run-configgraph2tac/tfgnn/default_run_config.yml\--definition-task-configgraph2tac/tfgnn/default_definition_task.yml\--logmodel/Seeg2t-train-tfgnn --helpfor more command line options,
and the various YAML files to change the hyperparameters and training epochs.
The trained model is stored in the log directory,model/in the above example.
(Note, ifmodel/already exists and contains a model, it will continue training that model.)Seeherefor the full Coq dataset.RunningThe above trained model (or another existing trained model)
can be run via a prediction server for interacting with Coq as follows:g2t-server\--archtfgnn\--tcp--port33333--host0.0.0.0\--modelmodel/\--log_level=info\--tf_log_level=critical\--tactic_expand_bound=256\--search_expand_bound=256\--update_new_definitionsThe server is available locally vialocalhost:33333or remotely viaURL:33333whereURLis the URL (or IP address) of the machine it is running on.
UseCTRL-Cto exit the server.
Seehttps://github.com/coq-tactician/coq-tactician-apifor instructions on how to call the server from Coq.One can also run the server via stdin/stdout by replacing--tcp --port 33333 --host 0.0.0.0with--stdinThis is intended for starting the server directly from within Coq.Seeg2t-server --helpfor more command line options.Using a GPUGraph2Tac uses Tensorflow for training and inference, and will support Nvidia GPUs.
To test that Tensorflow can access your system GPU, run the following python script.importtensorflowastfprint("How many GPUs available: ",len(tf.config.list_physical_devices('GPU')))and follow theTensorflow GPUinstructions if needed.
Note, for using GPUs with conda environments it may be necessary to setexportLD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/libForg2t-train-tfgnn, to train on the available GPUs, add--gpu allto the options forg2t-train-tfgnn.
Training on multiple GPUs is supported (but only tested up to two A100s).Forg2t-serverit will use any available GPUs.  (You can also control the number of CPUs via--cpu-thread-count.)DevelopmentIf you wish to develop Graph2Tac or run a previous commit, you may install it
from within therepositoryviapipinstall-e.You can run tests as followspytesttestsSee thetesting READMEfor more information.