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 7934275f68
Some checks are pending
Lean Action CI / build (push) Waiting to run
Layer 0 substrate round 2: Subobject + SIP + Modality + Bridge/Set
Four new modules, all building on the now-stable Layer 0 foundation
(Universe / Truncation / Decidable / Omega / Reify / Category).
THEORY.md §0.4 (Subobject + SIP), §0.5 (Modality), §0.6 (Bridge/Set).

## CubicalTransport/Subobject.lean (308 lines)

Sub T = CType.pi "$x" T (Ω ℓ) — re-anchored at ℓ.succ via
ULevel.max_succ_self_right.  Pointwise lattice operations as REAL
CTerms using existing Ω logical operators:
  · empty / total      — constant Ω.false_ / Ω.true_
  · inter / union      — pointwise Ω.and / Ω.or
  · implies / compl    — pointwise Ω.implies / Ω.not
  · singleton T a      — characteristic function of {a} via
                         CTerm.code (CType.path T x a) + IsNType -1
                         propositionality witness

Theorems with REAL Prop statements:
  · subobject_classifier — bidirectional ∃-quantified statement
                           (∃ S incl, mono into T)  ↔  (∃ χ, χ : Sub T)
                           (sorry, waits on: Σ-over-universe-codes
                            for image construction)
  · Ω_internal_logic_sound — four-clause Heyting algebra Path
                             equalities (∧-idempotence, ∧-commutativity,
                             modus ponens, implication absorption)
                             (sorry, waits on: prop-univalence via
                              Soundness.transp_ua)

## CubicalTransport/SIP.lean (320 lines)

StructureFunctor — Lean structure with toFun : CType ℓ → CType ℓ
and transport : (A B) → EquivData → EquivData (REAL EquivData,
not stub CTerm).

  · StructureFunctor.id_       — identity functor (transport = id)
  · StructureFunctor.comp G F  — substantively chains transports

Five categorical functoriality coherences PROVED (not stubbed):
  · id_.transport_idEquiv     := rfl
  · id_.transport_eq_id       := rfl
  · comp_id_right             := rfl
  · comp_id_left              := rfl
  · comp_assoc                := rfl
  · comp.transport_eq_compose := rfl

Theorems with REAL Prop statements:
  · SIP — given S, T, T', e and typed forward/inverse on e:
            ∃ lifted, HasType [] lifted.f (S.toFun T → S.toFun T')
                   ∧ HasType [] lifted.fInv ...
          (sorry, waits on: Soundness.transp_ua as structure-
           functor coherence)
  · contract_transports — equivalences induce path-equality on
                          contract values in Ω
                          (sorry, waits on: SIP + prop-univalence)

## CubicalTransport/Modality.lean (461 lines)

Modality structure with seven REAL Lean-level fields:
  · apply       : CType ℓ → CType ℓ
  · unit        : (A : CType ℓ) → CTerm
  · isModal     : CType ℓ → CType ℓ
  · modal_apply, modal_path, modal_sigma, unit_equiv_on_modal — CTerm-typed proof fields

LexModality extends Modality with preserves_pullbacks +
preserves_terminal CTerm-typed proofs.

Modality.id_ — identity modality with REAL CTerm bodies:
  unitT ℓ := .ind unitSchema [], unitTT := .ctor unitSchema "tt" [] []
  No free-variable placeholders.

Modality.comp G F — substantively chains:
  apply A = G.apply (F.apply A)
  unit A = .lam "$x" (.app (G.unit (F.apply A)) (.app (F.unit A) (.var "$x")))
  modal_sigma A B = G.modal_sigma (F.apply A) (fun b => F.apply (B b))
  ... etc.

Theorems with REAL Prop statements:
  · Modality_pullback_lex — Iff between Modality + pullback-preserving
                            extension and LexModality
                            (sorry, waits on: Category.lean's pullback
                             construction)
  · adjoint_modal_triple — quintuple-Σ existence of (ʃ, ♭, ♯) with
                           four conjuncts asserting CType + CTerm
                           non-triviality (apply ≠ apply false flags
                           are real distinctness checks, not tautologies)
                           (sorry, waits on: Layer 3 cohesive lift —
                            Topolei/Modal.lean)

Bonus: 5 rfl-lemmas + 4 substantive-dependence theorems
(Modality.id_apply_dep, comp_apply_G_dep, comp_apply_at_id,
comp_unit_F_dep, comp_unit_G_dep) proving fields don't collapse
to constants — analogues of Category.lean's no-collapse theorems.

## CubicalTransport/Bridge/Set.lean (224 lines)

CubicalSetC as a Lean Prop existential:
  def CubicalSetC {ℓ} (T : CType ℓ) : Prop :=
    ∃ (w : CTerm), HasType [] w (IsNType .zero T)

Substantive — the witness w is the cubical proof of 0-truncatedness,
immediately consumable by Hedberg.

Three theorem statements + one bidirectional discharge:
  · CubicalSetC_isProp                  := rfl
  · pathEqEquiv  (Iff statement)        := via path_to_eq + eq_to_path
  · CubicalSetC_of_CDecidableEq         (sorry, waits on Hedberg)
  · path_to_eq                          (sorry, waits on Hedberg
                                          + canonical-form readback)
  · eq_to_path                          (sorry, waits on dim-absent
                                          packaging on toCTerm a)

## Discipline summary

  · Total new sorries this round: 9 (across 4 files)
  · Every sorry annotated -- waits on: <specific dep>
  · Zero noncomputable / Classical.propDecidable
  · Zero CType.univ stubs / IsModal-style identity definitions
  · Zero "True := trivial" theorem placeholders
  · Zero "M.apply = M.apply" tautological proofs
  · Zero free-variable CTerm placeholders for non-binder names
  · No existing file modified — all four files are new

## Verification

  lake build (engine)        Build completed successfully (48 jobs)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-05 09:26:57 -06:00
.forgejo/workflows Add proprietary LICENSE; move CI to .forgejo/workflows/, run cubical-test 2026-04-27 23:04:16 -06:00
CubicalTransport Layer 0 substrate round 2: Subobject + SIP + Modality + Bridge/Set 2026-05-05 09:26:57 -06:00
docs REL2 universe stratification + topolei naming cleanup + Rust ABI v4 2026-05-04 00:21:14 -06:00
native/cubical Layer 0 substrate (Truncation, Decidable, Omega, Category, Reify) 2026-05-05 09:11:29 -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 REL2 universe stratification + topolei naming cleanup + Rust ABI v4 2026-05-04 00:21:14 -06:00
CubicalTest.lean Split: engine = cubical-transport HoTT only 2026-04-27 21:35:01 -06:00
CubicalTransport.lean REL2 universe stratification + topolei naming cleanup + Rust ABI v4 2026-05-04 00:21:14 -06:00
lake-manifest.json Drop Infoductor dependency; cubical-transport is now pure cubical engine 2026-05-01 07:52:59 -06:00
lakefile.toml REL2 universe stratification + topolei naming cleanup + Rust ABI v4 2026-05-04 00:21:14 -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 REL2 universe stratification + topolei naming cleanup + Rust ABI v4 2026-05-04 00:21:14 -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/libcubical_transport.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.