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>
156 lines
6.8 KiB
Text
156 lines
6.8 KiB
Text
/-
|
||
CubicalTransport.Value
|
||
======================
|
||
Weak-head normal forms for the universe-stratified cubical calculus
|
||
(cells-spec §5.4, Layer 0 §0.1 cascade).
|
||
|
||
Named-variable adaptation: our `CTerm` uses `String` binders rather than
|
||
de Bruijn indices, so `Env` is a name-keyed association list instead of
|
||
an `Array`. The three inductives (`CEnv`, `CVal`, `CNeu`) are mutually
|
||
recursive: `CVal` contains closures (which capture their `CEnv`), `CNeu`
|
||
(stuck terms) carries already-evaluated sub-values, and `CEnv` stores
|
||
`CVal`s.
|
||
|
||
## Universe-aware shape
|
||
|
||
CVal and CNeu constructors that carry a `CType` payload carry it at an
|
||
implicit `{ℓ : ULevel}` parameter — mirroring the corresponding CTerm
|
||
constructors in `Syntax.lean`. At the value level the level is
|
||
existentially packaged (forgotten by the constructor); the kernel-side
|
||
level discipline lives on CType, not on CVal.
|
||
|
||
Where a constructor stores TWO CTypes that must live at related levels
|
||
(e.g. domain at ℓ and codomain at ℓ'), both levels are bound implicitly.
|
||
|
||
Coverage matches the cells-spec's "λ-calculus fragment" milestone:
|
||
· function abstractions and applications (`vlam`/`napp`)
|
||
· dimension abstractions and applications (`vplam`/`npapp`)
|
||
· transport and composition as *stuck* values (`ntransp`/`ncomp`) —
|
||
reduction rules in `Transport.lean`/`Comp.lean`.
|
||
-/
|
||
|
||
import CubicalTransport.Syntax
|
||
|
||
mutual
|
||
/-- Name-keyed environment: a cons-list of `(name, value)` bindings. The
|
||
most-recently-extended binding shadows earlier ones of the same name. -/
|
||
inductive CEnv : Type where
|
||
| nil : CEnv
|
||
| cons : String → CVal → CEnv → CEnv
|
||
deriving Inhabited
|
||
|
||
/-- Weak-head normal-form values. -/
|
||
inductive CVal : Type where
|
||
/-- Function closure `(λ x. body)` with captured environment. -/
|
||
| vlam : CEnv → String → CTerm → CVal
|
||
/-- Dimension-abstraction closure `(⟨i⟩ body)` with captured environment. -/
|
||
| vplam : CEnv → DimVar → CTerm → CVal
|
||
/-- Embedded neutral term — a stuck computation. -/
|
||
| vneu : CNeu → CVal
|
||
/-- A *transported function value*: result of `transp^i (pi domA codA) φ f`.
|
||
|
||
Domain at level `ℓ`, codomain at level `ℓ'`; the result type
|
||
lives at `ULevel.max ℓ ℓ'` (CCHM Π rule). Levels are
|
||
existentially packaged at the value level. -/
|
||
| vTranspFun {ℓ ℓ' : ULevel} :
|
||
DimVar → CType ℓ → CType ℓ' → FaceFormula → CVal → CVal
|
||
/-- A *composed function value*: result of `hcomp (pi domA codA) φ tube base`.
|
||
Stores only `codA` (homogeneous comp on the domain is trivial
|
||
since A is fixed). -/
|
||
| vHCompFun {ℓ : ULevel} :
|
||
CType ℓ → FaceFormula → CVal → CVal → CVal
|
||
/-- A *point-wise applied tube*: represents `λj. (tube @ j) arg`. -/
|
||
| vTubeApp : CVal → CVal → CVal
|
||
/-- A *heterogeneous-composition function value*: result of
|
||
`comp^i (Π domA codA) φ u u₀` at the value level. -/
|
||
| vCompFun {ℓ ℓ' : ULevel} :
|
||
CEnv → DimVar → CType ℓ → CType ℓ' → FaceFormula →
|
||
CTerm → CTerm → CVal
|
||
/-- A *path-transport value*: result of `transp^i (Path A(i) a(i) b(i)) φ p`. -/
|
||
| vPathTransp {ℓ : ULevel} :
|
||
CEnv → DimVar → CType ℓ → CTerm → CTerm → FaceFormula →
|
||
CTerm → CVal
|
||
/-- A Σ pair value. -/
|
||
| vpair : CVal → CVal → CVal
|
||
/-- Schema constructor application — fully-evaluated, canonical
|
||
constructor of an inductive (or higher-inductive) type (REL1).
|
||
`params` is level-heterogeneous: each entry carries its own ULevel. -/
|
||
| vctor : CTypeSchema → String →
|
||
List (Σ ℓ : ULevel, CType ℓ) → List CVal → CVal
|
||
/-- Lifted dimension-expression value (REL1). -/
|
||
| vdimExpr : DimExpr → CVal
|
||
/-- Value form of `CTerm.code A`. Carries the encoded CType. -/
|
||
| vcode {ℓ : ULevel} : CType ℓ → CVal
|
||
|
||
/-- Neutral (stuck) terms. -/
|
||
inductive CNeu : Type where
|
||
/-- A free variable (name not bound in the current environment). -/
|
||
| nvar : String → CNeu
|
||
/-- Stuck function application. -/
|
||
| napp : CNeu → CVal → CNeu
|
||
/-- Stuck dimension application. -/
|
||
| npapp : CNeu → DimExpr → CNeu
|
||
/-- Transport with an already-evaluated argument. CType at any level. -/
|
||
| ntransp {ℓ : ULevel} :
|
||
DimVar → CType ℓ → FaceFormula → CVal → CNeu
|
||
/-- Heterogeneous composition (varying line) with already-evaluated
|
||
system body and base. -/
|
||
| ncomp {ℓ : ULevel} :
|
||
DimVar → CType ℓ → FaceFormula → CVal → CVal → CNeu
|
||
/-- Homogeneous composition (fixed type) with already-evaluated tube
|
||
and base. -/
|
||
| nhcomp {ℓ : ULevel} :
|
||
CType ℓ → FaceFormula → CVal → CVal → CNeu
|
||
/-- A stuck multi-clause heterogeneous composition. -/
|
||
| ncompN {ℓ : ULevel} :
|
||
CEnv → DimVar → CType ℓ →
|
||
List (FaceFormula × CVal) → CVal → CNeu
|
||
/-- A stuck glue introduction. -/
|
||
| nglueIn : FaceFormula → CVal → CVal → CNeu
|
||
/-- A stuck unglue. -/
|
||
| nunglue : FaceFormula → CVal → CVal → CNeu
|
||
/-- A stuck first projection. -/
|
||
| nfst : CNeu → CNeu
|
||
/-- A stuck second projection. -/
|
||
| nsnd : CNeu → CNeu
|
||
/-- A stuck inductive eliminator (REL1). `params` is level-heterogeneous. -/
|
||
| nIndElim : CTypeSchema → List (Σ ℓ : ULevel, CType ℓ) → CVal →
|
||
List (String × CVal) → CNeu → CNeu
|
||
end
|
||
|
||
-- Inhabited instances — needed so `partial def` evaluators can be elaborated
|
||
-- (Lean's partial-fixpoint compilation requires a default value for divergence).
|
||
|
||
instance : Inhabited CNeu := ⟨.nvar "⊥"⟩
|
||
instance : Inhabited CVal := ⟨.vneu default⟩
|
||
|
||
namespace CEnv
|
||
|
||
/-- Look up a variable name; returns `none` if the name is free. -/
|
||
def lookup : CEnv → String → Option CVal
|
||
| .nil, _ => none
|
||
| .cons n v rest, x => if x = n then some v else rest.lookup x
|
||
|
||
/-- Extend an environment with a new `(name, value)` binding. -/
|
||
def extend (env : CEnv) (x : String) (v : CVal) : CEnv :=
|
||
.cons x v env
|
||
|
||
@[simp] theorem lookup_nil (x : String) : CEnv.lookup .nil x = none := rfl
|
||
|
||
@[simp] theorem lookup_cons_hit (x : String) (v : CVal) (rest : CEnv) :
|
||
(CEnv.cons x v rest).lookup x = some v := by
|
||
simp [lookup]
|
||
|
||
theorem lookup_cons_miss (x y : String) (v : CVal) (rest : CEnv) (h : y ≠ x) :
|
||
(CEnv.cons x v rest).lookup y = rest.lookup y := by
|
||
simp [lookup, if_neg h]
|
||
|
||
@[simp] theorem extend_lookup_hit (env : CEnv) (x : String) (v : CVal) :
|
||
(env.extend x v).lookup x = some v := by
|
||
simp [extend]
|
||
|
||
theorem extend_lookup_miss (env : CEnv) (x y : String) (v : CVal) (h : y ≠ x) :
|
||
(env.extend x v).lookup y = env.lookup y := by
|
||
simp [extend, lookup, if_neg h]
|
||
|
||
end CEnv
|