|
| 1 | +\documentclass{article} |
| 2 | +\usepackage{amsmath} |
| 3 | +\usepackage{amsfonts} |
| 4 | +\usepackage{xcolor} |
| 5 | +\usepackage[utf8]{inputenc} |
| 6 | +\usepackage{tikz} |
| 7 | +\usetikzlibrary{cd} |
| 8 | +\usepackage{listings} |
| 9 | +\usepackage{hyperref} |
| 10 | +\usepackage{natbib} |
| 11 | + |
| 12 | +\begin{document} |
| 13 | + |
| 14 | +\title{Spherepop Calculus: Internalizing Probability, Concurrency, and Geometry} |
| 15 | +\author{Flyxion} |
| 16 | +\date{September 28, 2025} |
| 17 | +\maketitle |
| 18 | + |
| 19 | +\begin{abstract} |
| 20 | +Spherepop Calculus (SPC) is a novel computational formalism extending lambda calculus with geometric scope (\texttt{Sphere} and \texttt{Pop}), concurrent composition (\texttt{Merge}), probabilistic branching (\texttt{Choice}), and structural symmetries (\texttt{Rotate}). This paper explores SPC’s design, emphasizing the \texttt{doomCoin p} construct as a canonical example of its probabilistic and tensorial semantics. We compare SPC with traditional and probabilistic lambda calculi, highlighting its ability to internalize probability, concurrency, and geometric structure. Implementations in Haskell and a Racket evaluator skeleton demonstrate practical realizations of SPC’s concepts. |
| 21 | +% TODO: Add a sentence on applications (e.g., AI safety, risk analysis) to motivate practical relevance. |
| 22 | +\end{abstract} |
| 23 | + |
| 24 | +\section{Introduction} |
| 25 | +% Expand with: |
| 26 | +% - Motivation: Why geometric scoping unifies functional, concurrent, probabilistic computation. |
| 27 | +% - Historical context: λ-calculus (Church), probabilistic λ-calculus (Kozen), π-calculus (Milner). |
| 28 | +% - SPC’s philosophy: Internalizing probability/concurrency as first-class constructs. |
| 29 | +Spherepop Calculus (SPC) reimagines lambda calculus by introducing geometric scoping through \texttt{Sphere} and \texttt{Pop}, parallel composition via \texttt{Merge}, probabilistic branching with \texttt{Choice}, and structural operations like \texttt{Rotate}. Unlike traditional lambda calculus, SPC natively supports concurrent and probabilistic computations within a type discipline extending the Calculus of Constructions, with semantics in a presheaf topos enriched with the distribution monad. This paper elucidates SPC’s design, focusing on \texttt{doomCoin p} as a pedagogical archetype, and provides practical implementations in Haskell and Racket. |
| 30 | + |
| 31 | +\section{Core Constructs of Spherepop Calculus} |
| 32 | +SPC extends lambda calculus with the following primitives, each with distinct syntax, typing, and semantics: |
| 33 | + |
| 34 | +\begin{itemize} |
| 35 | + \item \textbf{Sphere/Pop}: Replaces lambda abstraction/application with geometric scoping, where \texttt{Sphere(x:A.t)} denotes a function and \texttt{Pop(f,u)} applies it. |
| 36 | + \item \textbf{Merge}: Represents parallel/nondeterministic composition, interpreted as a tensor product. |
| 37 | + \item \textbf{Choice}: Introduces probabilistic branching, returning either type $A$ or $\Dist(A)$. |
| 38 | + \item \textbf{Rotate}: Cyclic rotation over homogeneous Boolean tensors, capturing structural symmetries. |
| 39 | +\end{itemize} |
| 40 | + |
| 41 | +\subsection{Syntax and Typing} |
| 42 | +% TODO: Add formal grammar and typing rules for each construct. |
| 43 | +\[ |
| 44 | +\begin{array}{rcl} |
| 45 | +t,u &::=& \Var{x} \mid \Sphere(x{:}A.\,t) \mid \Pop(t,u) \mid \Merge(t,u) \mid \Choice(p,t,u) \mid \Rotate(k,t) \\ |
| 46 | + && \mid \LitUnit \mid \LitBool{b} \mid \LitNat{n} \mid \If(b,t,u) \mid \Add(t,u) |
| 47 | +\end{array} |
| 48 | +\] |
| 49 | +\[ |
| 50 | +\frac{\Gamma, x{:}A \vdash t : B}{\Gamma \vdash \Sphere(x{:}A.\,t) : A \to B} \quad |
| 51 | +\frac{\Gamma \vdash f : A \to B \quad \Gamma \vdash u : A}{\Gamma \vdash \Pop(f,u) : B} |
| 52 | +\] |
| 53 | +\[ |
| 54 | +\frac{\Gamma \vdash t : A \quad \Gamma \vdash u : B}{\Gamma \vdash \Merge(t,u) : A \otimes B} \quad |
| 55 | +\frac{\Gamma \vdash t : A \quad \Gamma \vdash u : A \quad p \in [0,1]}{\Gamma \vdash \Choice(p,t,u) : A} |
| 56 | +\] |
| 57 | +\[ |
| 58 | +\frac{\Gamma \vdash t : \Bool^{\otimes k}, k \ge 1}{\Gamma \vdash \Rotate(k,t) : \Bool^{\otimes k}} |
| 59 | +\] |
| 60 | + |
| 61 | +\subsection{Operational Semantics} |
| 62 | +% TODO: Expand with full small-step rules (from prior messages), including probability-mass composition. |
| 63 | +\[ |
| 64 | +\Pop(\Sphere(x{:}A.\,t), v) \longrightarrow t[v/x] |
| 65 | +\] |
| 66 | +\[ |
| 67 | +\Choice(p,t,u) \LongRightarrow_p t \quad \Choice(p,t,u) \LongRightarrow_{1-p} u |
| 68 | +\] |
| 69 | +\[ |
| 70 | +\Merge(v,w) \longrightarrow v \otimes w \quad \Rotate(k, v_1 \otimes \cdots \otimes v_n) \longrightarrow v_{1+k \mod n} \otimes \cdots \otimes v_{n+k \mod n} |
| 71 | +\] |
| 72 | + |
| 73 | +\subsection{Categorical Semantics} |
| 74 | +% TODO: Detail presheaf topos, distribution monad, tensor product for Merge. |
| 75 | +\texttt{Sphere/Pop} are exponentials/evaluation morphisms, \texttt{Merge} is a tensor product, and \texttt{Choice} is a convex combination in the distribution monad. |
| 76 | + |
| 77 | +\section{Canonical Example: \texttt{doomCoin p}} |
| 78 | +The \texttt{doomCoin p} construct exemplifies SPC’s probabilistic and tensorial semantics: |
| 79 | +\[ |
| 80 | +\doomCoin{p} \;\equiv\; \Choice(p, \LitBool{\#t}, \LitBool{\#f}). |
| 81 | +\] |
| 82 | + |
| 83 | +\subsection{Syntax and Typing} |
| 84 | +\[ |
| 85 | +\frac{\Gamma \vdash \LitBool{\#t} : \Bool \quad \Gamma \vdash \LitBool{\#f} : \Bool \quad p \in [0,1]}{\Gamma \vdash \doomCoin{p} : \Bool \text{ or } \Dist(\Bool)} |
| 86 | +\] |
| 87 | + |
| 88 | +\subsection{Operational Semantics} |
| 89 | +\[ |
| 90 | +\doomCoin{p} \LongRightarrow_p \LitBool{\#t} \quad \doomCoin{p} \LongRightarrow_{1-p} \LitBool{\#f} |
| 91 | +\] |
| 92 | +Example reduction for $\Merge(\doomCoin{0.2}, \doomCoin{0.5})$: |
| 93 | +\[ |
| 94 | +\Merge(\Choice(0.2, \#t, \#f), \Choice(0.5, \#t, \#f)) \LongRightarrow_{0.2 \cdot 0.5} \#t \otimes \#t \quad \text{(and other paths)}. |
| 95 | +\] |
| 96 | + |
| 97 | +\subsection{Denotational Semantics} |
| 98 | +\[ |
| 99 | +\llbracket \doomCoin{p} \rrbracket = p \cdot \delta_{\#t} + (1-p) \cdot \delta_{\#f} |
| 100 | +\] |
| 101 | +For $\Merge(\doomCoin{p_1}, \ldots, \doomCoin{p_n})$, the \texttt{anyDoom} observable yields: |
| 102 | +\[ |
| 103 | +\Pr[\anyDoom(\Merge(\doomCoin{p_1}, \ldots, \doomCoin{p_n}))] = 1 - \prod_{i=1}^n (1-p_i). |
| 104 | +\] |
| 105 | +% TikZ diagram showing categorical flow |
| 106 | +\begin{figure}[h] |
| 107 | +\centering |
| 108 | +\begin{tikzcd} |
| 109 | +\doomCoin{p} \arrow[r, "\llbracket \cdot \rrbracket"] \arrow[d, "\text{Choice}"] & p \cdot \delta_{\#t} + (1-p) \cdot \delta_{\#f} \arrow[d, "\text{tensor}"] \\ |
| 110 | +\Dist(\Bool) \arrow[r, "\Merge"] & \Dist(\Bool^{\otimes n}) \arrow[r, "\anyDoom"] & \Dist(\Bool) |
| 111 | +\end{tikzcd} |
| 112 | +\caption{Categorical flow: \texttt{doomCoin p} to \texttt{anyDoom} via tensor product.} |
| 113 | +\end{figure} |
| 114 | + |
| 115 | +\subsection{Rationale} |
| 116 | +\texttt{doomCoin p} is canonical because: |
| 117 | +\begin{itemize} |
| 118 | + \item \textbf{Intrinsic Probability}: $p$ is syntactic, not an external oracle. |
| 119 | + \item \textbf{Bernoulli Base Case}: Models doom as a Boolean. |
| 120 | + \item \textbf{Tensorial Independence}: \texttt{Merge} ensures the Independent Channels Lemma. |
| 121 | + \item \textbf{Pedagogical Clarity}: Intuitive and memorable syntax. |
| 122 | +\end{itemize} |
| 123 | + |
| 124 | +\section{Comparison with Lambda Calculi} |
| 125 | +\begin{itemize} |
| 126 | + \item \textbf{Lambda Calculus}: Uses external oracles, e.g., $\lambda r.\ \texttt{if } r < p \texttt{ then \#t else \#f}$. No concurrency or intrinsic probability. |
| 127 | + \item \textbf{Probabilistic Lambda Calculus}: Supports \texttt{choice(p,e1,e2)}, but lacks tensorial concurrency or geometric scoping. |
| 128 | + \item \textbf{SPC}: Unifies probability, concurrency, and geometry via \texttt{Choice}, \texttt{Merge}, and \texttt{Sphere/Pop}. |
| 129 | +\end{itemize} |
| 130 | +% TODO: Add theorem: SPC subsumes probabilistic λ-calculus via doomCoin p. |
| 131 | + |
| 132 | +\section{Operational Semantics (Appendix)} |
| 133 | +% From prior messages, full small-step semantics |
| 134 | +\[ |
| 135 | +\infer[\textsc{E-Beta}]{\Pop(\Sphere(x{:}A.\,t), v) \longrightarrow t[v/x]}{} |
| 136 | +\] |
| 137 | +\[ |
| 138 | +\infer[\textsc{E-Choice-1}]{\Choice(p,t,u) \LongRightarrow_p t}{} \quad |
| 139 | +\infer[\textsc{E-Choice-2}]{\Choice(p,t,u) \LongRightarrow_{1-p} u}{} |
| 140 | +\] |
| 141 | +% TODO: Add Rotate, Merge, probability-mass composition, soundness lemma. |
| 142 | + |
| 143 | +\section{Implementation in Haskell} |
| 144 | +The Haskell implementation (\texttt{spherepop.hs}) provides type checking and evaluation: |
| 145 | +\begin{itemize} |
| 146 | + \item \textbf{Type Checking}: Ensures type alignment for \texttt{Merge}, \texttt{Choice}, \texttt{Rotate}. |
| 147 | + \item \textbf{Evaluation}: Big-step semantics with distribution monad. |
| 148 | + \item \textbf{Observables}: \texttt{anyDoom} computes doom probabilities. |
| 149 | +\end{itemize} |
| 150 | +% TODO: Include code snippets, GHCI runs. |
| 151 | + |
| 152 | +\section{Racket Evaluator Skeleton} |
| 153 | +The Racket skeleton (\texttt{spherepop.rkt}) uses macros to desugar extended constructs into the core: |
| 154 | +\begin{itemize} |
| 155 | + \item \texttt{Choice\_n}: Nested \texttt{Choice} calls. |
| 156 | + \item \texttt{Bind}: Monadic sequencing via \texttt{Sphere/Pop}. |
| 157 | + \item \texttt{FoldOr/FoldAnd}: Boolean folds over tensors. |
| 158 | +\end{itemize} |
| 159 | +% TODO: Show macro definitions, example runs. |
| 160 | + |
| 161 | +\section{Conclusion} |
| 162 | +SPC advances lambda calculus by integrating geometric scoping, concurrency, and probability. The \texttt{doomCoin p} construct exemplifies its power, with implementations in Haskell and Racket demonstrating practical utility. Future work includes exploring probabilistic dependent types and applications in AI safety. |
| 163 | +% TODO: Add open problems, future directions. |
| 164 | + |
| 165 | +\bibliographystyle{plain} |
| 166 | +\bibliography{spherepop} |
| 167 | +\end{document} |
0 commit comments