-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathThe Calculus of Commitment.tex
More file actions
2830 lines (2031 loc) · 99 KB
/
The Calculus of Commitment.tex
File metadata and controls
2830 lines (2031 loc) · 99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
\documentclass[11pt]{article}
\usepackage{luatextra}
\usepackage{fontspec}
\setmainfont{Latin Modern Roman}
\usepackage{amsmath,amssymb,amsthm,mathtools,bm}
\usepackage{geometry}
\usepackage{setspace}
\usepackage{microtype}
\usepackage{csquotes}
\usepackage{hyperref}
\usepackage{enumitem}
\usepackage{physics}
\usepackage{tikz}
\usetikzlibrary{arrows.meta, positioning, shapes, decorations.pathreplacing}
\geometry{margin=1in}
\setstretch{1.15}
\setlength{\parindent}{0pt}
\setlength{\parskip}{0.6em}
\newtheorem{definition}{Definition}
\newtheorem{theorem}{Theorem}
\newtheorem{proposition}{Proposition}
\newtheorem{lemma}{Lemma}
\theoremstyle{remark}
\newtheorem{remark}{Remark}
\title{The Calculus of Commitment\\
\large A Structural Theory of Computation}
\author{Flyxion}
\date{\today}
\begin{document}
\maketitle
\begin{abstract}
This text develops Spherepop as a minimal structural calculus of merge and collapse, and then uses it as a unifying lens through which classical models of computation may be understood. Rather than beginning with the $\lambda$-calculus, typed judgments, or machine architectures, we begin with a primitive algebra of regions. From this foundation we reconstruct higher-order functions, type structure, stack-based execution, and functional evaluation as disciplined refinements of a simpler merge--collapse substrate.
The central thesis is that computational formalisms often presented as independent traditions can be seen as stratifications of a single structural principle: the controlled reduction of optionality under compositional constraint. Spherepop serves as the pedagogical base layer. From it we derive $\lambda$-abstraction as region-valued transformation, type theory as invariant preservation under composition, stack-based programming as explicit sequencing of region states, and functional programming as replayable history of pure transformations.
The goal of the text is not to replace established theories, but to provide a structural perspective that makes their common invariants visible.
\end{abstract}
\newpage
\section*{Preface}
This book develops a structural account of computation from a small set of elementary operations. Rather than beginning with machines, syntax, or programming languages, we begin with a simple algebra over regions and equivalence. From that base, familiar formalisms—$\lambda$-calculus, type systems, currying, pipelines, monads, algebraic effects, state, and continuation-passing style—are reconstructed as layered refinements of the same underlying structure.
The purpose of this reconstruction is not to replace established theories. The classical results of reduction theory, denotational semantics, and categorical logic remain intact. What changes is the vantage point. By isolating a minimal pair of operations—one that accumulates structure and one that resolves it—many seemingly distinct paradigms can be seen to share a common algebraic backbone. Abstraction becomes controlled identification, composition becomes associative accumulation, and evaluation becomes canonical normalization.
The development proceeds incrementally. We begin with the bare calculus. We then derive abstraction and composition, followed by typing and structured effects. Later chapters examine state, continuation, and mutation as disciplined variations in where and when structural resolution is permitted. Throughout, emphasis is placed on algebraic stability: associativity, identity, and invariance under canonical form.
The formal framework used to organize this presentation is referred to as \emph{Spherepop}. It is not proposed as an alternative model of computability, nor as a replacement for established formalisms. Rather, it serves as a compact vehicle for articulating the structural commitments that classical systems already presuppose but do not always foreground. Its purpose is expository and unifying: to make visible the algebraic backbone shared across otherwise diverse computational paradigms.
Viewed from this perspective, computation is not exhausted by symbol manipulation. It consists in the disciplined introduction, organization, and resolution of commitments within a formal system. The calculus developed in these chapters aims to render that discipline explicit, so that familiar constructions appear not as isolated techniques, but as expressions of a common structural logic.
\section{Motivation: Structure Before Symbol}
Computation is often introduced syntactically. One begins with symbols, variables,
application, reduction rules, and machine models. Only later does one ask what
structural invariants those systems preserve.
This text reverses that order.
We begin not with variables or functions, but with \emph{regions}.
A region is a finite structural commitment: a collection of distinguishable
elements subject to identification. Computation, at its most primitive level,
is the controlled evolution of such regions under two operations:
\begin{center}
\textbf{Merge} \qquad and \qquad \textbf{Collapse}.
\end{center}
Merge combines commitments. Collapse identifies them.
Everything that follows---abstraction, substitution, typing, stack discipline,
and pure functional evaluation---can be understood as increasingly refined
disciplines governing when and how merge and collapse may occur.
The guiding philosophical principle is this:
\begin{quote}
Structure precedes symbol. Symbol manipulates structure.
\end{quote}
By grounding computation in structural commitments rather than symbolic
rewriting alone, we expose the invariants common to otherwise distinct
computational paradigms.
\begin{figure}[h]
\centering
\begin{tikzpicture}
\node[region] (R) {
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node[atom] (a) {$a$};
\node[atom, right=8mm of a] (b) {$b$};
\node[atom, right=8mm of b] (c) {$c$};
\end{tikzpicture}\\[1mm]
$\Omega(R)=3$
};
\end{tikzpicture}
\caption{A region as a finite set of distinguishable atoms, with optionality measured by cardinality.}
\end{figure}
\section{Historical Development: From Symbolic Computation to Structural Algebra}
The development of computation theory has often been narrated
as a sequence of formal breakthroughs: recursive functions,
$\lambda$-calculus, Turing machines, domain theory, type systems,
functional languages, and categorical semantics.
Yet beneath these advances lies a quieter continuity:
the gradual recognition that computation is structural
rather than merely symbolic.
This section traces that development and situates
the merge--collapse viewpoint within it.
\subsection{The Foundational Era: Symbolic Computability}
Church and Turing formalized the notion of effective procedure
in the 1930s.
The $\lambda$-calculus introduced abstraction and substitution
as primitive operations,
while Turing machines rendered computation as state transition.
Despite their apparent differences,
both models reduced computation to
structured transformation under explicit rules.
The Church--Turing thesis unified these models,
suggesting that computation is invariant under representation.
\subsection{Reduction and Confluence}
The $\lambda$-calculus emphasized reduction.
$\beta$-reduction formalized substitution,
while later work established confluence
and normalization properties.
These results revealed a deep invariant:
evaluation order may vary,
but canonical results remain stable
when reduction is well-behaved.
This stability anticipates the role of canonical collapse
in merge--collapse semantics.
\subsection{Domain Theory and Denotational Semantics}
In the 1970s,
Scott introduced domain theory to give
mathematical meaning to recursive definitions.
Functions were no longer mere symbolic rewrites,
but continuous maps over structured spaces.
Denotational semantics reframed programs
as mathematical objects.
This shift from operational step-by-step reasoning
to structural interpretation marked a profound turn.
Computation became geometry.
\subsection{The Rise of Type Theory}
Type systems emerged to control abstraction.
Martin-L\"of’s intuitionistic type theory
and Reynolds’ parametric polymorphism
formalized invariants preserved under transformation.
Typing was no longer annotation,
but a structural guarantee:
certain collapses are permitted,
others forbidden.
In this light,
types are disciplined quotient structures.
\subsection{Functional Programming as Algebra}
Landin and Strachey recognized that programming languages
could be understood through the lens of $\lambda$-calculus.
Backus later called for liberation from the
von Neumann style,
arguing for algebraic composition over mutable state.
The work of Meijer, Wadler, Moggi, and others
made this algebraic view explicit.
Catamorphisms, monads, and folds reframed programs
as structured transformations over data.
Recursion schemes made collapse systematic.
Algebra replaced control flow.
\subsection{Category Theory and Internal Structure}
Category theory unified many strands.
Monoidal structure, internal hom,
and adjunctions provided a language
for abstraction itself.
The $\lambda$-calculus became the internal language
of Cartesian closed categories.
Programs were morphisms.
Types were objects.
Composition was structural.
This categorical turn revealed that
abstraction is not a syntactic trick,
but a reflection of deeper algebraic structure.
\subsection{From Algebra to Structural Reduction}
Spherepop continues this trajectory,
but begins one level lower.
Rather than starting from functions,
types, or morphisms,
it begins from two primitive structural operations:
\[
\text{merge} \quad \text{and} \quad \text{collapse}.
\]
Where $\lambda$-calculus begins with abstraction,
Spherepop asks what abstraction must be
at the level of raw structural commitment.
Where type theory imposes invariants,
Spherepop interprets types as disciplined quotient structures.
Where functional programming composes pure transformations,
Spherepop frames composition as associative merge
followed by canonical collapse.
In this sense,
Spherepop does not reject classical formalisms.
It seeks to expose the minimal structural substrate
from which they arise.
\subsection{A Structural Continuum}
The historical arc may therefore be summarized as:
\begin{center}
Symbolic Procedure
$\longrightarrow$
Reduction Theory
$\longrightarrow$
Denotational Geometry
$\longrightarrow$
Type Invariants
$\longrightarrow$
Algebraic Composition
$\longrightarrow$
Structural Merge--Collapse
\end{center}
Each stage refines the same insight:
computation is structured transformation
under invariant-preserving reduction.
Spherepop makes that structure explicit at its base layer.
The remainder of this text develops that layer
and reconstructs the higher strata from it.
\subsection{Algebraic Recursion Schemes}
A particularly important moment in the algebraic understanding of computation
came with the explicit treatment of recursion as a structural scheme rather
than as ad hoc self-reference.
Work by Meijer, Fokkinga, and Paterson formalized recursion patterns
as catamorphisms, anamorphisms, and hylomorphisms.
These recursion schemes made precise what had long been implicit:
data types carry algebraic structure,
and programs over them are homomorphisms.
A fold is not merely a loop.
It is a collapse into an algebra.
In merge--collapse language,
a catamorphism is precisely a disciplined collapse
of a recursively generated region into a canonical form.
An anamorphism, dually, is structured merge.
This algebraic viewpoint aligns directly with the thesis of this text:
computation is not instruction sequencing,
but structured transformation of commitment.
The importance of this development is methodological.
Rather than writing programs and then proving properties,
one calculates programs from algebraic laws.
Structure precedes implementation.
Spherepop inherits this orientation.
Its primitive operations are not operational instructions,
but algebraic transformations.
Higher-order abstraction and typed invariants
emerge from these transformations,
rather than being imposed externally.
\subsection{Spherepop’s Structural Commitments}
It is important to clarify how Spherepop differs
from classical computational formalisms.
First, it does not introduce a new notion of computability.
The Church--Turing thesis remains intact.
Spherepop is not a competing model of effective procedure.
Second, it does not replace $\lambda$-calculus,
type theory, or functional programming.
Rather, it attempts to identify the minimal structural substrate
common to them.
The distinctive commitments of Spherepop are:
\paragraph{1. Structural Primacy.}
Computation is defined in terms of merge and collapse,
prior to variables, substitution, or typing.
\paragraph{2. Quotient-Centric Abstraction.}
Abstraction is interpreted as disciplined introduction
of equivalence relations,
not merely syntactic binding.
\paragraph{3. Canonical Normalization.}
Collapse is canonical projection.
Confluence and referential transparency
are consequences of this property.
\paragraph{4. Separation of Authority and View.}
Operational histories (event logs)
are distinguished from derived semantic views (regions).
This mirrors the distinction between evaluation trace
and denotational meaning.
\paragraph{5. Optionality as a Structural Measure.}
The cardinality of a region measures degrees of freedom.
Computation reorganizes optionality under constraint.
These commitments yield a perspective
in which $\lambda$-calculus appears as disciplined merge--collapse,
type theory appears as invariant enforcement,
and functional programming appears as replayable structural history.
Spherepop is therefore best understood
not as a new calculus,
but as a structural lens
through which existing calculi may be reinterpreted.
In the sections that follow,
we return to the formal development,
now situated within this historical and conceptual frame.
\subsection{Substitution and Quotient: A Structural Comparison with $\lambda$-Calculus}
The classical $\lambda$-calculus is built upon substitution.
Application replaces a variable with a term,
yielding $\beta$-reduction.
From the merge--collapse perspective,
substitution is not primitive.
It is a consequence of quotient introduction.
In $\lambda$-calculus:
\[
(\lambda x.\, e)\; a \;\to\; e[x := a].
\]
In merge--collapse semantics:
\[
\operatorname{collapse}\big(\llbracket e \rrbracket \oplus \{a\}\big)
\quad \text{under } x \sim a.
\]
The essential difference is conceptual. Substitution operates at the level of syntax: it rewrites expressions by replacing bound variables with concrete terms. Its action is textual, proceeding by systematic replacement within a symbolic representation. Quotient, by contrast, operates at the level of structure. It introduces an identification within the governing equivalence relation, thereby collapsing distinctions canonically rather than rewriting symbols.
Substitution can thus be understood as a syntactic mechanism for achieving what quotient accomplishes structurally. Where substitution replaces occurrences of a name, quotient enforces identity between the structures those names denote. The former manipulates expressions; the latter reorganizes commitments.
This distinction clarifies several phenomena.
First, variable capture becomes a non-issue,
since identification occurs at the structural level,
not through name replacement.
Second, confluence arises from canonical collapse,
not merely from syntactic reduction properties.
Third, abstraction becomes the promise of future identification,
rather than the binding of a placeholder.
The $\lambda$-calculus can therefore be viewed
as a symbolic surface representation
of deeper quotient dynamics.
\subsection{Spherepop and the Internal Language of Categories}
Category theory offers a unifying framework for abstraction and composition by treating programs as morphisms and types as objects within a structured system. In particular, a Cartesian closed category supports a monoidal product, internal hom objects, and the operations of evaluation and currying. Within such a setting, the $\lambda$-calculus arises naturally as the internal language: abstraction corresponds to the formation of exponential objects, and application corresponds to evaluation.
From the merge--collapse perspective, these categorical constructions admit a structural interpretation. Merge supplies the monoidal structure, providing an associative means of combining regions with an identity element. Collapse functions as canonical projection, ensuring that structural identifications yield stable representatives. Abstraction may then be viewed as the formation of an internal hom object, organizing transformations as first-class regions, while application corresponds to the evaluation morphism that realizes these transformations within a composed structure.
On this reading, categorical semantics does not introduce a fundamentally new layer, but makes explicit the algebraic invariants already present in the merge--collapse substrate. The internal language of a Cartesian closed category can thus be understood as a disciplined refinement of the same structural principles.
More precisely, if $(\mathcal{R}, \oplus, \varnothing)$
denotes regions under merge,
then abstraction constructs an object
$[A \Rightarrow B]$
such that:
\[
A \oplus [A \Rightarrow B] \longrightarrow B.
\]
Collapse ensures that this morphism
is well-defined under equivalence.
Thus the structural content of a Cartesian closed category
is already present in minimal form
within merge--collapse semantics.
The categorical perspective does not introduce additional machinery so much as it clarifies the invariants already implicit in the structural calculus. The associativity of merge corresponds to the associativity of the monoidal product. The existence of an empty region as identity aligns with the categorical unit. Stability under canonical projection mirrors the requirement that morphisms respect the equivalence structure governing objects. These properties are not imposed from outside; they are conditions under which composition remains coherent and abstraction remains well-defined.
In this sense, the merge--collapse framework may be regarded as a pre-categorical substrate. When its operations are disciplined and organized according to these invariants, the familiar structures of categorical semantics emerge naturally. Cartesian closure, internal hom formation, and evaluation morphisms can then be understood as systematic refinements of an already structured algebra, rather than as externally introduced abstractions.
\subsection{A Historical Case Study: Deriving Folds from Merge--Collapse}
We now illustrate how a classical recursion scheme
arises naturally from merge--collapse dynamics.
Consider a recursively generated region
representing a list:
\[
R = \{x_1, x_2, \dots, x_n\}.
\]
A fold over this structure
combines elements using an algebra:
\[
\texttt{fold}\; f\; z\; [x_1,\dots,x_n].
\]
In structural terms,
the recursive data structure is built
by repeated merge:
\[
R = \{x_1\} \oplus \{x_2\} \oplus \dots \oplus \{x_n\}.
\]
A fold introduces a collapse
governed by algebra $f$.
Each merge increases optionality.
The fold collapses accumulated structure
into a canonical result.
Thus:
\[
\text{fold} \quad = \quad \text{structured collapse over recursive merge}.
\]
This derivation shows that data construction corresponds to merge, while evaluation corresponds to collapse. Recursion schemes, when viewed structurally, amount to disciplined iteration of these two operations. What appears in the algebraic programming tradition as a categorical construction—most notably in the presentation of folds as catamorphisms—can therefore be understood as an organized pattern of accumulation followed by canonical reduction.
From this vantage point, recursion schemes are not external refinements imposed upon an otherwise neutral calculus. They arise naturally once merge and collapse are taken as primitive. The categorical formulation makes their algebraic properties precise, but the structural necessity of their form is already present at the substrate level.
This case study thus reinforces the broader claim developed throughout the text: the abstractions of functional programming are not arbitrary design choices, but systematic refinements of a more elementary structural reduction. The framework employed here does not seek to displace established formalisms. It aims instead to expose their minimal generative core and to clarify the invariants that sustain them.
\section{Regions and Optionality}
We formalize the primitive semantic object.
\begin{definition}[Region]
A \emph{region} $R$ is a finite set of atomic names modulo an equivalence relation.
\end{definition}
Concretely, a region may be represented as a finite set
\[
R = \{a_1, a_2, \dots, a_n\},
\]
together with a quotient structure identifying certain elements.
The cardinality $|R|$ measures available distinguishable commitments.
We refer to this as \emph{optionality}.
\begin{definition}[Optionality]
For a region $R$, define
\[
\Omega(R) := |R|.
\]
\end{definition}
Optionality measures the degrees of freedom present in a region.
Computation reduces, restructures, and composes optionality.
\section{The Merge Operation}
Merge is structural composition.
\begin{definition}[Merge]
Given regions $R_1$ and $R_2$, their merge is
\[
R_1 \oplus R_2 := \operatorname{collapse}(R_1 \cup R_2).
\]
\end{definition}
Intuitively, merge forms the union of commitments and then normalizes
under the existing quotient.
Merge is associative up to canonical normalization.
\begin{proposition}
Merge is associative modulo representative equivalence.
\end{proposition}
\begin{proof}
Set union is associative. Collapse is a canonical projection.
Hence the composite operation is associative up to normalization.
\end{proof}
This already resembles monoidal composition.
\begin{figure}[h]
\centering
\begin{tikzpicture}[node distance=18mm]
\node[region] (R1) {
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node[atom] (a) {$a$};
\node[atom, right=7mm of a] (b) {$b$};
\end{tikzpicture}
};
\node[region, right=28mm of R1] (R2) {
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node[atom] (c) {$c$};
\node[atom, right=7mm of c] (d) {$d$};
\end{tikzpicture}
};
\node[opnode, below=16mm of $(R1)!0.5!(R2)$] (merge) {$\oplus$\\merge};
\node[region, below=16mm of merge] (R3) {
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node[atom] (a2) {$a$};
\node[atom, right=7mm of a2] (b2) {$b$};
\node[atom, right=7mm of b2] (c2) {$c$};
\node[atom, right=7mm of c2] (d2) {$d$};
\end{tikzpicture}
};
\draw[arrow] (R1) -- (merge);
\draw[arrow] (R2) -- (merge);
\draw[arrow] (merge) -- node[right, label]{canonicalize} (R3);
\end{tikzpicture}
\caption{Merge forms union followed by canonical normalization.}
\end{figure}
\section{The Collapse Operation}
Collapse performs identification.
\begin{definition}[Collapse]
Let $\sim$ be an equivalence relation over atomic names.
Collapse maps a region $R$ to its quotient
\[
\operatorname{collapse}(R) := R/{\sim}.
\]
\end{definition}
Collapse reduces optionality when identifications are nontrivial.
\begin{proposition}
If $k$ identifications are introduced, then
\[
\Omega(\operatorname{collapse}(R)) \le \Omega(R).
\]
\end{proposition}
Collapse corresponds to substitution, unification, or evaluation in
more familiar calculi.
\section{Programs as Region Transformations}
A \emph{program} in Spherepop is an expression built from:
\[
\text{Atom}, \quad \oplus, \quad \operatorname{collapse}, \quad \text{LetQuotient}.
\]
Its denotation is a region.
Evaluation is deterministic under a fixed quotient context.
This replayability will later correspond to referential transparency
in functional programming and confluence in $\lambda$-calculus.
\begin{figure}[h]
\centering
\begin{tikzpicture}[node distance=18mm]
\node[region] (R) {
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node[atom] (a) {$a$};
\node[atom, right=7mm of a] (b) {$b$};
\node[atom, right=7mm of b] (c) {$c$};
\end{tikzpicture}
};
\node[opnode, right=20mm of R] (coll) {collapse\\$\operatorname{collapse}$};
\node[region, right=20mm of coll] (Q) {
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node[rep] (r) {$[a]$};
\node[rep, right=10mm of r] (s) {$[c]$};
\end{tikzpicture}\\[-1mm]
\small with $a\sim b$
};
\draw[arrow] (R) -- (coll);
\draw[arrow] (coll) -- (Q);
\draw[arrow, faint] (a) to[bend left=18] (r);
\draw[arrow, faint] (b) to[bend left=8] (r);
\draw[arrow, faint] (c) to[bend left=18] (s);
\end{tikzpicture}
\caption{Collapse identifies atoms under an equivalence relation and projects to canonical representatives.}
\end{figure}
\section{From Regions to Functions}
We now observe a crucial structural step.
A function
\[
f : R \to R
\]
is simply a rule that merges input with additional structure
and possibly collapses the result.
Abstraction therefore corresponds to:
\[
\lambda x.\, e
\quad \Longleftrightarrow \quad
\text{a region transformer parameterized by } x.
\]
Application corresponds to merge followed by collapse under substitution.
Thus, the $\lambda$-calculus can be reconstructed as a disciplined
fragment of merge--collapse semantics.
In the next section, we formalize this reconstruction.
\begin{figure}[h]
\centering
\begin{tikzpicture}[node distance=14mm]
\node[opnode] (prog) {Program\\(expression)};
\node[opnode, right=26mm of prog] (eval) {Evaluation\\(merge + collapse)};
\node[region, right=26mm of eval] (out) {
\begin{tikzpicture}[baseline=(current bounding box.center)]
\node[rep] (u) {$u$};
\node[rep, right=8mm of u] (v) {$v$};
\end{tikzpicture}
};
\draw[arrow] (prog) -- (eval);
\draw[arrow] (eval) -- node[above, label]{denotation} (out);
\end{tikzpicture}
\caption{A program denotes a canonical region via deterministic evaluation.}
\end{figure}
\section{Axiomatization of the Merge--Collapse Calculus}
We now make explicit the algebraic laws implicitly assumed
throughout the previous development. The goal is not to over-formalize,
but to clarify the minimal structural commitments required.
\subsection{Primitive Objects}
We begin by fixing a countable set of atomic names $\mathcal{A}$. These atoms serve as the minimal distinguishable commitments within the system. A \emph{region} is defined to be a finite subset $R \subseteq \mathcal{A}$, representing a finite collection of such commitments.
In addition, we assume the presence of an equivalence relation $\sim$ over $\mathcal{A}$. This relation governs which distinctions are to be regarded as structurally irrelevant. All regions are interpreted modulo this equivalence: two regions are considered identical when their elements coincide up to the identifications induced by $\sim$. In this way, equivalence relations provide the formal mechanism by which collapse operates over accumulated structure.
\subsection{Primitive Operations}
Two operations are primitive:
\paragraph{Merge.}
\[
\oplus : \mathcal{R} \times \mathcal{R} \to \mathcal{R}.
\]
\paragraph{Collapse.}
\[
\operatorname{collapse}_\sim : \mathcal{R} \to \mathcal{R}/\sim.
\]
\subsection{Structural Laws}
The following axioms govern merge and collapse.
\paragraph{(M1) Associativity.}
\[
(R_1 \oplus R_2) \oplus R_3
=
R_1 \oplus (R_2 \oplus R_3).
\]
\paragraph{(M2) Identity.}
There exists an empty region $\varnothing$ such that
\[
R \oplus \varnothing = R.
\]
\paragraph{(M3) Commutativity (optional).}
If order is not semantically significant:
\[
R_1 \oplus R_2 = R_2 \oplus R_1.
\]
\paragraph{(C1) Idempotence of Collapse.}
\[
\operatorname{collapse}_\sim(\operatorname{collapse}_\sim(R))
=
\operatorname{collapse}_\sim(R).
\]
\paragraph{(C2) Canonical Projection.}
Collapse yields a unique representative region
for a given equivalence class.
\paragraph{(C3) Stability under Merge.}
\[
\operatorname{collapse}_\sim(R_1 \oplus R_2)
=
\operatorname{collapse}_\sim(
\operatorname{collapse}_\sim(R_1)
\oplus
\operatorname{collapse}_\sim(R_2)
).
\]
This law ensures evaluation order independence.
\subsection{Derived Laws}
From the axioms governing merge and collapse, several important consequences follow. First, normalization is confluent: distinct sequences of merge operations, when followed by collapse under a fixed equivalence relation $\sim$, yield canonically identical regions. This ensures that evaluation order does not affect denotation.
Second, denotation is deterministic once $\sim$ is fixed. Because collapse produces a unique representative for each equivalence class, the meaning of a region depends only on its accumulated commitments and the governing identifications, not on the history by which it was assembled.
Finally, the operations remain compatible with monoidal structure. Merge is associative with an identity element, and collapse respects this structure by acting as a projection that preserves equivalence classes under composition.
These derived properties are precisely those required for functional semantics to remain stable and for type-theoretic invariants to be preserved under transformation. They do not arise from additional constraints; they are structural consequences of the axioms already in place.
\subsection{Abstraction as Quotient Introduction}
Abstraction is formalized as controlled extension
of the equivalence relation.
Given $x \in \mathcal{A}$ and region $R$,
application introduces $x \sim a$
for some $a \in R$,
and collapse enforces the identification.
Thus abstraction is not primitive.
It is a derived operation:
quotient introduction followed by canonical projection.
\section{A Thermodynamic Interpretation of Optionality and Abstraction}
The merge--collapse calculus admits
a natural thermodynamic metaphor.
This metaphor is not essential,
but it clarifies the directionality of computation.
\subsection{Optionality as Degrees of Freedom}
Define optionality:
\[
\Omega(R) = |R|.
\]
Optionality measures distinguishable commitments.
It corresponds to degrees of freedom.
Merge tends to increase optionality.
Collapse tends to reduce it.
\subsection{Commitment and Work}
When two regions merge:
\[
R' = R_1 \oplus R_2,
\]
new structural commitments are introduced.
This resembles work input:
additional distinctions must be maintained.
When collapse identifies elements:
\[
R'' = \operatorname{collapse}_\sim(R'),
\]
distinctions are removed.
This resembles compression.
\subsection{Irreversibility and Canonical Form}
Collapse is idempotent and lossy:
once two atoms are identified,
the distinction cannot be recovered
without additional structure.
Thus collapse introduces irreversibility.
In functional programming,
evaluation similarly moves toward canonical form.
Normalization is entropy reduction
with respect to representational redundancy.
\subsection{Abstraction as Entropy Reduction}
Abstraction removes accidental distinctions.
If a region $R$ has optionality $\Omega(R)$,
and abstraction introduces identifications $\sim$,
then:
\[
\Omega(\operatorname{collapse}_\sim(R))
\le \Omega(R).
\]
This reduction corresponds to compression.
However, abstraction does not eliminate structure.
It preserves invariant relationships
while discarding irrelevant detail.
\subsection{Structured Equilibrium}
A fully collapsed region under fixed equivalence
represents structural equilibrium.
Further collapse has no effect.
Similarly, a normalized functional term
is in normal form.
The merge--collapse dynamic therefore mirrors:
\begin{center}
Expansion (merge)
$\longrightarrow$
Constraint (quotient)
$\longrightarrow$
Equilibrium (canonical collapse).
\end{center}
\subsection{Computation as Controlled Thermodynamic Flow}
Computation can thus be seen as
controlled redistribution of optionality.
Pure functional evaluation preserves total information
within a closed system,
but reorganizes it into canonical structure.
Side effects correspond to untracked merge operations.
Mutation corresponds to uncontrolled collapse.
Spherepop enforces explicit merge
and disciplined collapse,
making structural flow transparent.
\subsection{Limits of the Metaphor}
The thermodynamic analogy developed above should not be pressed beyond its scope. Optionality, as defined in this calculus, is a combinatorial measure over regions; it does not correspond to physical entropy, nor does collapse model physical dissipation. The analogy is heuristic rather than literal.
Nevertheless, it remains instructive. Merge increases structural differentiation, expanding the space of explicit commitments. Collapse reduces differentiation by enforcing identifications under an equivalence relation. Abstraction functions as a controlled form of compression, selecting which distinctions are to be retained and which are to be rendered irrelevant. Canonical form represents a stable configuration under repeated collapse, analogous to equilibrium under a fixed constraint regime.
Under this interpretation, computation can be viewed as the disciplined reorganization of structural freedom. It proceeds not by arbitrary transformation, but by accumulation followed by invariant-preserving reduction. The thermodynamic metaphor serves only to illuminate this dynamic, not to replace the formal account that grounds it.
\section{Currying and Composition: From $\lambda$-Calculus to Unix Pipes}
Currying transforms a function of multiple arguments
into a sequence of single-argument functions.
In classical notation:
\[
f : A \times B \to C
\]
becomes
\[
f : A \to (B \to C).
\]
This transformation is not merely syntactic.
It reveals that multi-argument functions are
iterated region transformers.
\subsection{Currying as Iterated Merge}
In merge--collapse semantics,
a function is a region transformer:
\[
f(R) = \operatorname{collapse}(R \oplus S_f).
\]
If $f$ depends on two inputs,
we may write:
\[
f(R_1, R_2)
=
\operatorname{collapse}(R_1 \oplus R_2 \oplus S_f).
\]
Currying reorganizes this into:
\[
f(R_1)(R_2)
=
\operatorname{collapse}(R_2 \oplus
\operatorname{collapse}(R_1 \oplus S_f)).
\]
Thus currying stages merge.
The first application partially commits structure.
The second completes it.
\subsection{Partial Application as Structural Commitment}
Consider a function
\[
\texttt{add} : \mathbb{N} \to \mathbb{N} \to \mathbb{N}.
\]
Applying one argument:
\[
\texttt{add}\; 2
\]
does not compute a number.
It produces a new transformer:
\[
x \mapsto 2 + x.
\]
Structurally, this corresponds to merging the commitment
for $2$ into the function region,
while leaving the second parameter uncollapsed.
Partial application is therefore controlled early merge.
\subsection{Unix Pipes as Sequential Composition}
Unix pipelines provide a useful operational analogy for sequential composition. Consider the command
\begin{verbatim}
cat file.txt | grep pattern | sort
\end{verbatim}
Each component in this pipeline consumes a stream, produces a transformed stream, and passes its output to the next stage. The composition is linear and associative: the output of one transformation becomes the input of the next, and the grouping of stages does not affect the final result so long as their order is preserved.
Currying expresses the same compositional structure within the $\lambda$-calculus. By reducing multi-argument functions to sequences of unary transformations, currying enables functions to be chained in a manner analogous to pipelines. Each application produces an intermediate result that serves as the input to the subsequent stage. The pipe operator in Unix and function composition in the $\lambda$-calculus thus reflect the same structural principle: sequential accumulation of transformation under associative composition.
Instead of:
\[
f(x,y,z),
\]
we write:
\[
f(x)(y)(z).
\]
Each stage produces an intermediate transformer,
analogous to a stream flowing through a pipe.
\subsection{Pipes as Region Flow}
Let $S$ represent a region encoding a data stream.
A pipeline:
\[
h \circ g \circ f
\]