The .plumb Language Reference
Lexical Rules & Comments
- Line comments start with
--and run to the end of the line. - Identifiers use ASCII letters, digits, and
_(cannot start with a digit). - Qualified names join identifiers with
.(e.g.,ontology.cold_dark_matter,std.core.c). - Numbers support integers (
42), decimals (73.04), and scientific notation (6.67430e-11). Useinffor infinity. - Always write explicit
*between a number and an identifier or function call (2 * pi, never2 pi— juxtaposition is rejected asP0107). - Attach unit exponents directly to the unit (
2 kpc^2), or parenthesize the whole quantity ((2 kpc)^2). Writing2 kpc ^ 2with spaces is rejected (P0109).
Imports
Place import statements at the top of a file, before any declarations.
-- Import everything exported by a module
import std.core
import std.cosmology.cmb.planck_2018
import std.cosmology.lss.desi_dr2_bao
-- Selective import (only specific names, with optional `as` alias)
import std.astronomy.ladder.parallax (lmc_deb, lmc_deb_sys as lmc_anchor_scale)
import std.gauge (sm_family_charges, math.sm_three_weyl_families)
Workspace modules resolve relative to the workspace root (e.g., import helpers.models loads helpers/models.plumb). Standard library modules always begin with std. and cannot be shadowed by workspace files.
- Imports are transitive and diamond-safe (if module
CimportsBwhich importsA,CseesA’s exports, and importing bothAandBdeduplicates cleanly withoutP0121). - Selective imports accept simple and dotted names. Each selection also loads the declarations it depends on. An alias after
asis a single identifier. - Importing a module makes its declarations available. Reference upstream checks through
derived fromorscope ... afterto make their results prerequisites.
Built-In Units (Closed Table)
Plumb accepts the unit symbols in this table. For a prefix absent from the table, write the scale explicitly, such as 1e-3 s for a millisecond.
| Dimension | Allowed unit symbols |
|---|---|
| Dimensionless | 1 (use Dimensionless in type annotations) |
| Length | m, cm, km, um, nm, AU, pc, kpc, Mpc, l_Pl |
| Time | s, d (86400 s), yr (Julian year, 31557600 s), Gyr (a billion Julian years) |
| Frequency | Hz, MHz, GHz |
| Mass | kg, g, Msun |
| Energy | J, eV, MeV, GeV, TeV |
| Force / Power / Pressure | N, W, Pa |
| Electromagnetism | A, C, V, Ohm, T |
| Amount | mol |
| Magnitude | mag |
| Temperature | K |
| Angle | arcsec, mas, uas, deg (3600 arcsec), rad (648000 / pi arcsec) |
Join compound unit symbols without spaces, as in km/s/Mpc, kg*m^2/s, or m/s^2. Write reciprocal units as 1/yr or yr^-1, for example 2 1/yr or 2 yr^-1. The Msun scale is the IAU 2015 nominal GM_sun divided by the adopted CODATA 2022 value of G.
Expressions, Built-In Functions & Control Forms
- Elementary functions:
abs(x),sqrt(x),min(a, b),max(a, b),mod(a, b)exp(x),ln(x),log10(x),sinh(x),cosh(x),tanh(x)(Dimensionless -> Dimensionless)sin(a),cos(a),tan(a)(Angle -> Dimensionless; pass a dimensionless phase assin(p * 1 rad))atan(x),asin(x),acos(x)(Dimensionless -> Angle; divide by1 radfor a dimensionless radian count)
- Local lexical bindings:
let y = e in b(nonrecursive;eresolves in the outer scope,bin the extended scope, shared within the same evaluation environment). - Piecewise expressions:
if p then a else b(mandatoryelse;pmust be a comparison/boolean predicate; both arms must have compatible scalar dimensions; derivative/quadrature kernels enforce local smoothness across branch boundaries). - Symbolic derivatives:
deriv(x, e)differentiates with respect to an independent scalar coordinatex(formal parameter, quantified variable, integral variable, or typed theory parameter) before call-site substitution, with dimensiondim(e) / dim(x). - Folds & integrals:
sum(r in tbl, ...),prod(r in tbl, ...),integral(u in range(lo, hi), ...). - Bracketed roots:
certified_root(x in range(lo, hi), residual)encloses the unique zero of a scalar residual and returns a quantity in the units of the bracket.
Declarations
convention — Exact Adopted Constants
convention c : m/s = 299792458 m/s "SI 2019 exact definition"
convention H100 : km/s/Mpc = 100 km/s/Mpc "Reference Hubble scale"
Conventions are exact point values (no uncertainty propagated). For empirical physical constants with uncertainties, use measurement (like m_e_codata2022 and G_codata2022 in std.core).
assumption — Typed Epistemic Premises
Each assumption has one of five kinds.
PhysicalOntology— postulates physical entities or couplings (forbidden on rawmeasurement!)RegimeApproximation— validity regime (flat FLRW, weak field, low redshift, etc.)CalibrationAndInstrument— telescope/detector/anchor calibration modelStatisticalModel— likelihood or error distribution assumptionMathematicalPremise— mathematical regularity or remainder premise
assumption ontology.cold_dark_matter : PhysicalOntology "Pressureless cold dark matter."
assumption regime.low_z_cosmography : RegimeApproximation
assumption calibration.hst_wfc3 : CalibrationAndInstrument
assumption stat.gaussian_errors : StatisticalModel
assumption math.smooth_integrand : MathematicalPremise
-- Optional: discharge a MathematicalPremise from a verified claim (Lean or built-in):
assumption math.hypercharge_sum : MathematicalPremise "Multiplicity-weighted hypercharges sum to zero."
states sum(f in sm_family_charges, f["d3"] * f["d2"] * f["Y"]) == 0
discharged by grav_u1
assumptions StatisticalModel {
stat.gaussian_clock "Gaussian laboratory clock uncertainty"
stat.independent_clocks "Independent laboratory clock readings"
}
Use assumptions <Kind> { ... } to group assumptions of one kind. Each entry keeps its full name and can carry a short description.
artifact — External Raw Data Files
External data files are declared by path relative to the workspace root (or std/ for standard-library modules). Exact-byte SHA-256 digests are stored in plumb.lock via plumb lock, never inline.
artifact my_axes : Axes from "data/my.axes.json" rows 3
artifact my_table : Table from "data/my.table.json" axes my_axes rows 3
artifact my_cov : Matrix from "data/my.cov.json" axes my_axes
-- Optional: declare nuisances already baked into a covariance matrix:
artifact full_cov : Matrix from "data/full.cov.json" axes my_axes includes zp_cal
Strict JSON Schemas for Data Artifacts
All JSON artifacts reject duplicate keys and unknown fields. All numeric entries in tables and matrices must be quoted decimal or rational strings (e.g., "0.3473", "1/4") so exact rational parsing suffers zero floating-point drift. Both Table and Matrix must set axis_manifest_sha256 to the exact SHA-256 hex digest of the referenced Axes file (compute it with sha256sum data/my.axes.json, then run plumb lock <dir>).
1. Axes (plumb.axis_manifest/v1):
{
"schema_version": "plumb.axis_manifest/v1",
"id": "demo_3",
"items": [
{"id": "r1", "role": "demo.flux", "unit": "mag", "coordinate": "z=0.1"},
{"id": "r2", "role": "demo.flux", "unit": "mag", "coordinate": "z=0.2"},
{"id": "r3", "role": "demo.flux", "unit": "mag", "coordinate": "z=0.3"}
]
}
Two fields connect a row to the model side:
"role"names a declaredrole(see below). Write its full dotted path ("demo.flux"). A bare name without a dot ("flux","Flux") is also accepted when it is the last segment of exactly one declared role, compared without regard to ASCII case. A row whose role is not declared, or whose bare name fits several declared roles, isP0302; a role whose dimension differs from the observable’s unit isP0301."coordinate"("z=0.1") supplies the row’s coordinate: the name before=(z) is the variable a prediction arm binds (demo.flux(z) = ...).
2. Table (plumb.table/v1):
{
"schema_version": "plumb.table/v1",
"id": "demo_values",
"axis_manifest_sha256": "<exact sha256 hex of demo.axes.json>",
"columns": ["z", "m_B"],
"rows": [
{"label": "r1", "values": {"z": "0.1", "m_B": "18.50"}},
{"label": "r2", "values": {"z": "0.2", "m_B": "20.10"}},
{"label": "r3", "values": {"z": "0.3", "m_B": "21.05"}}
]
}
3. Matrix (plumb.matrix/v1):
{
"schema_version": "plumb.matrix/v1",
"id": "demo_cov",
"axis_manifest_sha256": "<exact sha256 hex of demo.axes.json>",
"labels": ["r1", "r2", "r3"],
"includes": [],
"entries": [
["0.01", "0.002", "0.002"],
["0.002", "0.01", "0.002"],
["0.002", "0.002", "0.01"]
]
}
Finite Artifact Sums and Products
An exact_rational or interval_enclosure claim can fold over the rows of a pinned Table artifact. Declare one unit per column in the artifact type, in the JSON columns order. For the z and m_B columns above, write Table[Dimensionless, mag].
artifact my_axes: Axes from "data/my.axes.json" rows 3
artifact my_table: Table[Dimensionless, mag]
from "data/my.table.json"
axes my_axes
rows 3
claim magnitude_checksum: sum(r in my_table, r["m_B"]) == 59.65 mag
by exact_rational
claim normalized_product: prod(r in my_table, r["m_B"] / r["m_B"]) == 1
by exact_rational
The column units are declarations supplied by the author from the data release. The numeric JSON contains no column units to check them against. Each cell is scaled by its declared column unit. A vector observable on the same manifest can read a column in its value expression, for example value my_table["m_B"]. The column is converted from its declared unit to the observable unit. A vector’s select mask covariate may read typed columns on the same pinned manifest. Coordinate thresholds and comparison bindings must carry the column’s physical dimension. Reading an observed response to select rows gives blocked unconsumed_bias, including when another declaration names the same column or the compared profile supplies the response. The row binder exposes the column names with those fixed units, so adding a redshift to a magnitude is a dimension error. Products require a dimensionless body, such as the ratio above. Sums and products traverse the exact manifest row order, and nested folds are supported within the evaluation budget. Table row labels, the axis digest and every declared column are checked before evaluation, including columns the expression does not use. The axis manifest must use one uniform row unit spelling.
Artifact folds currently require a direct claim goal with by exact_rational or by interval_enclosure. Use the latter for certified bounds on sums such as sum(r in spectrum, ln(r["ratio"]) + sqrt(r["ratio"]) / pi). A bare Table needs column types before it can be folded. Definitions, comparisons and other claim methods refuse artifact folds. The table must contain at least one row and column. Each fold table may contain at most 65,536 cells, each numeric cell may contain at most 1,024 bytes, and the parsed numerators and denominators together may contain at most 16,777,216 bits. A claim has a shared evaluation budget of 750,000 expression steps, including nested folds.
A passing checksum certifies arithmetic on the pinned central values. With interval_enclosure, the reported endpoints bound numerical error. Statistical uncertainty propagation requires an explicit error model and the applicable covariance, including its off-diagonal entries. Fold inputs retain their shared data lineage when claims are used downstream. Running plumb lock after changing source or data records new pins, and each check verifies those pins again.
Inline table — Small Tables Directly in .plumb
For small symbolic or exact rational tables (e.g., particle quantum numbers), you can declare an inline table:
table sm_generation(mult, Y)
| Q_L => 6, 1 / 6
| u_c => 3, -2 / 3
| d_c => 3, 1 / 3
| L_L => 2, -1 / 2
| e_c => 1, 1
role — What a Quantity Is
A role identifies a measurable quantity by name. For example, and are distinct roles with the same dimension. Observables record roles. Predictions and rules produce them. A role has an optional unit and description and defaults to Dimensionless.
role cosmo.hubble_constant : km/s/Mpc "Present-day expansion rate H0."
roles bao {
d_m_over_r_d "Transverse comoving distance over drag horizon"
d_h_over_r_d "Hubble distance over drag horizon"
}
roles <prefix> { ... } adds the prefix to each entry, giving bao.d_m_over_r_d and bao.d_h_over_r_d above. An imported role keeps its identity under aliases. Use plumb doc std to find roles in the standard library.
nuisance and Top-Level bounded
-- Synthetic shared Gaussian nuisance for a magnitude zero-point.
nuisance zp_phot : mag ~ gaussian(sigma = 0.015 mag)
assuming calibration.synthetic_photometric_offset, stat.gaussian_errors
-- Synthetic deterministic bound for a common magnitude shift.
bounded ceph_metal_sys : abs(delta) <= 0.020 mag
assuming calibration.synthetic_metallicity_shift
measurement, inference, and prediction
All three declare observables with shape <role>, <role> as <unit>, or Vector[<axes_artifact>, <unit>]:
-
<role>takes its unit from the declared role.<role> as <unit>states the unit, which may be any unit of the role’s dimension (aMpcrole recorded inkpc); another dimension isP0301. -
Vector[<axes_artifact>, <unit>]has one row per item of the axis manifest, and every row names its own declared role. -
measurement: Raw empirical data. Cannot carryPhysicalOntologyassumptions (P0322). -
inference: Model-conditioned or derived summary. May carryPhysicalOntologyviaconditioned on ... requires .... -
prediction: Benchmark or synthetic prediction. Must declarederived from ...(P0321).
Write a scalar Gaussian reading as value +- sigma Unit so one unit applies to both numbers. Append assuming to name the statistical premise. Omit the unit for a dimensionless quantity. Add a braced block after the reading when you need extra clauses such as conditioned on, derived from, or bounded.
measurement length: lab.length = 2.4 +- 0.1 m assuming stat.gaussian_errors
Available stages inside an observable block (order matters — it is the forward model from physical truth to recorded data):
inference example_obs : Vector[my_axes, mag] {
value my_table["m_B"]
transform x => x - 0.012 mag
shared zp_phot along ones
shared ceph_metal_sys along 1
bounded local_dust : abs(delta) <= 0.02 mag along my_table["dust"]
noise gaussian(cov = my_cov) assuming stat.gaussian_errors
select mask covariate my_table["z"] > 0.05
derived from upstream_anchor
conditioned on fiducial_fit requires ontology.cold_dark_matter, regime.near_fiducial
valid when abs(predicted / fiducial - 1) <= 0.1
assuming calibration.synthetic_photometric_offset
}
Key stage notes:
noisesupportsgaussian(sigma = <expr>),gaussian(cov = <matrix>),published_null(sigma = <expr>, p_value = <p>),published_limit(confidence = <p>), andpublished_interval(lower = <quantity>, upper = <quantity>, level = <p>) assuming <construction>. Post-selected coincidence efficiency is declared withselect truncate latent coincidence(efficiency = <eta>).selectsupports:select mask covariate <pred>— ignorable selection on independent covariates (e.g.,my_table["z"] > 0.05).select model coordinate curve["rest_energy"] == wimp.rest_energyselects the tabulated row at the compared theory’s predicted rest energy.select truncate observed <pred>— non-ignorable outcome selection (e.g.,select truncate observed x < 24.5 mag, wherexis the implicit variable denoting the current observed value at that stage, or a table column likemy_table["m_B"] < 24.5 mag).
- Stage order:
transform,bounded, andselectare applied in declared order (for example, placingtransform x => x - 0.012 magbefore vs afterselect truncate observed x < 24.5 magchanges which rows survive, and atransformafter aboundedstage scales that systematic!).noiseandsharedGaussian nuisances commute in the pooled covariance. supersedes_for <observation> when not <assumptions>marks a deeper-tiermeasurementorinferencethat replaces a compressed summary when an audited candidate does not satisfy one of the listed assumptions. Each listed assumption must appear in the summary’sconditioned on ... requiresclause, and neither side may be aprediction(P0323). The clause only matters underplumb audit; see Verdicts & Receipts.derived from benchmark.commonnames 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.- Use
CSV layout tablewith a header and one axis. The optionallabels "id"andobjects "object_id"pins check row identities against the manifest.layout matrixreads numeric rows.layout count_prefixedreads 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. - A
FITSartifact reads one finite binary32 or binary64 primary image. Useaxes Afor a value vector andaxes A, Afor a square covariance in row-major order. The coordinates in each manifest follow the on-disk data order. - Declare a catalogue of stable object IDs with
catalogue sky: "Survey object identifiers". Declare a data release withrelease dr1: "First public data release" objects sky. Bind an Axes artifact to it withrelease dr1. Each manifest item may give anobjectstring from that catalogue. Rows with the same ID in the same release must agree on role, unit, coordinate and object. A release can declarecovariance Cover a manifest covering all its registered rows. A scalar can name the entire release inderived from dr1. - Comparisons report shared release rows as
Duplicate, repeated lineage asSharedLineage, common catalogue objects asSharedObjects, and nonzero cross-covariance between disjoint release rows asReleaseCoupled. The receipt records the class, count and up to eight identifiers. - A lineage-only
inference(novaluestage) can represent a shared posterior origin (likeplanck_2018_base_lcdm_posteriorinstd.cosmology.cmb.planck_2018) so downstream marginals (planck_2018_h0,planck_2018_rd) share a commonderived fromparent and cannot be combined as independent Gaussians.
For a published upper-limit curve declared as Table[GeV, cm^2], the vector inference can select by the candidate’s rest energy:
value curve["upper_limit"]
select model coordinate curve["rest_energy"] == wimp.rest_energy
noise published_limit(confidence = 0.9)
A candidate that predicts wimp.rest_energy = 9000 MeV selects the 9 GeV row, even with a separate binding at wimp_rest_energy = 40 GeV. An imported alias denotes the same role. The role must have one certified value across the supplied point or box, and the selection must identify exactly one row. With exclusion_contour, an off-grid prediction yields unassessed no_applicable_checker. Selecting an observed response column through an alias of the same table yields blocked unconsumed_bias.
For a deliberate lookup at a user-supplied energy, write select mask covariate curve["rest_energy"] == query_energy and bind at query_energy = 40 GeV.
def — Pure Functions & Expressions
def E_flat(z : Dimensionless, Omega_m : Dimensionless) : Dimensionless =
sqrt(1 + Omega_m * ((1 + z)^3 - 1))
def I_flat(z : Dimensionless, Omega_m : Dimensionless) : Dimensionless =
integral(u in range(0, z), 1 / E_flat(u, Omega_m))
Supported expression forms:
- Arithmetic:
+,-,*,/,^, unary- - Comparisons & logic:
==,!=,<,<=,>,>=,and,or,not - Built-in constants & math:
pi,inf,ones,sqrt(x),abs(x),exp(x),ln(x),log10(x) - Indexing:
my_table["col_name"] - Binders & aggregations:
integral(u in range(a, b), body),sum(row in my_table, body),prod(...),let x = e1 in e2,if cond then e1 else e2
Circular functions take an angle. For example, sin(90 deg) is exactly 1, and one degree equals 3600 arcseconds. tan(a) requires an angle range free of poles. The principal inverse functions asin, acos, and atan return angles. The hyperbolic functions sinh, cosh, and tanh take and return dimensionless values.
Use deriv(x, e) for a partial derivative with respect to an independent scalar coordinate. Its unit is the unit of e divided by the unit of x. For example, deriv(a, sin(a)) * 1 rad equals cos(a). A derivative at a pole, a domain hole, or an unresolved branch boundary cannot be certified.
In predictions, integration limits may vary across a parameter box. The enclosure covers the integrals for every pair of limits in the evaluated ranges, including reversed limits. Claim-based certified_quadrature requires closed limits that evaluate exactly.
Use certified_root when a model defines a coordinate implicitly. The bracket endpoints must be strictly ordered with compatible units. Plumb checks that the residual has a derivative of one strict sign throughout the bracket and that the endpoint values enclose zero. An endpoint may itself be the root. For parameter boxes these conditions must hold for every assignment in the box being evaluated. The result encloses all corresponding roots. Its width can reflect parameter variation as well as numerical precision.
def implicit_coordinate(p : Dimensionless) =
certified_root(x in range(1, 2), x^6 + p * x^3 - 18)
claim coordinate_bound : forall p in [1, 2], 1.4 < implicit_coordinate(p) < 1.7
expect conditional_result
by interval_enclosure
Root enclosures can be used in interval claims and theory predictions checked by consistency_graph. Use a bracket on which the residual is differentiable with a derivative bounded away from zero. Plumb currently requires an explicit formula if you need derivatives of the root as a function of other parameters.
theory — Parameters, Assumptions, Definitions, and extends
theory flat_lcdm {
H0 in [50, 90] km/s/Mpc
Omega_m
r_d : Mpc
assume ontology.cold_dark_matter, regime.flat_lcdm_background
def H_at(z : Dimensionless) : km/s/Mpc = H0 * E_flat(z, Omega_m)
}
- Declare a free parameter as
nameorname: Unit. Give it a default box withname in [lo, hi]for dimensionless values orname in [lo, hi] Unitfor a shared unit. Aconsistency_graphcomparison uses the default box when it has no explicitatbinding for that parameter. assume <assumption>, ...lists the premises the theory itself vouches for.defmembers are functions and constants of the theory.
A theory may extend another:
theory early_shift extends flat_lcdm {
eps : Dimensionless in [0, 0.1]
assume ontology.cand.early_shift
def H_at(z : Dimensionless) : km/s/Mpc = (1 + eps) * H0 * E_flat(z, Omega_m)
}
The child inherits the parent’s parameters, definitions, assumptions, and predictions. A replacement keeps the inherited member’s argument count and dimension (P0301). A definition can replace a parameter or vice versa.
- An inherited prediction is evaluated in the child: it reads the child’s members, including the ones the child replaced.
- If the child replaces a member that a prediction reads, the child must supply any required premises that came from that prediction’s
assumingclause. Narrowing a parameter box with the same type preserves those premises. - A child prediction for a role takes precedence over the parent’s prediction and premises for that role.
extendschains must not cycle (P0330).
predict — From a Theory to Roles
Write predict <role> = <expression> inside a theory to supply a value for that role. A named group can predict several roles together.
theory background extends flat_lcdm {
predict cosmo.hubble_constant = H0
assuming regime.low_z_cosmography
predict lcdm_bao assuming regime.template_near_fiducial {
bao.d_m_over_r_d(z) = c * I_flat(z, Omega_m) / (H0 * r_d)
bao.d_h_over_r_d(z) = c / (H0 * E_flat(z, Omega_m) * r_d)
bao.d_v_over_r_d(z) = (z * d_m_over_r_d(z)^2 * d_h_over_r_d(z))^(1/3)
}
}
- Every target is a declared role, every arm is labelled with one target (by its full path or its last segment), and every target has exactly one arm (
P0302,P0121). - An arm’s body has the dimension of its role (
P0301). - A binder takes the row’s coordinate of the same name (a lone binder takes the row’s only coordinate); any other binder takes the
atbinding of that name. - An arm may read a sibling role by its last segment or full path, as a value or applied to binders (
d_m_over_r_d(z)). A binder or theory parameter of the same name takes precedence; write the full path to read the role. - A prediction’s
assumingclause satisfiesconditioned on ... requiresand enters the ledger only when that prediction is evaluated.
rule — Reviewed Role-to-Role Maps
A rule derives roles from other roles independently of the theory. requires lists premises that must already hold. grants lists premises the rule contributes when applied.
rule alpha_drift_from_log_slope: (atomic.alpha_log_slope, cosmo.hubble_constant) -> atomic.alpha_drift
grants regime.alpha_log_slope_today
= -alpha_log_slope * hubble_constant
rule brans_dicke_ppn: (gravity.scalar_tensor_omega) -> gravity.ppn_gamma_minus_one
requires regime.unscreened_solar_system
grants regime.ppn_metric
= -1 / (2 + scalar_tensor_omega)
rule product_from_background : (cosmo.hubble_constant, cosmo.drag_horizon) -> cosmo.h0_rd, cosmo.rd_over_h0
{
cosmo.h0_rd = hubble_constant * drag_horizon
cosmo.rd_over_h0 = drag_horizon / hubble_constant
}
A rule can limit its numeric domain with one or more valid when clauses after requires and grants. Each clause compares a declared input role to a numeric literal of the same dimension. For example, a rule with a lifetime input can specify a closed interval:
rule local_response: (neutron.total_mean_life) -> bbn.helium_mass_fraction
requires ontology.sbbn_beta_decay, regime.yeh_2023_local_helium
valid when total_mean_life >= 868.4 s
valid when total_mean_life <= 888.4 s
= yeh_2023_helium(total_mean_life)
Plumb checks the inputs supplied by the selected prediction or rule chain on each selected row. Every bound must hold over the entire declared comparison box, even if a proposed witness satisfies it. A failed or uncertifiable bound produces blocked domain_violation. Guarded inputs require scalar expressions with known dimensions throughout. Use the compared theory’s parameters and unqualified members. Coordinate-taking arms, implicit table rows, and theory-qualified member references cannot certify an input bound. Calling a def directly uses only its defining expression.
Inside an arm each input role is in scope by its last segment or full path (and applied to binders when the role’s producer takes them). Arms follow the same rules as prediction arms.
For a role without a theory prediction, Plumb looks for a chain of up to six rules whose starting inputs the theory can predict. Each evaluated rule’s grants enter the ledger and count toward conditioning. The receipt records the chain in bridge_id.
- A prediction of the theory always outranks a rule.
- No chain:
Blocked(MissingBridge). Two chains (two predictions of the same theory onto the role, or two rules that both reach it):Blocked(AmbiguousBridge)— Plumb never picks one for you. - Rules must not form a cycle (
P0330).
condition
-- Condition defines a reusable correspondence requirement over any theory `T : Theory`
condition weak_field_limit(T : Theory, delta : Dimensionless) =
forall x in (0, delta], 0 <= T.support_ratio(x) - 1 <= (1 - delta)^(-1/2) - 1
claim and compare
claim verifies pure mathematical, symbolic, quadrature, scaling, or Lean-certified statements:
claim scaling_degeneracy :
forall s in (0, inf), invariant background.lcdm_bao under (H0, r_d) -> (s * H0, r_d / s)
expect conditional_result
by exact_scaling
claim my_identity : 1 + 1 == 2
expect conditional_result
by exact_rational
-- Sidecar Lean 4 proof (target generated by `plumb lean goal`, scaffolded by `plumb lean init`):
claim grav_u1 : sum(f in sm_family_charges, f["d3"] * f["d2"] * f["Y"]) == 0
assuming math.sm_three_weyl_families
by lean "particle/proofs/grav_u1.lean"
-- Existing local Lake project theorem:
claim balance : 1 / 2 + 1 / 2 == 1
by lean theorem Model.balance from lake "formal" module Model
Claims can also test theory-condition correspondence (T supports cond(...) / T conflicts cond(...)), supply explicit witness x = ..., and declare assuming ....
compare tests one or more observables against a model: a theory (each observed role is produced by the theory’s one prediction onto it, or by a chain of rules), a named prediction group (which must target every observed role), another observable obs1 ~ obs2, or a condition:
-- Point evaluation with exact `at` bindings
compare single_point : obs_a ~ my_theory
at H0 = 70 km/s/Mpc, Omega_m = 0.3
accept chi2 <= 16
expect compared
by gaussian_ldlt
-- Joint multi-observable consistency over a compact parameter BOX (`in [lo, hi]`)
compare network_check : obs_a, obs_b, obs_c ~ my_theory
at H0 in [60 km/s/Mpc, 80 km/s/Mpc], r_d in [140 Mpc, 155 Mpc], Omega_m = 0.3
accept chi2 <= 25
expect compared
by consistency_graph
Supported accept budgets include chi2 <= B, chi2 < B, and abs(pull) <= B (and reversed forms like B >= chi2). Always supply a dimensionless budget; dimensional budgets are refused.
Notes on compare bindings and multi-observable comparisons:
atonly needs to bind parameters the evaluated arms actually read. Underconsistency_graph, a parameter left unbound takes the default box its theory declares (name in [lo, hi]).- For a unitful interval in
at, write the unit on both endpoints. The trailing-unit form belongs to theory parameter declarations. - A comparison against a theory resolves each observed role separately, so the observables may record distinct roles and units, and several observables of one role share one prediction (under
gaussian_ldlt,bounded_gaussian, andconsistency_graph). - Naming a prediction as the model selects that prediction even when its theory has another prediction onto the same role.
- Run
plumb fmt <file>...to normalize layout and decimal spelling. Scientific notation such as2.1e-5keeps its exponent.
scope — Grouping, Sequential Gating (after), and open Phenomena
scope hubble_audit {
check first_check
check second_check after first_check
open cluster_lensing "Not yet catalogued in this workspace."
}
If first_check does not pass (Blocked, Conflict, NonIdentifiable, Unresolved, etc.), second_check is automatically gated as Blocked(BlockedByUpstream).
A referee can freeze observations, acceptance budgets, and audit policies before selecting a theory. A block can depend on a structural claim or another block in the same scope. In a multi-observation block, obs.chi2 names the score for that observation and chi2 names the joint score.
scope distance_tests {
baseline reference_theory
limit price <= 3, free_parameters <= 3
alpha 0.05
allow calibration.reviewed
check anchor: local_distance accept chi2 <= 9
check pair: local_distance, distant_distance
accept local_distance.chi2 <= 9, distant_distance.chi2 <= 4, chi2 <= 10
after anchor
}
Frozen scope policies:
baseline <theory>— sets the reference theory used to measure a candidate’s addedfree_parameters(when the candidate extends the baseline) anddropped_assumptions.limit price <= N, free_parameters <= M— caps candidate complexity (price = free_parameters + numeric_literals + dropped_assumptions) and added free parameters.plumb fmtnormalizes each limit onto its ownlimit ...clause.alpha <p>— records a decimal significance level strictly in(0, 1)on the frozen scope.allow <assumptions>— explicitly authorizes listed library assumptions when asserted by a candidate theory or prediction under audit. Any libraryMathematicalPremisethat isdischarged bya passing library claim is also admitted automatically into conditioned audit blocks without requiring anallowentry.
A candidate can declare its theory and referee immediately after the imports. Use the imported scope’s full name.
import std.atomic
audit proposal against std.atomic.alpha_variation
Define theory proposal in the same module. Both plumb check and plumb validate evaluate the candidate’s claims and the frozen scope.
A linear fit declares its observation vector and a design matrix whose first axis names parameters and whose second axis names observations. Inside the fit, index a parameter by its axis item ID.
fit ladder: magnitudes ~ linear(design) as q
emit (anchor: sn.absolute_magnitude = q["M_B"])
accept chi2 <= 12
by validated_gls
Each emitted label has a declared role. An emission can include exact affine combinations of the parameter coordinates. A named view label(axis_a, axis_b) groups emitted labels in the stated order.