diff --git a/AGENTS.md b/AGENTS.md index e6c318a7..6ac8aee5 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -9,7 +9,7 @@ This repository contains Lean 4 compiler backends released together as leanfran. - `maint/`: repository maintenance, version management, differential tests and extern-list generators. - `.github/`: CI and release automation. - `lakefile.toml`, `Main.lean`: the Lake package of the compiler. It links the library of every backend into the one executable `leanfran`, and `Main.lean` passes the arguments to the backend that `--lang` names. -- `Leanfran/`: the compiler's shared Lean library. `Leanfran/Embed/` runs `sync`, `check` and `status` for Rust, C, Clojure, Go, Python, TypeScript and PHP, and `Leanfran/Generate.lean` runs `leanfran generate`. +- `Leanfran/`: the compiler's shared Lean library. `Leanfran/Embed/` runs `sync`, `check` and `status` for all seven backends, and `Leanfran/Generate.lean` runs `leanfran generate`. - `flake.nix`, `flake.lock`, `lean-toolchain`: shared development dependencies, the compiler package and Lean version. - `LICENSE`: the Apache-2.0 text for the entire repository. Package builds include this file in their artifacts. @@ -20,10 +20,10 @@ This repository contains Lean 4 compiler backends released together as leanfran. - Settings of a project are the tables of `leanfran.toml`, which `Leanfran/Config.lean` reads and passes to the language packages. The first line of a generated file is that of `Leanfran/Header.lean`. - Add runtime behavior to the backend's native-oracle differential tests; compare the generated program with Lean's C backend. - Regenerate runtime extern lists with the backend's `make gen-externs` where available. -- Embedded Lean blocks of Rust, C, Clojure, Go, Python, TypeScript and PHP go through `Leanfran.Embed`. A backend supplies a `Leanfran.Embed.Backend` value (`Lean/Embed.lean`, `LeanC/Embed/Backend.lean`), and its language package supplies the runtime and the `scan` and `translate` commands that the compiler runs. Change the shared flow in `Leanfran/Embed/` and check it with `maint/test-embed.sh`; `maint/test-csimp.sh` checks the functions that replace their specs in the generated code. +- Embedded Lean blocks of every backend go through `Leanfran.Embed`. A backend supplies a `Leanfran.Embed.Backend` value (`Lean/Embed.lean`, `LeanC/Embed/Backend.lean`), and its language package supplies the runtime and the `scan` and `translate` commands that the compiler runs. Change the shared flow in `Leanfran/Embed/` and check it with `maint/test-embed.sh`; `maint/test-csimp.sh` checks the functions that replace their specs in the generated code. - When generated code changes, update both the emitter's generator version and its host-side freshness version together, once between two releases. `leanfran.manifest.json` and `leanfran.lock` record the generator version and the Lean version of each language. The C backend has one `generatorVersion`; raise it when the generated C, the block workspace, the C translation, or the obligations change. - Keep shared development rules here and backend implementation details in `docs/`. -- The guides, the language READMEs and the development guides have the sections and the words that `docs/add-language.md` lists. `maint/C/test-samples.sh` compares code of `docs/c-guide.md` with the samples, and the version scripts edit the versions in `docs/rust-guide.md` and the READMEs of Rust and Clojure. +- The guides, the language READMEs and the development guides have the sections and the words that `docs/add-language.md` lists. Every `langs//samples/Makefile` has `test` and `verify` targets; `maint/test-make-targets.sh` checks them. `maint/C/test-samples.sh` compares code of `docs/c-guide.md` with the samples, and the version scripts edit the versions in `docs/rust-guide.md` and the READMEs of Rust and Clojure. ## Verification and releases diff --git a/README.md b/README.md index e3692217..f4198e1a 100644 --- a/README.md +++ b/README.md @@ -135,7 +135,7 @@ Follow the [Go quick start](langs/Go/README.md) to add the Go module and tool to ### Embedded Lean blocks -In Python, TypeScript, PHP, Go, and C, Lean blocks live in your source files. The host package reads them, and the compiler builds and generates them with three commands: +In all seven languages, Lean blocks live in your source files. The host package reads them, and the compiler builds and generates them with three commands: | Command | Effect | | --- | --- | @@ -145,7 +145,7 @@ In Python, TypeScript, PHP, Go, and C, Lean blocks live in your source files. Th `leanfran sync`, `leanfran check` and `leanfran status` without `--lang` run the command for every `[embed.]` table of `leanfran.toml` in their order, and exit with the largest code. The [settings of `sync`, `check` and `status`](docs/generate-guide.md#settings-of-sync-check-and-status) describe the tables and projects with several languages. -`--dir ` selects the project directory and defaults to the working directory. The project root is the nearest directory from there upwards with `leanfran.toml`, or else with the package file of the language (`pyproject.toml`, `package.json`, `composer.json`, or `go.mod`). `leanfran --lang --help` lists the options of a command. Commit `leanfran.manifest.json` and `leanfran.lock`, which are at the project root, and the generated files; C keeps its output directory out of version control because its link settings hold absolute paths. `sync` keeps each language's Lake workspace in `.leanfran//` and writes `.leanfran/.gitignore`, which excludes that workspace and the lock file `.leanfran/lock`; commit `.leanfran/.gitignore` too. +`--dir ` selects the project directory and defaults to the working directory. The project root is the nearest directory from there upwards with `leanfran.toml`, or else with the package file of the language (`Cargo.toml`, `pyproject.toml`, `package.json`, `deps.edn`, `composer.json`, or `go.mod`). `leanfran --lang --help` lists the options of a command. Commit `leanfran.manifest.json` and `leanfran.lock`, which are at the project root, and the generated files; C keeps its output directory out of version control because its link settings hold absolute paths. `sync` keeps each language's Lake workspace in `.leanfran//workspace` and writes `.leanfran/.gitignore`, which excludes that workspace and the lock file `.leanfran/lock`; commit `.leanfran/.gitignore` too. | Exit code | Meaning | | --- | --- | @@ -180,7 +180,7 @@ In each project: 1. Upgrade the compiler and the host package to the same release. 2. Move the settings to `leanfran.toml` as the [settings table](#settings-from-0150) says. 3. Rename the labels, options and theorems of the [source table](#sources-from-0150). -4. Run `leanfran --lang sync`, then `check` for a project with verified functions, and commit the result. Until then, `status` reports every block and function as `stale`. A Rust crate follows the [Rust table](#rust-from-0150). +4. Follow the [Rust](#rust-from-0150) or [Clojure](#clojure-from-0150) migration if applicable. Run `leanfran --lang sync`, then `check` for a project with verified functions, and commit the result. Until then, `status` reports the old entries as stale. #### Settings from 0.15.0 @@ -229,26 +229,38 @@ Settings left in an old place of TypeScript, PHP, Go, C or Rust exit with 254 an | A function or a specification that throws or panics | Different in each language | `failed: ` as the value of the function, or `the spec failed` and `error: ` | | Few inputs satisfy `requires` | Different in each language | Fails with `: only of inputs satisfied requires (seed )` after 100 discarded inputs per run | -The random test of Clojure has no label. With PHP, `Verify::checkModel` takes `?int $runs = null, ?int $seed = null`. +With PHP, `Verify::checkModel` takes `?int $runs = null, ?int $seed = null`. #### Rust from 0.15.0 | | 0.15.0 | Now | | --- | --- | --- | -| `leanfran.lock` | TOML in the crate | The section `rust` of the JSON `leanfran.lock` in the directory of `leanfran.toml`, or else in the crate. A file that is not JSON exits with 254: delete it and run `cargo leanfran extract` and `cargo leanfran check` | +| `leanfran.lock` | TOML in the crate | The `rust` section of the JSON lock in the project root. Remove the TOML lock and regenerate it with `leanfran --lang rust check`; the compiler rejects a non-JSON lock with exit code 254 | | Generated code of `lean!` | `.leanfran/cache/` | `.leanfran/rust/cache/`. Change `include` of `Cargo.toml` | -| Row of `cargo leanfran status` | `` and `