Package: tweedledum-dev
/!\ (Warning) If you have used tweedledum before: the master branch history is broken.
/!\ The new master branch is a completely rewrite of the library. The old version can be found
/!\ on **alpha** branch. (Sorry for the inconvenience!!---but it is for a great cause)tweedledumis a library for synthesis, compilation, and optimization of
quantum circuits.  The library is written to be scalable up to problem sizes in
which quantum circuits outperform classical ones. Also, it is meant to be used
both independently and alongside established tools.Its design is guided by three mantras:Gotta run fast: execution-time performance is a priority.Your compiler, your rules.  You know better. At least, Tweedledum
hopes so! The library provides a standard set of operators that can be easily
extended (thanks to some type-erasure black magic).  However, the library will
leave your operators completely alone if you don't write passes that
specifically manipulate them.  Furthermore, Tweedledum will rarely take any
decision in your behalf, i.e., it does not provide generic methods to optimize
or synthesize circuits, you need to specifically call the algorithms you want.Opinionated, but not stubborn.  Many passes and synthesis algorithms have
many configuration parameters.  Tweedledum comes with reasonable defaults and
curated opinions of what value such parameters should take.  But in the end,
it all up to you.Corollary:  Because of it's flexibility, Tweedledum is capable of accepting
gates/operators that are defined as python classes.  Indeed, any pythonic
framework can use the library as a circuit manager.  Meaning that the library
can be used to slowly transition the core and performance sensitive parts of a
pythonic framework to C++, while maintaining the capability of users to develop
passes in python.InstallationKnown issueswithmacOS High Sierra (10.13)andmacOS Mojave (10.14).tweedledumhas two python packages that can be installed usingpip.  For
both, you will at leastPython 3.6.  Thetweedledumpackage contains the
latest stable release.  You can install it from PyPI using:Latest stable release (Linux/Mac/Windows)pip install tweedledumFor the developers, users or researchers who are comfortable living on the
absolute bleeding edge,tweedledum-devcontains that latest developments
merged into the master branch.Latest (Linux/Mac/Windows)pip install tweedledum-devWarning: The two packages cannot be installed together.Installation from source (Development)Installingtweedledumfrom the source, instead of using the Python Package
Index (PyPI) repository version, allows you to extend the latest version of the
code. In the following, I will explain two workflows I personally use for
development. Choose one that best suits your needs.Alright, both workflows start the same way. You clone the repository:git clone https://github.com/boschmitt/tweedledum.gitC++The first workflow is pure C++. We start by creating a directory to hold the
build output:mkdir build      
cd buildNote that the library has a directory namedexamples/.  If we set theTWEEDLEDUM_EXAMPLESCMake variable toTRUE.  Any.cppfile in this
directory will be compiled to its own executable.So, lets assume you have a file namedhello_world.cppin theexamples/.
First we configure our project and enable the examples:cmake -DTWEEDLEDUM_EXAMPLES=TRUE ..If you are on a *nix system, you should now see a Makefile in the current
directory. Now you can build the library by runningmake. At this point you
can build thehello_worldexecutable by callingmake hello_worldOnce the examples have been built you can run it:./examples/hello_worldC++ and PythonThe second workflow is a bit of a hack.  In Python we can install libraries in
editable mode, meaning that code changes to thePython codein the project
don't require a reinstall to be applied.If you want to install it in editable mode, you can do this with:pip install -e .The only problem now, is that if we change the C++ code, we will need to
reinstall the library.  Fortunately, there is a way to circumvent this
annoyance.After installing in editable mode, you will see that inpython/tweedledum/there is a cpython shared library_tweedledum.cpython-...Remove this file:rmpython/tweedledum/_tweedledum.cpython-...Now, we create a build directory as we did with the C++ workflow:mkdirbuildcdbuildWe can manually build the cpython shared library using:make_tweedledumThis will create the library in thebuild/directory. Now, all we need to
create a symbolic link inpython/tweedledum/that points the library inbuild/:ln-s_tweedledum.cpython-39-darwin.so../python/tweedledum/Now, whenever we change the C++ code and rebuild the python library, the changes
won't require a reinstall of the library to be available.Used third-party toolsThe library it is built, tested, bind to python, and whatnot using many
third-party tools and services. Thanks a lot!abc- ABC: System for Sequential Logic Synthesis and Formal Verificationbill- C++ header-only reasoning libraryCatch2test framework for unit-tests, TDD and BDDCMakefor build automationEigentemplate library for linear algebra{fmt}- A modern formatting librarykitty- truth table librarylorina- C++ parsing library for simple formats used in logic synthesis and formal verificationmockturtle- C++ logic network librarynlohmann/json- JSON for Modern C++parallel_hashmap- A family of header-only, very fast and memory-friendly hashmap and btree containers.percy- C++ header-only exact synthesis librarypybind11- Seamless operability between C++11 and Pythonrang- A Minimal, Header only Modern c++ library for terminal goodiesKnown issuesThese are issues that hopefully will be fixed, but currently are unsolved.  If
you know how to help with one of these issues, contributions are welcome!macOS: High Sierra (10.13) and Mojave (10.14)tweedledumoffers limited support for both systems.  While wheels might be
available for some releases, it is strongly advised to installtweedledumortweedledum-devby building them directly from source.  For example:CC=gcc-10CXX=g++-10CXXFLAGS="-static-libgcc -static-libstdc++"pipinstalltweedledum--no-binary:all:Note that such command requires a workinggcc10installation. (It also works
withgcc11, but no further tests were made.) I recommend the use ofHomebrewto installgcc. (Or maybeTigerbrew)LicenseThis software is licensed under the MIT licence (seeLICENSE).EPFL logic synthesis librariestweedledum is part of theEPFL logic synthesislibraries.
The other libraries and several examples on how to use and integrate the
libraries can be found in thelogic synthesis tool showcase.