Skip to content

hellas-ai/open-hypergraphs

open hypergraphs

Crate Documentation License

Open Hypergraphs are a general, differentiable and data-parallel datastructure for syntax. Here’s a few examples of suitable uses:

  • Differentiable array programs for deep learning (in catgrad).
  • Proofs and terms in first order logic
  • Programs in the λ-calculus
  • Circuits with feedback

This code is an implementation of the paper Data-Parallel Algorithms for String Diagrams.

Features

  • An imperative interface for constructing open hypergraphs in Rust the lax module)
  • Data-parallel algorithms for algebraic operations (the strict module)
  • Data-parallel diagram layering and decomposition
  • Functors, including optic transformation for ahead-of-time differentiation of syntax

Examples

An example for defining a simple expression language (polynomial circuits) and evaluating its terms is given here.

A complete example showing term construction, rendering as SVG using open-hypergraphs-dot, and serialization to JSON can be found here. This example produces the following open hypergraph:

image

which serializes to JSON as below:

{
    "sources": [3,0],
    "targets": [4],
    "hypergraph": {
        "nodes":[
            {"Interval":{"lower":0,"upper":1}},
            "Int","Int","Int","Int"
        ],
        "edges": ["Cast","Neg","Add"],
        "adjacency": [
            {"sources":[0],"targets":[1]},
            {"sources":[1],"targets":[2]},
            {"sources":[3,2],"targets":[4]}
        ],
        "quotient":[[],[]]
    }
}

About

a datastructure for scalable combinatorial syntax

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Contributing

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages