Merge pull request #31 from lenianiva/doc/main

doc: Documentation with jupyter-book
This commit is contained in:
Leni Aniva 2024-10-18 14:54:39 -07:00 committed by GitHub
commit 494842629b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 1118 additions and 2 deletions

40
.github/workflows/docs.yaml vendored Normal file
View File

@ -0,0 +1,40 @@
name: deploy-docs
# Run this when the master or main branch changes
on:
push:
branches:
- main
- docs/main
# This job installs dependencies, builds the book, and pushes it to `gh-pages`
jobs:
deploy-book:
runs-on: ubuntu-latest
permissions:
pages: write
id-token: write
steps:
- uses: actions/checkout@v3
# Install dependencies
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: 3.11
# Build the book
- name: Build the book
run: |
jupyter-book build docs
# Upload the book's HTML as an artifact
- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
path: "docs/_build/html"
# Deploy the book's HTML to GitHub Pages
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
.*
!.gitignore
!.github
# Python
*.py[cod]

View File

@ -16,6 +16,18 @@ poetry build
poetry install
```
## Documentation
Build the documentations by
```sh
jupyter-book build docs
```
Then serve
```sh
cd docs/_build/html
python3 -m http.server -d .
```
## Examples
For API interaction examples, see `examples/README.md`. The examples directory

1
docs/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/_build

71
docs/_config.yml Normal file
View File

@ -0,0 +1,71 @@
# Book settings
# Learn more at https://jupyterbook.org/customize/config.html
# Comprehensive example: https://github.com/executablebooks/jupyter-book/blob/master/docs/_config.yml
title: PyPantograph
author: Leni Aniva
#logo: logo.png
# Force re-execution of notebooks on each build.
# See https://jupyterbook.org/content/execute.html
execute:
execute_notebooks: force
# Define the name of the latex output file for PDF builds
latex:
latex_documents:
targetname: book.tex
# Add a bibtex file so that we can create citations
#bibtex_bibfiles:
# - references.bib
# Information about where the book exists on the web
repository:
url: https://github.com/lenianiva/PyPantograph # Online location of your book
path_to_book: docs # Optional path to your book, relative to the repository root
branch: main # Which branch of the repository should be used when creating links (optional)
# Add GitHub buttons to your book
# See https://jupyterbook.org/customize/config.html#add-a-link-to-your-repository
html:
use_issues_button: true
use_repository_button: true
sphinx:
config:
intersphinx_mapping:
ebp:
- "https://executablebooks.org/en/latest/"
- null
myst-parser:
- "https://myst-parser.readthedocs.io/en/latest/"
- null
myst-nb:
- "https://myst-nb.readthedocs.io/en/latest/"
- null
sphinx:
- "https://www.sphinx-doc.org/en/master"
- null
nbformat:
- "https://nbformat.readthedocs.io/en/latest"
- null
sd:
- "https://sphinx-design.readthedocs.io/en/latest"
- null
sphinxproof:
- "https://sphinx-proof.readthedocs.io/en/latest/"
- null
hoverxref_intersphinx:
- "sphinxproof"
mathjax3_config:
tex:
macros:
"N": "\\mathbb{N}"
"floor": ["\\lfloor#1\\rfloor", 1]
"bmat": ["\\left[\\begin{array}"]
"emat": ["\\end{array}\\right]"]
extra_extensions:
- sphinx.ext.intersphinx
- sphinx.ext.autodoc

11
docs/_toc.yml Normal file
View File

@ -0,0 +1,11 @@
format: jb-book
root: intro
parts:
- caption: Features
chapters:
- file: goal
- file: proof_search
- caption: API Documentation
chapters:
- file: api-server
- file: api-search

5
docs/api-search.rst Normal file
View File

@ -0,0 +1,5 @@
Search
=============
.. automodule:: pantograph.search
:members:

5
docs/api-server.rst Normal file
View File

@ -0,0 +1,5 @@
Server
=============
.. automodule:: pantograph.server
:members:

12
docs/goal.md Normal file
View File

@ -0,0 +1,12 @@
# Goals and Tactics
Executing tactics in Pantograph is very simple.
```python
from pantograph import Server
server = Server()
state0 = server.goal_start("forall (p q: Prop), Or p q -> Or q p")
state1 = server.goal_tactic(state0, goal_id=0, tactic="intro a")
```

25
docs/intro.md Normal file
View File

@ -0,0 +1,25 @@
# Intro
This is PyPantograph, an machine-to-machine interaction interface for Lean 4.
Its main purpose is to train and evaluate theorem proving agents. The main
features are:
1. Interfacing via the Python library, REPL, or C Library
2. A mixture of expression-based and tactic-based proofs
3. Pantograph has been designed with facilitating search in mind. A theorem
proving agent can simultaneously explore multiple branches of the proof.
4. Handling of metavariable coupling
5. Reading/Adding symbols from the environment
6. Extraction of tactic training data
7. Support for drafting
## Design Rationale
The Lean 4 interface is not conducive to search. Readers familiar with Coq may
know that the Coq Serapi was superseded by CoqLSP. In the opinion of the
authors, this is a mistake. An interface conducive for human operators to write
proofs is often not an interface conductive to search.
LeanDojo has architectural limitations that prevent it from gaining new features
such as drafting without refactoring. Almost all of Pantograph's business logic
is written in Lean, and Pantograph achieves tighter coupling between the data
extraction and proof search components.

4
docs/proof_search.md Normal file
View File

@ -0,0 +1,4 @@
# Proof Search
About search ...

View File

@ -31,7 +31,11 @@ class ServerError(Exception):
DEFAULT_CORE_OPTIONS=["maxHeartbeats=0", "maxRecDepth=100000"]
class Server:
"""
Main interaction instance with Pantograph
"""
def __init__(self,
imports=["Init"],
@ -222,7 +226,7 @@ class Server:
def load_sorry(self, command: str) -> list[GoalState | list[str]]:
"""
Executes the compiler on a Lean file. For each compilation unit, either
return the gathered `sorry`s, or a list of messages indicating error.
return the gathered `sorry` s, or a list of messages indicating error.
"""
result = self.run('frontend.process', {
'file': command,

926
poetry.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -30,6 +30,7 @@ termcolor = "^2.4.0"
matplotlib = "^3.9.2"
seaborn = "^0.13.2"
pandas = "^2.2.3"
jupyter-book = "^1.0.3"
[build-system]
requires = ["poetry-core"]