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
from proveit.logic import Equals
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(Equals(Prob(circuit_Ui_psi_m), one), Equals(Prob(circuit_Ui_Vj), Prob(circuit_psi_m_Vj)).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(\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, \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)
In [5]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
wrap_positionsposition(s) at which wrapping is to occur; 'n' is after the nth comma.()()('with_wrapping_at',)
justificationif any wrap positions are set, justify to the 'left', 'center', or 'right'leftleft('with_justification',)
In [6]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0ExprTuple1, 2
1Operationoperator: 4
operands: 3
2Operationoperator: 4
operands: 5
3ExprTuple6, 52
4Literal
5ExprTuple7, 8
6Operationoperator: 11
operand: 13
7Operationoperator: 11
operand: 14
8Operationoperator: 11
operand: 15
9ExprTuple13
10ExprTuple14
11Literal
12ExprTuple15
13Operationoperator: 18
operands: 16
14Operationoperator: 18
operands: 17
15Operationoperator: 18
operands: 19
16ExprTuple21, 20
17ExprTuple21, 23
18Literal
19ExprTuple22, 23
20ExprTuple24
21ExprRangelambda_map: 25
start_index: 52
end_index: 26
22ExprTuple27
23ExprRangelambda_map: 28
start_index: 52
end_index: 29
24ExprRangelambda_map: 30
start_index: 52
end_index: 53
25Lambdaparameter: 51
body: 31
26Variable
27ExprRangelambda_map: 32
start_index: 52
end_index: 53
28Lambdaparameter: 51
body: 33
29Variable
30Lambdaparameter: 51
body: 34
31IndexedVarvariable: 35
index: 51
32Lambdaparameter: 51
body: 36
33IndexedVarvariable: 37
index: 51
34Operationoperator: 40
operands: 39
35Variable
36Operationoperator: 40
operands: 41
37Variable
38ExprTuple51
39NamedExprselement: 42
targets: 44
40Literal
41NamedExprselement: 43
targets: 44
42Operationoperator: 45
operands: 47
43Operationoperator: 46
operands: 47
44Operationoperator: 48
operands: 49
45Literal
46Literal
47NamedExprsstate: 50
part: 51
48Literal
49ExprTuple52, 53
50Variable
51Variable
52Literal
53Variable