Stacking Modules, Lineage & Indirect Contradictions

Plumb is built so scientific knowledge stacks cleanly across modules — just like theorems stack in a proof assistant.

Compositional Stacking Across Modules

A module can import verified upstream modules, reuse their constants, formulas, assumptions, shared systematics, and observables, and stack new derived observables or comparisons on top:

  • Affine observable stacking: Write value obs_b - obs_a or value 2 * obs_a + obs_b. Plumb automatically propagates noise covariances, pools or cancels shared nuisances and bounded systematics, and inherits every upstream assumption and valid when premise.
  • Explicit lineage (derived from): When a published summary (like SH0ES shoes_2022_h0) was inferred from earlier rungs (shoes_2022_mb0, shoes_hubble_flow_aB, ngc4258_maser, lmc_deb), declare derived from .... Plumb transitively collects every upstream assumption into the finding’s AssumptionLedger and blocks downstream checks if an upstream check failed or was blocked.
  • Conditioning. To compare against a conditioned inference, satisfy every premise in requires through the theory’s assume, an evaluated prediction’s assuming, or an evaluated rule’s grants. Otherwise the result is blocked incompatible_conditioning. Plumb checks valid when row by row and over the full parameter box in consistency_graph. It reports domain_violation if it cannot certify the predicate.

Roles Connect Models to Data

A theory’s prediction applies to every record of the role it targets. Declare a new record with that role to compare it against the same theory.

Chaining rules to reach a role

Plumb can chain up to six rules from the roles a theory predicts to the role a check needs. The ledger includes each applied rule’s grants, and bridge_id records the chain. Here two rules derive the product H0rdH_0 r_d from the expansion rate and excess radiation.

assumption stat.g: StatisticalModel
assumption ontology.recomb: PhysicalOntology "Standard recombination history."
assumption regime.background: RegimeApproximation "Flat background expansion."

role particle.delta_neff: Dimensionless
role early.drag_horizon: Mpc
role early.rate: km/s/Mpc
role early.rate_times_drag: km/s

inference product_fit: early.rate_times_drag = 10187.1 +- 10 km/s {
  assuming stat.g
  conditioned on background_fit requires ontology.recomb, regime.background
}

theory early_universe {
  H0: km/s/Mpc
  dneff in [0, 2]
  predict early.rate = H0
  predict particle.delta_neff = dneff
}

rule drag_from_neff: (particle.delta_neff) -> early.drag_horizon
  grants ontology.recomb
  = 147 Mpc * (1 - delta_neff / 100)

rule product_from_background: (early.rate, early.drag_horizon) -> early.rate_times_drag
  grants regime.background
  = rate * drag_horizon

-- No prediction targets `early.rate_times_drag`: the chain is composed, and `dneff` takes its declared box.
compare product_through_rules: product_fit ~ early_universe
  at H0 = 70 km/s/Mpc
  accept chi2 <= 4
  expect compared
  by consistency_graph

-- Three or more extra species shorten the ruler too far for any point of the box.
compare product_excludes_large_neff: product_fit ~ early_universe
  at H0 = 70 km/s/Mpc, dneff in [3, 5]
  accept chi2 <= 4
  expect conflict certified_enclosure
  by consistency_graph

A prediction of the theory always outranks a rule; two rules that both reach the role are refused as ambiguous_bridge, and a cycle of rules is P0330.

Inheritance: Variants That Face Their Consequences

theory Child extends Parent inherits parameters, definitions, assumptions, and predictions. An inherited prediction reads the child’s version of each member. Replacing a member the prediction reads clears its inherited assuming premises.

assumption stat.g: StatisticalModel
assumption regime.standard: RegimeApproximation "The standard response."

role demo.signal: Dimensionless

inference signal_fit: demo.signal = 6 +- 1 {
  assuming stat.g
  conditioned on standard_fit requires regime.standard
}

