Skip to content

Commit

Permalink
Merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
msoeken committed Feb 23, 2019
2 parents 904116e + 20d7d5f commit 808adf9
Show file tree
Hide file tree
Showing 324 changed files with 114,906 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Compilation
build/
dist/
revkit.egg-info/
venv
**/__pycache__

# Documentation
docs/_build

# IDE
.vscode

# Test
.eggs
.pytest_cache
16 changes: 16 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
venv: venv/bin/activate
venv/bin/activate: requirements.txt docs/requirements.txt
test -d venv || virtualenv venv
venv/bin/pip install -r requirements.txt
venv/bin/pip install -r docs/requirements.txt
venv/bin/pip install qiskit==0.7.1
touch venv/bin/activate

devbuild: venv
venv/bin/python setup.py install

docs: devbuild docs/*.rst docs/conf.py
PATH=$(PWD)/venv/bin/:$(PATH) $(MAKE) -C docs html

test: devbuild
venv/bin/python setup.py test
71 changes: 69 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,69 @@
# RevKit
RevKit: Python quantum compilation library and framework
# RevKit 3.1

RevKit 3.1 is a Python quantum compilation library. RevKit is based on the C++
libraries [tweedledum](https://github.com/boschmitt/tweedledum) and
[caterpillar](https://github.com/gmeuli/caterpillar) (as well as other C++
libraries from the
[EPFL logic synthesis libraries](https://github.com/lsils/lstools-showcase)),
and exposes their functionality by means of simple Python APIs. It also
contains the module `revkit.export` with several functions for interoperability
with other quantum programming languages and frameworks.

## Example

The following example creates a quantum circuit that computes the oracle
function `(a ∧ b) ⊕ (c ∧ d)` onto an ancilla qubit.

```python
from revkit import netlist, oracle_synth, truth_table
import revkit.export.qiskit

function = truth_table.from_expression("[(ab)(cd)]") # (a ∧ b) ⊕ (c ∧ d)
circuit = oracle_synth(function)

qcircuit = circuit.to_qiskit()
```

## Installation

From PyPi *(not yet available)*

```
pip install revkit
```

From Github with `setuptools`

```
pip install git+https://github.com/msoeken/revkit@develop
```

From Github with `make`

```
git clone -b develop https://github.com/msoeken/revkit
cd revkit
make devbuild
```

A very recent C++ compiler with support for C++ 17 is required to build RevKit.
If compilation with the default compiler on your system does not work, try to
setting the `CC` environment variable to a more recent compiler.

## Previous versions

RevKit has a 10-year long history. The rapidly changing requirements for
quantum computing also influenced RevKit, such that it was redesigned several
times. Previous versions of RevKit can be found online, but are no longer
maintained. Since version 3.1, RevKit does no longer exist as a standalone
command line application, but solely as a Python library, with the focus of an
easy integration with other Python-based quantum programming frameworks. In
order to access the various functionality in other applications, the libraries
[tweedledum](https://github.com/boschmitt/tweedledum) and
[caterpillar](https://github.com/gmeuli/caterpillar) can be used directly
instead.

## EPFL logic sythesis libraries

RevKit is based on the [EPFL logic synthesis](https://lsi.epfl.ch/page-138455-en.html) libraries. The other libraries and several examples on how to use and integrate the libraries can be found in the [logic synthesis tool showcase](https://github.com/lsils/lstools-showcase).

20 changes: 20 additions & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS =
SPHINXBUILD = sphinx-build
SPHINXPROJ = RevKit
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
25 changes: 25 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Change Log
==========

Version 3.1 (not yet released)
------------------------------

* Data structures:
- Quantum circuit (:class:`revkit.netlist`)
- Gate and qubit (:class:`revkit.gate`, :class:`revkit.qubit`)
- Truth table (:class:`revkit.truth_table`)

* Decomposition algorithms:
- Barenco decomposition (:func:`revkit.barenco_decomposition`)
- Direct Toffoli decomposition (:func:`revkit.dt_decomposition`)

* Synthesis algorithms:
- Decomposition-based synthesis (:func:`revkit.dbs`)
- Gray synthesis (:func:`revkit.gray_synth`)
- Diagonal unitary synthesis (:func:`revkit.diagonal_synth`)
- Oracle synthesis (:func:`revkit.oracle_synth`)
- Transformation-based synthesis (:func:`revkit.tbs`)
- LUT-based hierarchical reversible logic synthesis (:func:`revkit.lhrs`)

* Interoperability:
- Create Qiskit quantum circuit from RevKit quantum circuit (:func:`revkit.netlist.to_qiskit`)
169 changes: 169 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
# -*- coding: utf-8 -*-
#
# Configuration file for the Sphinx documentation builder.
#
# This file does only contain a selection of the most common options. For a
# full list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
# import os
# import sys
# sys.path.insert(0, os.path.abspath('.'))


# -- Project information -----------------------------------------------------

project = 'RevKit'
copyright = '2019, Mathias Soeken'
author = 'Mathias Soeken'

# The short X.Y version
version = ''
# The full version, including alpha/beta/rc tags
release = '3.1'


# -- General configuration ---------------------------------------------------

# If your documentation needs a minimal Sphinx version, state it here.
#
# needs_sphinx = '1.0'

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.mathjax',
'sphinx.ext.viewcode',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path .
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']

# The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx'


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'sphinx_rtd_theme'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# html_theme_options = {}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']

# Custom sidebar templates, must be a dictionary that maps document names
# to template names.
#
# The default sidebars (for documents that don't match any pattern) are
# defined by theme itself. Builtin themes are using these templates by
# default: ``['localtoc.html', 'relations.html', 'sourcelink.html',
# 'searchbox.html']``.
#
# html_sidebars = {}


# -- Options for HTMLHelp output ---------------------------------------------

# Output file base name for HTML help builder.
htmlhelp_basename = 'RevKitdoc'


# -- Options for LaTeX output ------------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title,
# author, documentclass [howto, manual, or own class]).
latex_documents = [
(master_doc, 'RevKit.tex', 'RevKit Documentation',
'Mathias Soeken', 'manual'),
]


# -- Options for manual page output ------------------------------------------

# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
(master_doc, 'revkit', 'RevKit Documentation',
[author], 1)
]


# -- Options for Texinfo output ----------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
# (source start file, target name, title, author,
# dir menu entry, description, category)
texinfo_documents = [
(master_doc, 'RevKit', 'RevKit Documentation',
author, 'RevKit', 'One line description of project.',
'Miscellaneous'),
]


# -- Options for autodoc -----------------------------------------------------

autodoc_mock_imports = [
'revkit.export.qiskit'
]
import revkit.export.qiskit


# -- Extension configuration -------------------------------------------------
6 changes: 6 additions & 0 deletions docs/decomposition.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Decomposition algorithms
========================

.. autofunction:: revkit.barenco_decomposition

.. autofunction:: revkit.dt_decomposition
11 changes: 11 additions & 0 deletions docs/export_qiskit.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Qiskit export
=============

Including this module adds the following members to :class:`netlist`::

import revkit.export.qiskit


.. autoclass:: revkit.netlist
:noindex:
:members: to_qiskit
24 changes: 24 additions & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.. RevKit documentation master file, created by
sphinx-quickstart on Thu Feb 7 13:38:56 2019.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to RevKit's documentation!
==================================

.. toctree::
:maxdepth: 2
:caption: Contents:

changelog
types
decomposition
synthesis
export_qiskit

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

0 comments on commit 808adf9

Please sign in to comment.