Skip to content

Experimental Emulator of a Machine that Understands πœ‘-calculus

Notifications You must be signed in to change notification settings

objectionary/phie

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

logo

EO principles respected here We recommend IntelliJ IDEA

cargo crates.io PDD status codecov Hits-of-Code Lines of code License

It's an experimental emulator of a machine that understands πœ‘-calculus expressions, which is the formalism behind EO programming language.

To build it, install Rust and then:

$ cargo build --release

If everything goes well, an executable binary will be in target/release/fibonacci:

$ target/release/fibonacci 7 40

This will calculate the 7th Fibonacci number 40 times. Don't try to play with much larger numbers, this binary code is very slow. It's just an experiment.

To compile your own program instead of this primitive recursive Fibonacci calculator, you have to convert EO code into πœ‘-calculus expressions and then pass them to Emu struct like this:

use phie::emu::Emu;
pub fn main() {
    let mut emu: Emu = "
        Ξ½0(πœ‹) ↦ ⟦ πœ‘ ↦ Ξ½3(πœ‹) ⟧
        Ξ½1(πœ‹) ↦ ⟦ Ξ” ↦ 0x002A ⟧
        Ξ½2(πœ‹) ↦ ⟦ Ξ» ↦ int-add, ρ ↦ πœ‹.𝛼0, 𝛼0 ↦ πœ‹.𝛼1 ⟧
        Ξ½3(πœ‹) ↦ ⟦ πœ‘ ↦ Ξ½2(ΞΎ), 𝛼0 ↦ Ξ½1(πœ‹), 𝛼1 ↦ Ξ½1(πœ‹) ⟧
    ".parse().unwrap();
    let dtz = emu.dataize();
    print!("The result is: {}", dtz.0);
}

This code is equivalent to the following EO code:

[] > foo
  42 > x
  x.add x > @

But in a more "functional" way:

[] > foo
  42 > x
  int-add > @
    x
    x

More tests are in src/emu.rs file.

How to Contribute

First, install Rust and then:

$ cargo test -vv --release

If everything goes well, an executable binary will be in target/release/phie:

$ target/release/phie --help

Then, fork repository, make changes, send us a pull request. We will review your changes and apply them to the master branch shortly, provided they don't violate our quality standards. To avoid frustration, before sending us your pull request please run cargo test again. Also, run cargo fmt and cargo clippy.