KRL (Knot Resolution Language) is a compositional language for constructing, transforming, resolving, and retrieving topological objects: tangles, knots, and links.
The name reflects the central operation: resolution. In knot theory, resolution is how crossings are resolved in the skein relation — the algebraic heart of invariant computation. KRL extends this to cover every interaction with the system: resolving structure, resolving equivalence, resolving queries.
"Query" would name only one of four operations. "Resolution" names the mathematical act that runs through all of them.
KRL is the surface language of a four-layer stack:
KRL surface syntax ← this repository (TanglePL compiler module) TangleIR ← canonical interchange object VerisimMorphism ← abstract categorical view (VerisimCore) Skein.jl + QuandleDB ← persistence and semantic indexing
The TanglePL module (this repo) is responsible for:
-
Parsing KRL source text
-
Building and typechecking the AST
-
Compiling AST to
TangleIR -
Reconstructing source from IR (lossy but readable)
It is not responsible for:
-
Invariant computation (→ JuliaKnot.jl)
-
Persistence (→ Skein.jl)
-
Equivalence reasoning (→ QuandleDB)
| Operation | Knot concept | Repo | Example syntax |
|---|---|---|---|
Construct |
Tangles, ports, composition, tensor |
TanglePL |
|
Transform |
PD code, Reidemeister moves |
JuliaKnot.jl |
|
Resolve |
Isotopy, quandle, equivalence class |
QuandleDB |
|
Retrieve |
Jones/Alexander invariants, indexed store |
Skein.jl |
|
expr ::= atom
| expr ';' expr (* sequential composition *)
| expr '|' expr (* tensor product *)
| 'close' expr (* closure / trace *)
| 'mirror' expr
| 'simplify' expr
| 'let' IDENT '=' expr
atom ::= IDENT (* named tangle *)
| generator
generator ::= 'sigma' INT (* positive crossing *)
| 'sigma_inv' INT (* negative crossing *)
| 'cup' INT (* cup on strands i,i+1 *)
| 'cap' INT (* cap on strands i,i+1 *)
query ::= 'find' 'where' filter ('and' filter)*
filter ::= IDENT '=' value
| IDENT '<' INT
| IDENT '>' INT
All KRL expressions compile to TangleIR. This is the object that flows
between all layers of the stack:
struct Port
id::Symbol
side::Symbol # :top | :bottom | :left | :right
index::Int
orientation::Symbol # :in | :out | :unknown
end
struct CrossingIR
id::Symbol
sign::Int # +1 (positive) | -1 (negative)
arcs::NTuple{4,Int} # PD-style: (a, b, c, d) arc indices
end
struct TangleMetadata
name::Union{String,Nothing}
source_text::Union{String,Nothing}
tags::Vector{String}
provenance::Symbol # :user | :derived | :rewritten | :imported
extra::Dict{Symbol,Any}
end
struct TangleIR
id::UUID
ports_in::Vector{Port}
ports_out::Vector{Port}
crossings::Vector{CrossingIR}
components::Vector{Vector{Int}} # arc index groups per component
metadata::TangleMetadata
endTangleIR is the single hardest-designed artifact in the stack.
Every other interface is a view over it, a service to it, or a transformation of it.
using TanglePL, Skein
# parse and compile
ir = compile_tangle("sigma1 ; sigma1 ; sigma1")
# store
db = SkeinDB("knots.db")
id = store!(db, ir; name="trefoil")
# query
candidates = find_equivalence_candidates(db, ir)
# retrieve source
src = reconstruct_source(ir) # generates valid KRL; not necessarily original-
Grammar: defined (sketch above, formal PEG in progress)
-
AST: defined
-
Typechecker: boundary arity checking implemented
-
Compiler (AST → TangleIR): in development
-
Decompiler (IR → source): stub, in progress
-
Skein integration: planned
-
Skein.jl — persistence and query
-
QuandleDB — semantic fingerprinting
-
JuliaKnot.jl — invariant engine