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, ket0
from proveit.physics.quantum.QPE import _phase, two_pow_t
In [2]:
# build up the expression from sub-expressions
expr = Conditional(InSet(TensorProd(ket0, 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 0 \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
5ExprTuple51, 8
6Operationoperator: 10
operands: 9
7Operationoperator: 10
operands: 11
8Operationoperator: 12
operands: 13
9ExprTuple14, 15
10Literal
11ExprTuple16, 17
12Literal
13ExprTuple28, 18
14Operationoperator: 19
operand: 28
15Operationoperator: 21
operands: 22
16Operationoperator: 24
operands: 23
17Operationoperator: 24
operands: 25
18Operationoperator: 26
operands: 27
19Literal
20ExprTuple28
21Literal
22ExprTuple29, 30
23ExprTuple31, 47
24Literal
25ExprTuple31, 32
26Literal
27ExprTuple32, 33
28Literal
29Operationoperator: 37
operands: 34
30Operationoperator: 35
operands: 36
31Literal
32Operationoperator: 37
operands: 38
33Operationoperator: 39
operand: 44
34ExprTuple41, 42
35Literal
36ExprTuple51, 43
37Literal
38ExprTuple47, 43
39Literal
40ExprTuple44
41Literal
42Operationoperator: 45
operands: 46
43Variable
44Literal
45Literal
46ExprTuple47, 48, 49, 50, 51
47Literal
48Literal
49Literal
50Literal
51Variable