The Qwerty Programming Language #

Qwerty is a new quantum programming language with no gates. Instead, Qwerty is basis-oriented.

Here is an implementation of the Bernstein–Vazirani algorithm in Qwerty:

import sys
from qwerty import *

def bv(secret_string):
    def f(secret_string: bit[N], x: bit[N]) -> bit:
        return (secret_string & x).xor_reduce()

    def kernel(f: cfunc[N,1]) -> bit[N]:
        return '+'[N] | f.phase         \
                      | pm[N] >> std[N] \
                      | std[N].measure

    return kernel()

secret_string = bit.from_str(sys.argv[1])

Qwerty is embedded in Python, so invoking a Qwerty program is as easy as python bv.py 1101.

For more information, see: