Skip to content

Commit

Permalink
Merge pull request #8 from FL03/v0.0.3
Browse files Browse the repository at this point in the history
V0.0.3
  • Loading branch information
FL03 authored Aug 23, 2024
2 parents 17f43e6 + b5675c3 commit 037db9e
Show file tree
Hide file tree
Showing 76 changed files with 3,152 additions and 1,346 deletions.
24 changes: 14 additions & 10 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
assignees: [ FL03 ]
labels: [ bug ]
projects: [ '@FL03/rstm:dev' ]
title: 'Bug: '

---

Expand All @@ -12,6 +13,7 @@ A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:

1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
Expand All @@ -24,15 +26,17 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
Add any other context about the problem here.
7 changes: 4 additions & 3 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
assignees: [ FL03 ]
labels: [ enhancement ]
projects: [ '@FL03/rstm:dev' ]
title: 'Feature Request: '

---

Expand Down
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/issue.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ about: A generic issue template
assignees:
- FL03
labels: []
projects: ['@FL03/concision:features']
projects: ['@FL03/rstm:dev']
name: Generic Issue
title: ''
---
Expand Down
7 changes: 3 additions & 4 deletions .github/ISSUE_TEMPLATE/proposal.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---
about: A formal proposal discussing any new features, changes, or improvements to the project.
assignees:
- FL03
labels: ['proposal']
assignees: [ FL03 ]
labels: [ 'proposal' ]
name: Improvement Proposal
title: 'CNC-0000:'
title: 'Proposal: '
---


Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/clippy.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: clippy

concurrency:
cancel-in-progress: false
group: ${{ github.workflow }}-${{ github.ref }}

on:
pull_request:
branches: [ main ]
release:
types: [ created ]
repository_dispatch:
types: [ clippy ]
schedule:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/crates.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: crates

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
group: ${{ github.workflow }}-${{ github.ref }}

env:
BASENAME: ${{ github.event.repository.name }}
Expand All @@ -16,7 +16,7 @@ on:
workflow_dispatch:

jobs:
independents:
base:
env:
CRATE_NAME: ${{ github.event.repository.name }}-${{ matrix.suffix }}
name: Publish (${{ matrix.suffix }})
Expand All @@ -42,6 +42,7 @@ jobs:
- run: cargo publish --all-features -v -p ${{ env.CRATE_NAME }} --token ${{ secrets.CARGO_REGISTRY_TOKEN }}
publish:
name: Publish (${{ github.event.repository.name }})
needs: base
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: rust

concurrency:
concurrency:
cancel-in-progress: false
group: ${{ github.event.repository.name }}-rust
group: ${{ github.workflow }}-${{ github.ref }}

env:
CARGO_TERM_COLOR: always
Expand All @@ -12,10 +12,9 @@ on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
tags: [ v*.*.* ]
release:
types: [ created ]
types: [ published ]
repository_dispatch:
types: [ rust ]
schedule:
Expand Down Expand Up @@ -53,9 +52,9 @@ jobs:
cargo-${{ matrix.toolchain }}-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
cargo-${{ matrix.toolchain }}-${{ runner.os }}-
cargo-${{ matrix.toolchain }}-
cargo-
- name: cargo test (workspace) --full
run: cargo test -v --workspace -F full
- name: cargo (bench)
if: matrix.toolchain == 'nightly'
run: cargo bench --features full -v --workspace
- name: cargo test (workspace)[full]
run: cargo test -v --workspace -F full
run: cargo bench -F full -v --workspace

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ thiserror = "1"

[workspace.package]
authors = ["Joe McCain III <[email protected]>",]
categories = [ ]
categories = [ "mathematics", "science", "simulation" ]
description = "This crate focuses on building concrete implementations for Turing Machines."
edition = "2021"
homepage = "https://github.com/FL03/rstm/wiki"
keywords = [ ]
keywords = [ "turing", "turing-machine", "utm" ]
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/FL03/rstm.git"
version = "0.0.2"
version = "0.0.3"

[profile.dev]
opt-level = 0
Expand Down
91 changes: 76 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,23 @@
# rstm


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

