A project by J. Rogers, SE Ohio
KnotGEN is a Python implementation of a formal generative grammar that redefines a knot not as a static object, but as the result of a discrete sequence of constructive operations. It treats a knot's structure as a "recipe" of instructions, allowing for powerful new methods of analysis, simplification, and classification.
This project is the practical implementation of the concepts outlined in the paper, "KnotGEN: A Generative Grammar for the Algorithmic Construction of Knots".
Traditional knot theory analyzes a finished knot diagram (the "phenotype"). KnotGEN shifts the focus to the sequence of operations required to create it (the "genotype").
This "recipe-based" approach has two key advantages:
- Separation of Concerns: The abstract, shapeless recipe of the knot's topology is completely separate from its 3D geometric projection.
- Powerful Analysis: We can analyze the recipe itself to find redundancies and determine essential properties, like the knot's minimal crossing number, before ever drawing it.
The system is split into two distinct parts, reflecting the separation of concerns.
This class is responsible for building the abstract, shapeless recipe for a knot. It knows nothing about coordinates or 3D space. Its only job is to record your commands.
knot.cross(source, type, target): Adds a crossing operation to the recipe. Thesourcecan be the'end'of the path or an existingsegmentindex.knot.join(): Adds the final closing operation to the recipe.
This is a separate "baker" class that takes a completed recipe from the KnotBuilder and interprets it. Only at this stage are 3D coordinates calculated and a geometric projection created for visualization.
Here is how to build the recipe for a trefoil knot and then render it.
# main.py
from knotgen import KnotBuilder # Assuming the code is in a file named knotgen.py
# 1. Create the Recipe Builder
knot = KnotBuilder()
# 2. Build the recipe for a Trefoil knot
knot.cross('end', 'under', target_segment_index=1)
knot.cross('end', 'over', target_segment_index=2)
knot.cross('end', 'under', target_segment_index=3)
knot.join()
# 3. Pass the recipe to the renderer to create the 3D projection
# The 'verbose' flag can be passed to see the renderer's step-by-step construction
knot.display(verbose=False)Output:
The true power of KnotGEN lies in analyzing the recipe itself. The KnotAnalyzer can identify redundant operations and estimate knot invariants based on the "Progressive Locking Principle."
A loop or twist created by an operation is only topologically significant if it is "locked in" by a subsequent operation that passes a strand through it. Otherwise, the loop is redundant and can be simplified away.
The analyzer can identify segment cross operations that create "unlocked" loops.
Example:
# --- Recipe with a Redundant (Unlocked) Loop ---
unlocked_knot = KnotBuilder()
unlocked_knot.cross(1, 'under', 1) # Create a loop from segment 1
unlocked_knot.join() # Join without ever interacting with the loop
unlocked_knot.analyze_recipe()Analysis Output:
--- Analysis Report ---
[REDUNDANT] Operation at step 1: ('cross', 'segment', 1, 'under', 1)
-> This operation creates a loop that is NEVER used as a target by later steps. It is UNLOCKED and can be removed.
The analyzer uses this principle to estimate the knot's minimal crossing number, a key knot invariant.
- Recipe Crossing Count: A naive count of all crossing operations.
- Estimated Minimal Crossing Number: The count of only the essential, "locked-in" crossings.
Example Analysis Output:
--- Crossing Number Analysis ---
Recipe Crossing Count (Upper Bound): 3
Estimated Minimal Crossing Number: 3
This indicates that for the trefoil knot recipe, all three crossing operations are essential and non-redundant. For a recipe with an unlocked loop, this estimate would be lower than the recipe count, reflecting the possible simplification.
This generative approach has potential applications in fields where topology is created sequentially.
- Computational Topology: Providing a canonical "genotype" representation for knots to simplify algorithmic classification and the knot equivalence problem.
- Polymer Physics: Modeling the entanglement and knotting of long-chain polymers.
- DNA Supercoiling: Describing the action of enzymes like topoisomerase, which perform sequential crossing operations on the DNA strand.
- Theoretical Physics: Modeling the interaction of branes or cosmic strings where topological features arise from dynamic interactions.
This project is licensed under the MIT License. See the LICENSE file for details.