overview implementation

Sources: index of the per-file design notes

Every source file in the repository has a markdown sibling of the same name describing what it is for. Because the vault root is the repository root, those siblings are ordinary vault notes and link into the rest of the design. This note is the index of them.

All code files are comments only. Nothing is implemented, nothing is meant to run. See Repository Layout for the tree and the Rust/Julia split, and Roadmap for the order in which these would actually be written.

Rust — crates/

CrateFileNoteRole
sophia-hashsophia_hash.rssophia_hashpublic hashing API, the three-hash scheme
canonical.rscanonicalterm → canonical form. The most dangerous file here.
merkle.rsmerkleMerkle hashing, SCC construction, erasure
sophia-coresophia_core.rssophia_corethe SC term language, kernel, Prf/Cmp fragments
elaborate.rselaboratesurface → core, NbE, the Frontend trait
effects.rseffectseffect rows, regions, borrows
sophia-storesophia_store.rssophia_storebackend trait, the IR-persistence measurement
schema.rsschemanode/edge kinds, SQL mapping, migrations
sophia-equivsophia_equiv.rssophia_equivclaims, levels, modulo, substitution policy
egraph.rsegraphsaturation and extraction over egg
witness.rswitnessthe six witness formats and their checkers
sophia-emitsophia_emit.rssophia_emitlowering to MLIR and LLVM
sophia-frontend-metamathmetamath.rsmetamaththe M0 frontend
sophia-climain.rsmainthe sophia command-line driver

Julia — src/

FileNoteRole
Sophia.jlSophiapackage entry point; why there is a Julia half
CoreIR.jlCoreIRmirror of the core term language, for differential testing
Hashing.jlHashinghashing plus the Rust conformance suite
Store.jlStorethin client; the context query
Frontend.jlFrontendJulia lowered/typed IR → core terms
Annotations.jlAnnotations@equiv, @spec, @sophia_test, @assume
Precompile.jlPrecompilethe content-addressed code cache

Reading order for someone new

  1. Design Overview — what the system is
  2. sophia_hash → canonical → merkle — how identity works, and what can go wrong with it
  3. sophia_core → effects — the common language
  4. schema → sophia_store — how it is stored and what has to be measured
  5. sophia_equiv → witness — the central claim and its safeguards
  6. Precompile — the part that could pay for itself first

Where the risk is concentrated

Three files, for three different reasons:

  • canonical — the only silent failure mode in the system. An over-coarse canonical form identifies two different programs and nothing downstream detects it.
  • sophia_store — carries the empirical question that could invalidate the architecture: whether querying IR back out is competitive with regenerating it (Open Problems and Risks).
  • sophia_equiv — where a careless default turns the project into a miscompilation generator, via the congruence problem in Equivalence and Witnesses.