Witness Chain Pipeline Program
Can a single proof pattern carry formal reasoning from PDEs to smart contracts?
Formal verification typically produces results that remain within the theorem prover. A theorem about PDE well-posedness, a proof of governor convergence, or a verification of smart contract behavior each lives in its own module, its own domain, its own proof strategy. The question driving this work is whether a single proof pattern can thread through all of these — from pure mathematics to deployed systems — without dropping rigor at any stage.
The witness chain addresses this through type-level enforcement of step dependencies. The core insight is that “the result is correct” is a weaker claim than “the result was obtained through the required sequence of verified steps.” In adversarial environments — auditing a smart contract, certifying a governor's stability, validating a physics derivation — the distinction matters.
A 43-line kernel — two type classes and two theorems — instantiates into 1,348 lines of verified Lean 4 across five stages spanning symbolic PDEs, quantum-classical physics, trust engineering, and smart contract verification. Zero sorry. Zero admit. The pattern is the message.
Why this is Ruliology
This project demonstrates a universal formal systems pattern. The witness chain is not specific to any one domain — it is the connective tissue that threads through symbolic mathematics, quantum-classical physics bridges, trust engineering, and adversarial smart contract verification.
What was discovered through formalization: The same two type classes — IsChainRoot and IsWitnessStep — instantiate across five completely different domains. The pattern's strength is not in any single application but in its reuse: a 43-line kernel (WitnessChain.lean) generates non-bypassable proof chains for PDEs, physics, trust systems, and smart contracts.
The deeper point: In adversarial environments — whether auditing a smart contract or certifying a governor's stability — “the result is correct” is a weaker claim than “the result was obtained through verified steps.” The witness chain makes the stronger claim machine-checkable. This structural requirement — that each step must embed its predecessor — is the rule that all five instantiations share, and it is the ruliology.
The Witness Chain Pattern
The witness chain is a type-level proof architecture built on two type classes:
IsChainRoot
Marks a base witness with no upstream dependency. rootEvidence records the local property carried by the root. This is where the chain begins — the axiom, the base case, the first measurement.
IsWitnessStep
Marks each subsequent step and requires an explicit upstream projection. The type system enforces that every step embeds its predecessor. You cannot construct a step without providing the previous one.
The key theorem: upstream_exists — for any witness step w, there exists a concrete upstream witness u such that IsWitnessStep.upstream w = u. This is trivial to prove (it's rfl) but non-trivial in what it prevents: no one can claim to have completed a chain without actually building each link.
WitnessChain.lean — 43 lines. 2 type classes, 2 theorems, 1 definition.
This is the entire kernel. Everything else in the pipeline is an instantiation.
From Quantum Mechanics to Classical Dispersion
The Madelung transform converts the Schrödinger equation into a hydrodynamic system. This is a classical result in mathematical physics — what makes it a witness chain is that each derivation step is a typed structure that embeds its predecessor:
Schrödinger equation (IsChainRoot)
→ Step 1: Polar decomposition (ψ = √ρ · e^{iS/ℏ})
→ Step 2: Continuity + momentum extraction
→ Step 3: Linearization (pressure, quantum potential, momentum)
→ Step 4: Density wave equation (eliminate ∇·v₁)
→ Step 5: Plane-wave substitution → dispersion relationThe final output is the dispersion relation:
The theorem madelung_dispersion_chain proves the full derivation: given a Schrödinger equation, a Madelung state, equilibrium and perturbation conditions, there exist a density wave witness, a plane-wave evaluation, and a dispersion relation satisfying all the intermediate identities.
6 files, 719 lines: SchrodingerSpec, MadelungTypes, MadelungTransform, LinearizedDispersion, WitnessChain, MadelungChain.
Step1Witness through DensityWaveWitness — each is an IsWitnessStep embedding its predecessor.
Trust Dispersion Bridge
The trust bridge is where formal mathematics exits the theorem prover and becomes runtime-consumable. Governor parameters are reinterpreted as trust-medium physics:
| Governor Parameter | Trust Physics | Interpretation |
|---|---|---|
| √α | Trust elasticity | How quickly trust responds to perturbations |
| β/(2Δt) | Information friction | Damping of high-frequency trust oscillations |
| Contraction ρ | Convergence rate | Proved 0 ≤ ρ < 1 — governor always converges |
The StabilityBoundExport structure derives ToJson and FromJson, making proof-backed stability semantics directly consumable by dashboards, monitoring systems, and product code.
TrustDispersionCertificate.lean (166 lines) + TrustStabilityBounds.lean (81 lines).
Regime classification: wave-like vs friction-dominated. Crossover wavenumber identification. Contraction factor with membership proof.
Smart Contract Oracle Chain
The same witness chain pattern applied to smart contract differential parity verification. The BountyHunter oracle must verify that a decompiled contract behaves identically to the original — but the verification has a required order:
Why this matters: “Final parity passed” is a weaker claim than “parity passed through the required sequence of checks.” Without the witness chain, an auditor cannot distinguish between a genuine four-step verification and a shortcut that jumped to storage comparison. The type system makes the difference machine-checkable.
OracleChain.lean — 210 lines. 5 structures, 6 theorems, 5 constructors.
Worked example: transfer(address,uint256) with full 4-step chain traversal.
Stage 1: Symbolic PDE (PDE/Symbolic/Expr.lean)
ScalarExpr, VectorExpr, CoupledSystem
JSON / SMT-LIB2 / LaTeX export
│
Stage 2: Witness Chain Kernel (Core/WitnessChain.lean — 43 lines)
IsChainRoot, IsWitnessStep, upstream / upstream2
│ │
Stage 3: Madelung Derivation Stage 5: Oracle Chain
(PDE/Madelung/ — 6 files) (BountyHunter/Foundry/)
Schrödinger → dispersion OkRevert → ReturnBytes →
ω² = c_L²k² + D²k⁴ EventLog → Storage →
│ FullParity
Stage 4: Trust Bridge
(Bridge/Sharma/)
formal → ℝ → Float/JSON
StabilityBoundExport
Connective tissue: IsChainRoot + IsWitnessStep (43 lines)
Instantiation 1: Madelung (5-step quantum → classical derivation)
Instantiation 2: Trust Bridge (formal → JSON runtime export)
Instantiation 3: Oracle Chain (4-step smart contract parity)What is proved vs. what is empirical
FORMALLY VERIFIED (Lean 4)
- • Witness chain: upstream_exists, upstream2_exists
- • Madelung: full 5-step chain from Schrödinger to dispersion
- • D = ℏ/(2μ) with positivity hypotheses
- • Trust: contraction factor 0 ≤ ρ < 1 (governor converges)
- • Oracle: chain_requires_all_steps (full traversal)
- • All structures non-bypassable at the type level
EMPIRICAL / ENGINEERING
- • Float-level StabilityBoundExport accuracy vs real analysis
- • Runtime JSON consumption by dashboards (engineering integration)
- • Smart contract test coverage of transfer/approve functions
- • SMT-LIB2 export compatibility with external solvers
- • Physical interpretation of trust-medium parameters
What It All Means
The witness chain is a 43-line kernel that generates rigorous proof pipelines across unrelated domains. A single pair of type classes — one for roots, one for steps — instantiates into a quantum-to-classical physics derivation, a trust engineering certification system, and a smart contract audit framework. None of these share any mathematical content; what they share is the structural requirement that each step must embed its predecessor.
This is the ruliology: the discovery that a proof pattern extracted from one domain (PDE derivations) applies without modification to completely different domains (trust engineering, smart contracts). The pattern is the message.
Symbolic PDE Framework
Typed expression layer for partial differential equations with differential operators (dt, laplacian, divergence, biharmonic) and multi-format export to JSON, SMT-LIB2, and LaTeX. Single typed representation consumed by prover and external tools alike.
Key Results
- •Single typed representation consumed by prover + external tools
- •JSON, SMT-LIB2, LaTeX export from one source
- •Differential operators: dt, laplacian, divergence, biharmonic
Witness Chain Template
The reusable proof pattern. IsChainRoot marks a base witness; IsWitnessStep marks each subsequent step and requires an explicit upstream projection. The chain is non-bypassable at the type level. This 43-line kernel is the entire connective tissue.
Key Results
- •upstream_exists: every step contains a concrete upstream witness
- •upstream2_exists: two-step chain traversal guaranteed
- •Type-level enforcement — dependencies cannot be circumvented
Madelung Derivation
Converts the Schrödinger equation into a hydrodynamic system, then linearizes to derive the dispersion relation. Each derivation step is a witness structure registered as IsChainRoot or IsWitnessStep. 5-step chain from polar decomposition through plane-wave substitution.
Key Results
- •5-step chain: polar decomp → continuity → linearization → wave eq → dispersion
- •Final: ω² = c_L² k² + D² k⁴, D = ℏ/(2μ)
- •madelung_dispersion_chain: full chain theorem proved
Trust Dispersion Bridge
Bridges formal Madelung dispersion analysis to runtime trust/stability semantics. Governor parameters map to trust-medium physics; dispersion certificates provide frequency-domain bounds; Float-level exports are JSON-serializable for dashboards. Contraction factor proved in Ioo(0,1).
Key Results
- •√α → trust elasticity, β/(2Δt) → info friction
- •Regime classification: wave-like vs friction-dominated
- •StabilityBoundExport deriving ToJson, FromJson for runtime
BountyHunter Oracle Chain
Witness chain discipline applied to smart contract differential parity verification. A four-step chain proves that parity was established through the required sequence of checks — not just that it passed. Worked example with transfer(address,uint256).
Key Results
- •4-step non-bypassable: OkRevert → ReturnBytes → EventLog → Storage
- •chain_requires_all_steps: full traversal proof
- •Worked example: transfer(address,uint256)
Contribution Certificates
Immutable contribution records per MENTAT-CA-001. Each certificate is a cryptographically anchored MCR documenting authorship, contribution level, and provenance chain.
MENTAT Contribution Record
IDEA
Conceptual Contribution
CONTRIBUTION LEVEL: IDEA
Ontological EngineerWitness Chain: A Reusable Proof Pattern for Non-Bypassable Step Dependencies
Contributor
Apoth3osis Labs
R&D Division
Core architectural insight: a single type-level proof pattern — typed witness chains with explicit upstream projections — can carry formal reasoning from symbolic PDEs through physical derivations to runtime trust certificates and smart contract verification, without dropping rigor at any stage. The pattern is non-bypassable: the type system enforces that each step embeds its predecessor.
MENTAT Contribution Record
THEORY
Mathematical Foundation
CONTRIBUTION LEVEL: THEORY
Ontological EngineerSymbolic PDE Framework with Multi-Format Export
Contributor
Apoth3osis Labs
R&D Division
Typed expression layer for partial differential equations: ScalarExpr, VectorExpr, CoupledSystem with differential operators (dt, laplacian, divergence, biharmonic). Multi-format export (JSON, SMT-LIB2, LaTeX) ensures both theorem provers and external tools consume equations from a single typed representation. Foundation for the Madelung derivation pipeline.
Builds Upon
MENTAT Contribution Record
PROOF
Formally Verified
CONTRIBUTION LEVEL: PROOF
Ontological EngineerMadelung Derivation: Schrodinger to Dispersion via Witness Chain
Contributor
Apoth3osis Labs
R&D Division
Full formal derivation of the Madelung transform as a typed witness chain. Converts the Schrodinger equation into a hydrodynamic system through polar decomposition, continuity/momentum extraction, linearization, density wave equation, and plane-wave substitution. Final output: dispersion relation omega-squared = c_L-squared k-squared + D-squared k-to-the-fourth, where D = hbar/(2mu). Each step is a witness structure registered as IsChainRoot or IsWitnessStep.
Builds Upon
MENTAT Contribution Record
APPLICATION
Applied Contribution
CONTRIBUTION LEVEL: APPLICATION
Ontological EngineerTrust Dispersion Bridge: Formal Proofs to Runtime JSON
Contributor
Apoth3osis Labs
R&D Division
Bridges the Madelung dispersion analysis to runtime trust and stability semantics. Governor parameters map to trust-medium physics: sqrt(alpha) maps to trust elasticity, beta/(2*dt) maps to information friction. Dispersion certificates provide quantitative frequency-domain bounds. Float-level exports are JSON-serializable (deriving ToJson, FromJson) for dashboard consumption. Regime classification and crossover wavenumbers become runtime-queryable.
Builds Upon
MENTAT Contribution Record
APPLICATION
Applied Contribution
CONTRIBUTION LEVEL: APPLICATION
Ontological EngineerBountyHunter Oracle Chain: Smart Contract Parity Verification
Contributor
Apoth3osis Labs
R&D Division
Witness chain discipline applied to smart contract differential parity. Four-step non-bypassable sequence: OkRevert, ReturnBytes, EventLog, Storage, culminating in FullParityWitness. The chain makes a stronger statement than 'final parity passed' — it proves parity was established through the required sequence of checks. Machine-checkable in adversarial and audit environments.
Builds Upon
Governed by MENTAT-CA-001 v1.0 · March 2026
