galoisenne

πŸ•ΈοΈ Graphs, finite fields and discrete dynamical systems in Kotlin

https://github.com/breandan/galoisenne

Science Score: 49.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • β—‹
    CITATION.cff file
  • βœ“
    codemeta.json file
    Found codemeta.json file
  • βœ“
    .zenodo.json file
    Found .zenodo.json file
  • βœ“
    DOI references
    Found 48 DOI reference(s) in README
  • βœ“
    Academic publication links
    Links to: arxiv.org, researchgate.net, springer.com, ieee.org, acm.org
  • β—‹
    Committers with academic emails
  • β—‹
    Institutional organization owner
  • β—‹
    JOSS paper metadata
  • β—‹
    Scientific vocabulary similarity
    Low similarity (13.4%) to scientific vocabulary

Keywords

adjacency-matrix arithmetic-circuits automata finite-fields finite-state-machine functional-graphs graph graph-algorithms graph-grammars graph-matching graph-theory graph-transformation graph-visualizations graphs induction kotlin linear-algebra parsing
Last synced: 6 months ago · JSON representation

Repository

πŸ•ΈοΈ Graphs, finite fields and discrete dynamical systems in Kotlin

Basic Info
  • Host: GitHub
  • Owner: breandan
  • License: apache-2.0
  • Language: Kotlin
  • Default Branch: master
  • Homepage:
  • Size: 180 MB
Statistics
  • Stars: 138
  • Watchers: 7
  • Forks: 12
  • Open Issues: 1
  • Releases: 14
Topics
adjacency-matrix arithmetic-circuits automata finite-fields finite-state-machine functional-graphs graph graph-algorithms graph-grammars graph-matching graph-theory graph-transformation graph-visualizations graphs induction kotlin linear-algebra parsing
Created almost 6 years ago · Last pushed 6 months ago
Metadata Files
Readme License Code of conduct Citation

README.md

Kaliningraph: A Type Family of Algebraic Graphs

Kotlin 1.6.20 Maven Central CI

This library implements a new computational model which we call graph computation. In contrast with prior work, e.g., Turing's machine and Church's -calculus, the advantage of this model is that it can be directly translated to iterated matrix multiplication on GPUs and has many desirable algebraic properties. Furthermore, it offers a natural way to express algebraic circuits, neural networks, factor graphs, proof networks, and enjoys many connections to programming language theory, automata theory and category theory.

Kaliningraph currently supports backpropagation in Kotlin. Efforts to lower other propagation schemes, e.g., belief propagation, uncertainty propagation, unit propagation, survey propagation and constraint propagation are ongoing. All of these schemes operate according to a principle known as message passing and are in general known to be Turing complete. This unification allows us to study many common problems in related domains using well-studied tools from arithmetic circuit complexity, to spectral and algebraic graph theory.

Installation

Kaliningraph is hosted on Maven Central.

Gradle

kotlin dependencies { implementation("ai.hypergraph:kaliningraph:0.1.8") }

Maven

xml <dependency> <groupId>ai.hypergraph</groupId> <artifactId>kaliningraph</artifactId> <version>0.1.8</version> </dependency>

Jupyter notebook

To access notebook support, use the following line magic:

@file:DependsOn("ai.hypergraph:kaliningraph:0.1.8")

For more information, explore our tutorials:

Graphs, inductively

What are graphs? A graph is a (possibly empty) set of vertices.

What are vertices? A vertex is a unique label with neighbors (possibly containing itself).

What are neighbors? Neighbors are a graph.

Circuits, inductively

What is a circuit? A circuit is either:

  • A Boolean logic gate (e.g., and, or, not)
  • A circuit that takes two inputs and swaps them (a, b) -> (b, a)
  • A circuit that takes one input and gives one output a -> b
  • The serial composition of two circuits (a->c, c->d) -> (a->d)
  • The parallel composition of two circuits (a->b, c->d) -> (a, b) -> (c, d)

Getting started

Run the demo via ./gradlew jvmTest --tests "ai.hypergraph.kaliningraph.HelloKaliningraph" to get started.

Usage

Kaliningraph treats string adjacency and graph adjacency as the same. To construct a graph, simply enumerate walks.

This can be done using a raw string, in which case unique characters will form the vertex set. Whitespace delimits walks:

kotlin val graph = LabeledGraph { "abcde ace" }

Vertices can also be linked via the - operator. The graph builder DSL provides a small alphabet:

kotlin val graph = LabeledGraph { a - b - "c" - d - e; a - c - e }

This is equivalent to:

kotlin val abcde = LabeledGraph { a - b - c - d - e } val ace = LabeledGraph { a - "c" - e } val graph = abcde + ace

Equality is supported using the Weisfeiler-Lehman test:

