# marqdo-prove > **Status: `v0.1.0-beta.1` (beta).** The proof pipeline is real and > independently verified on the recorded environment, but the full stable > release gates are not all met. See [`docs/RELEASE.md`](docs/RELEASE.md) for the > beta scope, CI lanes and the explicit remaining work, and [`docs/STATUS.md`](docs/STATUS.md) > for executed evidence. Static, link-driven mathematical proof checking for Marqdo knowledge documents. A `.mq.md` document stays ordinary, readable Markdown. A Knowledge H2 that also has a direct `### 证明依赖` section is a *proof target*: its single display math block is compiled to a Lean 4 proposition, its Markdown links are resolved to other selected knowledge theorems (or to a finite exact-integer program model), and the fixed Lean + Mathlib backend either proves the proposition or reports, honestly, that it could not. Every verified result is saved as a content-addressed proof bundle that can be replayed without running proof search. The normative design and acceptance gates live in [`docs/DEVELOPMENT.md`](docs/DEVELOPMENT.md). [`docs/STATUS.md`](docs/STATUS.md) records what has actually been executed; planning is never presented as capability. ## What this first release supports * **Selection**: a proof unit is an effective-mode Knowledge H2 with exactly one direct H3 named `证明依赖`. Its goal is the *one and only* display math block in its direct body. Nothing is guessed: zero or several display blocks are an error, and formulas in H3 sections, tables, quotes or code blocks never become targets. * **Math**: arbitrary-precision integers, an optional single outer `\forall x,y,... \in \mathbb{Z}` binder, `+ - \cdot \times`, constant natural exponents `x^{12}`, comparisons, `\neg`, `\land`, `\lor`, `\Rightarrow`. No reals, matrices, sums, existence, fractions, implicit multiplication or free variables. * **Links**: dependency list items are exactly one Markdown link each. Links resolve inside an explicit controlled root only; exact anchor first, then the documented exact canonical-name fallback. Cycles, missing/ambiguous/external targets, escaped roots and incompatible project contexts are errors. * **Reuse**: declared dependencies must be verified first and are imported as real Lean theorems; a target's proof term may only use project declarations from that verified closure. `declared`, `used` and transitive dependencies are reported separately. * **Program models**: an Exec H2 with explicit all-`Int` parameters, local `+ - *` assignments and one final `return` can be referenced with `\operatorname{name}(...)`. The generated Lean definition is checked; this is an exact-integer model, **not** a statement about the real runtime. * **Verification**: search and verification are separate. The payload is the stock `lean4export` NDJSON closure; the verifier kernel-replays it with the bundled independent checker (`con-leche --verified`), regenerates the expected proposition from the current sources (never from the proof process), checks alpha-equivalence of the target type, rejects metavariables, and enforces the fixed axiom set `propext`, `Classical.choice`, `Quot.sound`. * **Bundles**: one directory with `manifest.json` + `proof.ndjson`, bound to source/Analysis digests, goal digest, models, dependencies, environment and payload SHA-256. A cache hit is replayed, never trusted. * **CLI**: `check` and `replay` only. Exit codes: 0 all requested targets verified (or no target), 1 at least one not verified, 2 engineering failure. `--out` with exactly one requested target makes that directory the bundle; with several targets it writes one self-contained bundle directory per target under `PATH//`. ## What it deliberately does not do Real/rational/complex/matrix mathematics, general automated theorem proving, natural-language formalization, LLMs, network knowledge, arbitrary `.olean` imports, executing fenced code, loops/branches/calls/floats in program models, or claims about the runtime. Unsupported input stays readable knowledge and is reported as `unsupported`/`invalid`; it is never silently accepted. ## Repository layout ```text src/ main.rs argument handling, presentation, exit codes lib.rs shared contract types (spans, outcomes, diagnostics, limits) analysis.rs the only `marqdo check --emit` integration + rev 3 validation document.rs proof-unit selection from the public document AST formula.rs the only restricted math lexer/parser/type checker linker.rs controlled multi-entry catalog, exact links, DAG, cycles model.rs finite exact-integer program model validation + Lean mapping lean.rs fixed backend: trusted generation, search, export, replay certificate.rs single `marqdo.proof` bundle contract and content cache prove.rs single orchestration of `check` / `replay` lean/ pinned Lean project (`lean-toolchain`, `lake-manifest.json`) examples/ author-facing `.mq.md` fixtures used by the tests tests/ real-CLI integration, formula/model contracts, acceptance docs/ the specification and executed-evidence status tool.json Marqdo CLI Tool manifest (api_revision 1, analysis 3) ``` ## Build Requires a Rust toolchain and the pinned Lean 4 + Mathlib environment. ```sh cargo build --release ``` The Lean backend is pinned by `lean/lean-toolchain` and `lean/lake-manifest.json`. To set it up (one-time, needs network): ```sh # install the exact toolchain and fetch the mathlib oleans for the pinned rev cd lean lake update lake exe cache get lake build marqdo-replay ``` The pinned backend needs real address space: on the recorded machine a low `RLIMIT_AS` fails during Mathlib loading (6 GiB and 9 GiB were measured failing, 12 GiB succeeds), so Prove bounds Lean by wall-clock/CPU budgets instead of an address-space rlimit. This and the other measured limitations are recorded in [`docs/STATUS.md`](docs/STATUS.md). `marqdo-prove` never downloads anything at runtime. It discovers the backend via `MARQDO_PROVE_LEAN_ROOT` (the `lean/` directory) and `MARQDO_PROVE_LEAN_BIN_DIR` (the toolchain `bin` directory); see `docs/STATUS.md` for the exact paths used in verified runs. The upstream CLI is required for static Analysis and is invoked only through `MARQDO_BIN` (an absolute path, argv, no shell): ```sh export MARQDO_BIN=/path/to/marqdo cargo run --release -- check examples/vector.mq.md --json cargo run --release -- check examples/arithmetic.mq.md --unit '平方函数的非负性' cargo run --release -- check examples/vector.mq.md --out /tmp/vector-proof cargo run --release -- replay examples/vector.mq.md /tmp/vector-proof ``` ## Tests ```sh cargo fmt --all -- --check cargo clippy --all-targets -- -D warnings cargo test # Lean-backed acceptance tests (real CLI + pinned backend, ignored by default) MARQDO_BIN=/path/to/marqdo cargo test --test e2e -- --ignored --test-threads=1 ``` Real-CLI tests read `MARQDO_BIN`; they skip (and say so) when it is not set. Lean-backed end-to-end tests additionally require the backend above; see `docs/STATUS.md` for the exact commands executed and their observed output. ## Exit codes and output Machine output is one JSON object on stdout (`--json`); diagnostics and progress go to stderr. Human output lists each target's outcome, scope, freshness, normalized statement, premises, declared/used dependencies, axioms and certificate location, followed by a summary. ## License Apache-2.0 (matching the upstream Marqdo CLI).