Unfolding Expressions in Computational Semantics
- Unfolding expressions are operations that convert implicit or folded representations into explicit forms while preserving essential structural invariants.
- They are applied in diverse fields, including geometry, high-energy physics, electronic structure, functional programming, and type theory.
- Practical applications range from edge-unfolding polyhedra and histogram reconstruction to controlled unfolding in proof assistants and constraint handling rules in program transformations.
“Unfolding expressions” denotes a family of operations in which a compact, implicit, folded, or detector-distorted representation is replaced by a more explicit one. In the supplied literature, the term ranges from cutting and flattening polyhedral surfaces into planar nets, to generating lists by anamorphisms, to reconstructing truth-level histograms from detector-level counts, to substituting recursive definitions in -letrec, to locally replacing constants by their defining expressions in dependent type theory, to inlining CHR constraints, to deriving source-level facts for lazy functional programs, and to assigning supercell eigenstates weights in the primitive Brillouin zone 0509054. A common thread is expansion under structural constraints: cuts must avoid overlap, coalgebras must terminate, recursive substitutions must preserve expressibility, and optimization or projection operators must preserve the relevant semantics.
1. Geometric and physical meanings of unfolding
In computational geometry, an edge-unfolding of a polyhedron is produced by cutting along edges and flattening the faces to a net, a connected planar piece with no overlaps. A grid unfolding allows additional cuts along grid edges induced by coordinate planes passing through every vertex, and a vertex-unfolding permits faces in the net to be connected at single vertices, not necessarily along edges [0509054]. For orthogonal polyhedra, the central result is that any orthogonal polyhedron of genus zero has a grid vertex-unfolding, and for an orthogonal polyhedron with vertices there is an algorithm that vertex-unfolds in time; the same work also presents a simpler vertex-unfolding algorithm that requires a refinement of the vertex grid [0509054]. The supplied material also states that there are orthogonal polyhedra that cannot be vertex-unfolded, so some type of gridding of the faces is necessary [0509054].
In high-energy physics, unfolding is the inverse problem of reconstructing true distributions of physical observables from detector-distorted measurements. At the level of probability densities, the detector is modeled by a response function
and the expected reconstructed distribution is
In the discretized formulation,
with unfolding defined as estimating from 0, 1, and 2 subject to physical constraints (Gasperini et al., 26 Feb 2026).
In electronic-structure theory, band structure unfolding reverses the folding caused by supercell calculations. Primitive-cell bands are folded into the reduced supercell Brillouin zone, and unfolding assigns to each supercell eigenstate a weight at each primitive-cell 3. The resulting unfolded spectral function is
4
with unfolding weight
5
The AO-based formulation explicitly accounts for the non-orthogonality of atomic orbitals and their atom-centered nature, and the implementation in FHI-aims is presented as enabling accurate and efficient unfolding of conduction, valence, and core states (Quan et al., 26 Jun 2025).
These cases all involve explicit expansion of latent structure, but the object being “unfolded” differs: a surface in geometry, a truth-level spectrum in HEP, and a supercell eigenspace in electronic structure. This suggests that “unfolding” is best treated as a structural operator rather than a single domain-specific procedure.
2. Unfolding as generation, recursion, and symbolic expansion
In recursion-scheme–based program synthesis, unfolding appears concretely as the anamorphism pattern. Origami’s list anamorphism is
9
with {1} the initial seed, {2} the predicate, {3} the head element, and {4} the next seed (Fernandes et al., 2024). The same source states that anamorphisms generate data structures from seeds, while hylomorphisms compose an anamorphism and a catamorphism:
0
and explicitly describes Hylo as “captur[ing] an Anamorphism followed by a Catamorphism, such as applying foldr to the result of unfold” (Fernandes et al., 2024).
The role of unfolding in Origami is methodological as well as operational. The recursion scheme is fixed, and only slots are evolved by Genetic Programming, so the unfolding shape is not synthesized; rather, the GP searches for the initial seed, the termination test, the element generator, and the seed transformer (Fernandes et al., 2024). The stated motivation is that recursion schemes decouple how to traverse or generate the data structure from how to process it, thereby avoiding some of the pitfalls of recursive functions during program synthesis (Fernandes et al., 2024).
In the unfolding semantics of higher-order, lazy functional programs, unfolding is a systematic way of “executing” a functional program symbolically by repeatedly replacing function calls with their definitions, producing a set of derived equations or facts. The language includes variables, constructors, user-defined functions, and predefined functions, with higher-order application encoded by @, and the semantics iterates an unfolding operator 6 over interpretations: 7
The meaning of a program is the least fixpoint or limit 8 (Rey-Poza et al., 2017). The paper emphasizes that these facts themselves are valid source code and can be used as a semantic representation of the program (Rey-Poza et al., 2017).
In both settings, unfolding is not merely expansion by substitution. In Origami it is a typed synthesis template over coalgebras; in unfolding semantics it is an interpretation transformer over facts, guards, and predefined functions. A plausible implication is that “unfolding expressions” in programming-language research often denotes controlled generation of explicit operational structure rather than unrestricted inlining.
3. Unfolding semantics in 9-letrec and related calculi
For the untyped 0-calculus with letrec, unfolding is the process of substituting occurrences of function variables by the right-hand side of their definition. A finite 1-letrec term expresses an infinite 2-term if the latter can be obtained as an infinite unfolding of the former (Rochel, 2016). The supplied material gives the intuitive example
3
which unfolds to the infinite 4-term
5
Formally, unfolding is defined by rewriting systems 6 and 7, with partial unfolding semantics
8
and total unfolding semantics with black holes
9
Theorem 1.25 is reported as establishing that these are well-defined functions (Rochel, 2016).
The central characterization theorem states: 0 The supplied details further state that a regular 1-term is strongly regular iff all its binding–capturing chains are finite (Rochel, 2016). This turns unfolding from an operational intuition into a criterion for expressibility.
Equality of unfoldings is also made algorithmic. The same work identifies a first-order term graph formalism on which bisimulation preserves and reflects the unfolding semantics of 2-letrec and which is closed under functional bisimulation, and from this derives efficient methods to determine whether two terms are equivalent under infinite unfolding and to compute the maximally shared form of a given 3-letrec term (Rochel, 2016). The graph-theoretic layer is therefore not ancillary: it is the mechanism by which infinite unfolding is compared and compressed finitely.
This literature treats unfolding as a semantics for recursive syntax. Unlike the recursion-scheme literature, where unfolds generate data from seeds, here unfolds map finite recursive syntax into infinite terms by rewriting, with regularity and bisimulation providing the corresponding invariants.
4. Controlled unfolding in type theory and proof assistants
In dependent type theory, unfolding is the operation of replacing a constant or definition by its defining expression. The supplied material gives addition as the canonical example: 4 with defining equations
5
Unfolding plus in 6 means replacing occurrences of + by these clauses and reducing (Gratzer et al., 2022).
“Controlling unfolding in type theory” proposes that definitions are opaque by default and can be selectively unfolded in a local manner. A top-level annotation such as
1
makes + transparent within the body of (⊕), while outside (⊕) it remains opaque (Gratzer et al., 2022). The details further state that unfolding is local and transitive: if definition 7 is unfolded and 8's body uses 9, then it must be legal to unfold 0 as well, and this is enforced via proposition symbols that track unfolding entailment (Gratzer et al., 2022).
The formal core calculus 1 introduces proposition symbols 2, dependent products over propositions 3, and extension types 4. The key rules include
5
6
and
7
The intended reading is that 8 is the type of elements of 9 that are definitionally equal to 0 when the unfolding condition 1 is assumed (Gratzer et al., 2022).
The same source states that the system has been implemented in the cooltt proof assistant and that a normalization theorem is proved for the core calculus (Gratzer et al., 2022). Here, unfolding expressions are not treated as tactics or ad hoc conversion settings, but as a type-theoretic construct with elaboration into a core language. This distinguishes controlled unfolding from unrestricted definitional equality.
5. Program transformation: CHR and lazy functional programs
In CHR, unfolding is defined as the replacement of a procedure call by its definition, specialized to user-defined constraints in rule bodies. The paper “Unfolding in CHR” defines an unfolding rule for annotated CHR programs, proves its correctness, and discusses conditions under which an unfolded rule can replace an original one while preserving program meaning (0807.3979). The operational setting uses the reference semantics 2 with a propagation history and a modified semantics 3 for annotated programs, and the supplied details state
4
The observable semantics is therefore qualified answers, and correctness means preservation of qualified answers under unfolding (0807.3979).
The central transformation is compile-time pre-application of one rule inside another. If a rule 5 has body constraints that match the head of a rule 6, and the guard and built-in constraints are strong enough, the unfolding rule replaces those body constraints by the renamed body of 7, conjoins the necessary guard information, and updates the local token store (0807.3979). Proposition 4.10 is reported as showing that if 8, where 9 is the unfolding of 0 by 1, then for every goal 2,
3
The same source also states that confluence and termination properties are preserved under the stated transformations (0807.3979).
The unfolding semantics of lazy functional programs uses a different technical apparatus but a similar intuition. A fact has the form
4
subject to the condition that 5 and 6 contain no user-defined function symbols and predefined functions are allowed only where they cannot be evaluated further (Rey-Poza et al., 2017). The unfolding operator generates these facts by symbolically replacing user-defined calls, while clean removes redundancy among overlapping facts (Rey-Poza et al., 2017). Adequacy is stated as equivalence between operational evaluation and evaluation with the limit interpretation 7 (Rey-Poza et al., 2017).
Both CHR and lazy functional unfolding are semantics-preserving program transformations, but the preserved semantics differs: qualified answers in CHR and adequacy with respect to a small-step operational semantics in lazy functional programming. This suggests that “unfolding expressions” in program transformation is best understood through the semantic invariant attached to the target language.
6. Optimization, inversion, and projection-based unfolding
In optimization-based HEP unfolding, the Poisson likelihood is approximated by a quadratic term and combined with curvature regularization to obtain
8
with integer decision variables 9 (Gasperini et al., 26 Feb 2026). The regularization term is a discrete Laplacian penalty,
0
and the quadratic form is written as
1
The same work derives a QUBO representation
2
implemented in QUnfold with classical mixed-integer solvers and D-Wave’s hybrid quantum solver (Gasperini et al., 26 Feb 2026).
In AO-based band unfolding, the corresponding central expression is a projection weight. After Löwdin orthogonalization, the primitive translation operator reduces to a permutation matrix, and the unfolding weight takes the compact form
3
Here 4 are Löwdin-orthogonalized supercell eigenvectors and 5 are eigenvectors of the primitive-cell translation operator in the orthogonalized representation (Quan et al., 26 Jun 2025). The same source presents the thermally averaged spectral function as
6
with each configuration sampled from the canonical ensemble (Quan et al., 26 Jun 2025).
These two uses are mathematically distinct—one is inverse estimation under regularization, the other is projector-based spectral decomposition—but each formulates unfolding as extraction of latent structure from a compressed representation by means of an explicit objective or projector. A plausible implication is that in contemporary physics literature the term “unfolding” increasingly denotes a reconstruction map equipped with a quantitative weight or loss.
7. Conceptual commonalities and major distinctions
Across the supplied sources, unfolding is always an operation from a more compact or folded representation to a more explicit one, but the preserved object varies sharply. In geometry, the invariant is a connected planar piece with no overlaps [0509054]. In 7-letrec, the invariant is infinite unfolding semantics and its characterization by strong regularity (Rochel, 2016). In controlled type theory, the invariant is definitional equality under explicit unfolding conditions mediated by extension types (Gratzer et al., 2022). In CHR, it is preservation of qualified answers, and under stated conditions also confluence and termination (0807.3979). In lazy functional programming, it is adequacy with respect to operational semantics (Rey-Poza et al., 2017). In HEP, it is statistical compatibility between 8 and measured counts under regularization (Gasperini et al., 26 Feb 2026). In band unfolding, it is spectral weight in the primitive-cell Brillouin zone (Quan et al., 26 Jun 2025). In Origami, it is a recursion-scheme template in which generation and processing are decoupled (Fernandes et al., 2024).
A recurring misconception is that unfolding is always unrestricted inlining. The supplied literature contradicts that view. Grid vertex-unfolding requires gridding because some orthogonal polyhedra cannot be vertex-unfolded without it [0509054]. Origami fixes the recursion scheme and searches only over typed slots (Fernandes et al., 2024). Controlled type theory makes definitions opaque by default and permits only local selective unfolding (Gratzer et al., 2022). CHR safe rule replacement requires explicit syntactic and guard conditions (0807.3979). Functional unfolding semantics restricts facts so that bodies and guards contain no user-defined function symbols (Rey-Poza et al., 2017). HEP unfolding depends on regularization and discretization choices (Gasperini et al., 26 Feb 2026). AO band unfolding depends on orthogonalization and translation-operator structure (Quan et al., 26 Jun 2025).
The term therefore does not name a single algorithmic pattern. It names a class of expansion operators whose technical content is determined by the structure being unfolded, the admissible transformation rules, and the semantic or geometric invariant that must be preserved.