logo

Expression of type ExprTuple

from the theory of proveit.physics.quantum.circuits

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, ExprTuple, Lambda, U
from proveit.linear_algebra import ScalarMult
from proveit.logic import Equals
from proveit.numbers import Exp, Mult, e, i, one, pi, two
from proveit.physics.quantum import Qmult, var_ket_u, varphi
from proveit.physics.quantum.circuits import phase_kickback_circuit
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda(varphi, Conditional(Equals(Prob(phase_kickback_circuit), one), Equals(Qmult(U, var_ket_u), ScalarMult(Exp(e, Mult(two, pi, i, varphi)), var_ket_u)))))
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(\varphi \mapsto \left\{\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert + \rangle} & \control{} \qw \qwx[1] & \qout{\frac{1}{\sqrt{2}} \cdot \left(\lvert 0 \rangle + \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi} \cdot \lvert 1 \rangle\right)\right)} \\
\qin{\lvert u \rangle} & \gate{U} & \qout{\lvert u \rangle}
} \end{array}\right) = 1 \textrm{ if } \left(U \thinspace \lvert u \rangle\right) = \left(\mathsf{e}^{2 \cdot \pi \cdot \mathsf{i} \cdot \varphi} \cdot \lvert u \rangle\right)\right..\right)
In [5]:
stored_expr.style_options()
no style options
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1
1Lambdaparameter: 102
body: 3
2ExprTuple102
3Conditionalvalue: 4
condition: 5
4Operationoperator: 7
operands: 6
5Operationoperator: 7
operands: 8
6ExprTuple9, 96
7Literal
8ExprTuple10, 11
9Operationoperator: 12
operand: 17
10Operationoperator: 14
operands: 15
11Operationoperator: 79
operands: 16
12Literal
13ExprTuple17
14Literal
15ExprTuple70, 74
16ExprTuple85, 74
17Operationoperator: 18
operands: 19
18Literal
19ExprTuple20, 21, 22
20ExprTuple23, 24
21ExprTuple25, 26
22ExprTuple27, 28
23Operationoperator: 60
operands: 29
24ExprRangelambda_map: 30
start_index: 96
end_index: 35
25Operationoperator: 51
operands: 31
26ExprRangelambda_map: 32
start_index: 96
end_index: 35
27Operationoperator: 66
operands: 33
28ExprRangelambda_map: 34
start_index: 96
end_index: 35
29NamedExprsstate: 36
30Lambdaparameter: 75
body: 37
31NamedExprselement: 38
targets: 39
32Lambdaparameter: 75
body: 40
33NamedExprsstate: 41
34Lambdaparameter: 75
body: 43
35Operationoperator: 81
operands: 44
36Operationoperator: 92
operand: 53
37Operationoperator: 51
operands: 46
38Literal
39Operationoperator: 47
operand: 99
40Operationoperator: 51
operands: 49
41Operationoperator: 79
operands: 50
42ExprTuple75
43Operationoperator: 51
operands: 52
44ExprTuple87, 96
45ExprTuple53
46NamedExprselement: 54
targets: 59
47Literal
48ExprTuple99
49NamedExprselement: 55
targets: 59
50ExprTuple56, 57
51Literal
52NamedExprselement: 58
targets: 59
53Literal
54Operationoperator: 60
operands: 67
55Operationoperator: 61
operands: 62
56Operationoperator: 88
operands: 63
57Operationoperator: 64
operands: 65
58Operationoperator: 66
operands: 67
59Operationoperator: 68
operands: 69
60Literal
61Literal
62NamedExprsoperation: 70
part: 75
63ExprTuple96, 71
64Literal
65ExprTuple72, 73
66Literal
67NamedExprsstate: 74
part: 75
68Literal
69ExprTuple99, 76
70Variable
71Operationoperator: 90
operands: 77
72Operationoperator: 92
operand: 84
73Operationoperator: 79
operands: 80
74Variable
75Variable
76Operationoperator: 81
operands: 82
77ExprTuple99, 83
78ExprTuple84
79Literal
80ExprTuple85, 86
81Literal
82ExprTuple87, 99
83Operationoperator: 88
operands: 89
84Literal
85Operationoperator: 90
operands: 91
86Operationoperator: 92
operand: 96
87Variable
88Literal
89ExprTuple96, 99
90Literal
91ExprTuple94, 95
92Literal
93ExprTuple96
94Literal
95Operationoperator: 97
operands: 98
96Literal
97Literal
98ExprTuple99, 100, 101, 102
99Literal
100Literal
101Literal
102Variable