|
Some checks are pending
Lean Action CI / build (push) Waiting to run
Typing.lean: minimal-viable typing rules for the three new CTerm
constructors (REL1 first cut; REL2 will refine to dependent
formulations).
- HasType.ctor : .ctor S c params args : .ind S params
(no per-arg premises; runtime enforces)
- HasType.indElim : non-dependent form — motive : .pi (.ind …) C,
result : C; branch coherence checked at eval
- HasType.dimExpr : placeholder typing at .univ (real interval-
typing requires a CType.interval primitive,
deferred to REL2)
HasType.weaken_core extended with the three new arms.
TransportLaws.lean: derived theorems for transport over .ind (T1,
T2, stuck), all reducing to existing axioms (eval_transp_top,
eval_transp_const, eval_transp_nonpath + vTransp_stuck). Pointwise
distribution through ctor args is REL1.1 future work.
CompLaws.lean: derived theorems for composition over .ind (C1, C2,
const-line, stuck) — corollaries of the existing eval_comp_*
axioms. Same REL1.1 deferral for pointwise distribution.
native/cubical/src/subst.rs: critical Rust fix. The previous
fallback `_ => mk_term_var(ctor_field(t, 0))` corrupted the new
TERM_DIMEXPR / TERM_CTOR / TERM_INDELIM tags by extracting field 0
(a CTypeSchema for ctor) and wrapping it as a malformed .var,
causing infinite recursion / OOM in subst-driven paths
(eval_comp_top calls substDim). Proper arms for all three new
tags + cterm_subst_dim_list and cterm_subst_dim_branches helpers.
Unknown-tag fallback now safely returns the input unchanged
instead of synthesising a malformed .var.
FFITest.lean: three new smoke arms exercising T1/T2 transport and
C1 composition over .ind natC. Result: 28/28 smoke + 46/46
properties = 74/74.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
||
|---|---|---|
| .. | ||
| include | ||
| src | ||
| test | ||
| build.rs | ||
| Cargo.lock | ||
| Cargo.toml | ||
| README.md | ||
| shim.c | ||
| WASM.md | ||
topolei-cubical — Rust backend
Rust implementation of the cubical-transport HoTT evaluator for topolei — Lean 4's cubical-HoTT kernel extension.
See FFI_DESIGN.md and FFI_COMPLETENESS.md at the project root for
the full C ABI contract and per-function axiom audit.
Build
# Native staticlib + cdylib (linux / macos / windows):
cargo build --release
# wasm32-unknown-unknown (for Lean-wasm composite artifacts):
cargo build --release --target wasm32-unknown-unknown
Artifacts:
| Target | Path |
|---|---|
| Native staticlib | target/release/libtopolei_cubical.a |
| Native cdylib | target/release/libtopolei_cubical.so (linux), .dylib (macos), .dll (windows) |
| Wasm cdylib | target/wasm32-unknown-unknown/release/topolei_cubical.wasm |
| Wasm staticlib | target/wasm32-unknown-unknown/release/libtopolei_cubical.a |
Discipline
no_stdthroughout — wasm32-unknown-unknown has no std, and native uses the same source for ABI uniformity.- Pure-functional evaluator — no IO, no threads, no allocator. All
objects live in Lean's heap; Rust operates via
lean_object*pointers. - Hand-rolled
lean_runtime.rs— ~12extern "C"declarations for the Lean runtime primitives we need. Nolean-sysdependency (that crate isn't wasm-ready).
Phase tracker
- Phase A ✅: crate skeleton + stubs.
- Phase B ✅: full evaluator implementation (14 FFI entries).
- Phase C ✅:
@[implemented_by]wiring + native staticlib linkage- smoke tests (9/9 passing via
lake build cubical-test).
- smoke tests (9/9 passing via
- Phase D.wasm ✅: wasm32 target + JS test harness (10/10 passing
via
node test/wasm_harness.mjs). SeeWASM.mdfor integration with a Lean-wasm composite artifact. - Phase D.properties ✅: 46 property-based tests in
CubicalTransport/PropertyTest.leancovering λ β-rules, Σ β-rules, eval determinism, DimExpr idempotence + literals, FaceFormula absorption, readback roundtrip. 55/55 total (9 smoke + 46 property). - Phase D.bench ✅: baseline perf benchmarks via
cubical-benchexe: λ β & Σ projections 11 ns/iter, normalizers ~50 ns/op, readback 11 ns/iter (100k iters, accumulator prevents DCE).
Testing
Two test surfaces, both currently passing:
Native smoke tests (Lean-side)
lake build cubical-test
./.lake/build/bin/cubical-test
Expected output: ── 9 / 9 passed ──, covering λ-fragment eval,
Σ β-rules, readback, and normalizer reductions. Source:
CubicalTransport/FFITest.lean + CubicalTest.lean.
Wasm smoke tests (Node.js harness)
cargo build --release --target wasm32-unknown-unknown
node test/wasm_harness.mjs
Expected output: ── 10 / 10 tests passed ──. The harness
implements a minimal JS version of Lean's runtime (bump allocator +
object header helpers) to exercise both scalar and heap-allocating
reductions. See WASM.md for the full ABI contract and integration
with a Lean-wasm composite artifact.
Layout
native/cubical/
├── Cargo.toml
├── README.md — this file
├── include/
│ └── topolei_cubical.h — C declarations (ABI v1)
└── src/
├── lib.rs — crate root; panic handler
├── lean_runtime.rs — hand-rolled Lean C ABI
└── ffi.rs — #[no_mangle] exports (stubs in Phase A)
Future expansion (Phases B–C):
└── src/
├── cubical/
│ ├── mod.rs
│ ├── eval.rs
│ ├── transport.rs
│ ├── comp.rs
│ ├── glue.rs
│ └── readback.rs
├── subst/
│ ├── mod.rs
│ ├── dim_expr.rs
│ └── face.rs
└── ...