theory standard {
  amp in [0, 10]
  def gain = 2
  predict demo.signal = amp * gain
    assuming regime.standard
}

-- Replaces nothing the prediction reads: the prediction and its grant are inherited.
theory relabelled extends standard {
  def note = 1
}

-- Replaces `gain`, which the prediction reads: the prediction still predicts, but no longer grants.
theory boosted extends standard {
  def gain = 3
}

compare standard_fits: signal_fit ~ standard
  accept chi2 <= 1
  expect compared
  by consistency_graph

compare relabelled_inherits: signal_fit ~ relabelled
  accept chi2 <= 1
  expect compared
  by consistency_graph

compare boosted_must_grant_for_itself: signal_fit ~ boosted
  accept chi2 <= 1
  expect blocked incompatible_conditioning from regime.standard
  by consistency_graph

Declare assume regime.standard inside boosted to run the comparison with the inherited prediction and the new gain.

Automatic Graph Protections

Before running statistics, Plumb builds a unified dependency graph across all loaded modules and enforces three strict guards:

Structural Cycles (P0330)

Imports, defs, conventions, theories (including extends), predictions, rules, observables, derived from, invariant claim targets, and scope ... after dependencies must form a DAG. Any loop — direct or spanning multiple files — is rejected at check time with P0330.

Circular Calibration (CircularCalibration)

You cannot test a theory or observable against data that already fed into the model side. Plumb traces every underlying data leaf (exact content SHA-256 + column for tables, or defining symbol origin for literal observables) on both the observed side and the model side. If they overlap (for example, comparing cal_anchor against a prediction or an inline predict arm derived from cal_anchor), Plumb refuses with Blocked(CircularCalibration):

assumption stat.cal_gaussian: StatisticalModel

role cal.flux: mag

measurement cal_anchor: cal.flux = 12 +- 0.05 mag
  assuming stat.cal_gaussian

prediction cal_self_model: cal.flux {
  value 12 mag
  derived from cal_anchor
}

compare circular_calibration_refused: cal_anchor ~ cal_self_model
  accept chi2 <= 4
  expect blocked circular_calibration
  by gaussian_ldlt

Aliased Data & Shared-Posterior Double Counting (UnknownDatasetDependence)

Two observables in a joint compare obs_a, obs_b ~ theory (or two inputs stacked into one observable) must not read the same underlying data leaf:

  • Copying a JSON table to a second file name does not fool Plumb — data leaves are keyed by content SHA-256.
  • Combining an upstream rung with a downstream summary derived from it (e.g., shoes_2022_h0 alongside ngc4258_maser) is refused.
  • Combining two published marginals from the same posterior (e.g., planck_2018_h0 and planck_2018_rd, which both declare derived from planck_2018_base_lcdm_posterior) is refused so they can never be falsely treated as independent Gaussians.

Indirect Contradictions & Minimal Conflict Cores (consistency_graph)

