Tiny expressions-based language for elementary cellular automata simulation

bump to v1.1

ecsolticia.bsky.social 624dd968 f943e3db

verified
+1 -1
Cargo.lock
··· 10 10 11 11 [[package]] 12 12 name = "ecaxpr" 13 - version = "0.1.0" 13 + version = "0.1.1" 14 14 dependencies = [ 15 15 "anyhow", 16 16 "mipl",
+1 -1
Cargo.toml
··· 1 1 [package] 2 2 name = "ecaxpr" 3 - version = "0.1.0" 3 + version = "0.1.1" 4 4 edition = "2024" 5 5 description = "Tiny expressions-based language for elementary cellular automata simulation" 6 6 license = "MIT"
+12 -6
README.md
··· 1 1 # ecaxpr 2 2 3 - Tiny expressions-based language for elementary cellular automata simulation. 3 + `ecaxpr` is a tiny, declarative, expressions and predicate logic-based language for elementary cellular automata simulation. 4 4 5 5 - [Tangled](https://tangled.org/@did:plc:h5uflu6cfdbvjsggusevvy6i/ecaxpr). 6 6 - [Crates.io](https://crates.io/crates/ecaxpr). 7 + - [Book](https://ecaxpr-book.pages.dev/). 7 8 8 9 --- 9 10 11 + There are a total of only 256 distinct elementary cellular automata. We can refer to each of them via a number from 0 to 255 by representing their state evaluation tables as bits. However, ecaxpr represents their rules not by just a simple number, but as a logical formulae. This provides a distinct way of experimenting with and thinking about these cellular automata. 12 + 13 + Here, an expression such as 10 14 11 15 ``` 12 16 l == ~(r | t) 13 17 14 - ***************#*************** 16 18 + ***************#*************** 15 15 19 ``` 16 20 17 21 becomes... ··· 35 39 ##*####**##*#**#*#####**####### 36 40 ``` 37 41 38 - --- 42 + ## Install, Get Started, Get Docs 43 + 44 + For installation instructions, documentation and a guide, you may refer to different sections of **The ecaxpr Book**. 39 45 40 - - [Installation](./docs/install.md). 46 + - [Installation](https://ecaxpr-book.pages.dev/install). 41 47 42 - - [Guide](./docs/guide.md). 48 + - [Getting Started](https://ecaxpr-book.pages.dev/guide). 43 49 44 - - [Language Reference](./docs/langrefs.md). 50 + - [Language Reference](https://ecaxpr-book.pages.dev/guide).
-16
docs/guide.md
··· 1 - # `ecaxpr` Guide 2 - 3 - `ecaxpr` is a domain-specific language. That domain here is elementary cellular automata. 4 - 5 - If you are unfamiliar with elementary cellular automata, and cellular automata in general, then this guide will not be able to help you. As such, you may consider resources like 6 - 7 - - [Cellular Automata (Wikipedia)](https://en.wikipedia.org/wiki/Cellular_automaton). 8 - 9 - - [Conway's Game of Life (Lifewiki)](https://conwaylife.com/wiki/Conway%27s_Game_of_Life). 10 - 11 - - [Wolfram Mathworld's entry on Elementary Cellular Automata](https://mathworld.wolfram.com/ElementaryCellularAutomaton.html). 12 - 13 - - [The "Rule 30" Wikipedia page - a particular ECA](https://en.wikipedia.org/wiki/Rule_30). 14 - 15 - This guide assumes that you have `ecaxpr` installed on your system. You may refer to the [Installation Instructions](./install.md) page if you have not already installed it. 16 -
-23
docs/install.md
··· 1 - # Install `ecaxpr`. 2 - 3 - ## Cargo Install 4 - 5 - More about this option: [cargo-install(1)](https://doc.rust-lang.org/cargo/commands/cargo-install.html). 6 - 7 - Ensure that the Rust toolchain is available to your environment. Then, 8 - 9 - ```bash 10 - cargo install ecaxpr 11 - ``` 12 - 13 - ## Manual Build 14 - 15 - Ensure that the Rust toolchain is available to your environment. 16 - 17 - ```bash 18 - git clone https://tangled.org/@did:plc:h5uflu6cfdbvjsggusevvy6i/ecaxpr 19 - cd ecaxpr 20 - cargo build --release 21 - ``` 22 - 23 - Finally, you can take `./target/release/ecaxpr` and do whatever you wish with your executable binary.
-82
docs/langrefs.md
··· 1 - # Language Reference 2 - 3 - Every `ecaxpr` file corresponds to an `ecaxpr` expression. 4 - 5 - An `ecaxpr` expression consists of three parts: 6 - 7 - 1. `L-expr`: A predicate logic expression representing the rules. 8 - 9 - 2. `State-expr`: An expression representing the initial state. 10 - 11 - 3. `Steps-expr`: A non-negative integer representing the number of steps to simulate. 12 - 13 - These names are mostly neologisms given for convenience and precise reference. 14 - 15 - Each part of the `ecaxpr` expression must occur in order exactly as stated. 16 - 17 - Newlines, spaces, and tabs do not matter. 18 - 19 - ## L-expr 20 - 21 - The following is a verbal description of the grammar of `L-expr`. 22 - 23 - For any operation that is mentioned as "taking in" `L-expr`, it should be assumed that what they produce are also `L-expr`. No exceptions arise. 24 - 25 - ### Predicates 26 - 27 - > The simplest of `L-expr` are `l`, `t`, and `r`. 28 - 29 - Given any cell in our elementary cellular automaton, `l` is the value of the cell to the left, `t` the value of the present cell ("this" cell), and `r` the value of the cell to the right. 30 - 31 - These are called **predicates**, a fancy name for variables in logic. 32 - 33 - ### Negation 34 - 35 - Given any `L-expr`, we can take its negation. 36 - 37 - To take the negation of a statement or predicate in logic means to invert its truth value. If it is true, then its negation is false, and vice versa. 38 - 39 - > If an `L-expr` predicate is writen as `X`, we take its negation as `~X` in an `L-expr`. Thus, if `X` is `t`, its negation is `~t`. 40 - 41 - ### Conjunction ("AND") 42 - 43 - Given any set of at least two `L-expr`, we can take their conjunction. 44 - 45 - To take the conjunction in logic means to check if *all* the conjuncted statements or predicates are true. The conjunction statement/predicate itself is only true if all of them are true, and false otherwise. 46 - 47 - For two statements/predicates, this corresponds to stating that both of them are true. In general, it corresponds to stating that *all* of them are true. 48 - 49 - > Suppose that we have two `L-expr` predicates written as `A` and `B`, respectively. Then, their conjunction is written as `A & B`. 50 - 51 - > Suppose that we have a list of N `L-expr` predicates, where N is some non-negative integer greater than or equal to 2. Suppose that they are written as `L1`, `L2`, `L3`, ..., `LN`, respectively. Then, their conjunction is written out as `L1 & L2 & ... & LN`. 52 - 53 - ### Disjunction ("OR") 54 - 55 - Given any set of at least two `L-expr`, we can take their disjunction. 56 - 57 - To take the disjunction in logic means to check if *at least one* of the disjuncted statements or predicates is true. The disjunction statement/predicate itself is only false if all of them are false, and true otherwise. 58 - 59 - > Suppose that we have two `L-expr` predicates written as `A` and `B`, respectively. Then, their disjunction is written as `A | B`. 60 - 61 - > Suppose that we have a list of N `L-expr` predicates, where N is some positive integer greater than or equal to 2. Suppose that they are written as `L1`, `L2`, `L3`, ..., `LN`, respectively. Then, their disjunction is written out as `L1 | L2 | ... | LN`. 62 - 63 - ### Equality 64 - 65 - Given any two `L-expr`, we can take their equality. 66 - 67 - To "take the equality" here means to check if both of the operands are of the same truth values. If so, then the equality is true, and false otherwise. 68 - 69 - > Suppose that we have two `L-expr` predicates written as `A` and `B`, respectively. Then, their equality is written as `A == B`. 70 - 71 - ## State-expr 72 - 73 - A `State-expr` consists of `*` and `#` in succession. 74 - 75 - - `*` represents white or `false` cells. 76 - - `#` represents black or `true` cells. 77 - 78 - Thus, `***#***` would correspond to an initial states configuration where the first three cells are `false`, followed by a `true` one, which is then followed by three more `false` cells. 79 - 80 - ## Steps-expr 81 - 82 - A `Steps-expr` is simply a non-negative integer.
+1 -1
src/lib.rs
··· 3 3 mod table; 4 4 mod states; 5 5 6 - use anyhow::{Result, Context, anyhow}; 6 + use anyhow::{Result, Context}; 7 7 use crate::ast::Parseable; 8 8 9 9 fn read_source(path: &str) -> Result<String> {