Lean 4 cubical-transport HoTT engine + Rust naga-IR FFI. The backend that powers topolei. Cells-spec implementation; the proof IS the implementation.
Find a file
Maximus Gorog 7ccebb606d
Some checks are pending
Lean Action CI / build (push) Waiting to run
ALGEBRA Phases A+B+C+D' + cubical_search tactic + doc state-of-play
Lands the metacoding stack from ALGEBRA_PLAN.md per the user's
discipline directive (no shortcuts, end-to-end correct).

CubicalTransport/Algebra/Meta.lean (Phase A — meta-mirror types):
- MetaCType: 11 constructors mirroring the cubical CType arms.
- MetaClassifier: lattice of "where in the codebase" predicates
  with .always / .never / .meet / .join / .atDecl / .inFile /
  .underAttribute / .dependencyOf / .inNamespace.
- MetaArtifact: source / declAt / refTo / empty.
- MetaPosition: (declName, filePath, range?) addressing.
- DecidableEq for MetaCType, MetaClassifier (manual mutual decEq
  for the recursive lattice arms).

CubicalTransport/Algebra/Edit.lean (Phase B — Edit + Context):
- Edit α: result + List EditOp.  Monad / Functor instances.
- Context α: focal artifact + position + siblings.  Functor +
  comonad operations (extract / extend).
- contextualEdit: the comonad-to-monad distributive law.
- MetaClassifier.atPosition: syntactic dispatch on classifier shape;
  meet/join lattice laws stated as theorems.

CubicalTransport/Algebra/Restructure.lean (Phase B — universal macro):
- restructure: the comp-shaped 5-field operation, returns Edit Unit.
- Frozen aliases: transport_artifact, relocate_invariant,
  rename_throughout, define_question_shape, compose_proof_fragments,
  materialize.
- Headless interpreter: SourceBuffer + EditOp.apply + Edit.runHeadless.
- Soundness scaffold: brokenRefs / selfConsistent / Edit.guarded.

CubicalTransport/Algebra/MacroAlias.lean (Phase C):
- @[macroAlias] attribute + AliasEntry registry (EnvExtension).
- Lookup helpers + diagnostic printer.