When testing a network of measurements against a multi-parameter theory over a compact parameter box (at p in [lo, hi], ...), consistency_graph checks whether one single shared parameter point satisfies all measurements simultaneously within the budget:

  • Feasible -> Compared: Plumb finds and certifies a concrete witness point (p_1, p_2, ...) inside the box whose certified upper bound χhi2≤budget\chi^2_{\text{hi}} \le \text{budget}, and records the witness and bounds in the receipt’s measures:
    • chi2_min.lo and chi2_min.hi — two-sided certified enclosure of the minimum joint χ2\chi^2 over the box (refined past the first feasible witness).
    • witness.<p>, witness.<p>.unit, at.<p>.unit, and param.<p>.lo / param.<p>.hi / param.<p>.unit — witnesses and surviving parameter ranges converted back to each parameter’s declared unit (km/s/Mpc, Mpc, deg, rad, mag, etc.). Systematic shift witnesses (witness.systematic.<label>) are recorded in SI because a single shared systematic can couple observables with different units.
    • q_dmap.lo and q_dmap.hi — certified two-sided enclosure of the partition-tension statistic QDMAP=χmin⁡2(A∪B)−∑kχmin⁡2(k)Q_{\mathrm{DMAP}} = \chi^2_{\min}(A \cup B) - \sum_k \chi^2_{\min}(k) across independent observable blocks (emitted only when no shared Gaussian nuisance or bounded systematic couples distinct blocks).
  • Infeasible -> Conflict(CertifiedEnclosure): Plumb certifies that χ2\chi^2 exceeds the budget everywhere in the box, then runs MARCO minimal unsatisfiable subset (MUS) enumeration to isolate minimal conflict cores (up to 20 cores, bounded by deterministic solve and exploration budgets). A minimal core contains a conflict that disappears when any remaining member is removed.
    • In receipt.json, the finding’s measures record:
      • conflict_core — comma-separated list of observables in the first minimal core
      • conflict_core.size — number of observables in that core
      • conflict_core.minimal — "proved" when minimality is certified
      • conflict_core.assumptions — comma-separated assumptions carried by the core
      • conflict_cores — semicolon-separated list of all certified minimal cores found (up to 20)
      • conflict_cores.complete — "true" when enumeration exhausted all minimal cores within the cap and solver budgets, "false" otherwise
      • chi2_min.lo and core.chi2_min.lo — certified lower bounds proving χ2>budget\chi^2 > \text{budget} everywhere in the box
    • On Conflict (and only on Conflict), any fixed parameter binding at p = v is recorded in the assumption ledger as <name>::fixed.<p> so fixed-point refutations explicitly show what was held constant without polluting passing ledgers.

Here is a runnable example where obs_x, obs_y, and obs_sum form an indirect contradiction (forcing x + y = 0 vs x = 5, y = 5) while obs_bystander is completely consistent — and Plumb isolates the exact 3-observable minimal conflict core (conflict_core = "obs_x,obs_y,obs_sum"):

assumption stat.g: StatisticalModel

role demo.x: Dimensionless
role demo.y: Dimensionless
role demo.s: Dimensionless
role demo.b: Dimensionless

measurement obs_x: demo.x {
  value 5
  noise gaussian(sigma = 1) assuming stat.g
}

measurement obs_y: demo.y {
  value 5
  noise gaussian(sigma = 1) assuming stat.g
}

measurement obs_sum: demo.s {
  value 0
  noise gaussian(sigma = 1) assuming stat.g
}

measurement obs_bystander: demo.b {
  value 1
  noise gaussian(sigma = 1) assuming stat.g
}

theory linear_net {
  x: Dimensionless
  y: Dimensionless
  b: Dimensionless
  predict demo.x = x
  predict demo.y = y
  predict demo.s = x + y
  predict demo.b = b
}

compare indirect_tension: obs_x, obs_y, obs_sum, obs_bystander ~ linear_net
  at x in [-10, 10], y in [-10, 10], b in [-10, 10]
  accept chi2 <= 9
  expect conflict certified_enclosure
  by consistency_graph

A linear fit can add an upstream estimate with pin p from upstream.p. Use pin (a, b) from upstream.view for coordinates with joint covariance. Declare each upstream fit in one pin. Plumb checks parameter roles, the full data identity, nuisance pooling, and conditioning before using these rows. A fit factor’s mean and cov_stat describe the estimate with the named systematic shifts fixed at zero. Signed loadings and bounded responses describe how the estimate moves with those shifts. When the residuals constrain a nuisance, comparing this conditional summary alone can give a different center, variance and verdict from a Gaussian-marginalized fit of the original data. Its center and variance can depend on how a published covariance was split into statistical noise and named loadings. Use the original data for the full joint fit. Plumb refuses to pin a factor carrying a residual constraint. It also blocks a comparison with another observation that shares the constrained nuisance. The consumer reports the upstream fit’s chi-square separately.