Cure v0.36.0 :: Universe Polymorphism, Interactive Tactics & Mechanised Verification
by Aleksei Matiushkin & Pedro Fonseca
Cure v0.36.0 is the largest release since the dependent pipeline landed in v0.34.0, spanning 178 commits across the type theory kernel, the proof and tactic engine, the Agda soundness development, and every supported editor.
In v0.35.0, Cure established its first machine-checked soundness proof in Agda alongside a standalone Tree-Sitter grammar and audit-driven kernel hardening. In v0.36.0, Cure takes three decisive steps toward interactive proof-assistant ergonomics on the BEAM:
- Full Agda-style universe polymorphism (Phase 5, U0–U7) — removing the fixed three-level
Type 0 : Type 1 : Type 2ceiling, introducing canonical maximum-plus level algebra, surface universe syntax and use-site inference, polymorphic standard-library families (Equivalent,List,Option,Sigma), and verified grade-0 erasure with byte-identical BEAM output. - Interactive proof tooling, extensible tactics & checked solvers (Phases 1–4) — live goal-state introspection across CLI diagnostics, REPL (
:goals), LSP (cure/proofState+ hole-goal inlay hints), and a native VS Code goals tree; template and typed goal-inspecting computed tactic macros; checkedsearch,assumption,positivity,decide, and boundedomegasolvers; explicit@simpadmission; deterministicrewrite using h all; and automatic proof-admission totality. - Mechanised soundness expansion & executable certificate replay — growing
proof/from 18 to 238 Agda modules with CI axiom-surface guards, mechanised confluence and erasure, native dependent-typing soundness, and an executable Elixir-to-Agda wire format that replays checked certificates end to end.
Alongside these language and metatheory milestones, v0.36.0 delivers a broad sweep of fixes and quality-of-life improvements across cure-lsp, cure fmt, Neovim, VS Code, Zed, highlightjs-cure, and the web playground, plus a new linear resource pool example (examples/cure_pool/).
Author Credits
This release is the result of sustained work across metatheory, compiler engineering, and editor tooling:
- Aleksei Matiushkin (@am-kantox): Designed and implemented Phase 5 universe polymorphism (U0–U7), Phases 1–4 interactive proof tooling, tactics, checked solvers, and automatic proof-admission totality, expanded the Agda soundness and executable certificate-replay development to 238 modules, and authored
examples/cure_pool. - Pedro Fonseca (@pedrohfonseca81): Built
mix cure.editors.syncfor single-source-of-truth editor grammars, brought Tree-Sitter highlighting toneovim-cureand the web playground, deliveredcure-lsp##hover documentation, byte-framed stdio, lexer-backed semantic tokens, andCure.tomlresolution, and fixed multi-line indentation incure fmtand grammar/LSP ergonomics across Neovim, VS Code, Zed, andhighlightjs-cure.
1. True Universe Polymorphism (Phase 5, U0–U7)
Previously, Cure's Core kernel lived inside a fixed three-level hierarchy (Type 0 : Type 1 : Type 2 capped by Universe.ceiling/0), and surface names like UniverseLevel, TypeN, TypeLimit, and Type(0) were parsed as ordinary type variables rather than universe expressions.
v0.36.0 replaces that fixed ceiling with end-to-end Agda-style universe polymorphism:
- Canonical maximum-plus level algebra (
Cure.Core.UniverseLevel): Every universe level is represented in canonical maximum-plus normal form (%UniverseLevel{constant, atoms}with sorted, deduplicated{atom_term, offset}entries and constant subsumption). Operations (zero,closed,atom,succ,max,equal?/3,leq?/3,shift/3,subst/3,free_vars/1) preserve normal form by construction, andvalidate/2rejects malformed or non-canonical representations. - Unbounded cumulativity:
Universe.ceiling/0has been removed. Trusted sorting and cumulativity now operate over arbitrary canonical levels, and every Core traversal walker was audited and upgraded to be level-aware and fail-closed. - Surface syntax & use-site inference:
UniverseLevel,universe_zero,universe_succ,universe_max,Type(l),TypeN,TypeLimit, andTypeLimitNare now first-class surface forms with least-upper-bound (LUB) inductive family sort inference, level unification, and use-site inference. - Polymorphic standard library (82 modules):
Std.Equivalent,Std.List,Std.Option, andStd.Sigmaare now single universe-polymorphic definitions across the entire 82-module standard library (71 inlib/std/+ 11 inlib/std_deps/). - Zero runtime cost (U6): Universe-level parameters are strictly grade-0 erased. Any runtime-relevant use of a universe level is rejected during elaboration/erasure, and emitted BEAM bytecode is verified byte-identical to the monomorphic baseline.
- Adversarial property testing (U7): Antigen now includes universe-polymorphic and adversarial generators, canonical maximum-plus shrinking, and §19.6 weak-kernel sensitivity antibodies.
2. Interactive Proofs, Extensible Tactics & Checked Solvers
Guided by docs/PATH_TO_LEAN4.md and tracked in docs/LEAN4_PARITY_STATUS.md alongside a pinned parity corpus (test/lean4_parity/), v0.36.0 closes Phases 1–4 of the interactive proof-engineering roadmap.
Live Goal-State Introspection Everywhere
Writing proofs without seeing the remaining goal state is working blind. v0.36.0 wires Cure.Elab.ProofState and Cure.Elab.SourceContext through every user-facing surface:
- CLI (
E110): Unfinished proof diagnostics now render the exact remaining target and authored local hypotheses. - REPL (
:goals): Displays proof states for the latest definition submission — even when the definition is refused — without installing the failed definition into the session. - LSP (
cure/proofState& hole-goal inlay hints): Responds to cursor positions in the negotiated UTF-8/16/32 encoding, enforces document version consistency (-32801on stale/closed buffers), and renders expected types at typed holes directly inline. - VS Code (
cure.goals&cure.showGoals): A native Goals tree view with request coalescing, cancellation, and automated verification against the real VS Code Extension Host in CI.
Checked Tactics & Extensible Proof Commands
- Unified tactic engine (
Cure.Elab.Tactic): Justification commands run through a single checked goal API (ProofGoal.new/5,inspect_goal/1) that preserves original-goal identity and checked proof evidence across sequence, choice, focus, all-goals, and bounded repeat combinators. - Application sessions & canonical-frame induction:
applyretains immutable pending parent goals with telescope-ordered independent premises, staged dependent premises, and explicit witness obligations for unresolved implicits. Ordinary induction and induction templates execute checked goal commands per branch with hygienic field and induction-hypothesis (IH) names. - Library-defined tactics:
- Template tactics (
tactic ... becomes ...) let libraries define reusable, contextual proof commands inside macro containers. - Typed computed tactics (
Std.Tactic) receive capturedSyntaxarguments and a typedStd.Tactic.Goal(withHypothesisrecords and structural target syntax), returning requests from a closed 256-operation vocabulary with fresh invocation handles and explicitfresh(...)hygiene markers. Crucially, the trust boundary never shifts: every expanded request is re-checked by the Core kernel against the original obligation.
- Template tactics (
Checked Solvers, @simp, and rewrite ... all
by search: Local evidence, checked projections, and tagged lemmas (retaining ambiguity errors rather than guessing silently).by assumption: Strictly local propositional evidence.by positivity: Curated natural-numberIsPositivefragment (successors, addition, multiplication, sign hypotheses).by decide/by decide using expr: NormalisesDecision(P)exclusively through certified Core and extracts checkedYesevidence at the original goal.by omega: Reconstructs checkedStd.Proof.IntOrderevidence from local hypotheses, reflexivity, transitivity, additive monotonicity, and literal-natural scaling (bounded to 128 local slots, depth 12, 512 steps, scalars ≤ 1024).@simp/@lemma(:simp): Explicit simplification admission guarded by a strict Core-size termination check (E112on non-decreasing or binder-containing endpoints), alongside certified recursive computation (beta,iota,zeta, certifieddelta).rewrite using h all: Deterministic left-to-right multi-occurrence rewriting via composed checked equality transports, leaving single-occurrence rewriting as the default.
Automatic Proof-Admission Totality
To prevent nonterminating recursive definitions from sneaking into logical proofs just because kernel typing accepts a recursive application, hole-free declarations that execute proof syntax or implicit search now require totality certification automatically (E013 proof_totality_unproven). Unlike @total true, this requirement cannot be waived with @total false — while ordinary partial runtime functions remain completely legal.
3. Mechanised Soundness & Executable Certificate Replay (proof/)
Between v0.35.0 and v0.36.0, the Agda formalisation grew from 18 modules to 238 modules, backed by a new CI job (ci(proof)) that machine-checks the entire development and guards its exact axiom surface:
- Confluence & honest classical soundness: Proved the diamond property and confluence of
_⇝_via value-free strict parallel reduction⇉. Along the way, we discovered that the earlier classical postulatenever-reached→no-valuewas false for binder-reducing_⇝_(sincetm-lam g d Ωis a canonical value that steps to itself forever). Both the false postulate and the theorem built on it were retired and replaced by the honest, zero-postulate normal-form dichotomysoundness-nf : Reached ⊎ DivergesNF(Proof.SoundnessConfluence). - Mechanised erasure & §8 regressions: Proved
erase-idemwith zero postulates and added regression suites fordocs/SOUNDNESS.md§8 (hole firewall on both paths, SCC verifier rejecting forged partitions, erasure-commutation congruence, and the negativeδ-commutation result). - Native dependent-typing soundness: Built
Core.DependentTyping,Proof.DependentSoundness, andProof.DependentSoundnessModelproving general dependent transport, conversion inversion, recursive native subject reduction with checked literal layouts, and constructive fuel/trace/tree soundness. - Executable Elixir-to-Agda certificate replay: Added
Cure.Core.ProofWire,ProofSnapshot,ProofSnapshotWire,ProofRecipe, andProofContextto serialise canonical executable snapshots and recipe certificates from Elixir and replay them in Agda — closing the M1 acceptance gate on a genuinely dependent converted argument, and discharging representation and adapter obligations (host-shaped table resolution, failure impossibility for three evaluator raise sites, narrowedδ-unfolding policy, and typedηpreserving head separation).
4. Linear Resource Pool Example (examples/cure_pool/)
v0.36.0 ships a complete Cure + Elixir/OTP resource pool example demonstrating what quantitative and dependent types buy in real BEAM infrastructure. Where ordinary runtime pools catch misuse only in production, examples/cure_pool rejects three classic pool bugs at compile time (verified by negative compile-fail fixtures) while preserving OTP supervision and crash-reclaim semantics:
- Checking out from an empty pool (
checkout_empty.cure) - Returning a lease twice (
double_return.cure) - Dropping an active lease without returning it (
dropped_lease.cure)
5. Editor, LSP, Formatter & Compiler Fixes
v0.36.0 resolves a long list of everyday friction points across the toolchain:
- Single-source-of-truth editor grammars (
mix cure.editors.sync): Generates keyword lists fromCure.Compiler.Lexer.keywords/0and stdlib declaration macros intotree-sitter-cure,vscode-cure,neovim-cure, andhighlightjs-cure, checked automatically bymix test. All editors now highlight/.../regexes accurately (replacing bogus~r/.../rules),##/###doc comments (removing nonexistent#| |#block comments),behavior, anddirectly. neovim-cure: Native Tree-Sitter highlighting on Neovim 0.11+ (:CureTSBuild), working installation instructions pointing atcure-lang/cure-lang, a single LSP client per project root, and.cureicons vianvim-web-devicons.vscode-cure: Findscure-lspandcureonPATHand across workspace folders, expands~and${workspaceFolder}, honourscure.trace.server, adds extension/file icons, and auto-indents after trailing=or->.cure-lsp:- Hover now displays
##documentation alongside full signatures (parameter types, return type, and effects), followinguse/asaliases andCure.tomlsource paths, and preserving trailing?on predicates. - Frames stdio
Content-Lengthin bytes instead of Unicode characters, eliminating protocol desync on multi-byte UTF-8 files. - Semantic tokens now come directly from the lexer (contextual keywords only in keyword position, never inside comments or strings).
- Fixed inlay hint and code lens line numbers, constructor classification, and removed redundant
# fn ...hints and unimplementedType | Effectslenses.
- Hover now displays
- Lexer & doc comments:
##blocks now start on their own line; a##block touching the first definition documents that definition rather than the enclosing module (with module docs separated by a blank line, aligned across the stdlib). - Formatter (
cure fmt): Indents every line of a multi-line node in the algebra formatter. - Diagnostics & CLI hardening:
- Unfilled holes reaching canonical emission render as user-facing
E014 UNFILLED HOLEinstead ofE101 CODE GENERATION FAILED. - Unresolved modules report
E091instead ofE101. cure helpis generated from a singleCure.CLI.Commandsregistry;cure watch --actionvalidates input at the CLI boundary (E099);Term.from_external/1decodesatom_litthrough existing-atoms-onlysym_atom/1;cure migrateexits viaexit({:shutdown, 1}).
- Unfilled holes reaching canonical emission render as user-facing
- Web playground: Syntax highlighting in
site/is now powered bytree-sitter-cure.
Summary of Changes
| Area | Milestone | Impact |
|---|---|---|
| Type Theory | Universe Polymorphism (U0–U7) | Unbounded canonical levels, Universe.ceiling/0 removed, polymorphic Equivalent/List/Option/Sigma, grade-0 erasure |
| Proof Ergonomics | Goal Introspection (CLI/REPL/LSP/VS Code) | E110 goals, :goals, cure/proofState, hole inlay hints, native VS Code cure.goals tree |
| Tactics | Checked Engine & Extensible Macros | Cure.Elab.Tactic, tactic ... becomes ..., typed computed tactics (Std.Tactic), canonical-frame induction |
| Automation | Checked Solvers & @simp |
search, assumption, positivity, decide, bounded omega, @simp termination check (E112), rewrite ... all |
| Soundness | Automatic Proof-Admission Totality | Hole-free proof declarations require totality (E013), unwaivable by @total false |
| Metatheory | 238-Module Agda Proof & Wire Replay | CI-checked confluence, soundness-nf, mechanised erasure, native dependent soundness, M1 Elixir→Agda replay |
| Examples | examples/cure_pool/ |
Compile-time linear & dependent guarantees for an OTP resource pool |
| Editors & LSP | mix cure.editors.sync, Hover & Byte Framing |
Unified grammars across 4 editors + playground, ## hover docs, UTF-8 byte framing, lexer semantic tokens |
Looking Ahead
With universe polymorphism complete, interactive proof-state tooling live across CLI, REPL, LSP, and VS Code, and 238 modules of Agda metatheory checked in CI, Cure v0.36.0 brings proof-assistant ergonomics much closer to everyday BEAM engineering without compromising its single, kernel-checked pipeline or zero-cost runtime erasure.
Install Cure v0.36.0, inspect your goals with :goals or VS Code's cure.goals view, try writing a polymorphic definition or a custom tactic, and explore the full parity scorecard in docs/LEAN4_PARITY_STATUS.md.