PDFs live in the local paper library. Restore exact saved versions with
python3 tools/paperbin.py restore; see PAPERS.txt.
Website · CLAIMS.md (Mechanically Checked Ledger) · ARCHITECTURE.md (Layer Map) · CONTRIBUTING.md (Rules & Routes)
svenvs (Self-Verifying ENVelopeS) is a formal architecture and live runtime built on HOL4, CakeML, and Candle (the verified HOL theorem prover compiled to machine code by CakeML). It fuses two things into one system with zero cheat tactics, zero mk_thm, and zero axioms:
- A Universal Proof-Gated Safety Envelope: An unconstrained inhabitant (
∀ctrl— never inspected or trusted by the proof) acts inside a verified runtime shield (enveloped). Every layer of the habitat—from action policies and safety specifications down to neural inference, compiler optimization passes, the prover build, and the proof-checker kernel itself—is mutable at runtime, gated by a single machine-checked rule: an upgrade is installed if and only if it carries an unforgeable theorem that safety is preserved. - A Fused Reflective Compiler-and-Prover: Running live on the verified
cakebinary, the system hosts the real fueled operational semantics of CakeML (eval_n) inside its own LCF kernel, executes verified in-kernel bytecode computation (Kernel.computeover:cvalin Candle andcv_trans/cv_evalover:cvin HOL4), and improves its own active compiler and rewriter across generations through an unforgeable theorem-gated cell.
Most formal verification assumes a static system and tries to specify what good behavior is. svenvs inverts both:
-
Start from a decidable negative floor (Corrigibility / Non-Lock-In):
Instead of trying to formalize "alignment,"
corrigibility/formalizes one concrete floor—the operator can always bring the systemhomewithin a bounded horizon (corrigibler_floor_holds). Everything above that floor—including the recovery mechanism itself—is mutable by the inhabitant, provided the upgrade carries a proof that recovery is never weakened or slowed past the deadline. -
One Certifier Theorem, Instantiated All the Way Down:
certifierScript.smlproves once that certifier soundness$\iff$ semantic transfer$\iff$ single-step gate safety$\iff$ unbounded stream/ratchet safety (sound_certifier_iff_transfers,cgate_safe,ratchet_stream). Every self-modification gate in the repository is an instance ofcgate, paired with a machine-checked necessity/counterexample theorem showing its seam is load-bearing.
What "verified" means here: exactly the cited theorems in CLAIMS.md and their explicitly labeled seams (encodes_obligation, encodes_soundness, frozen_checker_sound, attestation_faithful). Not verified selfhood, alignment, or a safe inhabitant.
The live Tier-3 runtime on the verified cake binary is unified into a single pipeline (candle/theplace.ml candle/ouroboros_rewrites.ml candle/ouroboros.ml):
- The Place & Live Kernel (
candle/theplace.ml): Loadssafety_preservation,safe_weakening,gate_safe, andself_improvement_is_safedirectly into the running Candle LCF kernel, swaps the kernel-interfaceREFLprimitive in-process for a proven-equivalent implementation, and boots the verified in-kernel:cvalcompute engine (Kernel.compute/THEPLACE_COMPUTE_THM). - Real CakeML Semantics Inside the Prover (
reflectsem/): Ports CakeML's full AST and fueled big-step evaluatoreval_n(45 datatypes, 134 kernel-checked defining equations) into the running Candle kernel, bridged to HOL4'sevaluate_ckand the deep-embedded optimizeroexp/ofoldinreflectsem/fueledBridgeScript.sml(oexp_eval_n_fuel_correct,ofold_eval_n_fuel_preserves). - Fast Verified In-Kernel
:cvalComputation (Kernel.compute): Instead of slow LCF term-rewriting (REWRITE_CONV),candle/ouroboros_rewrites.mlregisters:cvalS-expression equations (cval_nodes,cval_fuel,cval_fold,cval_eval) directly with Candle's verified CEK/bytecode machine (Kernel.compute), proving universal preservation theorems (ofold_preserves,orw_exp_preserves,OURO_KERNEL_COMPUTE_PRIMITIVE_THM,OURO_CVAL_COMPUTE_THM) with zero hypotheses. - Unforgeable Theorem-Gated Compiler Cell & Ouroboros Loop (
candle/ouroboros.ml):- The active compiler pass is held behind an LCF theorem gate (
install_compiler_pass : thm -> (exp -> exp) -> bool) that inspects the conclusion of a real kernelthm(∀k s env e. eval_n k (s, env, [pass e]) = eval_n k (s, env, [e])). Forged or unsound passes (bad_pass = fn _ => Lit (IntLit 0)) are rejected at the type/kernel boundary. - Across a 6-generation self-improvement loop (
ouro_loop), the system starts withorw_exp(orw_exp_preservesat Gen 0–1), upgrades its own active compiler cell in-loop toofold(ofold_preservesat Gen 2–5), transforms candidate ASTs through the active pass, proves semantic preservation againsteval_nfor all inputs(s, env), checks:cvalnode/fuel/evaluation metrics viaKernel.compute, and self-feeds the proven source throughCakeml.eval(Eval).
- The active compiler pass is held behind an LCF theorem gate (
- Self-Upgradable Compiler Root (
compilerOpt/+selfUpgrade/):compilerOpt/compilerOptScript.smldefines a recursive BVL constant-folding pass (bvl_fold), proves semantic preservation against CakeML'sbvlSem$evaluate(bvl_fold_correct,bvl_fold_is_ccorrect) and non-increasing code size (bvl_fold_nonincreasing), and packages the operational gate (compiler_pass_gate).selfUpgrade/selfUpgradeEndToEndScript.smlandselfUpgrade/cakeml-selfupgrade-root.patchwirecertified_eval_compiler_swapdirectly into CakeML'scompiler64ProgScript.smlREPLevalloop and self-compile into a working 1.19 GBcake-selfupgradebinary (scripts/apex-selfupgrade-root.sh).
All computational proof obligations in the HOL4 theories are accelerated with HOL4's verified :cv compute kernel (cv_trans / cv_auto_trans / cv_eval):
- Reflective
holSyntax_cvEngine (kernel/loebReduction/loebReductionScript.sml&selfproverConcrete/selfProverConcreteScript.sml): Translates the deep-embedded HOL syntax, type, term, α-equivalence, and context-update checkers (REV_ASSOCD,tymatch,type_ok_alist,term_ok_alist,welltyped_check,aconv_check,constrainable_update_check,check_updates_chain) into:cvfunctions with[cv_inline]bridges for finite-map lookups onthyof ctxt. This turns multi-hourEVAL_TACobligations over the 18-updatehol-reflectionlarge-cardinal context (lca_ctxt) and the 18-update realcandle_kernelProgTheorycontext (real_candle_ctxt) into sub-secondcv_evalkernel evaluations. - Executable Envelope, Neural, and Watchdog Theories:
corrigibility/corrigibilityEvalScript.sml,specneg/specNegEvalScript.sml,embodiment/embodimentEvalScript.sml,genealogy/genealogyEvalScript.sml, andagent/toolAgentRunScript.smlevaluate multi-step envelope trajectories, spec ratchets, and tool-agent firewalls viacv_eval.inference/mlpInferenceScript.smlverifies ReLU MLPs, hardmax attention (attn1_argmax_correct), residual encoder blocks (encoder_block_shape), and fixed-point softmax/quantized dot-product error envelopes (fxp_softmax_abs_error_lt_step,qdot_error_envelope) withcv_trans.kernel/watchdogFiniteScript.smldischarges the syntactic reflection seamencodes_obligationfor finite domains (wd_encodes_obligation) usingcv_evalonwd_obl_tm, and proves that finiteness alone cannot bypass Gödel/Löb (loeb_finite_obstruction).
| Layer | Directory / Files | What Is Proved & Executed |
|---|---|---|
| Universal Gate & Core |
., certifierScript.sml, safetyScript.sml, sv_weakeningScript.sml, upgradeScript.sml, viabilityScript.sml
|
safety_preservation, safe_weakening, authority_monotone, sound_certifier_iff_transfers, cgate_safe, ratchet_stream, self_improvement_is_safe, shield_exists_iff_viable. |
| Corrigibility Bedrock | corrigibility/ |
Decidable non-lock-in floor (corrigibler_floor_holds), mutable-but-gated off-switch, deadline preservation, cv_eval witnesses. |
| Negotiable Spec, Meta & Genealogy |
pca/, specneg/, genealogy/, liberty/, embodiment/
|
Proof-carrying actions, negotiable spec under fixed meta, amendable meta over eternal bedrock (meta_amendment_safe), forward-certified genealogy of judges (genealogy_sound), transparency (envelope_transparent_runr). |
| Tool-Agent & Embodied Firewall |
agent/, inference/
|
agent_enveloped_safe (decision_table.tsv extracted from HOL4; verified neural inference + quantized error bounds (mlpInferenceScript.sml); live Candle kernel closed-loop gate (agent/closedloop/). |
| Prover & Kernel Self-Upgrade |
embedded/, selfprover/, selfproverConcrete/, kernel/, kernel/loebReduction/
|
prover_self_improvement_is_safe (frozen HOL4 root vouches for mutable Candle+CakeML build, frozen_checker_sound discharged on real candle_kernelProgTheory via holSyntax_cv); self_improving_kernel_is_safe; wd_encodes_obligation; loeb_via_lca_from_encodes_soundness reducing encodes_soundness to lcaTheory. |
| Self-Upgrading Compiler & Prover |
compilerOpt/, selfUpgrade/, kernelMod/, loader/, kernelImpl/, recursive/, selfRecompile/, apex/
|
Verified bvl_fold pass (bvl_fold_correct); proof-gated REPL compiler swap (certified_eval_compiler_swap, proof_gated_repl_upgrade); altered cake-selfupgrade binary; verified do_install loader; mutual verifier+compiler genealogy (apexScript.sml). |
| Live Place & Ouroboros |
reflectsem/, candle/theplace.ml, candle/ouroboros_rewrites.ml, candle/ouroboros.ml
|
45 datatypes + 134 clauses of CakeML eval_n inside the live Candle kernel; Kernel.compute (:cval) bytecode evaluation; theorem-gated ouro_compiler_cell upgrading orw_exp ofold live across 6 generations (OUROBOROS_OK). |
| Composed Crown |
integration/integrationScript.sml, integration/integrationKernelScript.sml
|
Composes every layer above—including bvl_fold, ofold_eval_n_agrees, certified_eval_compiler_swap, real_candle_discharges_seam, and loeb_via_lca_from_encodes_soundness—into svenvs_full_stack_crown. |
# 1. Fast Tier-1 guided tour (pure HOL4, prints machine-checked theorems)
./demo.sh
# 2. Composed proof tower + strict ledger check (verifies every theorem in CLAIMS.md)
scripts/tower.sh --full
scripts/verify-claims.sh --strict
# 3. Live Candle Place + Kernel.compute + 6-generation Ouroboros loop (requires x86-64 cake binary)
scripts/reflectsem-live.sh --ouroboros
# 4. Theorem-gated compiler cell in live Candle & self-upgradable CakeML root binary
scripts/apex-compiler-cell-candle.sh
scripts/apex-selfupgrade-root.sh
# 5. Full tiered reproduction & repository hygiene audit
scripts/reproduce.sh
scripts/hygiene-audit.sh- Tier 1 requires only HOL4 at the pinned commit.
- Tier 2 adds the built CakeML/Candle theory chain (
WITH_KERNEL=1). - Tier 3 runs live inside the verified
cakebinary on x86-64 Linux. - Exact toolchain pins (full 40-hex commit SHAs), flags, and environment variables are documented in
scripts/INSTALL.md.
CLAIMS.md— The canonical, mechanically verified ledger of every theorem, runtime check, and labeled seam.ARCHITECTURE.md— Detailed layer breakdown, the tower of turtles, and why prover self-improvement avoids Löb's obstruction while kernel self-strengthening meets it.paper/svenvs.md,paper/self-optimizing-prover.md,paper/honest-assumptions.md— Accompanying papers.CONTRIBUTING.md— Repository rules: every claim is afile : theoremcitation checked byscripts/verify-claims.sh; every gate is operational with a necessity theorem beside it; zerocheat, zero oracles, full 40-hex commit pins.