CubicalTransport/Algebra/Methodology.lean (Phase D'):
- @[methodology Identifier] attribute + MethodologyEntry registry.
- cubical_search tactic: walks the methodology library by classifier
  dispatch, applies via exact/apply.  deriveByTransport stub awaits
  @[metaPath] (REL2.6+).
- Diagnostic printer for the registry.

CubicalTransport/Algebra/Test.lean: compile-time end-to-end tests:
- Construct meta-mirror values; check DecidableEq.
- Build Edit values via restructure; verify selfConsistent on a
  broken-ref batch (correctly flagged).
- Register an alias via @[macroAlias].
- Register two methodologies via @[methodology] and verify
  cubical_search dispatches to them on representative goals.

Runtime smoke tests: 4 new Algebra smokes verifying restructure
emits the right ops, the broken-ref guard fires, and the
classifier lattice computes correctly.  93/93 tests pass.

Documentation:
- docs/QUESTIONS.md §4: Levels 1, 2, 3-light marked LANDED with
  commit refs; full Level 3 graph-walking marked pending.
- docs/ALGEBRA_PLAN.md §6: phase table updated with status column;
  Phases A/B/C/D' marked landed; Phases B.2 (LSP) + D (widget) +
  REL2.6 methodology-transport explicitly marked pending.
- docs/EULERIAN.md §9, §10: "the map" and "autodiscovery" rows
  updated from "planned REL2.5" to "landed 2026-05-01" with
  module-level cross-references.
- docs/KERNEL_BOUNDARY.md §3.7: cubical_simp (light) and
  cubical_search marked landed; full graph-walking cubical_simp
  marked dependent on @[metaPath].

Pending items deliberately out of scope this session:
- LSP widget (D) — needs running Lean LSP server.
- B.2 LSP integration — needs CodeActionContext.
- @[metaPath] declarations + full deriveByTransport — REL2.6+.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 00:59:06 -06:00
.forgejo/workflows Add proprietary LICENSE; move CI to .forgejo/workflows/, run cubical-test 2026-04-27 23:04:16 -06:00
CubicalTransport ALGEBRA Phases A+B+C+D' + cubical_search tactic + doc state-of-play 2026-05-01 00:59:06 -06:00
docs ALGEBRA Phases A+B+C+D' + cubical_search tactic + doc state-of-play 2026-05-01 00:59:06 -06:00
native/cubical REL2 Phase 1: CType.interval primitive 2026-04-30 18:47:13 -06:00
.gitignore Initial commit: topolei — cubical-transport HoTT in Lean 4 + Rust FFI 2026-04-27 20:40:45 -06:00
build.sh Split: engine = cubical-transport HoTT only 2026-04-27 21:35:01 -06:00
CubicalBench.lean Split: engine = cubical-transport HoTT only 2026-04-27 21:35:01 -06:00
CubicalTest.lean Split: engine = cubical-transport HoTT only 2026-04-27 21:35:01 -06:00
CubicalTransport.lean ALGEBRA Phases A+B+C+D' + cubical_search tactic + doc state-of-play 2026-05-01 00:59:06 -06:00
lake-manifest.json Regenerate lake-manifest.json: package name cubicalTransport (was stale 'topolei') 2026-04-27 23:00:01 -06:00
lakefile.toml Split: engine = cubical-transport HoTT only 2026-04-27 21:35:01 -06:00
lean-toolchain Initial commit: topolei — cubical-transport HoTT in Lean 4 + Rust FFI 2026-04-27 20:40:45 -06:00
LICENSE Add proprietary LICENSE; move CI to .forgejo/workflows/, run cubical-test 2026-04-27 23:04:16 -06:00
NOTICE Add NOTICE: AI tooling acknowledgement; proprietary rights stand on human-directed whole 2026-04-27 23:10:32 -06:00
README.md Add proprietary LICENSE; move CI to .forgejo/workflows/, run cubical-test 2026-04-27 23:04:16 -06:00

cubical-transport-hott-lean4

A Lean 4 implementation of cubical-transport homotopy type theory (CCHM-flavor), with a fast Rust kernel exposed through C ABI.

The Lean side defines the syntax, semantics, and soundness theorems. The Rust side discharges the per-step β-rules of the evaluator. Lean axioms are routed through @[implemented_by] to Rust functions that return Lean objects in the same shape Lean would have produced; the soundness layer (CubicalTransport/Soundness.lean) certifies the backend at the boundary, so the kernel speed of the Rust code preserves the Lean-level proofs.

What's here

  • CubicalTransport/ — 22 Lean modules for syntax, substitution, dimensional structure, faces, typing, evaluation (eval / value / readback), transport, Glue, composition, and the soundness theorems.
  • native/cubical/ — Rust kernel (#![no_std], dual-target native staticlib + cdylib, wasm32 cdylib).
  • CubicalTest.lean, CubicalBench.lean — engine smoke + property tests (62/62 passing) and microbenchmarks.

Consuming the engine (with permission)

This Software is proprietary. See LICENSE — no use is granted by virtue of the repository being public. The instructions below are for the copyright holder and any party with prior written consent from mgorog@gmail.com.

Add as a Lake dependency from another Lean 4 project:

[[require]]
name = "cubicalTransport"
path = "../cubical-transport-hott-lean4"   # or git = "..."

Then import CubicalTransport.Syntax, import CubicalTransport.Eval, etc. Link against native/cubical/target/release/libtopolei_cubical.a in your own moreLinkArgs so the FFI symbols resolve.

Build

(cd native/cubical && cargo build --release)
lake build
./.lake/build/bin/cubical-test    # 62/62 tests pass

Reference

  • docs/FFI_DESIGN.md — C ABI contract between Lean and the Rust kernel.
  • docs/FFI_COMPLETENESS.md — per-function axiom audit.
  • docs/KERNEL_BOUNDARY.md — what this delivers in unmodified Lean 4 vs. what would need upstream Lean kernel work.
  • docs/NUMERICAL.md — numerical implementation principles.
  • docs/PHASE1_HISTORY.md — original transport/composition formalisation plan (archived; Phase 1 closed; preserved as methodology template for future phases).
  • docs/ZIGZAG_PORT.md — step-by-step Lean port plan for the n-category combinatorial engine (Phase 2+ higher-cell backend). Lands here in the engine. Read the cascade caveat at the top before editing: changes in the ported zigzag layer cascade to the sibling topolei repo.
  • native/cubical/README.md — Rust crate build + dev guide.
  • native/cubical/WASM.md — wasm32 ABI integration contract.

Used by

  • max/topolei — the cells-spec workspace interface, built on this engine. See its docs/cells-spec.md and docs/STATUS.md for the application-side picture.