Lean-inspired roadmap

Copy Markdown View Source

This document tracks which Lean ideas Theoria has already adapted and which ones are worth building next. It is not a plan to port all of Lean. Theoria should remain Elixir-native and keep the trusted kernel small.

Legend:

StatusMeaning
implemented enough for current Theoria
🟡partially implemented
🔴missing and important
intentionally postponed / maybe later
probably should not port directly

Core trusted kernel / expressions

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
Expr.sortUniverse sort term%Term.Sort{level}Keep hardening universe solverP0
Expr.const with universe levelsNamed constant with level args%Term.Const{name, levels}Add better level inference laterP0
Expr.appFunction application%Term.App{}StableP0
Expr.lamLambda abstraction%Term.Lam{}StableP0
Expr.forallEDependent function type%Term.Forall{}StableP0
Expr.letELocal definitions / zeta%Term.Let{} with zeta reductionStableP0
Expr.bvarDe Bruijn variables%Term.BVar{}StableP0
Expr.fvar, Expr.mvarFree/meta variables for elaborationNo kernel metavarsAdd elaborator-only holes/metavars later, not kernel firstP3
Literal supportNat/string literalsNo primitive literalsAdd through inductive/library encodings laterP4
Projection expressionsStructure field projectionsNo structures yetWait until structures/records existP4
Term hashing / sharingPerformancePlain structsAdd after benchmarks show needP4

Universe levels

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
Level.zeroProp / lowest universe%Level.Zero{}StableP0
Level.succType (u+1)%Level.Succ{}StableP0
Level.maxUniverse max%Level.Max{}Solver improvingP0
Level.paramUniverse polymorphism%Level.Param{}StableP0
Level normalizationCanonicalize universe exprs🟡Basic normalizationAdd more simplification lawsP1
Universe constraint solverDecide u ≤ max u v, etc.🟡Theoria.Level.Solver groundworkExpand solver with constraints, substitutions, diagnosticsP0
Universe metavariablesElaborator inferenceNoneAdd later for implicit universe inferenceP3
Cumulative universesSort/subsort checking🟡Sort typing exists; limited leq?Formalize cumulativity in checkingP1
Prop impredicativityLean's Prop behavior🟡Prop-valued forall rule addedAudit against intended theoryP1

Environment and declarations

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
EnvironmentStores constants/declarations%Theoria.Env{}Stable enoughP0
ConstantInfoDeclaration metadata🟡%Env.Constant{} plus metadataContinue typed metadata expansionP0
DefinitionValReducible definitionkind: :definition, value, reducible?StableP0
TheoremValOpaque proof declarationkind: :theoremStableP0
AxiomValTrusted assumptionkind: :axiom; axiom trackingStableP0
OpaqueValOpaque constants🟡Theorems/axioms opaque; constants no valueMaybe explicit opacity APIP2
Declaration replayValidate env integrityTheoria.Kernel.validate_env/1Keep adding corruption testsP0
Declaration dependency graphTrack dependenciesdependencies/2, transitive depsAdd hashing/artifacts laterP2
Trust reportsShow axioms/trusted deps%TrustReport{}Improve pretty/docsP2
Declaration hashingReproducibility/cacheNoneNeeded for artifacts/cachingP3
Persistent env extensionsExtensible metadataHardcoded metadata fieldsMaybe plugin-style metadata laterP4

Type checking and definitional equality

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
Type inferenceInfer term typesKernel.infer/2,3Keep property testingP0
Type checkingCheck against expected typeKernel.check/3,4Improve cumulativityP0
WHNFWeak-head normalizationNormalize.whnf/2More tests/fuelP0
Full normalizationNormalize termsNormalize.normalize/2Performance laterP1
Beta reduction(λ x => t) aImplementedStableP0
Delta reductionDefinitions unfoldReducible definitions unfoldAdd opacity controls laterP1
Zeta reductionlet unfoldsImplementedStableP0
Iota reductionRecursor computation🟡Simple and basic indexed recursors via %Reduction.Iota{} and rulesHarden dependent indexed casesP0
Eta reductionFunction etaNot supportedDecide explicitly; likely postponeP3
Proof irrelevanceLean Prop proof irrelevanceNot implementedDecide theory firstP4
Quotient reductionLean quotient kernel supportNoneProbably postpone/avoidP5
Fuel/termination controlAvoid nontermination🟡Fuel module existsAdd stronger stuck/error diagnosticsP1
Defeq propertiesEquivalence properties🟡Some testsAdd property-based well-typed term testsP1

