Skip to content

Repository files navigation

Systems Lean

Systems Lean is the project: Lean 4 with linear/affine ownership and QTT multiplicities 0 / 1 / omega, aimed at freestanding systems products, reached by a meet-in-the-middle bridge between Idris 2 and Lean 4.

The freestanding compiler product of this project is Slake.

(Checkout directory may still be named iso on disk; the project name is Systems Lean.)

North star

Slake is a compiler written in Systems Lean. Focus: freestanding runtimeless C (out/freestanding-c) with memory safety from linear types, no garbage collection on the product wire, and only the minimum Quantitative Type Theory multiplicities (0 / 1 / omega) needed for that path.

Living tip: freestanding product self-host complete and product residual free are both true; host still uses classic Lean Lake. Free is not "Lake is gone," not proof complete, not PROVABLY, not LLVM. Bootstrap status and Open residual: doc/SESSION-HANDOFF.md, RESIDUAL-systems.md. LLVM IR for Rust-native link stays deferred (out/llvm-ir).

Meet-in-the-middle Idris 2 and Lean 4 correspondence feeds Slake -- sides live under src/idris2/ and src/lean4/.

Three languages only for novel work: Idris 2, Lean 4 (including Systems Lean / Slake), and pure Nix flakes (small modules under nix/, not bash-in-Nix). No project Python; shell under script/ is migration debt to shrink. Freestanding C is generated product wire (emit / out), not a fourth source language. Thin just orchestrates only. Policy and language inventory: AGENTS.md, terms: doc/vocabulary.md, goals: doc/goals.md. Spec and proof stay separated; red/green tests stay required.

Read first

Doc Purpose
doc/goals.md Full goals, non-goals, honesty ladder
doc/vocabulary.md Stable terms (project = Systems Lean; Slake = compiler; tooling terms)
doc/architecture.md Meet-in-the-middle sketch
doc/divergence.md Honest differences and trusted computing bases
AGENTS.md Agent hygiene, isolation, project skills, pure Nix tooling, language inventory (SSoT -- single source of truth)
RESIDUAL.md Living open work for this project
.agents/skills/ Project skill discovery (symlinks; hosts walk this path)

References (read-only)

Path Upstream Role
ref/Idris2 Idris2 QTT / linear side
ref/lean4 Lean 4 Kernel / elaborator / proof side
ref/CompCert AbsInt CompCert ccomp source for CompCert-oriented C path
ref/rust rust-lang/rust Type layout / ABI + LLVM codegen reference (not llvm-project alone)

Do not treat ref/ as product source. Systems Lean language work and the Slake compiler live in this repository.

Entry maps: doc/idris-entry.md, doc/lean-entry.md, doc/compcert-entry.md, doc/rust-entry.md.

Project agent skills

Lean 4 coding-agent workflows ship as a project skill (no global install required for discovery):

Skill Discovery path Body (submodule)
lean4 .agents/skills/lean4 skills/lean4-skills (cameronfreer/lean4-skills)

After clone: git submodule update --init --recursive skills/lean4-skills. Policy, overrides, and when to use for residual/plans: AGENTS.md (Project agent skills). Inventory: skills/README.md. Lean entry map: doc/lean-entry.md.

Isolation

Work here. This repository is Systems Lean. Do not default to other trees for residual or implementation. Escalate off-repo only when a human is explicitly desperate for a specific solution.

Repository structure

.
+-- src/                 # Novel product work (not upstream)
|   +-- idris2/          # Idris side -- isomorphism / QTT (Quantitative Type Theory) side
|   +-- lean4/           # Lean 4 side -- kernel/elaborator-facing novel work
|   +-- systems/         # Freestanding Systems Lean + Slake host (min 0/1/omega; no product GC)
+-- out/
|   +-- freestanding-c/  # Generated freestanding product wire (release; not hand-authored)
|   +-- llvm-ir/         # LLVM IR for Rust-native link (deferred post self-host)
+-- ref/                 # Language/compiler upstream (Idris2, lean4, CompCert, rust)
+-- skills/              # Agent skill pack submodules (lean4-skills; not product)
+-- .agents/skills/      # Project skill discovery (symlinks into skills/)
+-- doc/                 # Goals, vocabulary, architecture, entry maps
+-- nix/                 # Pure Nix tooling modules (hygiene, progress, host/emit gates)
+-- script/              # Process glue only (optional git-hooks/pre-commit -> just check); no mills
+-- justfile             # thin orchestration: check | build (product wire; default: list)
+-- flake.nix            # Thin wire-up: checks / packages / devShell (no shell-farm apps)
+-- AGENTS.md            # Agent policy + skills + tree map + language inventory (SSoT)
+-- RESIDUAL.md          # Living open work

Full evolving map: AGENTS.md. Product code never under ref/ or skills/. Language inventory and freestanding C git policy: AGENTS.md (Three languages only -- single source of truth; do not fork a second inventory here). Terms: doc/vocabulary.md. Forks: doc/fork-idris.md, doc/fork-lean.md. Coordinator: doc/fork-coordinator.md. Agent residual loop (not a product map): WATCHER.md.

Tooling

Meters, hygiene, and host/emit gates are pure Nix under nix/ (not project Python; no shell-farm flake apps). Thin just only orchestrates.

nix develop       # elan (Lean/Lake pin manager) + idris2 + just + rg + scc
just              # list
just check        # CI-identical full suite
just progress     # pure Nix meters -> doc/PROGRESS.md
just watch        # every 300s: progress-scc + hygiene (just loop)
just build        # product freestanding wire (emit + out/freestanding-c)
just out-llvm-ir  # deferred (see out/llvm-ir/README.md)

Lean elaborator pin is leanprover/lean4:v4.32.0 (src/systems/lean-toolchain, src/lean4/lean-toolchain). In the dev shell: elan toolchain install "$(tr -d '[:space:]' < src/systems/lean-toolchain)" once. Workspace checks skip Lake when the pin is not installed (no surprise network download).

Side residuals: RESIDUAL-idris.md, RESIDUAL-lean.md. Coordinator: RESIDUAL.md. ASCII map: doc/ascii-symbol-map.md. Policy and language inventory: AGENTS.md.

License

  • Our work (everything we commit outside ref/ and skills/): The Unlicense -- public domain dedication. See LICENSES.md.
  • Author: Hunter "cryptoquick" Beast.
  • SPDX for our crates / modules / packages: Unlicense (Cargo, Lake, Idris, Nix metadata, optional file headers). Details in LICENSES.md.
  • Submodules under ref/ and skills/: keep their own licenses (Idris 2 BSD-style, Lean 4 Apache-2.0, CompCert non-commercial/AbsInt, Rust Apache-2.0 OR MIT, lean4-skills MIT, ...). Tracked in LICENSES.md.

Status

Active Systems / Slake residual and living tip: doc/SESSION-HANDOFF.md and RESIDUAL.md. Foundation docs and upstream submodules are in place; product work is under src/systems/.

About

Freestanding high assurance Lean 4 implemented with no runtime GC and linear type multiplicities, compiles AOT to CompCert C

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages