logo
In [1]:
import proveit
# Automation is not needed when only building an expression:
proveit.defaults.automation = False # This will speed things up.
proveit.defaults.inline_pngs = False # Makes files smaller.
%load_theorem_expr # Load the stored theorem expression as 'stored_expr'
# import the special expression
from proveit.physics.quantum.circuits import trivial_expansion_above
In [2]:
# check that the built expression is the same as the stored expression
assert trivial_expansion_above.expr == stored_expr
assert trivial_expansion_above.expr._style_id == stored_expr._style_id
print("Passed sanity check: trivial_expansion_above matches stored_expr")
Passed sanity check: trivial_expansion_above matches stored_expr
In [3]:
# Show the LaTeX representation of the expression for convenience if you need it.
print(stored_expr.latex())
\forall_{k, l, m \in \mathbb{N}^+}~\left[\forall_{\lvert u \rangle, \lvert v \rangle \in \mathbb{C}^{2^{l}}}~\left[\forall_{\lvert \psi \rangle \in \mathbb{C}^{2^{m}}}~\left[\begin{array}{l}\forall_{A_{1, 1}, A_{1, 2}, \ldots, A_{1, l}, A_{2, 1}, A_{2, 2}, \ldots, A_{2, l}, \ldots\ldots, A_{k, 1}, A_{k, 2}, \ldots, A_{k, l}}~\\
\left(\begin{array}{c} \begin{array}{l} \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) \end{array} \end{array}\right)\end{array}\right]\right]\right]
In [4]:
stored_expr.style_options()
namedescriptiondefaultcurrent valuerelated methods
with_wrappingIf 'True', wrap the Expression after the parametersNoneNone/False('with_wrapping',)
condition_wrappingWrap 'before' or 'after' the condition (or None).NoneNone/False('with_wrap_after_condition', 'with_wrap_before_condition')
wrap_paramsIf 'True', wraps every two parameters AND wraps the Expression after the parametersNoneNone/False('with_params',)
justificationjustify to the 'left', 'center', or 'right' in the array cellscentercenter('with_justification',)
In [5]:
# display the expression information
stored_expr.expr_info()
 core typesub-expressionsexpression
0Operationoperator: 34
operand: 2
1ExprTuple2
2Lambdaparameters: 3
body: 4
3ExprTuple78, 143, 142
4Conditionalvalue: 5
condition: 6
5Operationoperator: 34
operand: 9
6Operationoperator: 22
operands: 8
7ExprTuple9
8ExprTuple10, 11, 12
9Lambdaparameters: 13
body: 14
10Operationoperator: 36
operands: 15
11Operationoperator: 36
operands: 16
12Operationoperator: 36
operands: 17
13ExprTuple130, 134
14Conditionalvalue: 18
condition: 19
15ExprTuple78, 20
16ExprTuple143, 20
17ExprTuple142, 20
18Operationoperator: 34
operand: 24
19Operationoperator: 22
operands: 23
20Literal
21ExprTuple24
22Literal
23ExprTuple25, 26
24Lambdaparameter: 133
body: 28
25Operationoperator: 36
operands: 29
26Operationoperator: 36
operands: 30
27ExprTuple133
28Conditionalvalue: 31
condition: 32
29ExprTuple130, 33
30ExprTuple134, 33
31Operationoperator: 34
operand: 39
32Operationoperator: 36
operands: 37
33Operationoperator: 44
operands: 38
34Literal
35ExprTuple39
36Literal
37ExprTuple133, 40
38ExprTuple50, 41
39Lambdaparameters: 42
body: 43
40Operationoperator: 44
operands: 45
41Operationoperator: 55
operands: 46
42ExprTuple47
43Operationoperator: 48
operands: 49
44Literal
45ExprTuple50, 51
46ExprTuple60, 143
47ExprRangelambda_map: 52
start_index: 141
end_index: 78
48Literal
49ExprTuple53, 54
50Literal
51Operationoperator: 55
operands: 56
52Lambdaparameter: 132
body: 95
53Operationoperator: 58
operand: 61
54Operationoperator: 58
operand: 62
55Literal
56ExprTuple60, 142
57ExprTuple61
58Literal
59ExprTuple62
60Literal
61Operationoperator: 64
operands: 63
62Operationoperator: 64
operands: 65
63ExprTuple66, 67, 68
64Literal
65ExprTuple69, 70, 71
66ExprTuple72
67ExprRangelambda_map: 73
start_index: 141
end_index: 78
68ExprTuple74
69ExprTuple75, 76
70ExprRangelambda_map: 77
start_index: 141
end_index: 78
71ExprTuple79, 80
72ExprRangelambda_map: 81
start_index: 141
end_index: 143
73Lambdaparameter: 132
body: 82
74ExprRangelambda_map: 83
start_index: 141
end_index: 143
75ExprRangelambda_map: 84
start_index: 141
end_index: 142
76ExprRangelambda_map: 85
start_index: 141
end_index: 143
77Lambdaparameter: 132
body: 87
78Variable
79ExprRangelambda_map: 88
start_index: 141
end_index: 142
80ExprRangelambda_map: 89
start_index: 141
end_index: 143
81Lambdaparameter: 135
body: 90
82ExprTuple95
83Lambdaparameter: 135
body: 91
84Lambdaparameter: 135
body: 92
85Lambdaparameter: 135
body: 93
86ExprTuple132
87ExprTuple94, 95
88Lambdaparameter: 135
body: 96
89Lambdaparameter: 135
body: 97
90Operationoperator: 105
operands: 98
91Operationoperator: 105
operands: 99
92Operationoperator: 105
operands: 100
93Operationoperator: 105
operands: 101
94ExprRangelambda_map: 102
start_index: 141
end_index: 142
95ExprRangelambda_map: 103
start_index: 141
end_index: 143
96Operationoperator: 105
operands: 104
97Operationoperator: 105
operands: 106
98NamedExprselement: 109
targets: 107
99NamedExprselement: 115
targets: 107
100NamedExprselement: 108
targets: 114
101NamedExprselement: 109
targets: 116
102Lambdaparameter: 135
body: 110
103Lambdaparameter: 135
body: 112
104NamedExprselement: 113
targets: 114
105Literal
106NamedExprselement: 115
targets: 116
107Operationoperator: 128
operands: 117
108Operationoperator: 118
operands: 124
109Operationoperator: 118
operands: 119
110Operationoperator: 120
operands: 121
111ExprTuple135
112IndexedVarvariable: 122
indices: 123
113Operationoperator: 126
operands: 124
114Operationoperator: 128
operands: 125
115Operationoperator: 126
operands: 127
116Operationoperator: 128
operands: 129
117ExprTuple141, 143
118Literal
119NamedExprsstate: 130
part: 135
120Literal
121NamedExprsoperation: 131
122Variable
123ExprTuple132, 135
124NamedExprsstate: 133
part: 135
125ExprTuple141, 142
126Literal
127NamedExprsstate: 134
part: 135
128Literal
129ExprTuple136, 137
130Variable
131Literal
132Variable
133Variable
134Variable
135Variable
136Operationoperator: 139
operands: 138
137Operationoperator: 139
operands: 140
138ExprTuple142, 141
139Literal
140ExprTuple142, 143
141Literal
142Variable
143Variable