Skip to content

Commit

Permalink
update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dakk committed Nov 9, 2023
1 parent 05c3b9e commit 1fe2b29
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 23 deletions.
8 changes: 7 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,16 @@
### Week 3: (6 Nov 23)

- [x] Ast2logic: if-then-else statement
- [ ] Midterm call
- [x] Midterm call
- [x] Bool optimization refactoring

### Week 4: (13 Nov 23)

- [ ] Cirq exporter
- [ ] Improve exporting utilities
- [ ] Use cases
- [ ] Documentation

## Month 3:

### Week 1: (20 Nov 23)
Expand Down
2 changes: 2 additions & 0 deletions docs/source/algorithms.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Algorithms
====================================
14 changes: 8 additions & 6 deletions docs/source/howitworks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ In order to translate python code to quantum circuit, qlasskit performs several
1. it starts from the python *AST* (abstract syntax tree) rewriting it to a simplified version
by the _ast2ast_ module.
2. Then the simplified *AST* is translated to *boolean expressions* as intermediate
form by the _ast2logic_ module.
form by the _ast2logic_ module. In this step, boolean expression are simplified and optimized
for the final transformation.
3. Finally, these boolean expressions are compiled into a *quantum circuit* by the _compiler_ module.

While other existing libraries translate individual operations into quantum circuits and then
Expand Down Expand Up @@ -104,10 +105,11 @@ Result
------

The result of the compiler is a quantum circuit represented with qlasskit `QCircuit`. This circuit
can now be exported to one of the supported framework.
can now be exported to one of the supported framework as a gate or as a standalone circuit.


The previous example function `f`, is translated to the following quantum circuit:
The previous example function `f`, is translated to the following quantum circuit: the
result is available at qubit `_re`.


.. code-block:: text
Expand All @@ -120,10 +122,10 @@ The previous example function `f`, is translated to the following quantum circui
│ ├───┤ │ └───┘├───┤ │ │ └───┘
n.3: ─────┼──┤ X ├──┼────■──┤ X ├──┼────┼───────
│ └───┘ │ ┌─┴─┐└───┘ │ │
a_4: ─────┼─────────┼──┤ X ├───────┼────┼───────
_re: ─────┼─────────┼──┤ X ├───────┼────┼───────
┌─┴─┐ │ └─┬─┘ │ ┌─┴─┐
a_5: ───┤ X ├───────■────┼─────────■──┤ X ├─────
a_4: ───┤ X ├───────■────┼─────────■──┤ X ├─────
└───┘ ┌─┴─┐ │ ┌─┴─┐└───┘
_re: ─────────────┤ X ├──■───────┤ X ├──────────
a_5: ─────────────┤ X ├──■───────┤ X ├──────────
└───┘ └───┘
10 changes: 1 addition & 9 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,13 @@ Python and translate them into unitary operators (gates) for use in quantum circ



.. :doc:`howitworks`
.. How qlasskit internally works
.. :doc:`qlassf`
.. QlassF class
.. :doc:`qcircuit`
.. QCircuit class
.. toctree::
:maxdepth: 2

howitworks
supported
qlassf
algorithms
types
qcircuit

Expand Down
26 changes: 19 additions & 7 deletions docs/source/supported.rst
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ Function call

Bultin functions:
- `print()`: debug function, ignore by conversion
- `len(Tuple)`: returns the length of a tuple
- `max(a, b, ...)`, `max(Tuple)`: returns the max of a tuple
- `min(a, b, ...)`, `min(Tuple)`: returns the min of a tuple
.. - `sum(Tuple)`: returns the sum of the elemnts of a tuple
.. - `all(a, b, ...)`, `all(Tuple)`:
.. - `any(a, b, ...)`, `any(Tuple)`:
- `len(Tuple)`, `len(Qlist)``: returns the length of a tuple
- `max(a, b, ...)`, `max(Tuple)`, `max(Qlist)`: returns the max of a tuple
- `min(a, b, ...)`, `min(Tuple)`, `min(Qlist)`: returns the min of a tuple
- `sum(Tuple)`, `sum(Qlist)`: returns the sum of the elemnts of a tuple / list
- `all(Tuple)`, `all(Qlist)`: returns True if all of the elemnts are True
- `any(Tuple)`, `any(Qlist)`: returns True if any of the elemnts are True



Expand Down Expand Up @@ -191,4 +191,16 @@ Function def
.. code-block:: python
def f(t: Qlist[Qint4,2]) -> Qint4:
return t[0] + t[1]
return t[0] + t[1]
If then else
^^^^^^^^^^^^

.. code-block:: python
c = 0
if cond:
c += 12
else:
c += 13

0 comments on commit 1fe2b29

Please sign in to comment.