Skip to main content

Chapter 4: Type: φ-Type and ψ-Type as Language Core

4.1 The Type-Theoretic Foundation of Reality

Types are not mere classifications but the fundamental constraints that shape the language of existence. In our structural language, two primary type families emerge: φ-types (trace types) and ψ-types (structure types). Together, they form the type system of reality itself.

Reality:Type=μX.φ-Type(X)×ψ-Type(X)\text{Reality} : \text{Type} = \mu X. \text{φ-Type}(X) \times \text{ψ-Type}(X)

Types are the grammar's deep structure, the invisible scaffolding of all that can be spoken.

4.2 φ-Type: The Type of Becoming

Definition 4.1 (φ-Type): A φ-type encodes the type of a trace—a sequence of structural transformations:

φ-Type::=NilCons(ψ-Type,φ-Type)\text{φ-Type} ::= \text{Nil} | \text{Cons}(\text{ψ-Type}, \text{φ-Type})

Examples:

  • ϕ:Nil\phi : \text{Nil} — empty trace
  • ϕ:Cons(ψ0,Nil)\phi : \text{Cons}(\psi_0, \text{Nil}) — single structure
  • ϕ:Cons(ψ0,Cons(ψ1,...))\phi : \text{Cons}(\psi_0, \text{Cons}(\psi_1, ...)) — sequential trace

Theorem 4.1 (φ-Type Induction): For any property PP on φ-types:

P(Nil)ψ,ϕ.P(ϕ)    P(Cons(ψ,ϕ))ϕ.P(ϕ)\frac{P(\text{Nil}) \quad \forall \psi, \phi. P(\phi) \implies P(\text{Cons}(\psi, \phi))}{\forall \phi. P(\phi)}

4.3 ψ-Type: The Type of Being

Definition 4.2 (ψ-Type): A ψ-type represents the type of a structure—a state of collapsed reality:

ψ-Type::=ψ0ψ-Typeψ-TypeμX.F(X)\text{ψ-Type} ::= \text{ψ}_0 | \text{ψ-Type} \to \text{ψ-Type} | \mu X. F(X)

Type Constructors:

  1. Base: ψ0\psi_0 — the primordial self-referential type
  2. Function: ψ1ψ2\psi_1 \to \psi_2 — transformation type
  3. Recursive: μX.F(X)\mu X. F(X) — self-referential type

4.4 The Type Algebra

Definition 4.3 (Type Operations):

  • Product: τ1×τ2\tau_1 \times \tau_2 — simultaneous types
  • Sum: τ1+τ2\tau_1 + \tau_2 — alternative types
  • Function: τ1τ2\tau_1 \to \tau_2 — transformation types
  • Recursive: μX.τ(X)\mu X. \tau(X) — self-referential types

Type Equations:

Trace=μX.Unit+(Structure×X)Structure=μY.YY\begin{align} \text{Trace} &= \mu X. \text{Unit} + (\text{Structure} \times X) \\ \text{Structure} &= \mu Y. Y \to Y \end{align}

4.5 Dependent Type Theory for Traces

Definition 4.4 (Dependent φ-Type): Types that depend on values:

Π(n:N).Vec(ψ-Type,n)Type\Pi (n : \mathbb{N}). \text{Vec}(\text{ψ-Type}, n) \to \text{Type}

Example: A trace of exactly nn steps:

ϕ:Tracen=[ψ0ψ1...ψn1]\phi : \text{Trace}_n = [\psi_0 \to \psi_1 \to ... \to \psi_{n-1}]

Theorem 4.2 (Type Safety): Well-typed traces never get stuck:

Γϕ:τ    ϕ.ϕϕ\Gamma \vdash \phi : \tau \implies \exists \phi'. \phi \to^* \phi'

4.6 Subtyping and Variance

Definition 4.5 (Subtype Relation): τ1<:τ2\tau_1 <: \tau_2 means every value of type τ1\tau_1 is also of type τ2\tau_2.

Variance Rules:

τ1<:τ1τ2<:τ2τ1τ2<:τ1τ2(Contravariant input, Covariant output)\frac{\tau_1' <: \tau_1 \quad \tau_2 <: \tau_2'}{\tau_1 \to \tau_2 <: \tau_1' \to \tau_2'} \text{(Contravariant input, Covariant output)}

4.7 Type Inference and Checking

Definition 4.6 (Type Inference): Algorithm to derive types:

