Skip to content

hyperpolymath/krl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

KRL — Knot Resolution Language

What it is

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.

Architecture position

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)

The four KRL operations

Operation Knot concept Repo Example syntax

Construct

Tangles, ports, composition, tensor

TanglePL

compose sigma1 sigma1
tensor a b
close t

Transform

PD code, Reidemeister moves

JuliaKnot.jl

simplify t
normalise t
mirror t

Resolve

Isotopy, quandle, equivalence class

QuandleDB

equivalent? a b
classify t
near t

Retrieve

Jones/Alexander invariants, indexed store

Skein.jl

find where jones = p
where crossing < 8

Grammar (sketch)

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

TangleIR — the canonical interchange

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
end

TangleIR 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.

Usage

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

Status

  • 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

About

KRL (Knot Resolution Language, pronounced 'curl') — standalone DSL for knot/tangle construction, transformation, resolution, and retrieval

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors