Skip to content

Latest commit

 

History

History
156 lines (119 loc) · 5.62 KB

File metadata and controls

156 lines (119 loc) · 5.62 KB

§Λ|WEBVM — Local Lisp/Lambda Logic VM Configuration

Overview

The Baby Topos AI agent's Lisp/Lambda subsystem can be complemented with a local WebVM-based Lisp runtime running in Alpine Linux on WebVM. This provides a persistent, sandboxed REPL for exploring λ-calculus and S-expressions outside the Android runtime — useful for testing, debugging, and offline development.

Quick Start

1. Open WebVM Alpine

Navigate to: https://webvm.io/alpine.html

This boots an x86 Alpine Linux environment in the browser via CheerpX (WebAssembly).

2. Install CLISP (Common Lisp)

# In the WebVM terminal:
apk update
apk add clisp

Or for a lighter footprint, install TinyScheme (R5RS Scheme, closer to our LispRuntime):

# Build TinyScheme from source (Alpine has no prebuilt package)
apk add build-base wget
wget https://downloads.sourceforge.net/project/tinyscheme/tinyscheme/tinyscheme-1.42/tinyscheme-1.42.tar.gz
tar xzf tinyscheme-1.42.tar.gz
cd tinyscheme-1.42
make
./scheme  # Launch REPL

3. Alternative: ECL (Embeddable Common Lisp)

apk add ecl
ecl  # Launch REPL

Mapping: topostrasgo LispRuntime → Standard Scheme/CL

topostrasgo builtin Standard Scheme equivalent Notes
(define x val) (define x val) Same syntax
(lambda (x) body) (lambda (x) body) Same syntax
(let ((x v)) body) (let ((x v)) body) Same syntax
(begin e1 e2) (begin e1 e2) Same syntax
(cons a b) (cons a b) Same syntax
(car p) (car p) Same syntax
(cdr p) (cdr p) Same syntax
(map f lst) (map f lst) Same syntax
(filter pred lst) (filter pred lst) R5RS: may need SRFI-1
(fold f init lst) (fold-left f init lst) Different name in CL
(make-vec n) (make-vector n 0.0) Typed in topostrasgo
(vec-get v i) (vector-ref v i) Standard Scheme
(vec-set! v i x) (vector-set! v i x) Standard Scheme

Lambda Calculus in Standard Scheme

The topostrasgo LambdaEngine.kt implements:

  • β-reduction (normal order)
  • Y-combinator: Y = (lambda (f) ((lambda (x) (f (x x))) (lambda (x) (f (x x)))))
  • Church numerals: cn = (lambda (f) (lambda (x) (f (f ... (f x)...))))
  • Gödel encoding/decoding

Testing Y-Combinator in Scheme REPL

;; Y-combinator (call-by-value safe version: Z-combinator)
(define Z
  (lambda (f)
    ((lambda (x) (f (lambda (v) ((x x) v))))
     (lambda (x) (f (lambda (v) ((x x) v)))))))

;; Factorial via Z
(define factorial
  (Z (lambda (self)
       (lambda (n)
         (if (= n 0) 1 (* n (self (- n 1))))))))

(factorial 5)  ;; → 120

;; Church numerals
(define c0 (lambda (f) (lambda (x) x)))
(define c1 (lambda (f) (lambda (x) (f x))))
(define c2 (lambda (f) (lambda (x) (f (f x)))))
(define succ (lambda (n) (lambda (f) (lambda (x) (f ((n f) x))))))

;; Church to integer
(define (church->int cn) ((cn (lambda (x) (+ x 1))) 0))

(church->int (succ c2))  ;; → 3

Testing Gödelian Self-Reference

;; Quine (Gödelian diagonal) in Scheme
((lambda (x) (list x (list 'quote x)))
 '(lambda (x) (list x (list 'quote x))))
;; → outputs itself

Poincaré Disk Simulation

;; Hyperbolic distance on the Poincaré disk
(define (poincare-dist ax ay bx by)
  (let* ((dx (- ax bx))
         (dy (- ay by))
         (dist (sqrt (+ (* dx dx) (* dy dy))))
         (denom (sqrt (+ (expt (- 1 (+ (* ax bx) (* ay by))) 2)
                         (expt (- (* ax by) (* ay bx)) 2))))
         (ratio (min (/ dist (max denom 1e-10)) 0.9999)))
    (* 2 (atanh ratio))))

(poincare-dist 0.0 0.0 0.5 0.3)

Integration with topostrasgo

The WebVM Lisp VM is loosely coupled to the Android agent:

  1. Development sandbox: Test S-expressions before feeding them to the agent via §0|LISP commands
  2. Lambda calculus prototyping: Validate reduction strategies before they enter LambdaEngine.kt
  3. Offline theory development: Explore combinators and fixed points without substrate dependency
  4. No runtime coupling: WebVM runs in the browser, topostrasgo runs on Android — they share syntax but not state

Workflow

WebVM (browser) ──── prototype & test ──── copy S-expr ──── paste into topostrasgo ────┐
                                                                                        ↓
                                                                            BabyToposAI.ingestStimulus("(define ...)")
                                                                                        ↓
                                                                            LispSandbox.eval() → result
                                                                                        ↓
                                                                            HolographicTape + Mneme + Affect

§Λ|FIX Notes: Loose Coupling to DMN

The Lambda/Lisp subsystem is now loosely coupled to the DMN cycle:

  • Session budget: Max 40 DMN ticks per Lisp session, then auto-yield
  • Consecutive tick limit: Max 5 consecutive Lisp/Lambda ticks before forced cooldown
  • Priority: Reflection and daydream always take priority over Lambda ticks
  • Cooldown: 15 tick cooldown after forced yield before re-activation
  • Recovery: detectStuckState() specifically detects Lambda trapping and forces exit
  • Operator preemption: Any operator input resets the consecutive tick counter