# eryon

[![crates.io](https://img.shields.io/crates/v/eryon.svg)](https://crates.io/crates/eryon)
[![docs.rs](https://docs.rs/eryon/badge.svg)](https://docs.rs/eryon)
[![license](https://img.shields.io/crates/l/eryon.svg)](https://crates.io/crates/eryon)

***

_**The project is currently in the early stages of development and is not yet ready for production use.**_

`eryon` is designed to be a high-preformance distributed computing library for Rust. The framework is derived from the Neo-Riemannian theory of music, using the tonnetz to describe the configurations of individual instances as well as the global structure. The library is designed to be highly modular, allowing for the easy addition of new features and the ability to swap out components as needed.

## Overview

Eryon is a performant topological computing system inspired from the Neo-Riemannian theory of music. Eryon works by establishing the topological equivalence between a 2-simplex and the headspace ($Q\times\Sigma$) of a Universal Turing Machine (UTM). This allows us to bridge the two, rather alien worlds of computation and music theory using the triad as the basis for describing a topological unit of compute. As a result, we can begin to explore the implications of a UTM that is capable of making adjustment to its own headspace to gaurentee the completion of a given task and how these machines can interact with one another.

Eryon materializes these concepts using a so-called `Plant` defined to be a topological unit of compute. As defined by control theorists, a plant is a fully-controlled system existing within some environment that is a part of a _universe_. In the context of Eryon, the universe is a `Cluster` of `Runtime`s glued together to former a computational substrate. During initialization, the runtime automatically allocates the host's resources into uniform partitions represented as `VNode`s. Each `VNode` is then assigned a `Plant` used to perform computations. These computations are then orchestrated by the `Runtime` in manners that best suit the cluster.

### Background

#### _Turing Machines_

Turing machines are theoretical models of computation working along an infinite tape that is evenly divided into mutable cells. The head of the machine _responds_ to the state and symbol of the cell it is currently reading, and then _reacts_ by writing a new symbol, either moving left or right or staying in-place, and changing its state. The machine is said to _halt_ when it reaches a state that has no defined transition.

These machines rely on rules to dictate exactly how they should react to any given state-symbol pair. These rules are defined by a _transition function_ $\delta$ that maps the current state and symbol to a new state, symbol, and direction. The transition function is defined as follows:

$$
\delta:Q\times\Sigma\rightarrow Q\times\Sigma\times\{L,S,R\}
$$

Where $Q$ is the set of all possible states, $\Sigma$ is the set of all possible symbols, and $\{L,S,R\}$ is the set of all possible directions. This simplification of the original definition of Turing machines makes it possible to consider the machines as dynamical functions that can be analyzed using the tools of dynamical systems theory. Moreover, we can consider the _headspace_ of a machine to be the set of all state-symbol pairs in its $Q\cup\Sigma$.

Here, the headspace is of particular importance as it defines all possibilities of the head of the machine, sufficiently defining the machine's _configuration space_. Analyzing the topology of the headspace can provide insights into the behavior of the machine, such as the number of possible states, the number of possible symbols, and the number of possible transitions.

#### _Neo-Riemannian Theory_

The Neo-Riemannian theory is speaks to a loose collection of research relating to triads, their transformations, and a lattice based representation of tonal space called the tonnetz. To understand the theory, we must first understand the concept of a triad. A triad is a specific shord composed of three notes that maintain certain intervallic relationships with another. More specifically, a triad is a set of three notes that are separated by a third, a fifth, and a third. These intervals are called the _root_, _third_, and _fifth_ respectively. Each of these objects can be transformed using leading, parallel, and relative transformations (LPR). These transformations may be chained together in discrete and continuous settings to create a wide variety of tonal relationships.Moreover, each transformation is it's own inverse meaning that consecutive applications a particular transformation simply reverts the entity back into its original state.

The tonnetz was originally developed by Euler in the 18th century as a way to visualize the relationships between triads in tonal music. For years, researchers worked to find a general representation of the tonnetz that could be used to describe the relationships between all possible triads (augmented, diminished, major, and minor). It wasn't until 2012 when Dmitri Tymoczko published his paper "The Geometry of Musical Chords" that a general representation was found.

## Design

- `Plant`: isolated topological units of compute
- `VNode`: representations of individual partitions, each with its own `plant`
- `Runtime`: a headless system that manages allocated partitions to benefit the cluster
- `Cluster`: a user-owned collection of devices capable of supporting the `runtime`

## Features

- Knowledge coordination
  - Cross-node knowledge transfer and adaptation
  - Near-linear scaling performance
- Topological memory system with pattern recognition
- Runtime orchestration with automatic resource allocation
- Self-organizing surface networks for adaptive learning

## Roadmap

- `subnet` - allow users to create clusters from registered devices
- `mainnet` - a virtual network built ontop of the clusters
- `consensus` - implement a consensus algorithm for the network
- `blockchain` - introduce a hybrid multi-chain for monitizating computational resources
- `crypto` - implement a hybrid encryption scheme for securing data
- `gvf` - a generative visual framework
- `ui` - an elegant user interface for interacting with the system

## Getting Started

### Building from the source

Start by cloning the repository

```bash
git clone https://github.com/FL03/eryon.git
cd eryon
```

#### _Building the project_

```bash
cargo build --all-features -r -v --workspace
```

#### _Running tests_

```bash
cargo test --all-features -r -v --workspace
```

## Usage

Add this to your `Cargo.toml`:

```toml
[dependencies.eryon]
features = []
version = "0.x.x"
```

### Examples

#### _Initialization: locally initialize a full layer of the system_

```rust
    extern crate eryon;

    use eryon::prelude::{NeuralPlant, Runtime};

    fn main() -> anyhow::Result<()> {
        tracing_subscriber::fmt::init();
        tracing::info!("Welcome to {name}", name = "eryon");
        
         // Create and initialize the runtime
        let mut runtime = Runtime::<NeuralPlant>::new();
        runtime.init_complete_layer()?;

        Ok(())
    }
```

## Contributing

Pull requests are welcome. For major changes, please open an issue first
to discuss what you would like to change.

Please make sure to update tests as appropriate.
