Beispiel #1
0
def QubitRegisterSpace(num_Qbits):
    '''
    Transplanted here beginning 2/13/2020 by wdc, from the old
    physics/quantum/common.py
    '''
    # need some extra curly brackets around the Exp() expression
    # to allow the latex superscript to work on something
    # already superscripted
    return TensorExp({Exp(Complexes, num(2))}, num_Qbits)
Beispiel #2
0
def test():
        substitution.specialize({fx:Not(x), x:a, y:b}, assumptions=[Equals(a, b)])
        expr = Equals(a, Add(b, Frac(c, d), Exp(c, d)))
        gRepl = Lambda.globalRepl(expr, d)
        d_eq_y = Equals(d, y)
        d_eq_y.substitution(gRepl, assumptions=[d_eq_y])
        d_eq_y.substitution(expr, assumptions=[d_eq_y])
        d_eq_y.substitution(expr, assumptions=[d_eq_y]).proof()
        innerExpr = expr.innerExpr()
        innerExpr = innerExpr.rhs
        innerExpr = innerExpr.operands[1]
        innerExpr = innerExpr.denominator
        d_eq_y.substitution(innerExpr, assumptions=[d_eq_y])
        d_eq_y.substitution(expr.innerExpr().rhs.operands[2].exponent, assumptions=[d_eq_y])
        d_eq_y.subRightSideInto(gRepl, assumptions=[d_eq_y,expr])
        d_eq_y.subRightSideInto(expr, assumptions=[d_eq_y,expr])
        y_eq_d = Equals(y, d)
        y_eq_d.subLeftSideInto(gRepl, assumptions=[y_eq_d,expr])
        y_eq_d.subLeftSideInto(expr, assumptions=[y_eq_d,expr])
        y_eq_d.subLeftSideInto(expr, assumptions=[y_eq_d,expr]).proof()
        
Beispiel #3
0
phase_ = Literal(pkg, 'phase', {LATEX: r'\varphi'})

# t: Number of qubit registers for the quantum phase estimation.
#    We prove that this is the bits of precision of phase estimation.
t_ = Literal(pkg, 't')

# Psi: Outcome of register qubits following the quantum phase estimation circuit.
Psi_ = Literal(pkg, 'PSI', {STRING: 'Psi', LATEX: r'\Psi'})
# psi: indexed intermediate output registers inside the quantum phase estimation circuit.
psi_ = Literal(pkg, 'psi', {STRING: 'psi', LATEX: r'\psi'})
psi_k = SubIndexed(psi_, k)
psi_t = SubIndexed(psi_, t_)
psi_next = SubIndexed(psi_, Add(k, one))
psi_1 = SubIndexed(psi_, one)

U_pow_two_pow_k = Exp(U_, Exp(two, k))

# m: Random variable for the measurement of Psi as an integer from the register's binary representation.
m_ = Literal(pkg, 'm')

# phase_m: Random variable for the phase result of the quantum phase estimation.
#          phase_m = m / 2^t
phase_m_ = Literal(pkg, 'phase_m', {LATEX: r'\varphi_m'})

# b: The "best" outcome of m such that phase_m is as close as possible to phase.
b_ = Literal(pkg, 'b')

# 2^t
two_pow_t = Exp(two, t_)

# 2^{t-1}
Beispiel #4
0
fracCancelComplete = Forall(x,
                            Equals(Fraction(x, x), one),
                            domain=Complexes,
                            conditions=[NotEquals(x, zero)])
fracCancelComplete

reverseFractionOfSubtractions = Forall([w, x, y, z],
                                       Equals(Fraction(Sub(w, x), Sub(y, z)),
                                              Fraction(Sub(x, w), Sub(z, y))),
                                       domain=Complexes)
reverseFractionOfSubtractions

fracIntExp = Forall(n,
                    Forall((a, b),
                           Equals(Fraction(Exp(a, n), Exp(b, n)),
                                  Exp(Fraction(a, b), n)),
                           conditions=[NotEquals(a, zero),
                                       NotEquals(b, zero)]),
                    domain=Integers)
fracIntExp

fracIntExpRev = Forall(n,
                       Forall(
                           (a, b),
                           Equals(Exp(Fraction(a, b), n),
                                  Fraction(Exp(a, n), Exp(b, n))),
                           conditions=[NotEquals(a, zero),
                                       NotEquals(b, zero)]),
                       domain=Integers)
fracIntExpRev
Beispiel #5
0
from proveit import Etcetera
from proveit.logic import Forall, InSet, Equals, NotEquals
from proveit.number import Integers, Naturals, NaturalsPos, Reals, RealsPos, Complexes
from proveit.number import Exp, sqrt, Add, Mult, Sub, Neg, frac, Abs, GreaterThan, GreaterThanEquals, LessThan, LessThanEquals
from proveit.common import a, b, c, d, n, x, y, z, xEtc, xMulti
from proveit.number.common import zero, one, two
from proveit import beginTheorems, endTheorems

beginTheorems(locals())

expNatClosure = Forall((a, b),
                       InSet(Exp(a, b), NaturalsPos),
                       domain=Naturals,
                       conditions=[NotEquals(a, zero)])
expNatClosure

expRealClosure = Forall(
    [a, b],
    InSet(Exp(a, b), Reals),
    domain=Reals,
    conditions=[GreaterThanEquals(a, zero),
                GreaterThan(b, zero)])
expRealClosure

