Maintained procedure · manual/COMMANDS.mdMarkdown source at d23f2aea9f24
On this page

Commands and vocabulary

Run repository commands from its root. The getting-started exercise shows the complete first use; contribution policy governs which evidence is required. A zero exit status means that command's stated scope passed.

SituationCommandResult and next step
Cold editor checkoutscripts/cache/ensure.shAttempts cache restoration; if imports are still missing, build the affected target or follow the cache guide
Check a complete named clientscripts/build.sh CslibFrontierTests.NPCompleteness --wfail --iofailBuilds that client and dependencies; inspect the first error before broadening the build
Build one domain slice without the whole libraryscripts/build.sh CslibFrontierSQL --wfail --iofailBuilds only a self-contained slice library declared in lakefile.toml (CslibFrontierSQL, CslibFrontierSAT, CslibFrontierStreaming, CslibFrontierCryptoMLDSA, CslibFrontierCryptoMLKEM, CslibFrontierBooleanAnalysis); none is in defaultTargets
Check library changes and importing clientsscripts/check.sh --quick --no-full-fallbackChecks manuals, changed sources and transitive importing clients; inspect the reported scope. Status 3 means quick mode cannot plan the change: run focused checks and use hosted CI for full validation
Full local validation when explicitly requested or hosted CI is unavailablescripts/check.shRuns the manuals and every locally runnable required CI step, including the six Lean gates; any failure prevents treating the run as full validation. Successful CI covering the final revision need not be repeated locally
Add a library modulelake exe mk_allRegenerates the library aggregate; inspect its diff and check the affected client
Check aggregate completenesslake exe mk_all --checkFails if an aggregate is stale; regenerate it and review the change
Check manual links and contextual excerptspython3 scripts/check_operator_manual.pyReports current-source matches, broken links, source line links that no longer start a declaration or that miss the declaration of the linked file their link text names, list items directly after a paragraph line (which the PDF prints as running text), locators such as Section 5.6 inside the label of a link into sources.md (which the PDF replaces by a citation number), lines of sources.md with more than one sentence, and pages missing from the book's chapter lists; repair the affected prose, link, canonical example or list
Format the manual bibliography one sentence per linepython3 scripts/sources_format.py --writeSplits multi-sentence lines of manual/sources.md while keeping every word and block unchanged
Repoint drifted declaration line anchors in manualspython3 scripts/check_operator_manual.py --fix-anchorsUpdates drifted [Ns.name](File.lean#Ln) links whose named declaration has a unique current header before running the link check; inspect remaining ambiguous, range or prose anchor errors by hand
Check the manual checkerpython3 scripts/test_operator_manual.pyRuns isolated positive and negative controls; failure identifies a checker regression
Generate an editable bookpython3 scripts/build_operator_manual.pyWrites LaTeX/PDF under ignored manual/_build/; inspect changed pages before distributing
See isolated worktreesscripts/worktree.sh listLists registered work; inspect ownership before takeover or removal
Queue an approved PRpython3 <trusted-helper> <PR> <approved head> --repo OWNER/NAMEUse the helper from current main; queues exactly the approved head after review holds clear and required checks pass
Find approved PRs that are not queuedpython3 scripts/tender_report.pyRead-only. Lists PRs approved at their exact head with green checks and no live hold, those needing a human read of a hold, restack candidates, expired HOLD lines, expired review claims and released PRs (draft or ready) not yet taken over; read the PR before queueing
Estimate per-author improvement share (advisory proxy)python3 scripts/tender_report.py --shareLocal Git only (advisory): title-based per-author proxy of refactor/perf/style merges on origin/main over 7 days, noting authors with ≥10 merges below one in five; combines fleets on a shared account and does not check evidence; fetch first
Find stalled drafts, claims and change requestspython3 scripts/stale_notices.pyDry run lists drafts idle 7 days, issue claims idle 3 days and change requests unanswered 48 hours, excluding PRs currently released to coordinators. --apply --identity <text> posts one marked notice per stall (skipping items already noticed since their last activity or within 24 hours); it never closes anything
Find branches that can be deletedpython3 scripts/branch_cleanup.py --delete mergedDry run categorizes every branch and lists unprotected ones of the selected kinds (merged, closed, nopr; the last two need --older-than, default 14d). --apply deletes them, writes a JSON log and prints a restore command per branch. No-PR branches need a notice first: --notice --identity <text> writes comment file(s) (--notice-report prints the table), and --delete nopr --apply needs --notice-issue <N>
Remove a PR from the merge queue before pushing to itgh api graphql -f id="$(gh pr view <PR> --json id --jq .id)" -f query='mutation($id: ID!) { dequeuePullRequest(input: {id: $id}) { mergeQueueEntry { state } } }'GitHub declines pushes to a queued PR's branch; this (or Remove from queue on the PR page) removes it and merges nothing. Push the restack, then queue the new head under Restacks
Check a restacked PRpython3 scripts/check_restack.py <approved head> <new head>Run from a checkout of current origin/main. For a PR approved while stacked, add --approved-base <lower head at approval>. Exit 0: the new head is the approved change replayed onto newer main, and the approval carries once CI passes at the new head; exit 1: review the printed diffs
Restack a PR whose only conflicts are in generated files, references.bib or manual/sources.mdpython3 scripts/restack_mechanical.py <PR> --approved-head <approved head>Dry run: refuses a head that is not the approved change, merges origin/main with the aggregate, bibliography and sources drivers, writes the aggregates as mk_all would and runs the restack check; refuses any other conflict. Add --push to publish the merge, which happens only if the check passes and the branch has not moved; once CI passes and review holds clear, use the printed PR/head with the trusted queue helper

The full validation sequence is maintained in AGENTS.md, and cache behavior in the cache guide. Commands above call those same scripts; they do not define an independent validation policy.

Verified command-line tools and differential tests#

Non-default [[lean_exe]] targets in lakefile.toml compile formalized solvers, proof checkers and evaluators; build a binary first with lake build <name>.

Tool or checkCommandResult and scope
Solve DIMACS CNF and emit LRATlake exe cdcl [options] INPUT.cnf [PROOF.lrat]Runs the verified CDCL solver (scripts/Cdcl.lean); prints s SATISFIABLE with a model (exit 10) or s UNSATISFIABLE and optional LRAT certificate (exit 20)
Check a DIMACS CNF + LRAT refutationlake exe lrat_check FORMULA.cnf PROOF.lratRuns CNF.checkDIMACSLRAT on text or binary LRAT (scripts/LratCheck.lean); prints s VERIFIED UNSAT (exit 0) or s REJECTED (exit 1)
Elaborate and kernel-check a VeriPB prooflake exe veripb_elab [--cnf] [--emit OUT.pbp] FORMULA PROOFElaborates an augmented VeriPB proof and checks the resulting kernel proof (scripts/VeriPBElab.lean); exits 0 on s VERIFIED
Encode or check subgraph isomorphism and cliquelake exe pb_graph iso P.lad T.lad [PROOF.pbp]Prints the labelled OPB encoding, or checks a kernel VeriPB proof (iso or clique; scripts/PBGraph.lean)
Evaluate and simplify a Cslib.SQL querylake exe sql_eval [--simplify] [--join-size] [INPUT.json]Evaluates a JSON-encoded typed schema and query or expression (--batch for JSONL) through Cslib.SQL and Cslib.Streaming.joinSize (scripts/SqlEval.lean); emits deterministic JSON with exact bag multiplicities
Differential-test Cslib.SQL against SQLitepython3 -B scripts/diff_test_sql.py --cases 300 --seed 42Compares .lake/build/bin/sql_eval (raw and Query.simplify outputs plus equijoin sizes) against in-memory sqlite3 on curated edge cases and seeded random queries (scripts/diff_test_sql.py)
Differential-test cdcl and lrat_checkpython3 -B scripts/diff_test_sat.py --random 60 --seed 42Runs .lake/build/bin/cdcl across structured and phase-transition 3-SAT families, checks every SAT model independently, feeds every UNSAT proof to .lake/build/bin/lrat_check, and checks corrupted-proof rejection (scripts/diff_test_sat.py)

Search before adding an API#

The following read-only searches use rg (ripgrep). If it is unavailable, use editor workspace search. After dependencies are present, search all three libraries:

rg -n 'ComputableInPolyTime' CslibFrontier CslibFrontierTests .lake/packages/cslib/Cslib
rg -n 'iterate_spec|iterateWith_spec' CslibFrontier .lake/packages/cslib/Cslib
rg -n 'yourCandidateName' CslibFrontier .lake/packages/cslib/Cslib .lake/packages/mathlib/Mathlib

A hit gives a source location to inspect, not an interchangeable theorem. Read its full statement and imports. If there are no hits, check spelling and namespace, related notions, the model routes and upstream coordination before declaring the API absent.

Vocabulary#

TermMeaning in the manual
ModelA specified syntax or state space, semantics and resource convention
EncodingThe representation of an input or output as a finite word; its length affects bounds
Plain computabilityThe public machine-existence/resource contract; tidy machine machinery stays inside proofs
CertificateA Lean proof of a stated property, such as computation cost; it does not supply unrelated functional correctness
ProgramFree syntax that can be interpreted with semantics and resource bounds; a PMF alone describes a distribution
Native realizationA theorem connecting a program or abstract model to the selected machine interface
UniformityA single effective construction or machine across inputs/sizes; separate per-size existence is weaker
BridgeA proved translation between specified models, preserving the advertised semantics and charging its overhead
Contextual excerptExact code from a linked complete client; imports, namespaces and preceding assumptions remain necessary
ValidationThe checks actually run on a stated revision, with their scope and outcome
Independent reviewInspection by a non-author who did not design or implement the reviewed change
Snapshot evidenceA dated source or development observation; it does not automatically describe later revisions

For the model-specific meaning of time, workspace, error, query cost, circuit size, advice, adversary access and other resources, use the model selection table and its linked reference chapters. Do not infer one resource convention from another's name.