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 ExprTuple, Lambda
from proveit.core_expr_types import U_1_to_i, V_1_to_j
from proveit.logic import Equals, Implies
from proveit.numbers import one
from proveit.physics.quantum.circuits import circuit_Ui_Vj, circuit_Ui_psi_m, circuit_psi_m_Vj
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Lambda([U_1_to_i, V_1_to_j], Implies(Equals(Prob(circuit_Ui_psi_m), one), Equals(Prob(circuit_Ui_Vj), Prob(circuit_psi_m_Vj)).with_wrapping_at(2)).with_wrapping_at(2)))
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(U_{1}, U_{2}, \ldots, U_{i}, V_{1}, V_{2}, \ldots, V_{j}\right) \mapsto \left(\begin{array}{c} \begin{array}{l} \left(\textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{i} \\ \downarrow\end{array}} & \qout{\lvert \psi \rangle}
} \end{array}\right) = 1\right) \Rightarrow  \\ \left(\begin{array}{c} \begin{array}{l} \textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
& \gate{\begin{array}{c} \uparrow \\U_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\U_{i} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{2} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{j} \\ \downarrow\end{array}} & \qw
} \end{array}\right) =  \\ \textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & \gate{\begin{array}{c} \uparrow \\V_{1} \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\\cdots \\ \downarrow\end{array}} & \gate{\begin{array}{c} \uparrow \\V_{j} \\ \downarrow\end{array}} & { /^{m} } \qw
} \end{array}\right) \end{array} \end{array}\right) \end{array} \end{array}\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
1Lambdaparameters: 2
body: 3
2ExprTuple26, 28
3Operationoperator: 4
operands: 5
4Literal
5ExprTuple6, 7
6Operationoperator: 9
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 57
9Literal
10ExprTuple12, 13
11Operationoperator: 16
operand: 18
12Operationoperator: 16
operand: 19
13Operationoperator: 16
operand: 20
14ExprTuple18
15ExprTuple19
16Literal
17ExprTuple20
18Operationoperator: 23
operands: 21
19Operationoperator: 23
operands: 22
20Operationoperator: 23
operands: 24
21ExprTuple26, 25
22ExprTuple26, 28
23Literal
24ExprTuple27, 28
25ExprTuple29
26ExprRangelambda_map: 30
start_index: 57
end_index: 31
27ExprTuple32
28ExprRangelambda_map: 33
start_index: 57
end_index: 34
29ExprRangelambda_map: 35
start_index: 57
end_index: 58
30Lambdaparameter: 56
body: 36
31Variable
32ExprRangelambda_map: 37
start_index: 57
end_index: 58
33Lambdaparameter: 56
body: 38
34Variable
35Lambdaparameter: 56
body: 39
36IndexedVarvariable: 40
index: 56
37Lambdaparameter: 56
body: 41
38IndexedVarvariable: 42
index: 56
39Operationoperator: 45
operands: 44
40Variable
41Operationoperator: 45
operands: 46
42Variable
43ExprTuple56
44NamedExprselement: 47
targets: 49
45Literal
46NamedExprselement: 48
targets: 49
47Operationoperator: 50
operands: 52
48Operationoperator: 51
operands: 52
49Operationoperator: 53
operands: 54
50Literal
51Literal
52NamedExprsstate: 55
part: 56
53Literal
54ExprTuple57, 58
55Variable
56Variable
57Literal
58Variable