All Projects → rigetti → Oqaml

rigetti / Oqaml

Licence: apache-2.0
An OCaml based implementation of a Quil QVM

Programming Languages

ocaml
1615 projects

Projects that are alternatives of or similar to Oqaml

Cycle State Machine Demo
Non-trivial, real use case demo of a hierarchical state machine library with cyclejs
Stars: ✭ 25 (-19.35%)
Mutual labels:  state-machine, functional-programming
Kingly
Zero-cost state-machine library for robust, testable and portable user interfaces (most machines compile ~1-2KB)
Stars: ✭ 147 (+374.19%)
Mutual labels:  state-machine, functional-programming
Swiftrex
Swift + Redux + (Combine|RxSwift|ReactiveSwift) -> SwiftRex
Stars: ✭ 267 (+761.29%)
Mutual labels:  state-machine, functional-programming
D4s
Dynamo DB Database Done Scala-way
Stars: ✭ 27 (-12.9%)
Mutual labels:  functional-programming
Cfl
a Compileable statically typed Functional programming Language
Stars: ✭ 7 (-77.42%)
Mutual labels:  functional-programming
Bugz
🐛 Composable User Agent Detection using Ramda
Stars: ✭ 15 (-51.61%)
Mutual labels:  functional-programming
Purrr
A functional programming toolkit for R
Stars: ✭ 953 (+2974.19%)
Mutual labels:  functional-programming
Puddles
Tiny vdom app framework. Pure Redux. No boilerplate.
Stars: ✭ 24 (-22.58%)
Mutual labels:  functional-programming
Facsimile
Facsimile Simulation Library
Stars: ✭ 20 (-35.48%)
Mutual labels:  functional-programming
Revery Playground
Live, interactive playground for Revery examples
Stars: ✭ 14 (-54.84%)
Mutual labels:  functional-programming
Workflow
A Swift and Kotlin library for making composable state machines, and UIs driven by those state machines.
Stars: ✭ 860 (+2674.19%)
Mutual labels:  state-machine
Blog Src
Personal blog source.
Stars: ✭ 7 (-77.42%)
Mutual labels:  functional-programming
Mori Ext
Function bind syntax wrappers for mori
Stars: ✭ 15 (-51.61%)
Mutual labels:  functional-programming
Enum Fp
Functional Enum type / Sum type for javascript with simple pattern matching
Stars: ✭ 27 (-12.9%)
Mutual labels:  functional-programming
Opal
Simple and powerful programming language with type inference
Stars: ✭ 20 (-35.48%)
Mutual labels:  functional-programming
Mappy
A functional programming language. Like LISP but focused around maps rather than lists.
Stars: ✭ 10 (-67.74%)
Mutual labels:  functional-programming
Elm Cheat Sheet
An overview of Elm syntax and features
Stars: ✭ 928 (+2893.55%)
Mutual labels:  functional-programming
Goderive
Code Generation for Functional Programming, Concurrency and Generics in Golang
Stars: ✭ 848 (+2635.48%)
Mutual labels:  functional-programming
Funktionale
Functional constructs for Kotlin
Stars: ✭ 879 (+2735.48%)
Mutual labels:  functional-programming
Docker Iocaml Datascience
Dockerfile of Jupyter (IPython notebook) and IOCaml (OCaml kernel) with libraries for data science and machine learning
Stars: ✭ 30 (-3.23%)
Mutual labels:  functional-programming

Notice: This is research code that will not necessarily be maintained to support further releases of Forest and other Rigetti Software. We welcome bug reports and PRs but make no guarantee about fixes or responses.

OQaml

OQaml is licensed under the Apache 2.0 license.

Introduction

OQaml is a reference implementation of the Quantum Abstract Machine (QAM) outlined in R. Smith, M. J. Curtis and W. J. Zeng, "A Practical Quantum Instruction Set Architecture," (2016), arXiv:1608.03355 [quant-ph]. The purpose of OQaml is to demonstrate the conceptual similarities between a classical state machine and a Quantum state machine. It highlights the facts in which functional programming lends itself ideally to the operations on a quantum state as it enforces deliberate actions to force side-effects, i.e. interactions with the environment.

OQaml currently supports ProtoQuil (a subset of the full Quil instruction language) which includes one- and two-qubit gate instructions as well as a full state measurement.

Getting started

Setting up the environment

To hit the ground running to interact with OQaml you need to set up your OCaml environment as described in a short OQaml setup guide. The best way to interact with OQaml is the use of utop. A more general guide how to set up a good OCaml environment can be found in the RealWorldOCaml instructions.

OQaml actively uses Owl and JaneStreet's Core_extended. Both of which can be easily install using Opam. Note, however, that some functionality of OQaml requires the latest changes to the development branch of Owl, which is not yet available on Opam.

Installing OQaml

If you have already have a working OCaml environment you can install OQaml by cloning this repository and run.

make all
make install

from the repository root. This will install OQaml into your OCaml environment.

Interacting with the Ocaml QVM

If all functionality is installed then interactions with the OQaml QVM are best done using utop running

utop

This drops you into a OCaml REPL and you can start loading modules and interact with the QVM.

utop[0]> #require "oqaml";;
utop[1]> #require "owl";;
utop[2]> module V = Owl.Dense.Vector.C;;
module V = Owl.Dense.Vector.C
utop[3]> module Q = Oqaml;;
module Q = Oqaml
utop[4]> let tqvm = Q.init_qvm 3;;
val tqvm : Q.qvm = {Q.num_qubits = 3; wf =
        C0
R0 (1, 0i)
R1 (0, 0i)
R2 (0, 0i)
R3 (0, 0i)
R4 (0, 0i)
R5 (0, 0i)
R6 (0, 0i)
R7 (0, 0i)

;
reg = [|0; 0; 0;|]}
utop[5]> let prog = Q.CIRCUIT([Q.Y 2; Q.CNOT (0,1); Q.X 0]);;
val prog : Q.gate = Q.CIRCUIT [Q.Y 2; Q.CNOT (0, 1); Q.X 0]
utop[6]> Q.apply prog tqvm;;
- : Q.qvm = {Q.num_qubits = 3; wf =
        C0
R0 (0, 0i)
R1 (0, 0i)
R2 (0, 0i)
R3 (0, 0i)
R4 (0, 0i)
R5 (0, 0i)
R6 (0, 0i)
R7 (0, 1i)

;
reg = [|0; 0; 0;|]}

Note that the gates in the set prog are executed from right to left in the way quantum-mechanical notation acts on a state.

Walkthrough

More details can be found in the small getting started walkthrough.

Building the docs

To build the API docs you can run

make docs

This will create a subfolder containing an HTML project that exposes all public APIs of OQaml. To create the readme files and images you need the most recent development version of readme2tex; Compilation is done with

make readmes

will convert the tex markdown files to well readable markdown.

Development and Testing

The test infrastructure uses Alcotest. To run the tests you can execute

opam install alcotest
make test

How to cite OQaml

If you use the reference-qvm please cite the repository as follows:

bibTex:

@misc{oqaml2017.0.0.1,
  author = {Rigetti Computing},
  title = {OQaml},
  year = {2017},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/rigetticomputing},
  commit = {the commit you used}
}

and the paper outlining the mathematical specification of the quantum-abstract-machine:

bibTeX:

@misc{1608.03355,
  title={A Practical Quantum Instruction Set Architecture},
  author={Smith, Robert S and Curtis, Michael J and Zeng, William J},
  journal={arXiv preprint arXiv:1608.03355},
  year={2016}
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].