Skip to main content
What if a variable could hold multiple values? If you’ve used Python before, the syntax will look familiar:
Here, x simply holds 14. In Rhyme, we can write:
The syntax is still familiar, but x now holds multiple values in superposition. Here, the value of x is a combination of 14 and 23. But what does that actually look like? Let’s take a peek inside.

What’s inside a qint?

Each of the values 14 and 23 participates in the superposition with an amplitude. We can inspect their amplitudes:
Rhyme debugger showing qint amplitudes
You can think of amplitudes as numbers that describe how the superposition is distributed across its participating values. In this example, 14 and 23 both participate in the superposition with equal amplitudes: 12≈0.707\frac{1}{\sqrt{2}} \approx 0.707 So the superposition looks like: 14→12≈0.70714 \rightarrow \frac{1}{\sqrt{2}} \approx 0.707 23→12≈0.70723 \rightarrow \frac{1}{\sqrt{2}} \approx 0.707 But there is a problem: quantum mechanics does not allow us to directly see the amplitudes. If we want to get information from a superposition, we have to observe it.

From a superposition to a value

Let’s make this concrete. Suppose 14 and 23 are two node IDs in a network, representing two possible next hops for a packet:
Visual representation of the example
Now let’s observe it:
observe() collapses the superposition to exactly one of the values that participate in it. Before observation, both values co-exist as possibilities.
Rhyme debugger showing one value remaining after the collapse with amplitude of 1
Here, 23 is the observed value, with an amplitude of 1, while the amplitude of 14 is now 0.
qint in superposition before observation and its collapse value after observation
So what determines which value we observe? The amplitude tells us. The squared magnitude of an amplitude gives the probability of observing that value. In our example: 14→∣12∣2=0.514 \rightarrow \left|\frac{1}{\sqrt{2}}\right|^2 = 0.5 23→∣12∣2=0.523 \rightarrow \left|\frac{1}{\sqrt{2}}\right|^2 = 0.5 So 14 and 23 have equal probabilities of being observed: 50% each. For this example, the observed value can be either 14 or 23. Since the two values have equal amplitudes, repeated runs produce the two values with equal probabilities.

More than two values

A qint can also represent several values at once. For example:
Here, all four values participate in the superposition with equal amplitudes.
Rhyme debugger showing equal amplitudes of all four values
That’s the basic idea behind superposition: a value can be a combination of multiple values, each with its own amplitude. That’s it. You’ve just created a quantum integer, inspected the amplitudes of its values, and observed the result. qint creates a value in superposition. observe() collapses the superposition to one of its participating values. And that’s your first step into Rhyme!!