Inductive declarations

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
InductiveValMetadata for type former%Env.Inductive{}Add mutual/nested fields laterP0
ConstructorValMetadata for constructors%Env.Constructor{}StableP0
RecursorValMetadata for recursors🟡%Env.Recursor{} for simple and indexed recursorsHarden indexed validationP0
RecursorRuleIota rule metadata🟡%Env.RecursorRule{constructor, field_count, rhs, index_patterns} with constructor-index and result validationHarden edge casesP0
Inductive admission pipelineKernel checks inductive declarations🟡Inductive.Admission staged pathMove more ownership here; more Lean checksP0
Strict positivityReject negative recursive occurrences🟡Basic positivity checkHarden nested/mutual casesP0
Constructor target checksConstructors return the familyImplementedStableP0
Parameter preservationConstructors preserve paramsImplementedStableP0
Index arity checksIndexed result has correct argsImplementedStableP0
Recursive index occurrence rejectionLean-inspired safetyAddedStableP0
Constructor universe checksField universe ≤ result universe or Prop🟡Initial checkImprove with solverP0
Generated recursorsAuto rec/ind generation🟡Bool/Nat/List simple recursors and Vec indexed recursorHarden arbitrary indexed casesP0
Recursor RHS typingRules type-infer as expected shape🟡Domain and constructor-result validation addedHarden edge casesP0
Indexed inductivesFamilies like Vec A n🟡Vec-style families admit constructors and generated eliminatorsHarden dependent validationP0
Indexed eliminatorsVec.ind🟡Recursor.Application with validated rules/index patterns and basic iotaHarden dependent validationP0
Indexed iota reductionComputation for indexed recursors🟡Basic Vec library iota reduction with constructor-index/result validationHarden dependent edge casesP0
Mutual inductivesmutual Even/Odd🔴MissingAdd Inductive.Group laterP2
Nested inductivesRecursive occurrence under containers🔴Mostly rejected/unsupportedLater after positivity overhaulP3
Quotient inductivesLean-specific quotient supportNoneProbably do not port earlyP5
No-confusion principlesConstructor disjointness/injectivity🔴MissingGenerate later for inductivesP2
Below/brecOn recursorsCourse-of-values recursionMissingMaybe never / much laterP5

Built-in libraries / prelude

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
Prelude envStandard declarationsTheoria.Prelude.env/0Expand cautiouslyP0
BoolComputational boolInductive Bool with rec/indStableP0
NatNatural numbersInductive Nat with rec/ind/addExpand theorem corpusP0
ListListsInductive List with rec/ind/lengthAdd append/map/memberP1
True / FalseLogical constantsLibrary declarationsMight later encode inductivelyP1
AndConjunctionLibrary declarations/theoremsMaybe inductive laterP1
NotNegationDefinitionStableP1
OrDisjunction🔴MissingAdd as inductiveP1
ExistsExistential🔴MissingNeeds Sigma/dependent pairP1
IffLogical equivalence🔴MissingAdd after And/Imp basicsP2
ProdProduct type🔴MissingAdd as inductive/structureP1
SigmaDependent pair🔴MissingAdd after indexed eliminators strongerP1
OptionOptional values🔴MissingEasy inductive after library cleanupP2
Sum / EitherDisjoint union🔴MissingEasy inductiveP2
FinBounded naturals🔴MissingNeeds indexed familiesP2
VecLength-indexed list✅ / 🟡Theoria.Library.Vec with indexed vec_ind reduction and theorem corpusExpand theorem corpusP1
Decidable propositionsComputable decisions🔴MissingNeeded for automation/specsP2
Finite maps/setsProgram/spec library🔴MissingNeeded before Reach integrationP3

Equality

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
EqPropositional equality✅ / 🟡Primitive %Term.Eq{}Decide long-term primitive vs inductiveP0
Eq.reflReflexivity proofPrimitive %Term.Refl{}Stable for nowP0
Eq.rec / equality eliminatorRewrite/substitution principle🟡Primitive equality recursor with reflexivity reductionHarden and revisit inductive encoding laterP0
Eq.ndrecNondependent equality recursor✅ / 🟡Derived theorem/helperExpand transport libraryP1
Rewrite theorem supportRewrite by equality🟡Low-level Theoria.Equality transport helpersBuild tactic/simp layer laterP1
Congruence lemmasFunction/application congruence✅ / 🟡eq_congr theorem for unary functionsExpand congruence libraryP2
UIP / proof irrelevance decisionsEquality proof behaviorNot decidedDecide theory laterP4
Eq as indexed inductiveLean-like equality encodingNot yetRevisit after indexed iotaP2