[![clippy](https://github.com/FL03/rstm/actions/workflows/clippy.yml/badge.svg)](https://github.com/FL03/rstm/actions/workflows/clippy.yml)
[![rust](https://github.com/FL03/rstm/actions/workflows/rust.yml/badge.svg)](https://github.com/FL03/rstm/actions/workflows/rust.yml)

***

### _The library is currently in the early stages of development and is not yet ready for production use._
[![license](https://img.shields.io/crates/l/rstm.svg)](https://crates.io/crates/rstm)
[![lines of code](https://tokei.rs/b1/github/FL03/rstm?category=code)](https://tokei.rs/b1/github/FL03/rstm?category=code)

This library focuses on building concrete implementations for Turing Machines.

## Features
***

_**The library is currently in the early stages of development and is still settling in on a feel for the api.**_

This library focuses on building concrete implementations for Turing Machines.

## Getting Started

### Building from the source
### From the source

Start by cloning the repository

Expand All @@ -28,28 +27,90 @@ cd rstm
```

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

#### _Run an example_

```bash
cargo run -f F --example actor
```

## Usage

### Example
### Creating a new ruleset

Programs are essentially collections of rules that define the behavior of the machine. Facilitating the creation of these rules is the `ruleset!` macro. The macro allows developers to define a set of rules for the machine in a concise and readable manner while further emulating the transition function defined by "On topological dynamics of Turing machines" by Petr Kůrka; `δ: Q x A -> Q x A x {-1, 0, 1}.`


`ruleset!` is a macro that allows you to define a set of rules for the machine. The syntax is as follows:

```rust
ruleset![
(state, symbol) -> Direction(next_state, next_symbol),
...
]
```

The macro is hygenic, meaning developers will not need to import the `Direction` enum nor its variants in order to use the macro.



#### Example: Building a ruleset for a three-state, two-symbol Turing machine

```rust
use rstm::ruleset;

// define the ruleset for the machine
let rules = ruleset![
(0, 0) -> Right(1, 0),
(0, 1) -> Stay(-1, 1),
(1, 0) -> Left(0, 1),
(1, 1) -> Right(-1, 0),
(-1, 0) -> Right(0, 0),
(-1, 1) -> Right(1, 1),
];
```

### Examples

```rust
extern crate rstm;

fn main() -> Result<(), Box<dyn std::error::Error>> {
use rstm::{ruleset, Actor, Program, State};

fn main() -> Result<(), Box<dyn std::error::Error>> {
tracing_subscriber::fmt().with_target(false).init();

// initialize the tape data
let alpha = vec![0i8; 10];
// initialize the state of the machine
let initial_state = State(0);
// define the ruleset for the machine
let rules = ruleset![
(0, 0) -> Right(1, 0),
(0, 1) -> Right(-1, 1),
(1, 0) -> Right(0, 1),
(1, 1) -> Right(-1, 0),
(-1, 0) -> Left(0, 0),
(-1, 1) -> Left(1, 1),
];

let program = Program::new()
.initial_state(initial_state)
.rules(rules)
.build();

// create a new instance of the machine
let tm = dbg!(Actor::from_state(initial_state).with_tape(alpha));
tm.execute(program).run()?;
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.
Pull requests are welcome. Any improvements or modifactions should first be disccussed using a pull-request and/or by opening an issue. Additionally, please make sure to update tests as appropriate and to adhear to the feature gates.

## License

Expand Down
4 changes: 3 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Checkout the current and supported packages below

| Package | Current | Supported |
|---------|---------|-----------|
| rstm | 0.0.0 | <=0.0.0 |
| rstm | 0.0.3 | <=0.0.3 |

## Reporting a Vulnerability

Any issues or vulnerabilities should be reported to the maintainer of the package via email or by creating an [issue](https://github.com/FL03/rstm/issues/new) on the repository.
15 changes: 14 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,30 @@ repository.workspace = true
version.workspace = true

[features]
default = []
default = [
"alloc",
]

full = [
"default",
"rand",
"serde",
"tracing",
]

# ********* [FF] Dependencies *********
alloc = [
"num/alloc",
"serde?/alloc",
]

rand = [
"num/rand",
]

serde = [
"dep:serde",
"num/serde",
]

tracing = [
Expand All @@ -51,6 +60,10 @@ test = true
thiserror.workspace = true
paste.workspace = true

[dependencies.num]
# default-features = false
version = "0.4"

[dependencies.serde]
# default-features = false
features = ["derive"]
Expand Down
Loading

0 comments on commit 037db9e

Please sign in to comment.