Origami folding sequences as programs. A program names points and creases and folds along constructions that align them. Beloch evaluates it exactly, step by step, into a FOLD file, the exchange format of computational-origami tools. Its own renderer draws crease patterns and folded states from that file, and other FOLD tools can open it.
Playground ·
Language ·
Model ·
| crease pattern | folded |
|---|---|
The traditional crane, flat, in sixteen statements:
examples/crane.bel. It follows steps 2 to 17 of Ida's
crane program
(Ida 2020, Fig. 7.19); her last
two steps open the wings in 3D, which Beloch does not model yet. The native
evaluator folds it; the browser playground cannot evaluate it yet.
Both drawings are the renderer's output for the linked program.
scripts/render-readme-figures.sh redraws them, and CI fails when one no
longer matches its program.
paper square
fold (map .a onto .c) as --bd ; triangle: corner a onto corner c
reverse (map .b onto .c) as --h ; corner b tucked inside, onto c
reverse (map .d onto .c) as --v ; corner d likewise
That is the preliminary base
(packages/core/tests/cases/bases/preliminary-reverse.bel).
paper square gives the unit square with corners .a .b .c .d
counter-clockwise from the origin. A name with a dot is a point, a name with
two dashes is a crease. (map .a onto .c) is the fold line that carries one
point onto another, one of the seven Huzita-Justin axioms; as --bd names the
crease so later statements can use it.
Five verbs write to the paper. mark scores a crease and moves nothing,
fold folds along it, reverse makes an inside or outside reverse fold,
flip turns the paper over, and flatten folds a vertex flat along several
rays at once; given an odd number of them, it derives the one ray that is
missing. The evaluator works out where every layer goes and which creases end
up mountain or valley. The full grammar is in spec/BELOCH-GRAMMAR.md
and on the grammar page.
Written origami languages predate computers: Smith's Origami Instruction Language (1975) is executed by a human folder. Fisher (1994) gave a textual folding language with its own syntax and a program that executes it and tracks face layering. Ida's Eos (Ida et al. 2009; Ida 2020) is the most comprehensive system. Its language Orikoto is a subset of the Wolfram Language inside Mathematica; it folds by the Huzita-Justin rules, maintains the superposition relation between faces, and proves constructions correct with Gröbner bases, while the folds themselves are solved numerically (Ida et al. 2008). Caruana and Pace (2007) embed the axioms in Haskell for plane constructions and derive the preconditions a construction needs. eGami (Fastag 2009) generates diagrams from direct manipulation. Rabbit Ear (Kraft 2016) is a JavaScript library with the seven axioms as functions, FOLD manipulation and folding simulation; a construction written with it is a JavaScript program, and it reads the FOLD files Beloch emits.
Beloch combines what these hold separately: a standalone language that always terminates, evaluated to its folded state in exact arithmetic.
The evaluator computes the folded state of a folding sequence in exact
real-algebraic arithmetic (FLINT qqbar): where every layer lies, the stacking
order of the layers, and which creases end up mountain or valley. A coincidence
such as "this corner lies on this crease" is decided, and a √2 from axiom 5 or
the cube root of axiom 7 stays exact through every later fold. Fisher's
executor places lines near vertices by tolerance and Eos solves each fold
numerically; here the question is decided exactly.
flatten folds a vertex flat along several rays at once. Given an odd number
of rays, it derives the ray that Kawasaki's condition forces and scores it as
a new crease. This expresses folds no Huzita-Justin axiom constructs from the
points a program has named; the swivel rabbit ear below is one.
Both rest on the language: a program is a finite sequence of constructions and
folds, with no loops, no recursion (a def sees only earlier defs) and no
host language
(decision 0009). Every program
terminates, its statements are its folding sequence, and every crease in the
FOLD output names the statement and the construction that made it.
- Implemented: all seven axioms, the five verbs, FOLD output, crease
pattern and folded-state rendering, a browser build. The programs in
examples/evaluate end to end, up to the flat crane, and most of them carry assertions the test suite checks. - Formalized:
spec/MODEL.mddefines folded states and the operations on them. Its first sections are reviewed; the section on operations is a draft, and two of its lemmas, among them that a fold introduces no crossing, have pending proofs. - Not yet: Yoshizawa-Randlett folding diagrams, 3D states (decision 0015), and measurements on programs longer than a few dozen statements.
The playground needs no install. It runs the same evaluator, compiled to JavaScript with js_of_ocaml and backed by a WebAssembly build of FLINT. An operation that forces a value the browser backend cannot canonicalize says so and asks for the native evaluator; it never returns a wrong answer.
With Nix, the evaluator runs without a checkout:
nix run github:tophcodes/beloch -- fold program.bel # FOLD JSON on stdoutRendering needs the development shell (below), which puts the renderer on
PATH:
beloch render examples/crane.bel crane.svg --view cp # or --view folded
beloch render examples/crane.bel --open # render and open itWhat exact arithmetic costs
Exactness is paid for in evaluation time. Measured on the benchmark corpus
with dune exec packages/core/bench/bench_fold.exe, on one developer machine:
| program | time |
|---|---|
| fish base (√2 throughout) | 0.24 s |
| swivel rabbit ear | 0.13 s |
| rabbit ear | 0.13 s |
| two-ear fish | 0.24 s |
| cube root (axiom 7) | 0.13 s |
These are programs of ten to thirty statements. How the kernel behaves on
chained cubic folds, or on a crease pattern with hundreds of vertices, has not
been measured. The corpus is listed at the top of
packages/core/bench/bench_fold.ml.
The evaluator core is OCaml, the tooling around it TypeScript. A Nix flake provides both toolchains, so Nix and direnv are the only prerequisites:
direnv allow # or: nix develop
check # every test suite
check-all # what CI runs, adding docs, README drawings, siteThe kernel suites have known failures, recorded with their cause in
scripts/known-failures.txt; a failure beyond them fails the check.
- Caruana, G. and Pace, G. J. (2007). Embedded Languages for Origami-Based Geometry. Proceedings of the Computer Science Annual Workshop (CSAW), University of Malta.
- Fastag, J. (2009). eGami: Virtual Paperfolding and Diagramming Software. In R. J. Lang (ed.), Origami⁴, A K Peters, 273–283.
- Fisher, D. (1994). Origami On Computer. Honours thesis, Basser Department of Computer Science, University of Sydney.
- Ida, T. (2020). An Introduction to Computational Origami. Springer. doi:10.1007/978-3-319-59189-6
- Ida, T., Marin, M., Takahashi, H. and Ghourabi, F. (2008). Computational Origami Construction as Constraint Solving and Rewriting. Electronic Notes in Theoretical Computer Science 216, 31–44. doi:10.1016/j.entcs.2008.06.032
- Ida, T., Takahashi, H., Marin, M., Kasem, A. and Ghourabi, F. (2009). Computational Origami System Eos. In R. J. Lang (ed.), Origami⁴, A K Peters, 285–293.
- Kraft, R. (2016–). Rabbit Ear, a computational origami library. github.com/rabbit-ear/rabbit-ear
- Smith, J. S. (1975). Origami Instruction Language. British Origami Society Booklet No. 4.
BibTeX for all of them is in bibliography/references.bib.
@software{muehl_beloch,
author = {M{\"u}hl, Christopher},
title = {Beloch: origami folding sequences as programs},
year = {2026},
doi = {10.5281/zenodo.22884252},
url = {https://github.com/tophcodes/beloch}
}GitHub's "Cite this repository" button offers the same entry and APA, read
from CITATION.cff.
Beloch is named after Margherita Piazzola Beloch, whose 1936 work showed that folding solves general cubic equations. Axiom 7 is the Beloch fold.
Licensed MIT (LICENSE.md).