Recursor.Application, eliminators, and computation

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
Nondependent recursorNat.rec, List.recGenerated for simple typesStable-ishP0
Dependent induction principleNat.ind, List.indGenerated for simple typesStable-ishP0
Recursor major indexLocate major premiseEnv.Recursor.major_index/1Extend for indexed familiesP0
Iota rules from metadataRule-based computation✅ / 🟡Simple families and basic indexed familiesHarden indexed validationP0
Recursor rule RHS authoritativeNormalizer uses RHSImplementedContinue validationP0
Rule type shape validationReject wrong domains/extra lambdas/results✅ / 🟡Added structural and constructor-result validationHarden indexed edge casesP0
Indexed recursor declarationsVec.ind declaration🟡Iota declarations generated with rule metadataHarden indexed validationP0
Indexed recursor iotaComputation over Vec🟡Basic index-pattern-checked reductionHarden dependent casesP0
No-confusion recursorsConstructor discrimination🔴MissingLaterP2
Recursor compilation to efficient dispatchPerformanceSimple list lookupOptimize laterP4

Elaborator and syntax

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
Named syntax → core elaborationUser syntax to de Bruijn termsTheoria.Syntax, ElaboratorStable basic layerP0
DSL quoteErgonomic term syntaxterm do ... endStable enoughP0
Universe syntaxsort(u), const(:List, [u])ImplementedStableP0
InterpolationEmbed dynamic terms/levels/names^ supportStableP0
Theorem macroDeclare theorem modulestheorem macroImprove proof ergonomics laterP1
Expected-type elaborationInfer omitted info from expected type🔴MissingNeeded for tactics/sugarP2
Implicit argumentsLean-style {α} / inference🔴MissingLater, after kernel stableP3
Universe inferenceAvoid explicit levels🔴MissingNeeds universe metavars/solverP3
Holes/metavariablesInteractive proof construction🔴MissingNeeded for tacticsP2
Source spansBetter errors🔴MissingAdd to syntax/errorsP2
Parser-like notation extensibilityLean syntax macrosElixir macros onlyDo not port Lean parser architectureP5

Theorem management and proof checking

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
Theorem declarationsStore checked proofsTheoria.TheoremStableP0
Opaque theorem valuesTheorems do not reducekind: :theorem, reducible?: falseStableP0
Theorem module registryCheck all theorems__theoria_theorems__/0StableP0
Axiom trackingTrust boundaryaxioms/2, trust reportStableP0
Theorem checking Mix taskCI checkermix theoria.checkStableP0
Theorem corpusRegression proofs53 theorem-module proof(s) plus generated equation proofs, all covered by native validation and Lean oracleExpand librariesP1
Proof irrelevance for theorem proofsLean Prop behaviorNoneDecide theory laterP4
Proof artifact serializationCache/share proofs🔴MissingAdd before larger corporaP3
Incremental proof checkingAvoid checking everything🔴MissingAfter env hashingP3

Tactics and automation

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
Tactic state/goalsInteractive proof engine🔴MissingAdd untrusted proof-state layerP2
introIntroduce forall/implication🔴MissingFirst tactic milestoneP2
exactClose goal with term🔴MissingFirst tactic milestoneP2
assumptionFind local hypothesis🔴MissingFirst tactic milestoneP2
applyBackward reasoning🔴MissingAfter holes/metavarsP2
constructorUse constructor/introduction rule🔴MissingAfter inductive APIs matureP2
casesCase split🔴MissingNeeds eliminator usageP2
inductionInduction tactic🔴MissingNeeds robust recursorsP2
rewrite / rwRewrite by equality🟡Low-level equality transport, symm/trans/congr, provisional Theoria.Rewrite.once/3, and rewrite databases built from generated env equation metadataAdd proof-producing tactic ergonomicsP2
simpSimplifier🟡Tiny untrusted priority-aware Theoria.Simp.once/3 and normalize/3 over generated equation DBs, plus example CLINeeds attributes, richer rule sets, and proof-producing rewriteP3
omega / arithmetic solversAutomationMissingMuch later / maybe notP5
Metaprogramming frameworkLean tactic languageMissingDo not port Lean meta system directlyP5

