The agent has two intertwined symbolic computation subsystems:
- HyperLisp Sandbox — S-expression evaluator with topos bridge
- Lambda Calculus Engine — Pure untyped λ-calculus on the Poincaré disk
Package: lisp/
LVal (sealed)
├── LNum(value: Double) — numeric scalar
├── LSym(name: String) — symbol
├── LStr(value: String) — string
├── LBool(value: Boolean) — boolean
├── LCons(car: LVal, cdr: LVal) — cons cell (list building block)
├── LLambda(params, body, env) — closure
├── LVec(data: FloatArray) — vector (manifold-typed)
└── LBuiltin(name, fn) — built-in function
Tokenizer + recursive-descent S-expression parser:
- Max nesting depth: 64
- Supports: numbers, strings, symbols, quoted expressions, dotted pairs
Eval/apply core with:
- Special forms:
define,lambda,let,begin,if,cond,quote,set! - Manifold builtins:
make-vec,vec-get,vec-set!,vec-len,vec-dot,vec-norm - Topos bridge:
f*(pullback) andf_*(pushforward) — adjunctionf* ⊣ f_*
Safe evaluation wrapper:
- κ tracking: Each eval costs energy
- Session history: Persistent across DMN ticks
- Effect drain:
ToposEffectside-effects collected and applied
6 sorts, 6 geometric sequents. ToposEffect sealed hierarchy:
sealed class ToposEffect {
data class WriteManifold(val key: String, val vec: FloatArray)
data class ReadManifold(val key: String)
data class EmitSignal(val channel: String, val payload: String)
data class GoalProposal(val description: String)
data class AffectDelta(val dValence: Float, val dArousal: Float)
data class SelfAnnotation(val key: String, val value: String)
}LambdaTerm (sealed)
├── Var(name: String) — variable
├── Abs(param: String, body: LambdaTerm) — abstraction
├── App(func: LambdaTerm, arg: LambdaTerm) — application
├── GodelNum(n: Long) — Gödel number literal
├── ChurchNum(n: Int) — Church numeral
└── Quote(term: LambdaTerm) — quoted term (meta-level)
class LambdaEngine(
val maxReductions: Int = 500,
val maxTermSize: Int = 512,
val hyperbolicCurvature: Float = -1f // K = -1 standard hyperbolic plane
)Each β-reduction step is a geodesic movement on the Poincaré disk:
Position: (r, θ) in the unit disk {(x,y) : x² + y² < 1}
Cost per step: proportional to hyperbolic distance traveled
Curvature tensor: tracked at each reduction step
The Y-combinator is the fixed-point attractor on this manifold.
| Operation | Description |
|---|---|
reduce(term) |
Normal-order β-reduction with step tracking |
godelEncode(term) |
Assign unique natural number ⌈t⌉ ∈ ℕ |
godelDecode(n) |
Reconstruct term from Gödel number |
diagonalize() |
Construct self-referential term D = λn.(decode(n) ⌈n⌉) |
quine() |
Fixed point of self-application Q = D ⌈D⌉ |
detectFixedPoint() |
Cycle detection via Gödel codes |
Every λ-term receives a unique natural number:
⌈Var(x)⌉ = 2 × encode(x)
⌈Abs(x, M)⌉ = 3 × 2^⌈M⌉
⌈App(M, N)⌉ = 5 × 2^⌈M⌉ × 3^⌈N⌉
The diagonal lemma constructs self-referential terms — the foundation of Gödelian incompleteness.
8 sorts, 8 geometric sequents:
| Sequent | Meaning |
|---|---|
| β-progress | Every β-redex reduces in one step |
| Y-fixed | Y f reduces to f(Y f) |
| curvature-bound | Reduction cost ≤ hyperbolic curvature integral |
| normal-form | No redex ⊢ normal form |
| church-encode | Church numeral n ⊢ correct encoding |
| godel-round-trip | decode(encode(t)) = t |
| quine-existence | ∃Q: Q reduces to Q |
| size-bound | Term size bounded by maxTermSize |
The Lambda/Lisp subsystem is loosely coupled to the DMN cycle to prevent trapping:
| Parameter | Value | Purpose |
|---|---|---|
consecutiveLispLambdaTicks |
max 5 | Force cooldown after 5 consecutive ticks |
maxLispSessionDurationTicks |
40 | Hard session timeout |
| Cooldown | 15 ticks | Wait period after forced yield |
| Priority | Reflection > Daydream > Lambda | Lambda is lowest priority |
| Recovery | detectStuckState() |
Force exit on Lambda trapping |
A local Scheme REPL can run via WebVM for offline prototyping. See docs/webvm-lisp-lambda-vm.md.
WebVM (browser) → prototype S-expr → paste into app → LispSandbox.eval()