logo

Expression of type Conditional

from the theory of proveit.physics.quantum.QPE

In [1]:
import proveit
# Automation is not needed when building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_expr # Load the stored expression as 'stored_expr'
# import Expression classes needed to build the expression
from proveit import Conditional, k, t
from proveit.linear_algebra import ScalarMult, TensorProd
from proveit.logic import CartExp, InSet
from proveit.numbers import Complex, Exp, Interval, Mult, e, i, one, pi, subtract, two, zero
from proveit.physics.quantum import NumKet, QubitSpace, ket1
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Conditional(InSet(TensorProd(ket1, ScalarMult(Exp(e, Mult(two, pi, i, _phase, k)), NumKet(k, t))), TensorProd(QubitSpace, CartExp(Complex, two_pow_t))), InSet(k, Interval(zero, subtract(two_pow_t, one))))
expr:
In [3]:
# check that the built expression is the same as the stored expression
assert expr == stored_expr
assert expr._style_id == stored_expr._style_id
print("Passed sanity check: expr matches stored_expr")
Passed sanity check: expr matches stored_expr
In [4]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\left\{\left(\lvert 1 \rangle {\otimes} \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi \cdot k} \cdot \lvert k \rangle_{t}\right)\right) \in \left(\mathbb{C}^{2} {\otimes} \mathbb{C}^{2^{t}}\right) \textrm{ if } k \in \{0~\ldotp \ldotp~2^{t} - 1\}\right..
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
condition_delimiter'comma' or 'and'commacomma('with_comma_delimiter', 'with_conjunction_delimiter')
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Conditionalvalue: 1
condition: 2
1Operationoperator: 4
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 7
4Literal
5ExprTuple50, 8
6Operationoperator: 10
operands: 9
7Operationoperator: 10
operands: 11
8Operationoperator: 12
operands: 13
9ExprTuple14, 15
10Literal
11ExprTuple16, 17
12Literal
13ExprTuple18, 19
14Operationoperator: 20
operand: 43
15Operationoperator: 21
operands: 22
16Operationoperator: 24
operands: 23
17Operationoperator: 24
operands: 25
18Literal
19Operationoperator: 26
operands: 27
20Literal
21Literal
22ExprTuple28, 29
23ExprTuple30, 46
24Literal
25ExprTuple30, 31
26Literal
27ExprTuple31, 32
28Operationoperator: 36
operands: 33
29Operationoperator: 34
operands: 35
30Literal
31Operationoperator: 36
operands: 37
32Operationoperator: 38
operand: 43
33ExprTuple40, 41
34Literal
35ExprTuple50, 42
36Literal
37ExprTuple46, 42
38Literal
39ExprTuple43
40Literal
41Operationoperator: 44
operands: 45
42Variable
43Literal
44Literal
45ExprTuple46, 47, 48, 49, 50
46Literal
47Literal
48Literal
49Literal
50Variable