Equation compiler / pattern matching

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
Pattern matching compilerCompile equations to recursors🟡Internal Signature/FixedParams → Pattern → Clause → Validator → Branch → Context → Schema.Builder → Compiler → Recursor.Application pipeline; compiled Bool/Nat/List definitions store auditable equation metadata with derived fixed params, discriminants, and simple overlapsAdd public syntax and dependent matching laterP1
Structural recursionTermination by smaller argument🟡Library definitions use primitive Nat/List recursion; no general checkerStart conservative checkerP1
Termination checkerEnsure recursive definitions terminate🔴MissingStart conservativeP2
Equation lemmasGenerated simplification theorems🟡Signature + Case.Template + Schema.Builder + Compiled + Definition.Spec; compiler-owned validated schema-backed schematic generated lemmas for supported Bool/Nat/List definitions; derived fixed params/discriminants/overlaps; checked recursor-informed Matcher.Descriptor / Matcher.Type / Matcher.Spec / Env.Matcher declarations; Bool/Nat/List, including binary Bool, have real matcher type/body; Extension.Registry, Eqns, and Matcher.Eqns lookup/source/unfold/realization APIs; Lean oracle proof coverage; rewrite DB construction from env metadataTurn indexed recursor descriptors into dependent/indexed matcher descriptors, add broadly independently compiled matcher bodies, persistent lazy theorem registry, and persistent matcher equation extension for full Lean parityP2
Dependent pattern matchingMatch indexed families🔴MissingAfter indexed iotaP2
Inaccessible patternsLean dependent matching feature❌ / laterMissingProbably much laterP5
Partial functionsLean has partial supportMissingAvoid early; kernel should stay totalP5

Structures, classes, namespaces

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
Structures / recordsProduct-like named fields🔴MissingCould encode via Sigma/Prod firstP3
ProjectionsField accessors🔴MissingAfter structuresP3
TypeclassesInstance searchMissingNot needed earlyP5
NamespacesOrganize declarations🟡Atom/module names onlyMaybe add name module laterP3
AttributesMark simp/rewrite/etc.🔴MissingNeeded for simplifier laterP3
Sections/variablesLean source convenienceMissingElixir DSL can handle differentlyP5

Modules, compilation, artifacts

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
Import systemLoad modules/envs🟡Elixir modules/preludeAdd serialized env imports laterP3
.olean artifactsCompiled environment artifactsNoneAdd theorem/env artifacts laterP3
Environment hashesReproducibility/cacheNoneAdd before large librariesP3
Module-level trust reportsAudit imports🟡Theorem trust reportsExtend to artifactsP3
Incremental checkingFast rebuildsFull check currentlyLaterP4

Diagnostics and developer experience

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
Pretty printerHuman-readable termsTheoria.Pretty / InspectKeep improvingP1
Kernel error structsStructured errors%Theoria.Error{}Add richer contextP1
Elaborator errorsUser-level diagnostics🟡Basic pretty errorsAdd source spans/named contextsP2
Defeq mismatch diffExplain type mismatch🔴Basic left/rightAdd normalized diffP2
Trace/debug normalizationInspect reductions🔴MissingUseful soonP2
Docs generationExDocDocs integratedContinueP1

Testing and verification infrastructure

Lean feature / conceptLean roleTheoria statusCurrent Theoria stateNeeded roadmapPriority
Kernel corruption testsCatch invalid envs✅ / 🟡Leanchecker-inspired testsKeep expandingP0
Theorem corpus testsProve library facts53 theorem-module proof(s), generated equation proof checks, 57 defeq checks, 4 inductive checksExpand corpusP1
Property tests for termsSubst/shift/scope laws🟡Some propertiesAdd well-typed generatorP1
Normalization preservationReduction preserves type🔴Missing broadlyAdd property testsP1
Defeq lawsEquivalence properties🟡Native validation has 57 defeq checks mirrored to Lean, including equation-compiler checksAdd generated well-typed testsP1
Inductive admission fuzzingRandom invalid specs🔴MissingAdd after APIs stabilizeP2
Lean oracle validationExternal contributor oracleLogic/Equality/Bool/Nat/List/Vec theorem corpus plus defeq checks; Vec mirror generated from Inductive.SpecContinue as corpus growsP1
Real-world spec testsConsume by Reach/etc.🔴MissingLaterP4

Features probably not worth porting soon