kotlin val x = LabeledGraph { a - b - c - d - e; a - c - e } val y = LabeledGraph { b - c - d - e - f; b - d - f } assertEquals(x == y) // true

Visualization

Kaliningraph supports a number of graph visualizations.

Graphviz

Graph visualization is made possible thanks to KraphViz.

```kotlin val de = LabeledGraph { d - e } val dacbe = LabeledGraph { d - a - c - b - e } val dce = LabeledGraph { d - c - e }

val abcd = LabeledGraph { a - b - c - d } val cfde = LabeledGraph { c - "a" - f - d - e }

val dg = LabeledGraph(dacbe, dce, de) + Graph(abcd, cfde) dg.show() ```

Running the above snippet will cause the following figure to be rendered in the browser:

Matrix form

Graph visualization in both DOT and adjacency matrix format is supported.

| DOT Graph | Matrix | |:---------------------------------------------|:--------------------------------------------| | image | image_1 |

It is also possible to visualize the state and transition matrices and step through the graph (./gradlew jsBrowserRun --continuous).

Computation graph

Computational notebooks prototyping is also supported.

Notebook { a = b + c f = b - h }.show()

The above snippet should display something like the following:

Translation

Bidirectional translation to various graph formats, including Graphviz, JGraphT, Tinkerpop and RedisGraph is supported:

kotlin val g = LabeledGraph { a - b - c - a } .toJGraphT().toKaliningraph() .toTinkerpop().toKaliningraph() .toGraphviz().toKaliningraph()

Code2Vec

Code2Vec generation and visualization is supported. The following demo was generated using message passing on the adjacency matrix, for graphs of varying height. The technique to create the embeddings is described here. We use TSNE to visualize the resulting vectors in 2D, and can clearly distinguish the clusters.

Automata-based RegEx

A regex to NFA compiler is provided. To run the demo, run ./gradlew RegexDemo. You should see something like this:

Research questions

  • What is the best way to represent a graph?
  • Is it possible to statically check tensor arithmetic in the Kotlin type system?
  • How computationally powerful is matrix multiplication?
  • Is subgraph isomorphism feasible using random walks?
    • Treat graph as a sequence and run string convolution
    • Generate lazy random walk and halt after K steps
    • Convolve permuted variants of query in parallel
    • Need some kind of label permutation / edit distance metric
  • How do we represent a tensor/hypergraph?
  • How could we implement graph grammars/rewriting?
    • Rewrites as string substitution on the random walk sequence
    • Reconstruct graph from rewritten string using adjacency matrix
    • ~~Is there an algebraic definition for graph grammars?~~
    • ~~Maybe graph convolution. How to encode rewrites as a kernel?~~
    • ~~Rectangular matrix multiplication or square with upper bound?~~
    • ~~May be possible to represent using tensor contraction~~
    • Need to look into hyperedge replacement grammars
    • How do we identify confluent rewrite systems?
  • What are the advantages and disadvantages of graph rewriting?
    • Graphs as vertices and rewrites as edges in a nested graph?
    • Reduction/canonicalization versus expansion graph grammar
  • What happens if we represent the graph as a symbolic matrix?
    • Could we propagate functions instead of just values?
    • What if matrix elements were symbolic expressions? (cf. KeOps)
    • Should we represent the whole matrix as a big bold symbol?
  • Is there an efficient way to parallelize arithmetic circuits?
    • Translate formula graph to matrix using Miller's evaluator
    • How to distribute the work evenly across sparse matrices
  • What are some good way to visualize random walks?
    • Display states, transitions and graph occupancy side-by-side
  • Is there a connection between linear algebra and -calculus?

References

Knowledge graphs

Graph theory

Graph learning

Functional graphs

Graph rewriting

Unification

Termination checking

Algebra

Circuits

Propagation

Random walks

Software engineering

Proof search

Code search

Word problems

Software

Graphs

  • KeOps - Dense, sparse and symbolic tensor library
  • Alga - a library for algebraic construction and manipulation of graphs in Haskell
  • Bifurcan - high-quality JVM implementations of immutable data structures
  • Kraphviz - Graphviz with pure Java
  • JGraLab - a Java graph library implementing TGraphs: typed, attributed, ordered, and directed graphs (paper)
  • GraphBLAS - open effort to define standard building blocks for graph algorithms in the language of linear algebra
  • GraphBLAST - High-Performance Linear Algebra-based Graph Primitives on GPUs

Rewriting

  • Grez - graph transformation termination checker (manual)
  • GP2 - Rule-based graph programming language
  • AGG - development environment for attributed graph transformation systems supporting an algebraic approach to graph transformation (manual)
  • Henshin - an IDE for developing and simulating triple graph grammars (TGGs) (manual)
  • JavaSMT - Unified Java API for SMT solvers

Automata

Special thanks

