# Quantum Bayesian Networks

## January 21, 2019

### Qubiter TODO/Proposal: Loop Dependent Evaluation of Placeholder Variables (quantum programming languages, loops)

Filed under: Uncategorized — rrtucci @ 7:24 pm

This article is a proposal for a feature that I think would be cool for Qubiter to have. I’m not sure that there is a pressing need or strong interest for this feature in the community of qc programmers, so I will delay adding it to Qubiter until enough people ask for it. Color me doubtful that anybody will.

So this is the plan:

Below, we will use the language that Qubiter uses in its “English Files”. That language is explained succinctly in Qubiter’s Rosetta Stone pdf document:

https://github.com/artiste-qb-net/qubiter/blob/master/qubiter_rosetta_stone.pdf

Qubiter already has loops implemented. The beginning of a loop called 5 with 15 repetitions is indicated in an English File by the line

LOOP 5 NREPS= 15

and the end of loop 5 is indicated by

NEXT 5

In fact, Qubiter already accepts loops embedded inside loops, with an arbitrary number of embeddings possible.

Qubiter already has Placeholder variables implemented too. Their usage is illustrated in the following Jupyter notebook

https://github.com/artiste-qb-net/qubiter/blob/master/jupyter-notebooks/examples_of_placeholder_usage.ipynb

The plan is to combine loops and placeholder variables. Here is a simple example that conveys the potential of this plan. Suppose we have an English File that looks like this:

LOOP 1 NREPS= 2
ROTX #1 AT 0
LOOP 2 NREPS= 3
ROTX #2 AT 0
NEXT 2
NEXT 1

Then we can feed to the simulator constructor a dictionary that looks like this

var_values =
{
(0, _): {#1: 0.1, #2: _}
(1, _): {#1: 0.2, #2: _}
(0, 0): {#1: _, #2: 0.0}
(0, 1): {#1: _, #2: 0.1}
(0, 2): {#1: _, #2: 0.2}
(1, 0): {#1: _, #2: 0.3}
(1, 1): {#1: _, #2: 0.4}
(1, 2): {#1: _, #2: 0.5}
}

The `var_value` dictionary gives the values that the placeholder variables `#1` and `#2` will be assigned for each repetition of the loops. The keys of the `var_value` dictionary are a pair of numbers indicating which repetition is being serviced. The first number is the repetition index of LOOP 1, and the second number is the rep index of LOOP 2.

Update (Jan 22, 2019): I was thinking of possible applications of single and nested loops in quantum languages. Implementing the Trotter approximation, Grover’s algorithm, and the algorithm commonly referred to as QAOA, with a single loop are 3 obvious applications. Implementing the Trotter-Suzuki approximation would require not just one loop, but several nested loops. Last night, I wrote a simple jupyter notebook investigating further the implementation of Trotter-Suzuki with nested loops. Here it is

https://nbviewer.jupyter.org/url/www.ar-tiste.com/Python_Functions_For_Printing_Trotter_Suzuki_Approx.ipynb

The importance of loops in quantum languages begs the question, why do they arise at all? In classical programming languages, loops embody determistic repetitive (possibly adaptive repetitive) tasks. In quantum programming languages, they embody Markov chains. Both are ubiquitous in Nature. Nested loops describe tree structures, also very common in Nature.

Update (Feb.3, 2019): I decided to do this anyway. Here is a Jupyter notebook explaining what I did

https://github.com/artiste-qb-net/qubiter/blob/master/jupyter-notebooks/loops_at_english_file_level_using_loop_files.ipynb

## 1 Comment »

1. You missed one point though: Two mirrors staring each other! More generally, a Multi-Agent System can be constantly looping even if each member is doing just one thing – and from a distance that is! I called it the ARMAS model once but hey, there are a myriad of variations possible
https://arxiv.org/abs/1806.05108

Comment by technofeudalism — January 24, 2019 @ 12:38 pm

Blog at WordPress.com.