Skip to content

hyperpolymath/tangle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

151 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Tangle — a general language for knot mathematics

OpenSSF Best Practices License: MPL-2.0 Green Web

A research language for knots and their mathematics — topological, algebraic, geometric and logical — in which programs are structured objects and equivalence is defined by transformation.


Overview

Tangle is an experimental, Turing-complete programming language in which:

programs are structured as tangles (braids), and program equivalence is defined by isotopy.

Rather than treating programs as sequences of instructions, Tangle treats them as composable topological objects. This allows reasoning about programs in terms of structure, equivalence under transformation, and invariants of representation.

Its remit is deliberately broad: Tangle aims to be a general language for doing mathematics about knots — not a front end to any particular knot database.


Core idea

computation is construction of structured objects, and meaning is preserved under valid transformations.

In this setting:

  • programs are graphs/braids

  • execution corresponds to transformation

  • equivalence is not syntactic equality, but structural equivalence

This aligns with concepts from knot theory (Reidemeister moves), category theory (morphisms and composition), and algebraic invariants (classification via structure).


Relationship to KRL and QuandleDB

Tangle is a separate project from KRL and QuandleDB. The three share a subject matter, not an architecture.

Project What it is

Tangle (this repository)

A general language for knot mathematics. Turing-complete. Independent of any database.

QuandleDB

A knot database — stores presentations, invariants, fingerprints, equivalence classes and witnesses.

KRL

QuandleDB’s resolution language, developed jointly with it. Specified in the krl repository, implemented in quandledb/server/krl/.

Important

Earlier revisions of this README were titled "Tangle / KRL" and described Tangle as the substrate of a KRL → TangleIR → Tangle core → QuandleDB stack. That was wrong on both counts.

  • KRL is not Tangle’s surface language. It is QuandleDB’s, and it neither compiles to nor depends on Tangle.

  • There is no TangleIR. The identifier appears in no source file in this repository, nor in the KRL implementation — it existed only in prose.

The projects remain related by domain and are developed by the same author; what is removed here is a claimed architectural dependency that does not exist.


Formal core

A core fragment of the language is formalised and mechanised in Lean 4.

Verified on 2026-07-21 by running the repository’s own oracle, cd proofs && lean Tangle.lean — exit 0, no errors:

Property Status

progress

proved

preservation

proved

determinism

proved

type_safety

proved

Decidability of type checking (infer == HasType)

proved

The proofs are self-contained (no Mathlib dependency) and contain zero uses of sorry and zero axiom declarations across 2,128 lines — so "builds" and "proved" mean the same thing here, which is not automatic.

They cover echo types: structured loss as a type-system feature. close (braid closure) is the canonical lossy map, and echoClose/lower/residue make that loss recoverable at the type level — a simply-typed shadow of echo-types. All four safety theorems cover them.

See proofs/Tangle.lean, proofs/README.md, docs/spec/FORMAL-SEMANTICS.md, and PROOF-NARRATIVE.md / PROOF-NEEDS.md.

This formal core covers the structural heart of the language, though not all surface features.


Dialects

Tangle’s breadth is expressed as dialects, each with its own grammar sketch under dialects/:

  • braid-calculus — braid words and their relations

  • skein-algebra — skein relations and invariant computation

  • string-diagram — monoidal-category string diagrams

  • virtual-knot — virtual knot theory

  • quantum-circuit — circuits as topological objects


Current status

Tangle is an active research system. Read it as a formally grounded core with an evolving implementation around it.

Area State

Lean 4 formal core

Verified — see above

Grammars

src/tangle.ebnf, src/tangle-jtv.ebnf, spec/grammar.ebnf, plus five dialect sketches

OCaml compiler (compiler/)

Lexer, parser, AST, typechecker, evaluator, pretty-printer, REPL, braid equivalence, plus LSP and WASM targets. Not built by CI

Rust / Zig components

18 .rs, 3 .zig. Not built by CI

Database integration

Not implemented

Note

Only the Lean proofs are gated by CI (.github/workflows/lean-proofs.yml). The OCaml compiler, the Rust components and the Zig components are not built by any workflow, so their state is unverified by this repository’s own CI.


Research directions

  • richer categorical abstractions

  • optimisation via equivalence classes

  • alternative evaluation models based on rewriting

These are not yet stable features.


How to read this repository

  • proofs/Tangle.lean — mechanised type-safety proof (the load-bearing artefact)

  • docs/spec/FORMAL-SEMANTICS.md — formal model

  • src/tangle.ebnf — surface grammar

  • dialects/ — the breadth of the language

  • compiler/lib/ — the OCaml front end

Licence

This project is licensed under the Mozilla Public License, v. 2.0. See the LICENSE file for details. This document is CC-BY-SA-4.0.

About

Tangle — topological programming language

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

2 stars

Watchers

0 watching

Forks

Releases

No releases published

Sponsor this project

  •  

Packages

 
 
 

Contributors