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.physics.quantum.circuits import circuit__psi_m__u_Akl_v, circuit__u_Akl_v
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Prob(circuit__u_Akl_v), Prob(circuit__psi_m__u_Akl_v))
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{
\multiqin{3}{\lvert u \rangle} & \gate{A_{1, 1}} \qwx[1] & \gate{A_{2, 1}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{k, 1}} \qwx[1] & \multiqout{3}{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{A_{1, 2}} \qwx[1] & \gate{A_{2, 2}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{k, 2}} \qwx[1] & \ghostqout{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \ghostqout{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{A_{1, l}} & \gate{A_{2, l}} & \gate{\cdots} & \gate{A_{k, l}} & \ghostqout{\lvert v \rangle}
} \end{array}\right), \textrm{Pr}\left(\begin{array}{c} \Qcircuit@C=1em @R=.7em{
\qin{\lvert \psi \rangle} & { /^{m} } \qw & { /^{m} } \qw & \gate{\cdots} & { /^{m} } \qw & \qout{\lvert \psi \rangle} \\
\multiqin{3}{\lvert u \rangle} & \gate{A_{1, 1}} \qwx[1] & \gate{A_{2, 1}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{k, 1}} \qwx[1] & \multiqout{3}{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{A_{1, 2}} \qwx[1] & \gate{A_{2, 2}} \qwx[1] & \gate{\cdots} \qwx[1] & \gate{A_{k, 2}} \qwx[1] & \ghostqout{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{\vdots} \qwx[1] & \gate{\vdots} \qwx[1] & \gate{\ddots} \qwx[1] & \gate{\vdots} \qwx[1] & \ghostqout{\lvert v \rangle} \\
\ghostqin{\lvert u \rangle} & \gate{A_{1, l}} & \gate{A_{2, l}} & \gate{\cdots} & \gate{A_{k, l}} & \ghostqout{\lvert v \rangle}
} \end{array}\right)\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
operand: 6
2Operationoperator: 4
operand: 7
3ExprTuple6
4Literal
5ExprTuple7
6Operationoperator: 9
operands: 8
7Operationoperator: 9
operands: 10
8ExprTuple11, 12, 13
9Literal
10ExprTuple14, 15, 16
11ExprTuple17
12ExprRangelambda_map: 18
start_index: 86
end_index: 23
13ExprTuple19
14ExprTuple20, 21
15ExprRangelambda_map: 22
start_index: 86
end_index: 23
16ExprTuple24, 25
17ExprRangelambda_map: 26
start_index: 86
end_index: 88
18Lambdaparameter: 77
body: 27
19ExprRangelambda_map: 28
start_index: 86
end_index: 88
20ExprRangelambda_map: 29
start_index: 86
end_index: 87
21ExprRangelambda_map: 30
start_index: 86
end_index: 88
22Lambdaparameter: 77
body: 32
23Variable
24ExprRangelambda_map: 33
start_index: 86
end_index: 87
25ExprRangelambda_map: 34
start_index: 86
end_index: 88
26Lambdaparameter: 80
body: 35
27ExprTuple40
28Lambdaparameter: 80
body: 36
29Lambdaparameter: 80
body: 37
30Lambdaparameter: 80
body: 38
31ExprTuple77
32ExprTuple39, 40
33Lambdaparameter: 80
body: 41
34Lambdaparameter: 80
body: 42
35Operationoperator: 50
operands: 43
36Operationoperator: 50
operands: 44
37Operationoperator: 50
operands: 45
38Operationoperator: 50
operands: 46
39ExprRangelambda_map: 47
start_index: 86
end_index: 87
40ExprRangelambda_map: 48
start_index: 86
end_index: 88
41Operationoperator: 50
operands: 49
42Operationoperator: 50
operands: 51
43NamedExprselement: 54
targets: 52
44NamedExprselement: 60
targets: 52
45NamedExprselement: 53
targets: 59
46NamedExprselement: 54
targets: 61
47Lambdaparameter: 80
body: 55
48Lambdaparameter: 80
body: 57
49NamedExprselement: 58
targets: 59
50Literal
51NamedExprselement: 60
targets: 61
52Operationoperator: 73
operands: 62
53Operationoperator: 63
operands: 69
54Operationoperator: 63
operands: 64
55Operationoperator: 65
operands: 66
56ExprTuple80
57IndexedVarvariable: 67
indices: 68
58Operationoperator: 71
operands: 69
59Operationoperator: 73
operands: 70
60Operationoperator: 71
operands: 72
61Operationoperator: 73
operands: 74
62ExprTuple86, 88
63Literal
64NamedExprsstate: 75
part: 80
65Literal
66NamedExprsoperation: 76
67Variable
68ExprTuple77, 80
69NamedExprsstate: 78
part: 80
70ExprTuple86, 87
71Literal
72NamedExprsstate: 79
part: 80
73Literal
74ExprTuple81, 82
75Variable
76Literal
77Variable
78Variable
79Variable
80Variable
81Operationoperator: 84
operands: 83
82Operationoperator: 84
operands: 85
83ExprTuple87, 86
84Literal
85ExprTuple87, 88
86Literal
87Variable
88Variable