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__u_Akl_v, circuit__u_Akl_v__psi_m
from proveit.statistics import Prob
In [2]:
# build up the expression from sub-expressions
expr = ExprTuple(Prob(circuit__u_Akl_v), Prob(circuit__u_Akl_v__psi_m))
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{
\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} \\
\qin{\lvert \psi \rangle} & { /^{m} } \qw & { /^{m} } \qw & \gate{\cdots} & { /^{m} } \qw & \qout{\lvert \psi \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
11ExprTuple18
12ExprRangelambda_map: 17
start_index: 76
end_index: 21
13ExprTuple22
14ExprTuple18, 19
15ExprRangelambda_map: 20
start_index: 76
end_index: 21
16ExprTuple22, 23
17Lambdaparameter: 66
body: 24
18ExprRangelambda_map: 25
start_index: 76
end_index: 77
19ExprRangelambda_map: 26
start_index: 76
end_index: 78
20Lambdaparameter: 66
body: 28
21Variable
22ExprRangelambda_map: 29
start_index: 76
end_index: 77
23ExprRangelambda_map: 30
start_index: 76
end_index: 78
24ExprTuple33
25Lambdaparameter: 70
body: 31
26Lambdaparameter: 70
body: 32
27ExprTuple66
28ExprTuple33, 34
29Lambdaparameter: 70
body: 35
30Lambdaparameter: 70
body: 36
31Operationoperator: 42
operands: 37
32Operationoperator: 42
operands: 38
33ExprRangelambda_map: 39
start_index: 76
end_index: 77
34ExprRangelambda_map: 40
start_index: 76
end_index: 78
35Operationoperator: 42
operands: 41
36Operationoperator: 42
operands: 43
37NamedExprselement: 44
targets: 50
38NamedExprselement: 45
targets: 52
39Lambdaparameter: 70
body: 46
40Lambdaparameter: 70
body: 48
41NamedExprselement: 49
targets: 50
42Literal
43NamedExprselement: 51
targets: 52
44Operationoperator: 54
operands: 53
45Operationoperator: 54
operands: 62
46IndexedVarvariable: 55
indices: 56
47ExprTuple70
48Operationoperator: 57
operands: 58
49Operationoperator: 61
operands: 59
50Operationoperator: 63
operands: 60
51Operationoperator: 61
operands: 62
52Operationoperator: 63
operands: 64
53NamedExprsstate: 65
part: 70
54Literal
55Variable
56ExprTuple66, 70
57Literal
58NamedExprsoperation: 67
59NamedExprsstate: 68
part: 70
60ExprTuple76, 77
61Literal
62NamedExprsstate: 69
part: 70
63Literal
64ExprTuple71, 72
65Variable
66Variable
67Literal
68Variable
69Variable
70Variable
71Operationoperator: 74
operands: 73
72Operationoperator: 74
operands: 75
73ExprTuple77, 76
74Literal
75ExprTuple77, 78
76Literal
77Variable
78Variable