Lean featureWhy not nowTheoria direction
Lean parser/frontend architectureTheoria is Elixir-nativeUse Elixir macros/DSL
Lean tactic metaprogramming systemHuge project by itselfSmall untrusted tactic layer
QuotientsComplicated kernel featureAvoid until real need
TypeclassesPowerful but large complexityMaybe later, not core
Elaborator elaboration monadLean-specific scaleSmall expected-type elaborator
Compiler/codegenLean compiles programsTheoria checks specs/proofs, not app code
Native arithmetic solversHeavy automationAdd only after core proof layer
Full mathlib compatibilityNot the goalBuild small Theoria-native library
Lean syntax notation frameworkNot Elixir idiomaticDSL helpers/macros

Practical milestone roadmap

Milestone 0 — current state

AreaStatus
Kernel terms
Universes🟡
Env declarations
Bool/Nat/List
Simple recursors
Iota via rules
Inductive metadata
Indexed family admission🟡
Indexed eliminators🟡 Vec-style iota validated locally and by Lean oracle
Tactics🔴
Equation compiler🟡 Internal Bool/Nat/List constructor-equation compiler

Milestone 1 — finish current inductive foundation

StepDeliverablePriority
Generate indexed eliminatorsGenerate.indexed_eliminators/1; Vec.ind declaration with iota metadataP0
Add indexed recursor metadata without rules%Env.Recursor{num_indices > 0, rules: []} allowed with reduction: nilP0
Improve indexed induction type checking✅ Generated indexed eliminator type kernel-infers after installP0
Extend docsExplain indexed eliminators are noncomputational for nowP1
Add testsVec-like install + metadata testsP0

Milestone 2 — indexed iota

StepDeliverablePriority
Extend RecursorRule✅ Add index-pattern metadataP0
Generate indexed rulesVec.nil, Vec.cons rule metadataP0
Validate indexed rule typesFull dependent motive/index checkingP0
Normalize indexed recursors✅ Reduce Vec.ind ... vec_nil / vec_consP0
Add Vec library✅ Real Theoria.Library.VecP1

Milestone 3 — equality eliminator

StepDeliverablePriority
Add Eq.rec primitive or declaration✅ Primitive rewrite principleP0
Add rewrite helper theorem APIsrewrite/subst/ndrec/symm/trans/congr term buildersP1
Decide primitive vs inductive EqArchitecture decisionP1
Add equality theorem corpus✅ symmetry, transitivity, congruenceP1

Milestone 4 — equation compiler

StepDeliverablePriority
Pattern AST✅ Constructors/vars/wildcards with recursive validationP1
Bool/Nat/List equation compiler🟡 Internal layered compiler with Lean-shaped equation info, fixed params, validation, branch descriptors, explicit contexts, callback body contexts, and generic dispatchP1
Generated equation theorems🟡 Schema-backed schematic lemmas for Bool/Nat/List definitions with optional theorem installation, Eqns lookup, Lean oracle checks, and CLI reportingP2
Termination checker v0Structural onlyP2
Replace hand-written library defsbool_not, bool_and, bool_or, nat_add, list_length, list_append use the equation compiler pathP2

Milestone 5 — proof ergonomics

StepDeliverablePriority
Proof state/goalsUntrusted proof engineP2
intro, exact, assumptionBasic tacticsP2
apply, constructorUseful proof automationP2
cases, inductionRecursor-backed tacticsP2
rewrite, simpEquality-backed automationP3

Milestone 6 — library growth

StepDeliverablePriority
Or, Exists, Prod, SigmaCore logic/dataP1
Option, Sum, FinProgramming dataP2
Nat order/arithmetic, <, +, * factsP2
List append/map/memberUseful list libraryP2
Decidable predicatesAutomation/specsP3

Milestone 7 — specs and Reach integration

StepDeliverablePriority
Theoria.SpecElixir-facing spec layerP3
Executable property bridgeStreamData/ExUnit integrationP3
Finite graph libraryGraph predicates/theoremsP3
Reach invariant specsCFG/dataflow/effects invariantsP4
Report integrationCI/spec reportsP4

Strategic recommendation

For the next several cycles, prioritize:

1. opaque indexed eliminators
2. indexed recursor metadata
3. indexed iota rules
4. equality eliminator
5. equation compiler

Avoid spending much time on tactics or DSL cosmetics until those are done. Theoria's differentiator will be a small, credible kernel, not surface syntax.