Skip to content

BasisResearch/Autumn.cpp

Repository files navigation

Autumn.cpp (a.k.a. Autumn.Wasm) A CPP Implementation of Autumn that compiles to WASM (and more)

License: MIT

This repository hosts the Autumn interpreter, built with C++. It compiles to libraries usable in WebAssembly (WASM), C++, Python and Julia.

Example Programs: Particles, Magnets, and Space Invader

Setting Up the Environment

Create a Conda environment using the following command:

conda env create --file environment.yml

Using the pre-built package

To avoid the hassle in re-building, please try visiting the Release page. Download the corresponding version and use it according to the Wiki

Building the C++ Interpreter

Install Julia Package

Run julia and install CxxWrap

using Pkg
Pkg.add("CxxWrap")

Compile the C++ interpreter by running:

mkdir build && cd build
cmake .. -DCMAKE_PREFIX_PATH=$(julia -e 'using CxxWrap;print(joinpath(CxxWrap.prefix_path()), "/lib/cmake")')
make  -j12
cd ..

If you’re using macOS with Apple Silicon, use cmake .. -DCMAKE_OSX_ARCHITECTURES=arm64 in place of cmake .. to ensures that all files are compiled and linked for arm64 architecture.

Running Autumn programs

Python

Then, in the same folder, execute the following commands:

cp build/*.so .
python python_test_mpl.py tests/grow.sexp 2> stderr_python.txt 

If you want to visualize preset of animation, first, install ffmpeq

# Mac
brew install ffmpeg
# Linux
apt install ffmpeg libffmpeg

Julia Build

In your julia project:

using Pkg;
Pkg.develop(path=joinpath(first(DEPOT_PATH), "packages", "AutumnInterpreter"))
Pkg.add("Plots") # This is for visualization
Pkg.add("PlotlyJS") # This is for visualization
Pkg.add("JSON3") # This is for visualization
Pkg.add("WebIO")
Pkg.add("Observables")
Pkg.add("JSExpr")
using AutumnInterpreter

Finally, try out these tests:

julia test.jl
julia test2.jl

The main purpose is to allow building Autumn agent in Julia. For interactive purpose, please use Python package.

WASM Build

sh install_scripts/setup_emscripten.sh
source ./emsdk/emsdk_env.sh
make web
cp interpreter_web.* ./flask_server/static/

What's working?

BBQ Egg Gravity 3 Grow Magnets Paint Particles Sokoban II Waterplug Game of Life Gravity 4 Ice Mario Particle 1 Sand Sokoban Wind

Bleeding Edge

We welcome and hope to receive contributions in the following modules:

  • python_test_mpl_ci.py This is used for headless CI testing.
  • python_test is a faster interface under development, but is not working properly, use python_test_mpl.py instead.

Citations

@article{das2023autumn,
author = {Das, Ria and Tenenbaum, Joshua B. and Solar-Lezama, Armando and Tavares, Zenna},
title = {Combining Functional and Automata Synthesis to Discover Causal Reactive Programs},
year = {2023},
issue_date = {January 2023},
publisher = {Association for Computing Machinery},
address = {New York, NY, USA},
volume = {7},
number = {POPL},
url = {https://doi.org/10.1145/3571249},
doi = {10.1145/3571249},
journal = {Proc. ACM Program. Lang.},
month = jan,
articleno = {56},
numpages = {31},
keywords = {synthesis, reactive, causal, automata}
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgement

We acknowledge the open-source projects and communities that made this interpreter possible:

Contributors

Dat Nguyen, Archana Warrier, Yichao Liang, Cambridge Yang, Michelangelo Naim, Zenna Tarvares

About

Autumn.CPP (aka. Autumn.WASM) A cpp implementation of Autumn that compiles to WASM, Python and Julia bindings.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published