Skip to content

Grammar, appendices, and references

Appendix A — grammar (informal) (since v0.0)

Section titled “Appendix A — grammar (informal) (since v0.0)”

The Menhir grammar is authoritative once written; this sketch is a guide.

program := "paper" "square" stmt*
stmt := crease_stmt | point_stmt | flip_stmt
crease_stmt := [ CREASE_NAME ":" ] [ "@" ] axiom [ "moving" point_operand ] [ "mountain" ]
point_stmt := POINT_NAME ":" point_expr
flip_stmt := "flip"
axiom := "through" point_operand point_operand ; axiom 1
| "map" point_operand "onto" point_operand ; axiom 2
| "perp" line_operand "through" point_operand ; axiom 3
| "map" point_operand "onto" line_operand "perp" line_operand ; axiom 4
| "map" line_operand "onto" line_operand [ "toward" point_operand ] ; axiom 5
point_expr := "cross" line_operand line_operand ; line intersection (binding RHS)
point_operand := POINT_NAME | ".(" line_operand line_operand ")" ; named, or inline cross
line_operand := CREASE_NAME | "--(" point_operand point_operand ")" ; named, or inline through
POINT_NAME := "." ident
CREASE_NAME := "--" ident

A bare axiom statement is a precrease (computes a crease line, paper stays flat). The @ prefix performs the fold (§4.6); moving/mountain describe it. flip turns the whole sheet over (§4.7). (since v0.7-dev) Any operand may be an inline anonymous construction--(.a .b) is the line through two points, .(--a --b) the point where two creases meet; these nest freely and coexist with the cross/through keywords (which remain for named bindings). Brackets appear only as operands, never as a binding right-hand side.


Deferred, in rough order of likely arrival: non-flat (constructible-angle) folds · rotate · fold maneuvers (reverse/squash/sink/petal, via unfold + layer selection) · axioms 6, 7 · regions · parts/imports · step blocks · a dedicated render/animation engine · YR diagrams. These are not part of the language until a slice lands and this spec is extended.

Landed: faces (v0.1); axiom 3 — perpendicular (v0.2); axiom 4 — projection (v0.4-dev); axiom 5 — angle bisector (v0.3-dev); the map … onto … verb and the @ fold modifier (v0.6-dev); and (v0.7-dev) the action model@ fold execution, the folded-state runtime, derived mountain/valley, the dual creasePattern + foldedForm FOLD output, flip, and inline anonymous operands (--(.a .b) / .(--a --b)). See ADR 0011. Mountain/valley is derived from fold actions, not a separate annotation pass.


Machine-readable entries: paper/references.bib. Each entry links to a public source where one exists, and to the local full text in refs/ (gitignored — local checkout only).

[hull2020] Thomas C. Hull. Origametry: Mathematical Methods in Paper Folding. Cambridge University Press, 2020. doi.org/10.1017/9781108778633 · local PDF. The fold axioms and Hull’s Basic Origami Operations are in §1.5 “The Basic Origami Operations”.

[justin1986] Jacques Justin. Résolution par le pliage de l’équation du troisième degré et applications géométriques. L’Ouvert, no. 42 (March 1986), pp. 9–19. local PDF. First complete statement of the seven fold axioms (classic numbering).

[foldformat] Erik D. Demaine, Jason S. Ku, Robert J. Lang. FOLD File Format Specification (v1.2). github.com/edemaine/fold · local copy. Relevant sections: “Edge information: edges_...” (edge assignments) and “Custom Properties” (the namespace:key convention used by beloch:*).