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:


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


and the end of loop 5 is indicated by


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


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:

ROTX #1 AT 0
ROTX #2 AT 0

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


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


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

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

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Blog at WordPress.com.

%d bloggers like this: