\documentclass[10pt,twocolumn,letterpaper]{article}
\usepackage{mathpazo}
\usepackage[letterpaper,top=.76in,bottom=.74in,left=.66in,right=.66in,
  headheight=14pt,headsep=13pt,footskip=24pt,columnsep=.27in]{geometry}
\usepackage{amsmath,amssymb,amsthm}
\usepackage{microtype,booktabs,graphicx,xcolor,fancyhdr,titlesec}
\definecolor{ink}{HTML}{123953}
\definecolor{muted}{HTML}{4E5C65}
\usepackage[unicode,colorlinks,linkcolor=ink,citecolor=ink,urlcolor=ink]{hyperref}
\hypersetup{pdftitle={Guarded Recursion for Meta-Learning Factories},
  pdfsubject={Higher categorical semantics, Lean proofs, and QEMU replay}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[L]{\footnotesize\sffamily\color{muted}GUARDED RECURSION FOR META-LEARNING FACTORIES}
\fancyhead[R]{\footnotesize\sffamily\color{muted}RESEARCH MANUSCRIPT}
\fancyfoot[R]{\small\sffamily\color{muted}\thepage}
\renewcommand{\headrulewidth}{.35pt}
\titleformat{\section}{\large\bfseries\raggedright}{\thesection}{.65em}{}
\titleformat{\subsection}{\normalsize\bfseries\raggedright}{\thesubsection}{.65em}{}
\titlespacing*{\section}{0pt}{2.0ex plus .4ex minus .2ex}{.8ex}
\titlespacing*{\subsection}{0pt}{1.5ex plus .3ex minus .2ex}{.55ex}
\raggedbottom
\setlength{\parindent}{1em}
\setlength{\parskip}{0pt}
\setlength{\emergencystretch}{1.2em}
\allowdisplaybreaks[1]
\theoremstyle{plain}
\newtheorem{theorem}{Theorem}[section]
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{proposition}[theorem]{Proposition}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newcommand{\E}{\mathcal X}
\newcommand{\Spaces}{\mathcal S}
\newcommand{\N}{\mathbb N}
\newcommand{\Map}{\operatorname{Map}}
\newcommand{\Alg}{\operatorname{Alg}}
\newcommand{\colim}{\operatorname*{colim}}
\newcommand{\Eq}{\operatorname{Eq}_{h}}
\newcommand{\id}{\mathrm{id}}
\newcommand{\haltlabel}{\mathsf{stop}}
\newcommand{\cont}{\mathsf{next}}
\newcommand{\hole}{\mathsf{hole}}
\newcommand{\node}{\mathsf{node}}

\begin{document}
\twocolumn[{%
\begin{minipage}{\textwidth}
{\small\sffamily\bfseries\color{ink} HIGHER CATEGORICAL SEMANTICS\par}
\vspace{.10in}
{\fontsize{25}{28}\selectfont\bfseries Guarded Recursion for\\[-.04in] Meta-Learning Factories\par}
\vspace{.04in}
{\large\color{muted}Finite construction records, behavioral semantics, and executable replay\par}
\vspace{.11in}
{\color{ink}\hrule height .75pt}
\vspace{.10in}
\small
\textbf{Abstract.}
An autonomous factory that can construct a successor has two recursive descriptions.
Its finite construction records are inductive, while observations of its controller unfold coinductively.
For an arity-bounded polynomial in an $\infty$-topos, we construct the homotopy-initial algebra of construction records and a unique guarded solution whose limit gives terminal behavior.
A truncation theorem relates finite records with holes to controller observations.
A conserved credit budget bounds the number of paid births and yields a sufficient observation horizon for the executable fragment.
The example learns a binary initialization for a support/query adaptation rule and passes it to a daughter.
Lean checks the discrete semantics and both unary and branching accounting.
In QEMU, daughters booted from complete ELF images emitted by their parents and matched the Lean reference over 188 valid boots, including 110 verified births.
Eight malformed manifests were rejected.
\vspace{.05in}\par
\textbf{Keywords.} Guarded recursion, $\infty$-topos, polynomial functor, coalgebra, meta-learning, simulation.
\end{minipage}
\vspace{.15in}
}]
\thispagestyle{plain}

\section{Problem and scope}
A factory controller can deliver a product or install a successor with the same factory interface.
A product with sensing, decision, and actuation, such as a vehicle with a driving controller, motivates the distinction between these roles.
For example, Tesla's Model~3 manual describes Full Self-Driving (Supervised) as a driver-assistance feature that requires an attentive driver~\cite{tesla}.
Here, autonomy refers to a simulated controller making its own decision to produce a successor inside a run.

A finite witness of successful assembly admits structural induction.
A controller that can start a successor admits finite observations even when the specification has no given maximum depth.
Its observable behavior includes when work stops, the costs paid, and the state delivered to a successor.
A meta-learner makes that state depend on adaptation across tasks.

Self-replicating lunar manufacturing was investigated as a design study~\cite{nasa}, and physical modular self-reproduction has been demonstrated in a different setting~\cite{zykov}.
The experiments here concern a virtual factory with three simulated components and a self-copying controller image.
The factory constructs a complete daughter executable in a guest.
A host harness starts a fresh guest from the emitted bytes.
This operational definition allows a reproducible test of inherited state and recursive execution.

The paper gives an $\infty$-categorical interpretation, an accounting invariant for branching lineages, and a discrete adequacy theorem checked by Lean.
The formalization is aligned with the deterministic guest by an independent executable comparison.

\section{Construction and observation}
\subsection{Ambient category}
Let $\E$ be an $\infty$-topos with initial object $0$ and terminal object $1$.
One choice is $\operatorname{Fun}(\mathcal C^{op},\Spaces)$, where a small category $\mathcal C$ indexes observation or interface contexts and $\Spaces$ denotes spaces.
For parameters varying in $P\in\E$, the same constructions live in the slice $\E_{/P}$.
In the latter case $1$ denotes the identity on $P$, and products are taken over $P$.
An object of labels may therefore carry both parameter dependence and automorphisms.
We use standard properties of $\infty$-topoi, including left exactness of filtered colimits and pointwise computation of limits in functor categories~\cite{lurie}.

\begin{definition}[Constructor signature]\label{def:signature}
Fix $d<\infty$ and label objects $A_k\in\E$ for $0\leq k\leq d$.
Define the endofunctor
\[
F(X)=\coprod_{k=0}^d A_k\times X^k .
\tag{1}\label{eq:poly}
\]
An element of $A_k$ describes an event with $k$ successor slots.
The nullary labels record completed or terminal events.
In the controller, event labels can record observations, the choice of initialization, and debit information.
In construction syntax, they can record assembly operations and component interfaces.
\end{definition}

The signature in~\eqref{eq:poly} uses ordered slots.
One can give $A_k$ an action of the symmetric group $\Sigma_k$ and take homotopy orbits of the diagonal action on $A_k\times X^k$.
The sequential-colimit proof below also applies to this variant because homotopy orbits are colimits.
Polynomial functors and their compositional structure have a broader theory~\cite{gambino}.

An $F$-algebra is $(Z,a)$ with $a:FZ\to Z$.
The space of algebra maps from $(W,w)$ to $(Z,a)$ is the homotopy equalizer of the two maps
\[
\Map(W,Z)\rightrightarrows\Map(FW,Z),
\]
given by $f\mapsto f w$ and $f\mapsto aF(f)$.
Its points consist of a map and a specified commutative-square homotopy.
Initiality means that this entire mapping space is contractible~\cite{awodey}.
An $F$-coalgebra is $(S,\gamma)$ with $\gamma:S\to FS$.
An execution state contains every value on which the next event depends.
Dependence on hidden state or previously seen observations belongs in $S$.

\subsection{Finite construction records}
Let $W_0=0$, $W_{n+1}=FW_n$, and take the initial chain $i_0:0\to F0$, $i_{n+1}=F i_n$.
There is a canonical algebra structure on the colimit of this chain.

\begin{theorem}[Homotopy-initial construction algebra]\label{thm:initial}
For the signature~\eqref{eq:poly},
\[
 W=\colim_{n\in\N}W_n
 \quad\text{has}\quad w:FW\xrightarrow{\simeq} W.
\]
The algebra $(W,w)$ is initial in $\Alg_F(\E)$.
\end{theorem}

\begin{proof}
Sequential colimits commute with finite products in an $\infty$-topos.
Product with a constant label preserves colimits, as does coproduct over the arities.
Thus $F$ preserves the initial-chain colimit.
Cofinality of the successor shift gives
$FW\simeq\colim_n W_{n+1}\simeq W$.

Fix an algebra $(Z,a)$ and set $M_n=\Map(W_n,Z)$.
Write $r_n:M_{n+1}\to M_n$ for restriction and $t_n:M_n\to M_{n+1}$ for $x\mapsto aF(x)$.
For $n\geq1$, naturality gives $r_n t_n\simeq t_{n-1}r_{n-1}$.
The endomorphisms $T_0=\id$ and $T_{n+1}=t_n r_n$ give a coherent map of the tower. The identification $M_0\simeq 1$ supplies the initial compatibility.
On $\lim M_n\simeq\Map(W,Z)$ this map sends $f$ to $aF(f)w^{-1}$, as can be checked on the chain inclusions.
Algebra maps form $\Eq(\id,\lim T_n)$, which is $\lim_n\Eq(\id,T_n)$ because limits commute.

For $u:B\to A$ and $v:A\to B$, applying $u$ or $v$ to a point and its specified path induces maps
$\Eq(\id,vu)\rightleftarrows\Eq(\id,uv)$.
The composites apply the relevant endomorphism to the point and path.
They are homotopic to the identity by the specified path, whose naturality square commutes up to the canonical path-composition homotopy.
Apply this with $u=r_n$, $v=t_n$ and use $r_n t_n\simeq T_n$.
Each bonding map on the equalizers is an equivalence and the zeroth equalizer is contractible.
The limit is contractible.
\end{proof}

If all $A_k$ are discrete, $W$ is the set of finite rooted terms whose node labels and arities agree.
Its structure map installs a root above the supplied subterms.
An algebra map evaluates the term into any algebra of summaries, such as event logs or accumulated costs.
A label may contain additional local evidence of feasibility.
Without such evidence, initiality gives the syntax and its fold, while validity is a predicate on that syntax.

\subsection{Higher symmetries}
Consider $\E=\Spaces$, $A_0=BG$, $A_2=1$, and $A_1=0$.
Here $BG$ is the groupoid of a component interface whose automorphism group is $G$.
For an ordered full binary tree shape $T$ with $\ell(T)$ leaves, the corresponding summand of $W$ is
\[
 \prod_{j=1}^{\ell(T)} BG.
\]
This follows by induction on the finite chain and passage to the colimit, since the inclusions in this example add tree shapes.
For $G=\mathbb Z/2$, the automorphism group over $T$ is $(\mathbb Z/2)^{\ell(T)}$.
Replacing $BG$ by $K(G,m)$ for abelian $G$ and $m\geq2$ gives summands with nontrivial $\pi_m$.
Taking connected components retains the tree shape and identifies these distinct higher data.
Thus the denotation can carry higher structure even when the branching shape is deterministic.

\section{Guarded controller semantics}
\subsection{The topos of observation depths}
Define
\[
 \mathcal T(\E)=\operatorname{Fun}(\N^{op},\E).
\]
An object is a tower $X_0\leftarrow X_1\leftarrow\cdots$.
This diagram category is an $\infty$-topos. A left exact localization presenting $\E$ induces a pointwise left exact localization presenting $\mathcal T(\E)$.
For presheaf $\E$, it is the presheaf category on $\mathcal C\times\N$.
The delay functor satisfies
\[
 (\triangleright X)_0=1,\qquad
 (\triangleright X)_{n+1}=X_n .
\]
The first restriction is the terminal map and later restrictions come from $X$.
This is right Kan extension along the successor inclusion of $\N^{op}$.
There is a natural $X\to\triangleright X$, given by restriction at positive indices.
This is the observation-depth interpretation of the later modality from the topos of trees~\cite{birkedal}.

Let $F$ also denote pointwise application to a tower.
Starting from $B_0=1$, put $B_{n+1}=FB_n$.
For $p_n:B_{n+1}\to B_n$, let $p_0$ be the terminal map and set $p_{n+1}=F p_n$.
A state with $n+1$ observations available can emit its current event and give $n$ observations to each successor.

\begin{theorem}[Guarded unfolding]\label{thm:guarded}
The tower $Y_n=B_{n+1}$ has an equivalence $Y\simeq F(\triangleright Y)$.
The space of towers equipped with such a specified equivalence, with structure-preserving equivalences as morphisms, is contractible.
For a coalgebra $\gamma:S\to FS$, the maps
\[
 o_0={!}:S\to 1,\qquad o_{n+1}=F(o_n)\gamma
 \tag{2}\label{eq:observe}
\]
form a coherent cone to the $B_n$.
The cone with these unfolding equations is unique up to contractible choice.
\end{theorem}

\begin{proof}
The displayed solution satisfies the equations on objects and restrictions.
At stage $0$ a solution consists of an object with a chosen equivalence to $F1$.
That space is contractible.
Over a solution through stage $n$, stage $n+1$ adds an object with a chosen equivalence to $F(Y_n)$.
The naturality square for the new restriction identifies that arrow, under the chosen equivalences, with the restriction prescribed by $F\triangleright$.
The space of arrows equipped with a path to a specified arrow is contractible.
These data determine the next finite tower. The spine of a linearly ordered simplex determines the functor up to contractible coherent extension.
The restrictions of solution spaces therefore have contractible fibers.
Taking the limit proves the first assertion.

For the cone, $p_0o_1\simeq o_0$ by terminality.
Inductively, $p_{n+1}o_{n+2}=F(p_no_{n+1})\gamma\simeq F(o_n)\gamma=o_{n+1}$.
Recursively applying $F$ to the cone on the previous finite tower and precomposing with $\gamma$ supplies the higher compatibilities.
Equivalently, on the mapping-space tower $M_n=\Map(S,B_n)$ the cone is a fixed point of the endomorphism given at stage zero by the terminal map and at stage $n+1$ by $x\mapsto F(p_n x)\gamma$.
Here $p_n x$ means postcomposition.
The endomorphism factors at each stage through the preceding restriction.
Its homotopy equalizer with the identity is contractible by the same restriction argument as in Theorem~\ref{thm:initial}.
\end{proof}

\paragraph{Terminal coalgebra.}
For the ordered signature~\eqref{eq:poly}, $F$ preserves inverse sequence limits.
To see this, put $A=\coprod_k A_k$ and view $F(X)\to A$ in the slice.
Under $\E_{/A}\simeq\prod_k\E_{/A_k}$ its components are $A_k\times X^k\to A_k$.
Each component preserves limits because powers and pullback of $X\to 1$ preserve limits.
The underlying object of an inverse sequence limit in the slice is its limit in $\E$, since the indexing category has contractible nerve and the constant $A$ diagram has limit $A$.
Thus $F(\lim B_n)\simeq\lim FB_n$, and the shift gives a coalgebra on $B=\lim B_n$.
It is terminal by the dual initial-chain argument of Theorem~\ref{thm:initial}, and its map from $S$ is the cone of Theorem~\ref{thm:guarded}.
In sets, $F(X)=O\times(1+X)$ gives nonempty finite traces with a stop marker and infinite traces~\cite{jacobs}.

\paragraph{Change of context.}
For a geometric inverse-image functor $g^*$ between $\infty$-topoi, transporting the label objects transports the polynomial.
Finite products and all colimits are preserved.
Consequently $g^*$ commutes with the initial-chain colimit and each finite observation stage, including the restrictions.
This applies in particular to pullback between slices.
Commuting with an external limit $\lim B_n$ additionally requires preservation of that limit.
At higher types an identification of full observations consists of a coherent family of identifications in the tower.

\subsection{Truncated construction records}
Let $W^\sharp$ be the initial algebra of $G(X)=1+F(X)$ given by Theorem~\ref{thm:initial}.
The added nullary constructor $\hole$ marks a boundary where the observation has stopped unfolding.
A genuine terminal event is still a labeled node of arity zero.
Let $\node:FW^\sharp\to W^\sharp$ be the other part of the structure map.
Define
\begin{align*}
 j_0 &= \hole:1\to W^\sharp,\\
 j_{n+1} &= \node\circ F(j_n):B_{n+1}\to W^\sharp .
\end{align*}
The cut $T_k$ replaces subrecords at depth $k$ by $\hole$.
Formally, $T_0$ is constant at $\hole$, and the decomposition $W^\sharp\simeq 1+FW^\sharp$ gives
\[
 T_{k+1}=[\,\hole,\ \node\circ F(T_k)\,].
\]
In this equation the root has depth zero.

\begin{theorem}[Compatibility of construction and observation]\label{thm:cut}
Let $p_{n,k}:B_n\to B_k$ be the restriction for $k\leq n$.
There are canonical homotopies
\[
 T_k j_n\simeq j_k p_{n,k},\qquad
 T_k j_n o_n\simeq j_k o_k .
\]
In particular, the cut records $j_no_n$ recover the observation tower with its depth restrictions.
\end{theorem}

\begin{proof}
At $k=0$ both composites are the constant hole map.
For $k+1\leq n+1$, use $p_{n+1,k+1}=F(p_{n,k})$.
The left composite equals $\node F(T_kj_n)$, which is homotopic to
$\node F(j_kp_{n,k})=j_{k+1}p_{n+1,k+1}$ by induction.
The homotopies respect composition of restrictions by the functorial construction.
The second formula follows by precomposing with $o_n$ and using the cone identities.
For recovery at fixed depth, $j_0$ is a coproduct inclusion and therefore a monomorphism.
By induction $F(j_n)$ is a monomorphism because finite products and disjoint coproducts preserve monomorphisms in an $\infty$-topos.
The node map is also a coproduct inclusion.
Thus $j_n$ identifies $B_n$ with the subobject of records it represents.
\end{proof}

\section{Meta-learning and conservation}
\subsection{A two-level learner}
A task episode $e=(D_s,D_q)$ supplies support data and query data.
A hyperparameter $h\in H$ selects an initialization.
The inner map $U_h(D_s)$ adapts this initialization to a task.
The outer objective for a nonempty finite episode multiset $E$ is
\[
 J_E(h)=\sum_{(D_s,D_q)\in E}
        \ell\bigl(U_h(D_s),D_q\bigr).
 \tag{3}\label{eq:meta}
\]
A deterministic selector $M$ minimizes~\eqref{eq:meta} over the chosen finite $H$ and retains the inherited $h$ when it is among the minimizers.
For the two-element $H$ used here, that rule resolves every tie.
This is a finite support/query objective of the form used for learning an initialization for rapid adaptation~\cite{finn}.
The child inherits the selected hyperparameter and adapts afresh to its own episodes.

\paragraph{Composition in context.}
Let $D$ be the object of generation states other than the initialization, and write $S=D\times H$.
Given a morphism $m:D\times H\to H$ interpreting the outer update and a feasibility-and-assembly map $a:S\to FS$, the round map is
\[
 S\xrightarrow{(\pi_D,m)}S\xrightarrow{a}FS.
\]
One can retain the input initialization in the event label by carrying it as an additional parameter through $a$.
In the slice over a task context, equivariant data and update maps give the same composition there.
The unfolding is natural in coherent coalgebra maps: if
$\gamma' f\simeq F(f)\gamma$, then $o'_n f\simeq o_n$ coherently in $n$.
Indeed, both families have the same zero stage and satisfy the unfolding equations~\eqref{eq:observe}.
Thus a change of controller representation that preserves the update and assembly coalgebra preserves its observations.

For the guest, $H=\{0,1\}$.
A support observation $s$ is either a bit or absent, and a query $q$ is a bit.
The inner update is $U_h(s)=s$ if present and $U_h(\varnothing)=h$ otherwise.
Loss is $[U_h(s)\ne q]$.
Let $t(g)=[g\bmod4<2]$ be the target at generation $g$ and $\bar t=1-t$.
The training episode list $E_g$ and validation episode list $V_g$ are
\begin{align*}
 E_{2j} &= [(\varnothing,t),(\varnothing,t),
             (\varnothing,\bar t),(\bar t,\bar t)],\\
 E_{2j+1} &= [(\varnothing,t),(\varnothing,\bar t),
             (t,t),(\bar t,\bar t)],\\
 V_g &= [(\varnothing,t),(\bar t,\bar t),
            (\varnothing,t),(t,t)] .
\end{align*}
In each line $t=t(g)$ for that line's generation.
On even generations $M=t$ with training loss $1$, against $2$ for $\bar t$.
On odd generations both choices have training loss $1$.
The validation loss $Q_g(h)$ is $0$ when $h=t(g)$ and $2$ otherwise.
The rule adapts to the support observation on each episode, and the missing-support episodes make the initialization observable.
Validation uses a separate deterministic episode list from the same task generator.

\subsection{State, transition, and inheritance}
The concrete state is $s=(g,b,h)$, with generation $g$, natural credit balance $b$, and inherited bit $h$.
Set $\hat h=M(E_g,h)$, $q=Q_g(\hat h)$, and $c=3+q$.
The controller emits $o(s)$, the round record containing $s$, the two training losses, $\hat h$, the validation losses for the selected and fixed priors, $c$, and the optional child.
Its coalgebra for $F(X)=O\times(1+X)$ is
\[
 \gamma(s)=
 \begin{cases}
 (o(s),\cont(g+1,b-c,\hat h)) & b\geq c,\\
 (o(s),\haltlabel) & b<c.
 \end{cases}
 \tag{4}\label{eq:transition}
\]
The three base credits correspond to the three component flags.
The extra charge ties learner performance to feasibility in the model.
The task generator depends on $g$ and the transition is deterministic.
A lineage may differ in length solely because of inheritance.
At $(g,b)=(1,3)$, inherited $1$ leads to a daughter with $(g,b,h)=(2,0,1)$.
Resetting the bit to $0$ gives cost $5$, so it stops at the same input generation.
The odd-generation tie makes this comparison sensitive specifically to the inherited bit.

\subsection{Accounting for branching lineages}
The unary guest implements a special case of the following invariant.
A funded state carries $b\in\N$.
An expansion replaces it by $k\leq d$ funded child states with balances $b_i$, emits a cost $c\geq\delta>0$, and satisfies
\[
 b=c+\sum_{i=1}^k b_i.
 \tag{5}\label{eq:budget}
\]
A paid expansion has at least one child. An unexpanded state, including a state that stops, retains its unspent balance in the frontier accounting.
Any parent that participates again must itself be represented by a funded successor.
Thus the invariant counts all outstanding claims, including any continuation of the parent.

\begin{proposition}[Conservation and finite horizon]\label{prop:budget}
After any finite sequence of paid expansions from a root with balance $b_0$,
\[
 \sum_{u\in\mathrm{frontier}}b_u
  +\sum_{v\in\mathrm{expanded}}c_v=b_0.
 \tag{6}\label{eq:conserved}
\]
There are at most $\lfloor b_0/\delta\rfloor$ paid expansions, at most
$1+d\lfloor b_0/\delta\rfloor$ created state nodes, and at most
$\lfloor b_0/\delta\rfloor+1$ observation levels along a lineage.
If every transition either stops or performs a paid expansion, the cut records of Theorem~\ref{thm:cut} stabilize by that level.
\end{proposition}

\begin{proof}
Initially the sole balance is $b_0$.
For each expansion, replace the removed balance $b$ by the debit and child balances in~\eqref{eq:budget}; this preserves~\eqref{eq:conserved}.
After $m$ paid events the debit sum is at least $\delta m$, and all residual balances are nonnegative.
The node count uses at most $d$ new nodes per expansion.
An observed path consists of paid expansions and at most one final stop.
This bounds its required observation depth.
\end{proof}

The selector may alter the costs and therefore change realized lineages.
Accounting uses the conservation equation and the lower bound on each debit.
If the controller can wait without consuming credits, the count still bounds paid births. A bound on clock steps requires a bound on waiting.

\section{Executable adequacy}
\subsection{Inductive records and finite observations}
For a deterministic coalgebra $\gamma:S\to O\times(1+S)$ in sets, define
$\operatorname{obs}_0(s)=[\,]$ and
\[
 \operatorname{obs}_{n+1}(s)=
 \begin{cases}
 [o] & \gamma(s)=(o,\haltlabel),\\
 o::\operatorname{obs}_n(s') & \gamma(s)=(o,\cont s').
 \end{cases}
 \tag{7}\label{eq:list}
\]
This is the list decoding of~\eqref{eq:observe}.
At the truncation boundary the decoder forgets the successor tag unless the event label records it.
The concrete round label has an explicit optional child field, so the reported logs retain the tag at every emitted round.

Let $R$ be the free algebra of $G_{\mathrm{list}}(X)=1+O\times X$.
Write $\mathrm{end}$ for the nullary constructor and
$\mathrm{extend}(o,r)$ for the unary constructor.
Define $R_n(s)$ by~\eqref{eq:list} with $[\,]$ replaced by $\mathrm{end}$ and cons by $\mathrm{extend}$.
In the stop case the result is $\mathrm{extend}(o,\mathrm{end})$.
Equivalently, the fold from $W^\sharp$ to $R$ sends a hole to $\mathrm{end}$ and both kinds of labeled nodes to $\mathrm{extend}$, with an empty tail for a nullary labeled node.
The universal map $\mathrm{fold}:R\to\operatorname{List}(O)$ uses $[\,]$ and cons as the target constructors.

\begin{theorem}[Finite-depth adequacy]\label{thm:adequacy}
For any deterministic unary coalgebra in sets,
\[
 \mathrm{fold}(R_n(s))=\operatorname{obs}_n(s).
\]
For $k\leq n$, taking the first $k$ observations of $\operatorname{obs}_n(s)$ gives $\operatorname{obs}_k(s)$.
The compatible family satisfying~\eqref{eq:list} is unique.
For~\eqref{eq:transition}, $\operatorname{obs}_n(s)$ stabilizes for
$n\geq\lfloor b/3\rfloor+1$.
\end{theorem}

\begin{proof}
For depth zero the fold returns the empty list.
At positive depth both definitions prepend the same $o$.
A stopping branch has no tail, and a continuing branch has the same tail by induction on depth.
Prefix compatibility follows by induction on $k$ with $n$ and $s$ generalized.
When $k>0$, also $n>0$, and the two traces have the same head.
For a stop there is nothing to truncate after the head.
For a successor use the induction hypothesis with $k-1$ and $n-1$.
Uniqueness follows by induction on the stage equations.
Finally, each successor decreases the balance by at least three and the final stop contributes one observation.
Equivalently, induction on $k$ proves that $b<3k$ implies
$\operatorname{obs}_{k+j}(s)=\operatorname{obs}_k(s)$ for all $j$.
\end{proof}

\subsection{Lean proof boundary}
\texttt{Factory/Semantics.lean} contains the abstract unary observation function, the finite-record fold, and the compatible-family object.
The Lean kernel checks uniqueness of the record fold, finite-depth adequacy, and uniqueness of the compatible family.
It also checks optimality of the finite selector, credit conservation along the lineage, and stabilization of the observation for every natural input balance and every extension of the stated horizon.
\texttt{example\_lineage} and \texttt{example\_inheritance} are concrete decision proofs.

The artifact uses the Lean~4.19.0 standard library~\cite{lean}.
The transcript lists the axioms of the exported results with
\texttt{\#print axioms}.
The reported dependencies are drawn from Lean's standard
\texttt{propext}, \texttt{Classical.choice}, and \texttt{Quot.sound}.
The executable computes the finite reference trace.
\texttt{Factory/Branching.lean} checks the cut identity, injectivity of the stage embeddings, and the accounting bound for branching ledgers in sets.
The $\infty$-topos theorems are proved in Sections 2 and 3.
The C guest and boot path are checked by differential replay on the specified inputs.

\section{QEMU experiments}
\subsection{Boot and handoff protocol}
Each 32-bit Multiboot guest runs one factory generation with a single virtual CPU under QEMU's TCG accelerator~\cite{qemu}.
Each lineage begins with a freestanding ELF seed image and a Multiboot module for its starting state.
The VM has no network interface or writable guest disk.
The seed manifest is a 24-byte little-endian record of six unsigned 32-bit words:
magic, format version, generation, credits, inherited bit, and component mask.
The expected mask is $7$, the union of the simulated frame, controller, and fabricator flags.
The guest validates the incoming manifest, computes one controller round, assembles the simulated component flags if it can pay, and emits a JSON observation over serial.
For a birth it copies its mapped ELF prefix, including program headers, and replaces the embedded manifest.
The emitted image carries the controller and the complete daughter state.
The guest sends the image and the manifest as hex bytes, then QEMU exits through the ISA debug-exit device.

The Python replay harness records the serial output, checks the embedded manifest against the Lean prediction, and verifies that the executable matches the seed's normalized loadable bytes outside the manifest slot.
It passes the unmodified daughter image to QEMU as the next kernel.
The daughter boots from its embedded state without an external manifest.
Each observed child must appear as a subsequent boot.
The host provides the emulator and schedules each guest.
The C interface accepts $b\leq120$, $h\in\{0,1\}$, and $g+\lfloor b/3\rfloor\leq 10^6$.
These bounds keep guest arithmetic in range and the largest input can produce at most 40 births.
The Lean theorems use unbounded natural numbers.

\subsection{Design and measured results}
The suite comprises six named scenarios, a grid of 72 initial states, and eight malformed inputs.
The grid covers all four generation residues, credit balances $0$ through $8$, and both priors.
The named cases include the high-credit and high-generation limits, the unaffordable case, and the matched inheritance intervention.
For every valid boot the harness compares the complete round JSON to the compiled Lean reference and checks daughter bytes when present.
Malformed inputs test missing components, version, magic, short or long records, out-of-range prior, credits, and generation.

\begin{table}[!ht]
\centering
\small
\begin{tabular}{@{}lrrr@{}}
\toprule
Input $(g,b,h)$ & Boots & Births & Query loss\\
\midrule
Lineage $(0,16,0)$ & 6 & 5 & 0\\
Inherited $(1,3,1)$ & 2 & 1 & 0\\
Reset $(1,3,0)$ & 1 & 0 & 2\\
Low credit $(0,2,0)$ & 1 & 0 & 0\\
Max credit $(0,120,0)$ & 41 & 40 & 0\\
Max generation $(10^6,2,1)$ & 1 & 0 & 0\\
Grid (72 inputs) & 136 & 64 & ---\\
\midrule
All valid runs & 188 & 110 & ---\\
\bottomrule
\end{tabular}
\caption{QEMU TCG results. Query loss sums validation errors over observed rounds, including the terminal round.}
\label{tab:results}
\end{table}

All 188 valid boots matched the Lean reference, 110 produced verified daughters, and the eight malformed inputs returned the expected rejection.
The six-round lineage had balances $16,13,10,7,4,1$ and selected priors $1,1,0,0,1,1$.
Its aggregate query error was $0$.
Evaluating the fixed priors $0$ and $1$ on the same six generations gave $8$ and $4$ errors respectively.
These are counterfactual query scores on a shared set of tasks. Enforcing those priors during execution can change which generations are reached.
The matched inherited/reset case at $(1,3)$ compares actual births with the same generation, budget, and episode generator.

The periodic target and chosen starting state make correct inheritance persist through ties in the main lineage.
Starting on an odd generation with a mismatched bit gives the counterexample in Table~\ref{tab:results}.
The results establish the behavior of the finite objective and its effect on the declared budget in this generator.
Generalization to other task distributions requires separate evidence.

\subsection{Replication protocol}
The accompanying bundle contains the \LaTeX{} source, Lean sources, the guest sources and linker script, the replay harness, the proof transcript, tool versions, all observed serial logs, manifests and daughter images, and a machine-readable expected summary.
On a host with Lean~4.19.0, GNU make, a compiler and binutils supporting i386 ELF, Python~3, and QEMU with the specified PC machine model, \texttt{make verify} builds and checks the Lean code, builds the guest, and repeats the differential comparison.
It checks the resulting summary against the captured one.
\texttt{make paper} builds the two-column manuscript.
The README gives the commands and output locations.
The reported replay used QEMU~10.0.13 with the versioned \texttt{pc-i440fx-7.2} machine model, GCC~14.2.0, and Lean~4.19.0.

\section{Interpretation}
The initial algebra gives a universal evaluation rule for finite construction witnesses, including labels with higher symmetries.
The guarded coalgebra gives a universal rule for observations of successive execution stages.
The cut theorem connects them at each finite depth.
With positive conserved credits, the cut captures the entire run at a calculable depth.
The executable intervention shows that inherited meta-state can determine the existence of the next factory even when assembly code and starting resources are identical.

The production model assumes a fixed component signature, an exogenous task generator, and a cost rule.
A model of physical closure would need an operational account of component sourcing, metrology, repair, and the infrastructure that starts and verifies a successor.
The QEMU evidence covers the emulated controller, assembly flags, and byte-for-byte reproduction of the bootable factory described above.

\paragraph{Artifact and assistance statement.}
The manuscript, proof sources, and experiment were prepared with AI assistance.
The reproducibility bundle contains the complete computational inputs and reported outputs.

\begin{thebibliography}{10}
\small
\bibitem{lurie} J. Lurie.
\href{https://arxiv.org/abs/math/0608040}{\emph{Higher Topos Theory}}.
Annals of Mathematics Studies 170, Princeton University Press, 2009.

\bibitem{gambino} N. Gambino and J. Kock.
\href{https://arxiv.org/abs/0906.4931}{Polynomial functors and polynomial monads}.
\emph{Math. Proc. Cambridge Philos. Soc.}, 154(1), 153--192, 2013.

\bibitem{awodey} S. Awodey, N. Gambino, and K. Sojakova.
\href{https://arxiv.org/abs/1504.05531}{Homotopy-initial algebras in type theory}.
arXiv:1504.05531, 2015.

\bibitem{birkedal} L. Birkedal, R. E. M\o gelberg, J. Schwinghammer, and K. St\o vring.
\href{https://arxiv.org/abs/1208.3596}{First steps in synthetic guarded domain theory}.
\emph{Log. Methods Comput. Sci.}, 8(4), 2012.

\bibitem{jacobs} B. Jacobs.
\href{https://doi.org/10.1017/CBO9781316823187}{\emph{Introduction to Coalgebra: Towards Mathematics of States and Observation}}.
Cambridge University Press, 2016.

\bibitem{finn} C. Finn, P. Abbeel, and S. Levine.
\href{https://proceedings.mlr.press/v70/finn17a.html}{Model-agnostic meta-learning for fast adaptation of deep networks}.
\emph{Proc. ICML}, PMLR 70, 1126--1135, 2017.

\bibitem{nasa} NASA/ASEE study team.
\href{https://ntrs.nasa.gov/citations/19830007081}{Replicating systems concepts: self-replicating lunar factory and demonstration}.
\emph{Advanced Automation for Space Missions}, NASA CP-2255, 1982.

\bibitem{zykov} V. Zykov, E. Mytilinaios, B. Adams, and H. Lipson.
\href{https://www.nature.com/articles/435163a}{Self-reproducing machines}.
\emph{Nature}, 435, 163--164, 2005.

\bibitem{tesla} Tesla.
\href{https://www.tesla.com/ownersmanual/model3/en_us/Owners_Manual.pdf?download=1}{\emph{Model 3 Owner's Manual}}, U.S. edition.
Full Self-Driving (Supervised) and limitations.

\bibitem{lean} Lean FRO and contributors.
\href{https://lean-lang.org/doc/reference/latest/releases/v4.19.0/}{Lean 4.19.0 release notes}, 2025.

\bibitem{qemu} QEMU contributors.
\href{https://www.qemu.org/docs/master/system/invocation.html}{QEMU system invocation manual}.
\end{thebibliography}
\end{document}
