# Plumb — User & AI-Agent Guide Index (`llms.txt`) > Plumb is a formal verification language for empirical and theoretical physics. > Declare scientific meaning in `.plumb`, import established results from `std`, and pin raw JSON tables and covariances with `plumb lock`. Use `plumb check` to see verdicts and `--out` to save them in `receipt.json`. - Website: https://plumb-lang.sh - Full single-file guide: https://plumb-lang.sh/llms-full.txt - Install (macOS / Linux): `curl -LsSf https://plumb-lang.sh/install.sh | sh` or `brew install sprajs/tap/plumb` - Install (Windows): `irm https://plumb-lang.sh/install.ps1 | iex` or `scoop bucket add sprajs https://github.com/sprajs/scoop-bucket && scoop install sprajs/plumb` - Install (Cargo / npm): `cargo install plumb-lang` or `npm install -g plumb-lang` (`npx plumb-lang`) - Repository & Releases: https://github.com/sprajs/plumb ## Use Lean 4 for General Formal Proofs (`by lean`) Plumb is **not** a general theorem prover or computer algebra system. Use Plumb's built-in checkers for physics plumbing (units, biases, covariance, epistemic cycles, intervals, quadrature, derivatives, piecewise/trig/hyperbolic models, and polynomial/scaling/SOS claims). Whenever a closed comparison `claim` (rational arithmetic, table folds, or identities lowered by Plumb) needs a machine-checked proof — or draws on a general proof inside a locally vendored **Mathlib** / **Physlib** or custom Lake project to prove that closed target and discharge a `MathematicalPremise` — **use Lean 4 directly**: - **Sidecar proof:** write `claim c : by lean "proofs/c.lean"`. Run `plumb lean goal --claim c` to see the exact Lean target Plumb generates, and `plumb lean init --claim c` to create the proof file. - **Existing Lake project:** write `claim c : by lean theorem Mod.thm from lake "formal" module Mod`. Local Lake projects build offline in the sandbox from pinned local sources (external libraries such as Mathlib/Physlib are not fetched over the network during `plumb check`). - **Premise discharge:** propagate verified results into downstream ledgers with `assumption math.x : MathematicalPremise states discharged by c` (inspected with `plumb trace`). - **Seamless background locking & caching:** `plumb lock` automatically pins `.lean` proof sources and local Lake inputs (including `.lean` proofs inside `std/` and `examples/`). Plumb auto-discovers system Lean / `~/.elan`, checks statement agreement and transitive axioms (via isolated `lake comparator` export verification when available, or kernel-environment replay without loading untrusted extensions), enforces a subprocess timeout (`PLUMB_LEAN_TIMEOUT_SECS`, default `120`), and caches verified results locally so warm checks run in milliseconds. Run `plumb doctor --lean` to inspect backend and cache status (`plumb doc lean`). ## Built-In CLI Documentation (Offline, Always Version-Matched) With the `plumb` binary installed, start with these commands. - `plumb doc` — list all guide topics - `plumb doc ` — read one page (`mental-model`, `quickstart`, `language`, `biases`, `ladders`, `verdicts`, `checkers`, `std`, or alias `lean` / `parity`) - `plumb doc std.` — print any built-in `std` module source verbatim (e.g., `plumb doc std.astronomy.ladder.cepheids`) - `plumb doc --all` — print the complete user guide as one Markdown stream - `plumb doc --search ` — search all guide sections - `plumb doc --json` — export structured JSON documentation - Look for `overlap.class`, `overlap.count` and `overlap.first` in a joint dependence refusal. - Use `CSV layout table` with a header and one axis. The optional `labels "id"` and `objects "object_id"` pins check row identities against the manifest. `layout matrix` reads numeric rows. `layout count_prefixed` reads the dimension followed by its square in entries. Declare matrix axes in order. A square CSV covariance can name its common axis once. Use comma (default) or space as the delimiter. Nonzero decimal covariance entries must fit the normal binary64 range. - Gaussian comparisons with a covariance block above 64 rows or a decimal CSV covariance report certified `chi2.lo` and `chi2.hi`. A score enclosure crossing the budget can yield `unresolved bound_too_loose`. - A `FITS` artifact reads one finite binary32 or binary64 primary image. Use `axes A` for a value vector and `axes A, A` for a square covariance in row-major order. The coordinates in each manifest follow the on-disk data order. - Use `catalogue` and `release` for stable object and row identities. Bind an Axes manifest with `release NAME`; a release may declare `objects CATALOGUE` and `covariance MATRIX`. - `derived from benchmark.common` names an opaque data source. Reusing the same tag across observations blocks an independence assumption. Reusing it across a model and its observation blocks circular calibration. - `plumb explain ` — explain any diagnostic code (`P0001`–`P0406`) - `plumb list checkers` — list all 19 built-in `by ` verification methods (including `lean`) - `plumb lean goal [--claim ]` / `plumb lean init` / `plumb doctor --lean` — inspect, scaffold, and diagnose Lean 4 proofs - `plumb parity --theory --scope --points ` — export exact per-block `chi2` & Gaussian `log_likelihood = -0.5 * chi2` at fixed points for external MCMC / fitter parity checks ## Guide Pages (Raw Markdown at `/docs/.md`) - [Mental Model: How Plumb Thinks](https://plumb-lang.sh/docs/mental-model.md): Core philosophy, `.plumb` vs raw JSON vs lockfiles, built-in checkers vs. Lean 4 and external MCMC/fitters, four non-negotiable rules. - [Quickstart & Everyday Workflow](https://plumb-lang.sh/docs/quickstart.md): Complete runnable `.plumb` example and CLI commands (`check`, `fmt`, `lock`, `trace`, `compare`, `validate`). - [The `.plumb` Language Reference](https://plumb-lang.sh/docs/language.md): Complete syntax (`let`, `if/then/else`, `deriv`, trig/hyperbolic/inverse builtins), closed unit table, strict JSON schemas (`Axes`, `Table`, `Matrix`), declared `role`s, observables, theories (`extends`, default parameter boxes), inline role predictions with scoped `assuming` clauses, `rule` declarations, Lean premise discharge, claims, compares, scopes. - [Uncertainties, Biases & Selection](https://plumb-lang.sh/docs/biases-and-errors.md): Statistical `noise`/`shared` nuisances vs deterministic `bounded` systematics (`P0312`), pooling vs exact cancellation, `includes` rules (`P0315`), covariate masks vs outcome truncation. - [Stacking Modules, Lineage & Indirect Contradictions](https://plumb-lang.sh/docs/composition-and-ladders.md): Multi-module stacking, rules composed onto roles, theory inheritance that drops a replaced prediction's grants, `derived from`, `conditioned on`, cycles (`P0330`), circular calibration, shared-posterior double counting, and `consistency_graph` Minimal Conflict Cores (MUS). - [Verdicts, Receipts & CLI Reference](https://plumb-lang.sh/docs/verdicts-and-receipts.md): Every `Disposition`, `RefusalReason`, `expect` syntax, `receipt.json` schema, `--parent` receipt hash-chaining, `audit_summary` (`status`, `next_action`, `complexity`, `unused_parameters`, `unsatisfied_conditioning`, `accommodation`), `plumb parity` for MCMC/fitters, and CLI exit codes (`0`/`2`/`3`). - [Built-In Checkers & Diagnostics](https://plumb-lang.sh/docs/checkers-and-diagnostics.md): Exact claim & compare method names, Lean 4 proof workflow (`by lean`), and diagnostic troubleshooting table. - [Standard Library (`std/`) Reference](https://plumb-lang.sh/docs/std-reference.md): Searchable module index and worked examples across measurement science, condensed matter, civil nuclear physics, particle physics, astronomy and cosmology. ## Syntax and checks - Write multiplication as `2 * pi` and attach unit powers as in `2 kpc^2`. - **Angle & expression contracts:** `sin`/`cos`/`tan` take `Angle` (`deg`, `rad`, `arcsec`, `mas`, `uas`; e.g., `sin(x * 1 rad)` for a dimensionless phase) and return `Dimensionless`; `atan`/`asin`/`acos` return `Angle`; `sinh`/`cosh`/`tanh` take and return `Dimensionless`. Local bindings use `let y = e in b`, piecewise uses `if p then a else b` (strict boolean guard, mandatory `else`), and symbolic derivatives use `deriv(x, e)` with dimension `dim(e) / dim(x)`. - **Implicit coordinates:** `certified_root(x in range(lo, hi), residual)` returns an enclosure in the units of the strictly ordered bracket. The residual must have one strict derivative sign throughout the bracket, and the endpoint values must enclose zero for every evaluated parameter assignment. Use it in `interval_enclosure` claims and `consistency_graph` predictions. - Group declarations with `roles demo { ... }` and `assumptions StatisticalModel { ... }`. Write scalar Gaussian readings as `value +- sigma Unit` and theory parameter boxes as `name in [lo, hi] Unit`. Explicit interval bindings in `compare ... at` take a unit on each endpoint. - Use `theory T { assume ... }` to declare premises and `predict role = expression` to predict a role. Use `rule ... requires ... grants ...` to derive roles from other roles. A rule's `valid when` bounds must hold over the whole input range used in a comparison. - Set reference checks and frozen policies with `scope ... { baseline ... limit price <= N, free_parameters <= M alpha

