KRL (Knot Resolution Language) is QuandleDB’s canonical resolution DSL: a database-facing language whose domain is knot/tangle identity, equivalence, transformation, and disambiguation. It is the user- and author-facing language for constructing, transforming, resolving, and retrieving knot/tangle presentations, invariants, fingerprints, equivalence classes, witnesses, and disambiguation results.
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.
KRL is database-facing but not merely a query language. "Query" would name only one of four operations; "resolution" names the mathematical act that runs through all of them. Two framings to avoid: "a database language" alone wrongly suggests SQL-for-knots, and "a surface DSL over Tangle" alone makes QuandleDB incidental and KRL too compiler-ish. KRL is precisely QuandleDB’s resolution DSL — it lowers through TangleIR into Tangle-level computation, with QuandleDB and Skein.jl as its persistence and computation backends.
KRL is the surface language of a federated resolution stack. Each layer answers a distinct question:
| Layer | Role — and the question it answers |
|---|---|
KRL |
User-/author-facing resolution DSL. "What question or claim are we making about
knot-structured identity?" Spec, ABI, FFI scaffolds; implementations in
|
TangleIR |
Lowered intermediate representation. "What normalized computational object
represents that resolution task?" Defined in |
Tangle |
Full computational / programming substrate. "What executable knot-theoretic
program or transformation system carries this out?" Proven type-safe small-step
semantics ( |
QuandleDB |
Persistence + invariant/equivalence database. "Where presentations, invariants,
fingerprints, equivalence classes, witnesses, and results live."
( |
Skein.jl |
Computational / backend library. "One engine that computes, transforms,
normalizes, or evaluates the objects." ( |
This repo is responsible for:
-
The KRL grammar specification (
spec/grammar.ebnf). -
Idris2 ABI types (
src/interface/Abi/). -
Zig FFI scaffolds (
src/interface/ffi/). -
Example programs (
examples/). -
The proof narrative (
PROOF-NARRATIVE.md) and obligations registry.
The actual KRL parser, lowering, and adapter implementations live
in the companion repos KRLAdapter.jl (canonical) and
quandledb/server/krl/ (server-side query parser — different role).
See PROOF-NARRATIVE.md for the two-implementation rationale and
the equivalence obligation KR-6.
KRL is not responsible for:
-
Invariant computation (→ JuliaKnot.jl)
-
Persistence (→ Skein.jl)
-
Equivalence reasoning (→ QuandleDB)
-
Surface-language implementation (→ KRLAdapter.jl)
KRL has exactly four operations. The four-verb shape is deliberate: it stops "querying" from becoming the whole identity of the language.
| construct |
create or declare presentations, structures, claims, datasets |
| transform |
rewrite, normalize, compose, concatenate, permute, mutate |
| resolve |
decide / disambiguate / evaluate equivalence or identity questions |
| retrieve |
inspect, fetch, project, explain, or return stored or computed results |
| Operation | Knot concept | Primary site | Example syntax |
|---|---|---|---|
Construct |
Tangles, ports, composition, tensor |
TanglePL |
|
Transform |
PD code, Reidemeister moves |
JuliaKnot.jl |
|
Resolve |
Isotopy, quandle, equivalence class |
QuandleDB |
|
Retrieve |
Invariants, witnesses, stored resolutions |
Skein.jl + QuandleDB |
|
|
Note
|
Retrieve is not arbitrary database querying. It recovers resolution-relevant artefacts: presentations, invariants, witnesses, equivalence classes, prior resolutions, explanations, and provenance. Generic data access — arbitrary filters, dashboards, reporting, analytics,
exploratory search, index tuning — is an engine-layer affordance (Skein.jl
predicates over SQLite; QuandleDB’s filtered endpoints), deliberately not
elevated to a KRL operation or a rival query language. A separate query
language is deferred, not absent; see
|
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