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.
- 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
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:
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":[[],[]]
}
}