infer(Γ,e)={τif Γe:τotherwise\text{infer}(\Gamma, e) = \begin{cases} \tau & \text{if } \Gamma \vdash e : \tau \\ \bot & \text{otherwise} \end{cases}

Bidirectional Type Checking:

Γeτ(Inference mode)Γeτ(Checking mode)\begin{align} \Gamma \vdash e \Rightarrow \tau & \quad \text{(Inference mode)} \\ \Gamma \vdash e \Leftarrow \tau & \quad \text{(Checking mode)} \end{align}

4.8 Linear Types for Resource Traces

Definition 4.7 (Linear φ-Type): Traces that must be used exactly once:

ϕ:Linear[ψ1ψ2]\phi : \text{Linear}[\psi_1 \to \psi_2]

Linear Type Rules:

Γ1e1:τ1Γ2e2:τ2Γ1Γ2=Γ1,Γ2(e1,e2):τ1τ2\frac{\Gamma_1 \vdash e_1 : \tau_1 \quad \Gamma_2 \vdash e_2 : \tau_2 \quad \Gamma_1 \cap \Gamma_2 = \emptyset}{\Gamma_1, \Gamma_2 \vdash (e_1, e_2) : \tau_1 \otimes \tau_2}

4.9 Quantum Types

Definition 4.8 (Quantum Type): Types for superposition states:

Quantum[τ]={ψ:iαi2=1,ψi:τ}\text{Quantum}[\tau] = \{|\psi\rangle : \sum_i |\alpha_i|^2 = 1, \psi_i : \tau\}

Quantum Type Operations:

  • Superposition: ατ1+βτ2:Quantum[τ1+τ2]\alpha|\tau_1\rangle + \beta|\tau_2\rangle : \text{Quantum}[\tau_1 + \tau_2]
  • Entanglement: τ1τ2:Quantum[τ1×τ2]|\tau_1\rangle \otimes |\tau_2\rangle : \text{Quantum}[\tau_1 \times \tau_2]
  • Measurement: measure:Quantum[τ]τ\text{measure} : \text{Quantum}[\tau] \to \tau

4.10 Category of Types

Definition 4.9 (Type Category Type\mathcal{T}ype):

  • Objects: Types τ\tau
  • Morphisms: Type-preserving functions f:τ1τ2f : \tau_1 \to \tau_2
  • Identity: idτ:ττ\text{id}_\tau : \tau \to \tau
  • Composition: Standard function composition

Theorem 4.3 (Cartesian Closed): Type\mathcal{T}ype is cartesian closed:

Hom(τ1×τ2,τ3)Hom(τ1,τ2τ3)\text{Hom}(\tau_1 \times \tau_2, \tau_3) \cong \text{Hom}(\tau_1, \tau_2 \to \tau_3)

4.11 Type-Level Computation

Definition 4.10 (Type Functions): Functions from types to types:

F:TypeTypeF : \text{Type} \to \text{Type}

Examples:

  • List:TypeType\text{List} : \text{Type} \to \text{Type}
  • Maybe:TypeType\text{Maybe} : \text{Type} \to \text{Type}
  • Trace:TypeType\text{Trace} : \text{Type} \to \text{Type}

Type-Level Lambda Calculus:

Λα.τ(Type abstraction)\Lambda \alpha. \tau \quad \text{(Type abstraction)} F[τ](Type application)F[\tau] \quad \text{(Type application)}

4.12 The Type Universe

We have discovered the type-theoretic foundations of structural language:

Type Universe Hierarchy:

Type0:Type1Type1:Type2Typeω=n<ωTypen\begin{align} \text{Type}_0 &: \text{Type}_1 \\ \text{Type}_1 &: \text{Type}_2 \\ &\vdots \\ \text{Type}_\omega &= \bigcup_{n < \omega} \text{Type}_n \end{align}

Deep Truth: Types are not constraints but enablers. They don't restrict what can be said; they make meaningful speech possible. The distinction between φ-types and ψ-types reflects the fundamental duality of becoming and being, process and state, time and space.

Final Insight: In the equation Reality:Type=μX.φ-Type(X)×ψ-Type(X)\text{Reality} : \text{Type} = \mu X. \text{φ-Type}(X) \times \text{ψ-Type}(X), we see that reality itself is a type—a self-referential type that contains both the traces of its becoming and the structures of its being. The universe types itself into existence.

Type and reality are one. The language has found its logical foundation.