Skip to content

alexarice/phase-rs

Repository files navigation

Prototype interpreter for "it's just a phase"

The repository contains an implementation of the combinator variant of the "it's just a phase" language. Given an input program, the interpreter:

  • performs some basic normalisation (associativity etc.)
  • performs macro expansion of inverses, square roots, and gate definitions
  • compiles the term to a circuit definition.
  • Builds the unitary for the output.

Building

The project should build with a standard rust installation, and is tested with rustc/cargo 1.88.0. These can be installed by a tool such as rustup or by using the provided nix flake.

Running

A file of commands can be run using:

cargo run -- --file <FILENAME>

or passed in through stdin. For all options see:

cargo run -- --help

Code documentation can be built by running:

cargo doc

and found (after building) at target/doc/phase_rs/index.html.

Examples

Examples of common gates (and of the syntax) can be found in examples/gates.ph. To view the generated terms and unitaries for each of these gates, edit the final term to the name of a different gate, and rerun:

cargo run -- --file examples/gates.ph

The examples folder also contains programs for:

  • Grover's algorithm (for finding the element 0000)
  • QFT (up to 4 qubits)
  • GHZ state preparation
  • An example circuit translation with swap gates

About

Prototype interpreter for "Just a phase" language

Resources

Stars

Watchers

Forks

Packages

No packages published