allow ... check ... open ... }`. In the candidate module, `audit T against std.module.scope` runs the imported scope with `plumb check`, emitting `audit_summary` (`status`, `next_action`, `complexity`, `exceeded_limits`, `unused_parameters`, `unsatisfied_conditioning`, `accommodation`). With a `baseline`, a candidate parameter that only the baseline's conflict-core observations read is classified `accommodation` rather than `not_contradicted`. Pass `--parent ` on `plumb check` / `plumb audit` to hash-chain attempts on the same scope. - Selective imports accept simple or dotted names, for example `import std.gauge (sm_family_charges as charges, math.sm_three_weyl_families)`. - Keep `PhysicalOntology` premises in `inference ... conditioned on requires ` (`P0322`). Satisfy them through theory assumptions, an evaluated prediction, or an evaluated rule. - A deeper-tier observation in the referee library can declare `supersedes_for

when not ` (`P0323`). Under `plumb audit`, a candidate that does not satisfy that requirement of the summary faces the superseding observation instead (the finding's `supersession` measure records it). Without one, the audit is `uncovered` / `escalate_tier` and lists the requirement in `audit_summary.unsatisfied_conditioning`. - Keep `bounded` systematics outside `gaussian(...)` (`P0312`). Use `bounded_gaussian` or `consistency_graph`. - A measured centre with unspecified uncertainty produces `blocked unspecified_uncertainty` in a statistical comparison, including when used inside a prediction. Declare `noise none assuming ` only when using the source as an explicitly fixed record. - Use `exclusion_contour` for membership in a published upper limit or a two-sided scalar `published_interval(lower = ..., upper = ..., level = ...)`. Name the statistical construction. The check returns membership at the stated level. - For a published mass scan, `select model coordinate curve["rest_energy"] == wimp.rest_energy` selects the candidate's predicted rest energy in the typed column's units. Role aliases preserve identity. A 9 GeV prediction selects 9 GeV even with a separate 40 GeV binding. An off-grid prediction gives `unassessed no_applicable_checker` with `exclusion_contour`. For a manual lookup, use `select mask covariate curve["rest_energy"] == query_energy` with a unit-bearing `at query_energy` binding. - Use `sum` or `prod` in a direct `exact_rational` or `interval_enclosure` claim over a pinned table with one unit declared per column, for example `Table[Dimensionless, mag]`. The table keeps its data lineage. Supply a separate covariance model when comparing observations. - In `Table` and `Matrix` artifacts, quote decimal and rational values. Set `axis_manifest_sha256` to the exact digest of the `Axes` file. Run `plumb lock ` to pin the inputs. - Completed checks, including `Conflict` and `Blocked`, exit `0`. Input and validation errors exit `2`. Internal or I/O execution errors exit `3`. ## Built-in unit symbols - Dimensionless `1` or `Dimensionless` in annotations - Length `m`, `km`, `um`, `nm`, `cm`, `AU`, `pc`, `kpc`, `Mpc`, `l_Pl` - Time `s`, `d`, `yr`, `Gyr` - Frequency `Hz`, `MHz`, `GHz` - Mass `kg`, `g`, `Msun` - Energy `J`, `eV`, `MeV`, `GeV`, `TeV` - Magnitude `mag`, temperature `K`, angle `arcsec`, `mas`, `uas`, `deg`, `rad` - Force `N`, power `W`, pressure `Pa` - Current `A`, charge `C`, potential `V`, resistance `Ohm`, magnetic flux density `T` - Amount of substance `mol` Join units without spaces, as in `km/s/Mpc` or `N/A^2`. Both `1/yr` and `yr^-1` express reciprocal years. For prefixes outside the table, write the conversion explicitly, such as `1e-3 s` for a millisecond. Use `correlated name: a, b cov matrix assuming premise` to supply cross-covariance for a joint Gaussian comparison. Scalar pairs also accept a covariance expression in the product of their units. Duplicate rows block even with a declaration. Use `--no-cache` with `check`, `audit`, or `parity` for a cold covariance proof. Warm and cold runs have the same audit body. A linear fit uses `fit F: y ~ linear(L) as q` and `by validated_gls`. Use `q["axis_id"]` for a parameter and `emit (label: role = expr)` to name an affine projection. L has parameter rows and observation columns. Use a fit's name or a named view to consume multiple emitted axes jointly. A single coordinate is available as `fit_name.label`. All projections carry the full fit identity. The `emitted` receipt map preserves statistical covariance and the upstream chi-square separately. Fit factors retain signed nuisance loadings and bounded responses. A residual constraint on a shared systematic requires a joint fit of the original data. Use `pin (a, b) from upstream.view` to retain joint covariance. Every pinned role must match, input identities must be disjoint, and the consumer must grant upstream conditioning. P0317 identifies repeated pins from the same fit.