The following individuals have helped inspire this project through their enthusiasm and thoughtful feedback. Please check out their work.

Owner

  • Name: breandan
  • Login: breandan
  • Kind: user

GitHub Events

Total
  • Issues event: 1
  • Watch event: 18
  • Issue comment event: 2
  • Push event: 287
  • Fork event: 2
Last Year
  • Issues event: 1
  • Watch event: 18
  • Issue comment event: 2
  • Push event: 287
  • Fork event: 2

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 2,049
  • Total Committers: 3
  • Avg Commits per committer: 683.0
  • Development Distribution Score (DDS): 0.001
Past Year
  • Commits: 367
  • Committers: 1
  • Avg Commits per committer: 367.0
  • Development Distribution Score (DDS): 0.0
Top Committers
Name Email Commits
breandan b****e@n****o 2,047
Ilya Muradyan i****n@j****m 1
Xujie Si s****x@X****l 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 9 months ago

All Time
  • Total issues: 5
  • Total pull requests: 2
  • Average time to close issues: 3 months
  • Average time to close pull requests: about 5 hours
  • Total issue authors: 4
  • Total pull request authors: 2
  • Average comments per issue: 2.0
  • Average comments per pull request: 0.5
  • Merged pull requests: 2
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 1
  • Pull requests: 0
  • Average time to close issues: N/A
  • Average time to close pull requests: N/A
  • Issue authors: 1
  • Pull request authors: 0
  • Average comments per issue: 2.0
  • Average comments per pull request: 0
  • Merged pull requests: 0
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • ileasile (2)
  • gijsdh (1)
  • sgilson (1)
  • altavir (1)
Pull Request Authors
  • ileasile (1)
  • XujieSi (1)
Top Labels
Issue Labels
Pull Request Labels

Dependencies

build.gradle.kts maven
  • org.jetbrains:annotations 23.0.0 compileOnly
  • ca.umontreal.iro.simul:ssj 3.3.1 implementation
  • com.datadoghq:sketches-java 0.7.0 implementation
  • com.github.TUK-CPS:jAADD -SNAPSHOT implementation
  • com.github.analog-garage:dimple master-SNAPSHOT implementation
  • com.redislabs:jredisgraph 2.6.0-RC2 implementation
  • de.uni-koblenz.ist:jgralab 8.1.0 implementation
  • guru.nidi:graphviz-kotlin 0.18.1 implementation
  • info.debatty:java-string-similarity 2.0.0 implementation
  • io.kotest:kotest-assertions-core $kotestVersion implementation
  • io.kotest:kotest-property $kotestVersion implementation
  • io.kotest:kotest-runner-junit5 $kotestVersion implementation
  • io.lacuna:bifurcan 0.2.0-alpha6 implementation
  • junit:junit 4.13.2 implementation
  • org.apache.datasketches:datasketches-java 3.3.0 implementation
  • org.apache.tinkerpop:gremlin-core $tinkerpopVersion implementation
  • org.apache.tinkerpop:tinkergraph-gremlin $tinkerpopVersion implementation
  • org.eclipse.collections:eclipse-collections 11.1.0 implementation
  • org.eclipse.collections:eclipse-collections-api 11.1.0 implementation
  • org.graalvm.js:js 22.1.0.1 implementation
  • org.jetbrains.kotlinx:kotlinx-coroutines-core 1.6.3 implementation
  • org.jetbrains.kotlinx:kotlinx-datetime 0.3.3 implementation
  • org.jetbrains.kotlinx:kotlinx-html 0.7.5 implementation
  • org.jetbrains.kotlinx:kotlinx-html-jvm 0.7.5 implementation
  • org.jetbrains.kotlinx:multik-api $multikVersion implementation
  • org.jetbrains.kotlinx:multik-api $multik_version implementation
  • org.jetbrains.kotlinx:multik-default $multikVersion implementation
  • org.jetbrains.kotlinx:multik-jvm $multik_version implementation
  • org.jetbrains.kotlinx:multik-native $multik_version implementation
  • org.jetbrains.lets-plot:lets-plot-kotlin-jvm 3.3.0 implementation
  • org.jgrapht:jgrapht-core $jgraphtVersion implementation
  • org.jgrapht:jgrapht-ext $jgraphtVersion implementation
  • org.jgrapht:jgrapht-opt $jgraphtVersion implementation
  • org.junit.jupiter:junit-jupiter 5.9.0-RC1 implementation
  • org.logicng:logicng 2.2.1 implementation
  • org.slf4j:slf4j-simple 1.7.32 implementation
  • org.sosy-lab:java-smt 3.12.0 implementation
  • org.sosy-lab:javasmt-solver-mathsat5 5.6.5 implementation
.github/workflows/main.yml actions
  • actions/checkout v2 composite
  • actions/setup-java v1 composite