Back to blog

Consciousness Kernel: A Computational Model in Racket

A computational model approaching consciousness based on Global Workspace Theory, using Racket's metaprogramming capabilities for exploratory implementation.

#AI#Consciousness#Racket#Scheme#Metaprogramming

Introduction

This project attempts to approach the problem of consciousness through computational modeling. Based on Baars' Global Workspace Theory, we use Racket's macro system and functional programming paradigm to construct a simplified model of information competition and broadcasting.

Core Concept

The system's core mechanism is a "global workspace"—different functional modules can broadcast information to this space, and through competitive selection, determine attention allocation:

(define (broadcast workspace message)
  (send workspace publish message))
 
(define (attend-to workspace callback)
  (send workspace subscribe callback))
 
(broadcast global-workspace
  (make-message 'sensory "red object detected"))
 
(attend-to global-workspace
  (lambda (msg)
    (when (eq? (message-type msg) 'sensory)
      (process-sensory msg))))

Theoretical Foundation

Global Workspace Theory

Baars' Global Workspace Theory posits that consciousness is an information integration mechanism. Multiple parallel specialized processing modules compete to propagate information to the global workspace, making it accessible to other modules.

Computational Model Mapping

Theory ConceptImplementation
Specialized modulesIndependent Racket threads/coroutines
Global workspacePublish/subscribe message bus
CompetitionPriority-based scheduler
AttentionSingle active broadcast source

Implementation Details

Publish/Subscribe Mechanism

(struct workspace (subscribers lock) #:mutable)
 
(define (make-workspace)
  (workspace '() (make-semaphore 1)))
 
(define (publish ws message)
  (call-with-semaphore (workspace-lock ws)
    (lambda ()
      (for ([sub (workspace-subscribers ws)])
        ((cdr sub) message)))))
 
(define (subscribe ws key callback)
  (call-with-semaphore (workspace-lock ws)
    (lambda ()
      (set-workspace-subscribers!
        ws
        (cons (cons key callback)
              (workspace-subscribers ws))))))

Competition Mechanism

(define (compete workspace messages)
  (define ranked
    (sort messages
          (lambda (a b)
            (> (message-priority a)
               (message-priority b)))))
  (if (not (null? ranked))
      (publish workspace (car ranked))
      (publish workspace (make-message 'idle "no input"))))

Exploratory Conclusions

Through this simple computational model, we observed:

  1. Information Integration: Information from multiple independent modules can be integrated through broadcasting
  2. Attention Switching: Competition mechanism can simulate dynamic attention allocation
  3. Emergent Behavior: Simple rules can produce complex system behavior

Limitations and Reflections

Theoretical Limitations

  • This model is a gross simplification of GWT, ignoring neuroscience details
  • Does not address the subjective experience (qualia) of consciousness
  • Lacks learning and adaptation mechanisms

Technical Limitations

  • Single-machine implementation, no distributed scaling
  • No persistent state
  • Lacks performance optimization

Project Status

This project serves as a theoretical exploratory programming exercise, aiming to provide an actionable modeling approach from a computational perspective for consciousness research. The project is archived and no longer actively developed.


Related Links


Last updated: 2025-11-26