expRealPosClosure = Forall([a, b],
                           InSet(Exp(a, b), RealsPos),
                           domain=Reals,
                           conditions=[GreaterThan(a, zero)])
expRealPosClosure

expComplexClosure = Forall([a, b],
Beispiel #6
0
def RegisterSU(n):
    '''
    Transplanted here beginning 2/13/2020 by wdc, from the old
    physics/quantum/common.py
    '''
    return SU(Exp(num(2), n))
Beispiel #7
0
    Equals(Sum(n, Operation(f, n), Interval(zero, one)),
           Add(Operation(f, zero), Operation(f, one))))
sumZeroAndOne

indexShift = Forall(
    f,
    Forall([a, b, c],
           Equals(
               Sum(x, Operation(f, x), Interval(a, b)),
               Sum(x, Operation(f, Sub(x, c)), Interval(Add(a, c), Add(b,
                                                                       c)))),
           domain=Integers))
indexShift

infGeomSum = Forall(x,
                    Equals(Sum(m, Exp(x, m), Interval(zero, infinity)),
                           Fraction(one, Sub(one, x))),
                    domain=Complexes)
infGeomSum

finGeomSum = Forall([x, k, l],
                    Equals(
                        Sum(m, Exp(x, m), Interval(k, l)),
                        Fraction(Sub(Exp(x, Add(l, one)), Exp(x, k)),
                                 Sub(x, one))),
                    conditions=[
                        InSet(k, Integers),
                        InSet(l, Integers),
                        InSet(x, Complexes),
                        LessThan(k, l)
                    ])
Beispiel #8
0
from proveit import Etcetera
from proveit.logic import Forall, InSet, Equals, NotEquals
from proveit.number import Integers, Naturals, NaturalsPos, Reals, RealsPos, Complexes
from proveit.number import Exp, sqrt, Add, Mult, Sub, Neg, frac, Abs, GreaterThan, GreaterThanEquals, LessThan, LessThanEquals
from proveit.common import a, b, c, d, n, x, y, z, xEtc, xMulti
from proveit.number.common import zero, one, two
from proveit import beginTheorems, endTheorems

beginTheorems(locals())

expNatClosure = Forall((a, b), InSet(Exp(a, b), NaturalsPos), domain=Naturals, conditions=[NotEquals(a, zero)])
expNatClosure

expRealClosure = Forall([a, b], InSet(Exp(a, b), Reals), domain=Reals,
                       conditions=[GreaterThanEquals(a, zero), GreaterThan(b, zero)])
expRealClosure

expRealPosClosure = Forall([a, b], InSet(Exp(a, b), RealsPos), domain=Reals,
                       conditions=[GreaterThan(a, zero)])
expRealPosClosure

expComplexClosure = Forall([a, b], InSet(Exp(a, b), Complexes), domain=Complexes, 
                    conditions=[NotEquals(a, zero)])
expComplexClosure

sqrtRealClosure = Forall([a], InSet(sqrt(a), Reals), domain=Reals,
                         conditions=[GreaterThanEquals(a, zero)])
sqrtRealClosure

sqrtRealPosClosure = Forall([a], InSet(sqrt(a), RealsPos), domain=RealsPos)
sqrtRealPosClosure
Beispiel #9
0
ketMinus = Ket(MINUS)

Xgate = Gate(X)
Ygate = Gate(Y)
Zgate = Gate(Z)
Hgate = Gate(H)

CTRL_UP = Literal(pkg, 'CTRL_UP')
CTRL_DN = Literal(pkg, 'CTRL_DN')
CTRL_UPDN = Literal(pkg, 'CTRL_UPDN')

WIRE_UP = Literal(pkg, 'WIRE_UP') # wire goes up to link with another wire
WIRE_DN = Literal(pkg, 'WIRE_DN') # wire goes down to link with another wire
WIRE_LINK = Literal(pkg, 'WIRE_LINK') # link destination for WIRE_UP or WIRE_DN

QubitSpace = Exp(Complexes, two)
QubitRegisterSpace = lambda n : TensorExp(Exp(Complexes, two), n) 
RegisterSU = lambda n : SU(Exp(two, n))

invRoot2 = frac(one, sqrt(two))

B1 = Variable('B1')
B2 = Variable('B2')
B3 = Variable('B3')
C1 = Variable('C1')
C2 = Variable('C2')
C3 = Variable('C3')
I = Variable('I')
IB = Variable('IB')
IC = Variable('IC')
Beispiel #10
0
fracCancelComplete = Forall(x,
                            Equals(frac(x, x), one),
                            domain=Complexes,
                            conditions=[NotEquals(x, zero)])
fracCancelComplete

reversefracOfSubtractions = Forall([w, x, y, z],
                                   Equals(frac(Sub(w, x), Sub(y, z)),
                                          frac(Sub(x, w), Sub(z, y))),
                                   domain=Complexes)
reversefracOfSubtractions

fracIntExp = Forall(n,
                    Forall((a, b),
                           Equals(frac(Exp(a, n), Exp(b, n)),
                                  Exp(frac(a, b), n)),
                           conditions=[NotEquals(a, zero),
                                       NotEquals(b, zero)]),
                    domain=Integers)
fracIntExp

fracIntExpRev = Forall(n,
                       Forall(
                           (a, b),
                           Equals(Exp(frac(a, b), n),
                                  frac(Exp(a, n), Exp(b, n))),
                           conditions=[NotEquals(a, zero),
                                       NotEquals(b, zero)]),
                       domain=Integers)
fracIntExpRev