The artifact is a Haskell library bellkat
plus several examples provided as executables within the same Haskell package.
We provide two build options: Nix-based and Stack-based, for each we give a Docker file that can simplify the setup of the development environment.
Reproducing the results from the paper can be done in two ways:
- from a respective development environment (Nix- or Stack-based)
- using an executable Docker container providing a Haskell interpreter with
bellkat
already "in scope" (recommended, see "Preparation" section in "Reproducing the results" below)
Docker note: please, be aware that docker run
commands may have to be prefixed with sudo
,
depending on the docker setup (see details here).
Please, check Haskell language server documentation for editor support (optional).
- install Nix package manager
- enable Nix flakes
- to enter environment run
nix develop
from the artifact's root - run
hpack
(no arguments) to generate.cabal
file
For convenience, we provide Dockerfile.nixdev
with the environment already set up:
docker build --tag bellkat:nixdev --file Dockerfile.nixdev . # build the image
docker run --rm --interactive --tty bellkat:nixdev # to enter the environment
-
install Stack
-
install the following extra dependencies:
Those can be installed on ubuntu as follows:
apt-get install libz-dev libtinfo-dev libcairo-dev libpango1.0
For convenience, we provide Dockerfile.stackdev
with the environment already set up:
docker build --tag bellkat:stackdev --file Dockerfile.stackdev . # build the image
docker run --rm --interactive --tty bellkat:stackdev # to enter the environment
cabal build
stack build
Bell pairs (e.g., to specify initial states):
-
$A \sim B$ is represented by"A" ~ "B"
Basic actions:
-
$cr\langle X \rangle$ is represented bycreate "X"
-
$tr\langle X \rightarrow Y \sim Z \rangle$ is represented bytrans "X" ("Y", "Z")
-
$sw\langle X \sim Y @ Z \rangle$ is represented byswap "Z" ("X", "Y")
-
$di\langle X \sim Y\rangle$ is represented bydistill ("X", "Y")
Operations:
- sequential composition is represented by
<>
- parallel composition
$||$ is represented by<||>
- iteration
$p^\ast$ is represented bystar p
Tests:
- checking absence
$[{{X \sim Y}}]$ is represented bytest ("X" /~? "Y")
- checking presence
${{X \sim Y}} \blacktriangleright {{X \sim Y}}$ is represented bytest ("X" ~~? "Y")
Features:
-
Deciding validity of a policy
$p$ on inputs from$\mathcal{N}_0$ and set of valid states$\mathcal{N}$ (definition 4.10) is represented byisPolicyValid N0 N p
, whereN
is represented as a predicate$\mathcal{M}(BP) \rightarrow \mathbb{B}$ . -
Deciding equivalence of policies
$p$ and$q$ on inputs from$\mathcal{N}_0$ (Theorem 4.4) is represented byarePoliciesEquivalent N0 p q
. -
Drawing histories of protocols (Figure 3):
-
drawHistoriesSVG p
(to create an.svg
image) -
drawHistoriesText p
(to output a textual representation)
-
-
Docker (recommended): change to artifact's root and create the container by running
docker build --tag bellkat:latest .
Note all the docker commands below use bind mount to handle input and output files.
-
Stack: change to the artifact root
-
Nix: change to the artifact root and run
nix develop
The protocols are specified in examples/P1.hs
, history would be saved in P1.svg
.
-
Docker (recommended)
docker run --rm --mount type=bind,source=$(pwd),target=/opt/bellkat -it bellkat:latest\ examples/P1.hs --width 1000 --output P1.svg # or (for textual version) docker run --rm --mount type=bind,source=$(pwd),target=/opt/bellkat -it bellkat:latest\ examples/P1Text.hs
-
Stack:
stack run p1 -- --width 1000 --output P1.svg # or (for textual version) stack run p1text
-
Nix:
cabal run p1 -- --width 1000 --output P1.svg # or (for textual version) cabal run p1text
The protocols are specified in examples/P2.hs
, history would be saved in P2.svg
.
-
Docker (recommended)
docker run --rm --mount type=bind,source=$(pwd),target=/opt/bellkat -it bellkat:latest\ examples/P2.hs --width 1000 --output P2.svg # or (for textual version) docker run --rm --mount type=bind,source=$(pwd),target=/opt/bellkat -it bellkat:latest\ examples/P2Text.hs
-
Stack:
stack run p2 -- --width 1000 --output P2.svg # or (for textual version) stack run p2text
-
Nix:
cabal run p2 -- --width 1000 --output P2.svg # or (for textual version) cabal run p2text
Perform four checks using examples/P3.hs
(uses HSpec library, please check its documentation to understand the uses of describe
, it
and shouldBe
within the example):
- check that the protocol always creates a
$A \sim E$ Bell pair - check that the protocol does not always creates a
$A \sim C$ Bell pair - check that 1 qubit memory at location
$A$ are not enough - check that 3 qubits memory at location
$A$ are not enough - check that 2 qubits at
$A$ and 4 qubits at$D$ are enough
The first two are related reachability property (discussed on line 942 of the paper), while the rest are related to memory requirements (discussed on line 943 of the paper):
-
Docker (recommended)
docker run --rm --mount type=bind,source=$(pwd),target=/opt/bellkat -it bellkat:latest\ examples/P3.hs
-
Stack:
stack run p3
-
Nix:
cabal run p3
Most of the relevant documentation is present in BellKAT.Prelude
module. To see it nicely
formatted (not for docker), you can build documentation using Haddock:
- Stack:
stack haddock
- Nix:
cabal haddock
In both cases, the output should display the path to index.html
root of the documentation
If you want to work with your own protocols or modify existing ones you have multiple options:
-
modify the existing examples
-
create new examples within BellKAT repository
-
Creating a new file (say
MyExample.hs
) insideexamples/
(e.g., by copyingexamples/P3.hs
) -
Tell
stack
orcabal
about the example by addingmy-example: dependencies: - bellkat main: examples/MyExample.hs
to
package.yaml
-
Run your example with stack, using
stack run my-example
orcabal run my-example
-
(optional) to enable editor support add
- path: "examples/MyExample.hs" component: "exe:my-example"
to
hie.yaml
-
Continue editing
examples/MyExample.hs
as you wish.
-
-
Use
BellKAT
as a library:-
Stack: see the template in
reuse-templates/stack
, then usestack build stack run
-
Nix: see the template in
reuse-templates/nix
, then usenix develop # to enter the shell hpack # to generate .cabal file cabal build cabal run
-