Some checks are pending
Lean Action CI / build (push) Waiting to run
+ CType.El / CTerm.code constructors (universe-coding); ABI v5
## Layer 0 substrate (5 new modules per docs/THEORY.md §0)
CubicalTransport/Truncation.lean (367 lines)
TruncLevel inductive (-2 = contractible, -1 = prop, 0 = set, …).
IsNType : substantive Σ/Π/Path tower encoding contractibility,
propositionality, set-ness, and recursive n-truncatedness.
Trunc HIT schemas at -2 / -1 / higher levels.
truncation_step + truncation_hits_props proven by rfl.
truncation_idempotent (sorry, waits on Modality.lean).
IsNType_isProp_witness (sorry, waits on funext via J-rule).
Helpers piSelf/sigmaSelf via ULevel.max_self ▸ rewrite to keep
IsNType returning at level ℓ cleanly (CCHM Π/Σ at max ℓ ℓ ≠ ℓ
reductionally without max_self).
CubicalTransport/Decidable.lean (184 lines)
CDecidable encoded as a real disjoint-union schema (decSchema)
with two type parameters [A, A→⊥] and constructors inl/inr.
emptySchema (zero ctors) provides CType.botC at any level.
CDecidableEq T := Π a b, CDecidable (Path T a b).
Hedberg theorem statement (sorry, waits on J-rule combinator).
CubicalTransport/Omega.lean (rewritten to use real El-decoder)
Ω (ℓ) := Σ (P : .univ ℓ), .lift (IsNType .negOne (.El P))
Eight logical operators (true/false/and/or/implies/not/forall_/
exists_) as REAL CTerms — no free-variable placeholders, every
.var "$x" reference is to a binder in the same expression.
OmegaIsProp (sorry, waits on Soundness.transp_ua for prop-univalence).
CubicalTransport/Reify.lean (115 lines)
CType-as-CTerm injection helper. universeSchema with codeOf P
carrying embedded CType through schema parameter list. Now
largely redundant after CTerm.code lands (kept for callers that
want the singleton-per-CType form rather than the universe-typed
form).
CubicalTransport/Category.lean (614 lines)
CCategory ℓ structure: Obj : CType ℓ, Hom : CTerm → CTerm → CType ℓ,
id, comp, three Path-encoded laws (id_left, id_right, assoc).
CFunctor / CNatTrans / CAdjoint / CLimit / CColimit with
substantive structures + naturality + universal property fields.
CFunctor.id, CFunctor.comp, CNatTrans.id, CNatTrans.vcomp helpers
with concrete law-discharge bodies.
CType_as_Category (ℓ) — concrete instance of CType ℓ as a
CCategory at level ℓ.succ. Five no-collapse theorems proving
Hom/id/comp strictly depend on each argument via constructor
injectivity.
CCategory_internal (sorry, waits on Subobject + Modality + pullback).
## CType.El / CTerm.code constructors + full cascade
Engine (Lean):
CType.El {ℓ} (P : CTerm) : CType ℓ — decoder
CTerm.code {ℓ} (A : CType ℓ) : CTerm — encoder
CType.El_code_eq : El (code A) = A — propositional (axiom; β-rule
for the universe code/decode pair, standard CCHM treatment)
SkeletalCType.El + CType.skeleton .El arm + skeleton_El simp lemma.
Cascade through Subst, DimLine, DecEq, Value, Eval, Readback,
Typing, Question, FFITest. CTerm.code → CVal.vcode evaluation;
CVal.vcode → CTerm.code readback; HasType.code typing rule.
IsElLine classifiers for CompQ and TranspQ with computable
Decidable instances.
Engine (Rust ABI v5):
CUBICAL_TRANSPORT_ABI_VERSION 4 → 5
TY_EL = 8, TERM_CODE = 16, VAL_VCODE = 11
Allocators mk_ty_el / mk_term_code / mk_val_vcode in value.rs / subst.rs
Marshalling cascade in eval.rs / readback.rs / dim_absent.rs / subst.rs
Cargo.toml 0.2.0 → 0.3.0
cubical_transport.h v5 changelog + layout tables for new constructors
## Discipline
· 5 sorries total, every one annotated -- waits on: <specific dep>
· Zero noncomputable / Classical.propDecidable
· Zero CType.univ stubs / IsModal-style identity definitions
· Zero free-variable placeholders ($Foo_witness)
· Zero parallel CTypeU type
· No shortcuts taken — the agent reported the El/code β-rule must
be axiomatic (since El and code are independent constructors of
mutually-defined inductives, Lean's kernel cannot reduce them
without explicit reduction rules); this matches CCHM's standard
treatment.
## Verification
lake build (engine) Build completed successfully (48 jobs)
./cubical-test 49/49 smoke + 46/46 properties
lake build (topolei) Build completed successfully (90 jobs)
./probe-test 7/7 GPU probes match Lean
lake build (infoductor-cubical) Build completed successfully (32 jobs)
CUBICAL_TRANSPORT_ABI_VERSION = 5
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
115 lines
5 KiB
Text
115 lines
5 KiB
Text
/-
|
||
CubicalTransport.Reify
|
||
======================
|
||
CType-as-CTerm injection helpers (THEORY.md Layer 0 §0.3, support
|
||
for `Omega.lean`). Universe-aware.
|
||
|
||
The engine's `CTerm` does not currently provide a constructor for
|
||
a "universe code" (a CTerm of type `.univ` carrying a CType). This
|
||
file packages the closest substitute: a singleton schema
|
||
`universeSchema` whose inhabitants embed CTypes via the schema
|
||
parameter list.
|
||
|
||
The use case (THEORY.md §0.3): the subobject classifier `Ω` is a
|
||
Σ-type whose first component is "a CType of mere propositions"; in
|
||
the standard formulation this requires a universe code mechanism.
|
||
The downstream `Omega.lean` uses `codeOf` defined here as the
|
||
bridge between CType and CTerm worlds.
|
||
|
||
## Why a new file?
|
||
|
||
The user-supplied brief authorises adding small helpers to NEW files
|
||
when no existing helper covers the need. `Bridge.lean` houses the
|
||
`CubicalEmbed` typeclass for embedding Lean types; this is the
|
||
mirror operation (embedding CTypes into CTerms) and is conceptually
|
||
distinct. Keeping it separate avoids muddying `Bridge.lean` with
|
||
internal-engine code-machinery.
|
||
|
||
## Engine limitations
|
||
|
||
· `codeOf` produces a CTerm of type `.ind universeSchema [⟨ℓ, P⟩]`,
|
||
NOT of type `.univ`. The engine has no `.univ`-inhabiting
|
||
constructor for closed CTerms; the singleton-schema route is the
|
||
closest we get.
|
||
|
||
· `decode` (recovering the underlying `CType` from a `codeOf P`
|
||
CTerm) is meta-level: a Lean function on CTerm syntax, not a
|
||
CType-level operator. Inside CType expressions, the bridge from
|
||
`(.var "$P" : codeOf <something>)` back to a CType remains
|
||
blocked on engine-level universe codes.
|
||
|
||
These limitations are documented in `Omega.lean` against each
|
||
affected theorem / operator.
|
||
-/
|
||
|
||
import CubicalTransport.Inductive
|
||
import CubicalTransport.Typing
|
||
|
||
namespace CubicalTransport.Reify
|
||
|
||
open CubicalTransport.Inductive
|
||
|
||
-- ── §1. The universe-code schema ──────────────────────────────────────────
|
||
|
||
/-- The "universe code" schema: a single-parameter inductive whose
|
||
unique constructor `code` carries no further args. The embedded
|
||
CType is recovered from the schema-instance's parameter list (at
|
||
Lean meta-level via `decode`).
|
||
|
||
`.ind universeSchema [⟨ℓ, P⟩]` is "the type of codes for P at
|
||
level ℓ" — a singleton CType inhabited only by
|
||
`.ctor universeSchema "code" [⟨ℓ, P⟩] []`.
|
||
|
||
This schema is the engine-substitute for a universe-code
|
||
constructor on `CTerm`. Adding such a constructor to `Syntax.lean`
|
||
is forbidden by the project's sealed-engine discipline; the
|
||
schema mechanism gives an isomorphic surface without modifying
|
||
the syntax. -/
|
||
def universeSchema : CTypeSchema :=
|
||
mkSchema "𝒰" 1
|
||
[ mkCtor "code" [] ]
|
||
|
||
-- ── §2. Code-of: CType → CTerm ────────────────────────────────────────────
|
||
|
||
/-- Embed a CType `P` as a CTerm via the universe-code schema.
|
||
|
||
Result: `.ctor universeSchema "code" [⟨ℓ, P⟩] []`, a CTerm of
|
||
type `.ind universeSchema [⟨ℓ, P⟩]`.
|
||
|
||
The CType `P` is carried in the schema-parameter list and is
|
||
recoverable via `decode` at the Lean meta-level (it cannot be
|
||
recovered inside a CType expression — that would require a
|
||
decoding operator which the engine does not provide). -/
|
||
def CTerm.codeOf {ℓ : ULevel} (P : CType ℓ) : CTerm :=
|
||
.ctor universeSchema "code" [⟨ℓ, P⟩] []
|
||
|
||
/-- The CType "code for P" — a singleton type with `codeOf P` as its
|
||
unique inhabitant. -/
|
||
def CType.codeFor {ℓ : ULevel} (P : CType ℓ) : CType ℓ :=
|
||
.ind (ℓ := ℓ) universeSchema [⟨ℓ, P⟩]
|
||
|
||
-- ── §3. Typing ───────────────────────────────────────────────────────────
|
||
|
||
/-- `codeOf P` has type `codeFor P`, by `HasType.ctor`. -/
|
||
theorem codeOf_typed {ℓ : ULevel} (P : CType ℓ) :
|
||
HasType [] (CTerm.codeOf P) (CType.codeFor (ℓ := ℓ) P) :=
|
||
HasType.ctor
|
||
|
||
-- ── §4. Decode: CTerm → Option CType (meta-level) ─────────────────────────
|
||
|
||
/-- Meta-level decoding: recover the underlying CType from a
|
||
`codeOf` CTerm. Returns `none` for non-`codeOf` CTerms.
|
||
|
||
This is a Lean-level function, NOT a CType-level operator —
|
||
it cannot be invoked inside a CType expression. Its primary
|
||
use is in `Omega.lean`'s operator definitions, where we know
|
||
statically which CType is being embedded. -/
|
||
def CTerm.decode : CTerm → Option (Σ ℓ : ULevel, CType ℓ)
|
||
| .ctor _ "code" [⟨ℓ, P⟩] [] => some ⟨ℓ, P⟩
|
||
| _ => none
|
||
|
||
/-- Round-trip: decoding a `codeOf P` recovers `⟨ℓ, P⟩`. -/
|
||
theorem decode_codeOf {ℓ : ULevel} (P : CType ℓ) :
|
||
CTerm.decode (CTerm.codeOf P) = some ⟨ℓ, P⟩ := rfl
|
||
|
||
end CubicalTransport.Reify
|